Jump to content

update query


astralaaron
 Share

Recommended Posts

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

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

$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 1
i 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

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

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

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

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

You mean that you added ` around each element before = ? I never do that and those works fine with me :s
yeah.. 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

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

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
ahh thank you for clearing that up for me. that makes perfect sence
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...