Jump to content

How can I fix this?


Faracus
 Share

Recommended Posts

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

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

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

it looks like $query1 is evaluating a number . print out $sql3 to see what the query looks like and to be sure.

Edited by birbal
Link to comment
Share on other sites

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 by Faracus
Link to comment
Share on other sites

use backtick around $query1. its better though to avoid integer column name. use a descriptive name instead.

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...