Faracus Posted April 19, 2012 Share Posted April 19, 2012 I'm trying to make this code work $sql3= "UPDATE lottomax SET " . $query1 . "='" . $number1 . "'";if (!mysql_query($sql3,$con)){die('Error: ' . mysql_error());} and I keep getting this error: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 '5='1'' at line 1 Link to comment Share on other sites More sharing options...
birbal Posted April 19, 2012 Share Posted April 19, 2012 i assume $number1 is int field. if it is like so remove the quotes around it. $sql3= "UPDATE lottomax SET $query1=$number1"; and you dont need to use concatenate oprator inside double quotes value of variable wil be evaluated itself Link to comment Share on other sites More sharing options...
Faracus Posted April 19, 2012 Author Share Posted April 19, 2012 sadly, I'm still getting the error "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 '5=1' at line 1" Link to comment Share on other sites More sharing options...
birbal Posted April 19, 2012 Share Posted April 19, 2012 it looks like $query1 is evaluating a number . print out $sql3 to see what the query looks like and to be sure. Link to comment Share on other sites More sharing options...
Faracus Posted April 19, 2012 Author Share Posted April 19, 2012 if I put in "You have chosen " . $query1 . ", and updated the total to " . $number1 . ".<br /> it prints out the right values. and if I print out sql3 I get UPDATE lottomax SET 5=1 Link to comment Share on other sites More sharing options...
birbal Posted April 19, 2012 Share Posted April 19, 2012 use backtick around $query1. its better though to avoid integer column name. use a descriptive name instead. Link to comment Share on other sites More sharing options...
Faracus Posted April 19, 2012 Author Share Posted April 19, 2012 Thanks for all the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.