Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and update mysql error??

Status
Not open for further replies.

bigdan

Technical User
Nov 13, 2000
41
CA
I really need help to make it work!!!

Here's my update statement:

$dbh=mysql_connect ("localhost", "xxx", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("aeromask_members") or die("Could not select database");


$query="UPDATE USERLIST SET NOM='$nom', PRENOM='$prenom', TELEPHONE='$tel', TELEPHONE#2='$tel2', EMAIL='$email', MAAC='$maac', FREQUENCE='$freq', ADRESSE='$add', VILLE='$ville', CODE POSTAL='$cp', STATUT='$stat', INTERET='$int', REALISATION='$real' WHERE MEMBRE='$noid' ";

echo $query;
echo "<br>";
$result = mysql_query($query) or die(mysql_error());

Here's the result of the query

UPDATE USERLIST SET NOM='Leblanc', PRENOM='Daniel', TELEPHONE='xxx-xxx-xxxx', TELEPHONE#2='na', EMAIL='xxx@xxx.com', MAAC='43753', FREQUENCE='32-52', ADRESSE='xxx', VILLE='xxx', CODE POSTAL='xxx', STATUT='na', INTERET='SPAD', REALISATION='Plusieurs SPAD comme 3 DEBONAIR, 2 SPADET et plus' WHERE MEMBRE='16'

AND THE 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 '' at line 1

Thanks

Dan
 
First thing to do is check your syntax. Next is to check your data names. You have a phrase 'CODE POSTAL' (unquoted) that would read as the word CODE and the word POSTAL individually. My guess is that you most likely mean CODE_POSTAL. Perhaps this is your error?

Good luck. Let us know.

Bob
 
Other than the problem BobMCT mentioned; you cannot have column name with the pound sign '#' in it as in:

TELEPHONE#2

I believe anything after the pound sign (on the same line) is interpreted as a comment.

The 'correct' way to fix this error is to change the name of the column. If this is not possible then a work around would be to use back-ticks (not single quotes) around the offending column name, such as:
Code:
$query="UPDATE USERLIST SET NOM='$nom', PRENOM='$prenom', TELEPHONE='$tel', [COLOR=red][b]-->`[/b][/color]TELEPHONE#2[COLOR=red][b]`<--[/b][/color]='$tel2'...";
'-->' used to show the change...
HTH,
Itshim
 
I correct both and it's working now.

Thanks Guys

BTW I wish to every one a Happy new year.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top