Jump to content

How can I fix this?


Faracus

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.

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...