Faracus Posted April 19, 2012 Report 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 Report 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 Report 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 Report Share Posted April 19, 2012 (edited) it looks like $query1 is evaluating a number . print out $sql3 to see what the query looks like and to be sure. Edited April 19, 2012 by birbal Link to comment Share on other sites More sharing options...
Faracus Posted April 19, 2012 Author Report Share Posted April 19, 2012 (edited) 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 Edited April 19, 2012 by Faracus Link to comment Share on other sites More sharing options...
birbal Posted April 19, 2012 Report 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 Report Share Posted April 19, 2012 Thanks for all the help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now