PDA

View Full Version : db error


Boofo
01-02-2003, 09:20 AM
I got this db error earlier tonight and was wondering if someone could please tell me what it means?

Database error in vBulletin 2.2.9:

Invalid SQL: UPDATE user SET signature='\"Everybody wants to go to heaven, but nobody wants to die.\"

~Boofo\'s Babe~ ' WHERE userid=
mysql error: You have an error in your SQL syntax near '' at line 1

mysql error number: 1064

Date: Thursday 02nd of January 2003 10:33:48 AM
Script: http://www.bearfacts2.com/forum/forum/sedit.php
Referer: http://www.bearfacts2.com/forum/sedit.php


The file in question is a signature editing file. Here is the code I thought was causing it:

if ($action=="SaveChanges") {
$newsignature=censortext($signatureform);
$DB_site->query("UPDATE user SET signature='".addslashes($newsignature)."' WHERE userid=$bbuserid");

and here is what I changed it to:

if ($action=="SaveChanges") {
$newsignature=censortext($signatureform);
$DB_site->query("UPDATE user SET signature='".addslashes($newsignature)."' WHERE userid='$bbuserinfo[userid]'");

The reason I changed "userid=$bbuserid" to "userid='$bbuserinfo[userid]'" was because in 2 other places in the same file on db queries they were using "userid='$bbuserinfo[userid]'" and not just userid=$bbuserid. Would that make a difference?

Xenon
01-02-2003, 01:40 PM
$bbuserid is just defined in a cookie, and is never globalized in anyfunctions, $bbuserinfo['userid'] is defined nearly boardwide so you should always use this

Boofo
01-02-2003, 01:47 PM
Was that what caused the db error then? The apostrophe in the name wouldn't have had anything to do with it, would it? I don't know why they used "$bbuserinfo['userid']" when calling info from the database and used "$bbuserid" to write it back. I guess I need to know if I fixed it by changing that variable or will I have problems on down the road somewhere with it? :)

Xenon
01-02-2003, 01:59 PM
the userid, has no appostrophe in it ;)

always use bbuserinfo[userid], i think that bbuserid was producing the error

Boofo
01-02-2003, 02:15 PM
Thank you, sir. That was what I needed to hear. :) What I don't get is when I was running that same file on v2.2.5, it worked fine and I never got an error with it. :)

Xenon
01-02-2003, 02:39 PM
i think vb225 has globalized also bbuserid, not sure, but i could be that...