Click to See Complete Forum and Search --> : database out of order


Phalon
09-14-2006, 08:59 PM
I have a weird situation where everything in my database in putting its self in backwards, even though it went the right way the first time.


if($stat=='sedit'){
$id=$_GET['id'];
$s1=$_POST['_1'];
$s2=$_POST['_2'];
$s3=$_POST['_3'];
$s4=$_POST['_4'];
$s5=$_POST['_5'];
$s6=$_POST['_6'];
$s7=$_POST['_7'];
$s8=$_POST['_8'];
$s9=$_POST['_9'];
$s10=$_POST['_10'];
$s11=$_POST['_11'];
$s12=$_POST['_12'];
$s13=$_POST['_13'];
$s14=$_POST['_14'];
$s15=$_POST['_15'];
$s16=$_POST['_16'];
$s17=$_POST['_17'];
$s18=$_POST['_18'];
$s19=$_POST['_19'];
$s20=$_POST['_20'];
$d1=$_POST['d_1'];
$d2=$_POST['d_2'];
$d3=$_POST['d_3'];
$d4=$_POST['d_4'];
$d5=$_POST['d_5'];
$d6=$_POST['d_6'];
$d7=$_POST['d_7'];
$d8=$_POST['d_8'];
$d9=$_POST['d_9'];
$d10=$_POST['d_10'];
$d11=$_POST['d_11'];
$d12=$_POST['d_12'];
$d13=$_POST['d_13'];
$d14=$_POST['d_14'];
$d15=$_POST['d_15'];
$d16=$_POST['d_16'];
$d17=$_POST['d_17'];
$d18=$_POST['d_18'];
$d19=$_POST['d_19'];
$d20=$_POST['d_20'];
$m1=$_POST['m_1'];
$m2=$_POST['m_2'];
$m3=$_POST['m_3'];
$m4=$_POST['m_4'];
$m5=$_POST['m_5'];
$m6=$_POST['m_6'];
$m7=$_POST['m_7'];
$m8=$_POST['m_8'];
$m9=$_POST['m_9'];
$m10=$_POST['m_10'];
$m11=$_POST['m_11'];
$m12=$_POST['m_12'];
$m13=$_POST['m_13'];
$m14=$_POST['m_14'];
$m15=$_POST['m_15'];
$m16=$_POST['m_16'];
$m17=$_POST['m_17'];
$m18=$_POST['m_18'];
$m19=$_POST['m_19'];
$m20=$_POST['m_20'];
$month=date("m");
$day=date("d");
$year=date("Y");

for($x=1; $x<=20; $x++){
switch($x){
case 1:
$query="INSERT INTO scores VALUES('$id','1','$s1','$m1','$d1','$month','$day','$year')";
mysql_query($query) or die("Unable to complete1");
break;
case 2:
$query="INSERT INTO scores VALUES('$id','2','$s2','$m2','$d2','$month','$day','$year')";
mysql_query($query) or die("Unable to complete2");
break;
case 3:
$query="INSERT INTO scores VALUES('$id','3','$s3','$m3','$d3','$month','$day','$year')";
mysql_query($query) or die("Unable to complete3");
break;
case 4:
$query="INSERT INTO scores VALUES('$id','4','$s4','$m4','$d4','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 5:
$query="INSERT INTO scores VALUES('$id','5','$s5','$m5','$d5','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 6:
$query="INSERT INTO scores VALUES('$id','6','$s6','$m6','$d6','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 7:
$query="INSERT INTO scores VALUES('$id','7','$s7','$m7','$d7','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 8:
$query="INSERT INTO scores VALUES('$id','8','$s8','$m8','$d8','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 9:
$query="INSERT INTO scores VALUES('$id','9','$s9','$m9','$d9','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 10:
$query="INSERT INTO scores VALUES('$id','10','$s10','$m10','$d10','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 11:
$query="INSERT INTO scores VALUES('$id','11','$s11','$m11','$d11','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 12:
$query="INSERT INTO scores VALUES('$id','12','$s12','$m12','$d12','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 13:
$query="INSERT INTO scores VALUES('$id','13','$s13','$m13','$d13','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 14:
$query="INSERT INTO scores VALUES('$id','14','$s14','$m14','$d14','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 15:
$query="INSERT INTO scores VALUES('$id','15','$s15','$m15','$d15','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 16:
$query="INSERT INTO scores VALUES('$id','16','$s16','$m16','$d16','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 17:
$query="INSERT INTO scores VALUES('$id','17','$s17','$m17','$d17','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 18:
$query="INSERT INTO scores VALUES('$id','18','$s18','$m18','$d18','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 19:
$query="INSERT INTO scores VALUES('$id','19','$s19','$m19','$d19','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
case 20:
$query="INSERT INTO scores VALUES('$id','20','$s20','$m20','$d20','$month','$day','$year')";
mysql_query($query) or die("Unable to complete");
break;
default:
echo $x;
}
}
$query="UPDATE members SET new='0' WHERE num='$id'";
mysql_query($query) or die("New update failed");
mysql_close();
header("Location: memadmin.php");
exit();}

What I'm curious about is why id enters its self from 20 to 1 instead of 1 to 20

chazzy
09-14-2006, 10:01 PM
is autocommit on or off?

Phalon
09-15-2006, 11:15 AM
I have no idea what that is

chazzy
09-15-2006, 01:28 PM
it's either in php or mysql, and tells the system to autocommit on update or if you need to give an explicit COMMIT;

The behavior you are describing is like what would happen if you had autocommit off, it writes to the database backwards essentially.

The order of insert shouldn't matter though.