View Full Version : db error
Boofo
01-24-2003, 04:31 AM
I just got the following error while trying to send a private message. Can someone please tell me what is happening here and maybe how to fix it?
Database error in vBulletin 2.2.9:
Invalid SQL: INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title ,message,dateline,showsignature,iconid,messageread ,folderid,receipt,attachmentid,showimage) VALUES (NULL,28,28,1,'try again','If you get a chance, can you please try what you did before again? Also, did you get a \"page not found\" or \"this page can not be displayed\" error?',1043389319,'1','0',0,0,1,0,)
mysql error: You have an error in your SQL syntax near ')' at line 1
mysql error number: 1064
Date: Friday 24th of January 2003 06:21:59 AM
Script: http://www.bearfacts2.com/forum/forum/private.php
Referer: http://www.bearfacts2.com/forum/private.php
Xenon
01-24-2003, 11:29 AM
look at the end: "0,1,0,)"
you hav a , where it shouldn't be :)
Boofo
01-24-2003, 11:54 AM
No matter who tries to send a pm, they get a db error now. Here's the code in question:
$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title ,message,dateline,showsignature,iconid,messageread ,folderid,receipt,attachmentid,showimage) VALUES (NULL,$touserinfo[userid],$touserinfo[userid],$bbuserinfo[userid],'".addslashes(htmlspecialchars($title))."','".addslashes($message)."',".time().",'$signature','$iconid',0,0,$receipt,$attachmentid ,$showimage)");
Xenon
01-24-2003, 03:55 PM
seems the showimage makes problems..
change it to:
$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title ,message,dateline,showsignature,iconid,messageread ,folderid,receipt,attachmentid,showimage) VALUES (NULL,$touserinfo[userid],$touserinfo[userid],$bbuserinfo[userid],'".addslashes(htmlspecialchars($title))."','".addslashes($message)."',".time().",'$signature','$iconid',0,0,$receipt,$attachmentid ,".intval($showimage).")");
Boofo
01-24-2003, 04:55 PM
I did this and it now seems to work. But is this the right way to do it or should I change it to what you have in the post abaove?
$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title ,message,dateline,showsignature,showimage,iconid,m essageread,folderid,receipt,attachmentid) VALUES (NULL,$touserinfo[userid],$touserinfo[userid],$bbuserinfo[userid],'".addslashes(htmlspecialchars($title))."','".addslashes($message)."',".time().",'$signature','$showimage','$iconid',0,0,$receipt, $attachmentid)");
I also moved it in the lines, but I don't think it really matters where it is at in there, does it?
Xenon
01-24-2003, 09:35 PM
no it doesn't matter where in the string it is...
well, your and my query are different.
yours hasn't the hack in anymore, mine would work with the hack (whichone it ever was?)
so if you don't need the hack yours is correct, if it's a needed hack you should use mine
Boofo
01-24-2003, 10:57 PM
The hack is still in there. I moved it behind showsignature and '$signature'. All I did was change $showimage to '$showimage' and it started working. What I was asking is am I going to have problems somewhere else with that change? What does ".intval($showimage)." do that '$showimage' doesn't do, or vice-versa?
Xenon
01-25-2003, 11:11 AM
well it depends on how you save the value in the db.
lets say $showimage is an empty string, then '$showimage' would become '', intval($showimage) would become that: 0
so if you save in the db as integer, you should use intval
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.