astralaaron Posted May 16, 2007 Share Posted May 16, 2007 does anyone see anything wrong with this? ive checked everything.. echo'd out all of the variables they are all right.. <?php mysql_connect("localhost","root","****")or die("could not connect");mysql_select_db("tuneschedule")or die("could not select db");$schid = $_POST['schid'];$date = $_POST['date'];$from = $_POST['from'];$until = $_POST['until'];$program = $_POST['program'];$sql = "UPDATE schedule SET date = '$date', from = '$from', until = '$until', program = '$program' WHERE id = $schid";$result = mysql_query($sql);if ($result){header('location:http://localhost/tuneinordie/admin/admin.html');} else { echo mysql_error();}?> Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 this is crazy.. I am using the same program to update my news stories and it works fine...this is killing me!I am getting this error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from = '9am', until = '5pm', program = 'please worka' WHERE id = 1' at line 1 Link to comment Share on other sites More sharing options...
sajan Posted May 16, 2007 Share Posted May 16, 2007 $sql = "UPDATE schedule SET date = '$date', from = '$from', until = '$until', program = '$program' WHERE id = $schid";this is crazy.. I am using the same program to update my news stories and it works fine...this is killing me!I am getting this error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from = '9am', until = '5pm', program = 'please worka' WHERE id = 1' at line 1i think the culprit is WHERE id = $schid" .Try using WHERE id = '$schid' ".this may get rid of the error. Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 i think the culprit is WHERE id = $schid" .Try using WHERE id = '$schid' ".this may get rid of the error.i have tried that already but thanks :-(just so you see, i just tried it again and got this error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from = '91', until = '52', program = 'please workasd' WHERE id = '1'' at line 1 Link to comment Share on other sites More sharing options...
Anders Moen Posted May 16, 2007 Share Posted May 16, 2007 Try this maybe: <?php mysql_connect("localhost","root","****")or die("could not connect");mysql_select_db("tuneschedule")or die("could not select db");$schid = $_POST['schid'];$date = $_POST['date'];$from = $_POST['from'];$until = $_POST['until'];$program = $_POST['program'];$sql = "UPDATE schedule SET date = '$date', from = '$from', until = '$until', program = '$program' WHERE id = '$schid'";$result = mysql_query($sql);if ($result){header('location:http://localhost/tuneinordie/admin/admin.html');} else { echo mysql_error();}?> Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 Try this maybe:<?php mysql_connect("localhost","root","****")or die("could not connect");mysql_select_db("tuneschedule")or die("could not select db");$schid = $_POST['schid'];$date = $_POST['date'];$from = $_POST['from'];$until = $_POST['until'];$program = $_POST['program'];$sql = "UPDATE schedule SET date = '$date', from = '$from', until = '$until', program = '$program' WHERE id = '$schid'";$result = mysql_query($sql);if ($result){header('location:http://localhost/tuneinordie/admin/admin.html');} else { echo mysql_error();}?> What did you change??? Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 The problem is fixed,$sql = "UPDATE schedule SET date = '$date', from = '$from', until = '$until', program = '$program' WHERE id = $schid";$result = mysql_query($sql);needed to be$sql = "UPDATE schedule SET `date` = '$date', `from` = '$from', `until` = '$until', `program` = '$program' WHERE id = $schid";$result = mysql_query($sql);works fine now. Link to comment Share on other sites More sharing options...
Anders Moen Posted May 16, 2007 Share Posted May 16, 2007 You mean that you added ` around each element before = ? I never do that and those works fine with me :s Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 You mean that you added ` around each element before = ? I never do that and those works fine with me :syeah.. on my news update page I do not have the ` around it. and it works..but on this page it would not work! i tested everything and re-wrote it about 20 times..then right as I was about to give up I thought to try to add ` ` around them.. and it worked..? why I dont know!but I am happy to see it working! Link to comment Share on other sites More sharing options...
Lulzim Posted May 16, 2007 Share Posted May 16, 2007 then right as I was about to give up I thought to try to add ` ` around them.. and it worked..? why I dont know!but I am happy to see it working!There are some reserved words in MySQLIf you use any of these reserved words in table or column names (in this case from is used), you should put the column/table name in `` to tell MySQL that this is a name of table or column and not a MySQL special command Link to comment Share on other sites More sharing options...
astralaaron Posted May 16, 2007 Author Share Posted May 16, 2007 There are some reserved words in MySQLIf you use any of these reserved words in table or column names (in this case from is used), you should put the column/table name in `` to tell MySQL that this is a name of table or column and not a MySQL special commandahh thank you for clearing that up for me. that makes perfect sence Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.