ShaolinF Posted January 23, 2008 Share Posted January 23, 2008 Hey guys, I have 1 records in a table called events with 3 coloumns called eventName, ticketAmount and ticketPrice. I am trying to UPDATE this table with the following statement but it is not working: //UPDATE Data $result = mysql_query("UPDATE event SET eventName = $_POST['eventnm'], ticketAmount = $_POST['tickno'], ticketAmount = $_POST['tickprice']"); Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/ Share on other sites More sharing options...
Ken2k7 Posted January 23, 2008 Share Posted January 23, 2008 $result = mysql_query("UPDATE event SET eventName = {$_POST['eventnm']}, ticketAmount = {$_POST['tickno']}, ticketAmount = {$_POST['tickprice']}"); Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/#findComment-446670 Share on other sites More sharing options...
ShaolinF Posted January 23, 2008 Author Share Posted January 23, 2008 I run the code and I get the following: Invalid query: 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 ' ticketAmount = 122, ticketPrice = 1.22' at line 1 Whole query: //Error Check if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $result; die($message); } Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/#findComment-446682 Share on other sites More sharing options...
Ken2k7 Posted January 23, 2008 Share Posted January 23, 2008 You're not being specific enough both on your query and your question here on support. $result = mysql_query("UPDATE event SET eventName = {$_POST['eventnm']}, ticketAmount = {$_POST['tickno']}, ticketAmount = {$_POST['tickprice']}"); You should add in a WHERE clause. Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/#findComment-446688 Share on other sites More sharing options...
ShaolinF Posted January 23, 2008 Author Share Posted January 23, 2008 can you give me an example please ? Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/#findComment-446729 Share on other sites More sharing options...
hamza Posted January 24, 2008 Share Posted January 24, 2008 Dear, 1- USE SINGLE Quotes. 2- USE VARIABLE WITH SET it is right way. AND THEN TRY IT ............................. Quote Link to comment https://forums.phpfreaks.com/topic/87331-update-help/#findComment-447634 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.