BlameThePixel!

BTForum » BlameTheOffTopic Forums » BlameTheGeneralOffTopic » PHP, very weird error.

[]Dingbats
;
Send PM
An Avatar
Posts: 1970
Threads: 50
Mood: Optative
Money: £268.57 (D)
(+ Friend)
Not online within the last half an hour
I'm making a PM script, but MySQL think there are errors in it. Here it is (the code to add the PM do the database):
\n
/* ENDS HERE */ $title = addslashes($_POST["title"]); $msg = nl2br(addslashes($_POST["msg"])); $date = date("Y-m-d"); /* Insert into database */ $sql = "INSERT INTO pms (to, from, title, msg, date) VALUES ('".$to."', '".$from."', '".$title."', '".$msg."', '".$date."')"; $result = mysql_query("$sql"); $bajs = mysql_error(); ?>
\n
I have a form on another page with input boxes with the names I've written in the code, that isn't the problem. The database tables is called 'pms' and the columns in it are called what I've written in there. $bajs is echoed later on the page, and this is what it says:
"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 'to, from, title, msg, date) VALUES ('her', 'Dingbats', '12".
The title I filled in was '1234567890'. It seems that the SQL string is to long or something, though that seems weird since I have SQL strings that are way longer than that one.
Maybe I've done some simple n00b mistake in there, can someone please help me?:|
18.05.04 17:20
Post #1
[Softbrain Games] [Hide Sig (2)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
from and date might be reserved keywords for mysql, which would be why it identifies that bit as the error

________________
Cant be arsed to remake my sig.
18.05.04 20:09
Post #2
[Hide Sig (7)] [Profile] [Quote]
[S]Zogger!
Looking For Status
Send PM
Posts: 3954
Threads: 62
Money: £93.82 (D)
(+ Friend)
Not online within the last half an hour
good point. I'm pretty sure from will cause a mysql error, seeing as it's "select * FROM". Don't know about date tho.

________________
You know I'm a dancing machine
19.05.04 07:40
Post #3
[Hide Sig (8)] [Profile] [Quote]
[]Dingbats
;
Send PM
An Avatar
Posts: 1970
Threads: 50
Mood: Optative
Money: £268.57 (D)
(+ Friend)
Not online within the last half an hour
Thanks, I'll try changing that.:)
19.05.04 14:00
Post #4
[Softbrain Games] [Hide Sig (2)] [Profile] [Quote]
[S]ReadMe
Absent
Send PM
Posts: 2820
Threads: 85
Money: £43.42 (D)
(+ Friend)
Not online within the last half an hour
i think 'to' might throw an error too - i know i had to name my database fields 'sender' and 'recipient' when making my PMs system

________________
Cant be arsed to remake my sig.
22.05.04 10:39
Post #5
[Hide Sig (7)] [Profile] [Quote]
[]Dingbats
;
Send PM
An Avatar
Posts: 1970
Threads: 50
Mood: Optative
Money: £268.57 (D)
(+ Friend)
Not online within the last half an hour
Yep, I've changed 'to' to 'to_', 'from' to 'from_' and 'date' to 'date_', and it works now.:)
24.05.04 12:31
Post #6
[Softbrain Games] [Hide Sig (2)] [Profile] [Quote]

Post Reply

Jump To:


Your Comments:

Donate to BlameThePixel:
Donate to BTP Via PayPal


[22 Queries, Page Loaded in 0.321712 Seconds]

ShoutMeUp

Xmas Greetings from waka waka waka waka []Unvalidated EmailChristmasRiddle MERRY CHRISTMAS EVERYONE! []Spleet Except for Spleet. []TheAbdBoy Always bummin' a brother out. []Spleet Happy New Year everyone! But Spleet. []TheAbdBoy

Word Association

All

-10 Ago-

MiddleEastern []AlphaWolf camel [S]Bloopy toe []TheAbdBoy moose knuckle [S]Bloopy MeatLoaf []Spleet IdDoAnything4Lo ve []AlphaWolf rub n tug []TheAbdBoy tugboat []The Pope rope [S]Bloopy race []TheAbdBoy

-Latest-


Must be logged in to add new words

FictoLeague

You have to be logged in to vote...

Member Stats

Date: 21.11.24.
Members: 4731.
Latest: []Unvalidated Emailsdsakldsaldklasdsdsa
Active:
0 user(s)
1 guest(s)

On chat:
Lots of people

Files: 3330

Bloopy's Site
Get Firefox Get Opera Donate to BTP Via PayPal