FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problems with SQL





ChrisCh
Heya. An SQL statement of mine isn't working properly, and I can't work out why it's doing what it is. The code is:
Code:
$sqlmsg = "insert into messaging (from_user, to_user, subject, msg, time, ip, msg_read, msg_all, high_priority) values ('$curruser2', '$to_user', '$msgsubject', '$message', '$time', '$sendip', '$msg_read', '$allmsg2', '$hp2')";
mysql_query ($sqlmsg) or die(mysql_error());

(all variables have been declared and contain valid data for the database, connection has been successfully made to the database, etc...). The error that it's giving is this:
Quote:
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 'high_priority) values ('admin', 'user', 'testing', 'message',


It's strange because I have queries like this in other areas of my site and it's just this one that doesn't seem to be working! If anyone knows what I'm doing wrong here, a push in the right direction would be greatly appreciated! Smile
mathiaus
I'm going to go ahead and guess that high_priority either doesn't exist or is spelt wrong or just named differently in the database.
rohan2kool
before u run the query with $sqlmsg as the query, output the query for debugging purposes using echo($sqlmsg);

that's only for debugging so that u can see how the query looks like b4 it's executed and after the variables have been substituted.
muggle
HIGH_PRIORITY is a reserved word in MySQL if you really want to use it you have to quote it;
See http://www.brainbell.com/tutorials/MySQL/MySQL_Reserved_Words.htm for more reserved words.
Related topics
Help: SQL error after uploading new files(thread updated)
Facing Many Problems
New forum area (computer problems)
Why not have a report button??
SLOW UPLOADING AN SQL FILE
Problems With Index Page
Interview: Derek Liu, Gaia Online Anime Community
I cant install php chat tables nor set up diffrent subdomain
FTP problems --> Use Filezilla and/or active mode
I can't upload my Database SQL script ! Helllppppp!!!!
Server 1 has same problems than server 2??
Importing databases
Help! Some problems in CPanel, database all of a sudden.
Move database to different SQL server
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.