pouncer Posted November 23, 2006 Share Posted November 23, 2006 this is my class_functions.php[code=php:0]<?php require_once("php_classes/class_db.php"); DB::Connect(); class Functions { // Send a private message to a user. function SendPrivateMessage($From, $To, $Subject, $Message) { $privmessage = mysql_query("INSERT INTO private_messages (From, To, Subject, Message, Date_Sent) VALUES('$From', '$To', '$Subject', '$Message', now())") or die (mysql_error()); } function RegistrationMessage() { return "Hellogfdhgfdg"; } }?>[/code]This is my test.php[code=php:0]<?php require_once('php_classes/class_functions.php'); $func = new Functions(); $msg = $func->RegistrationMessage(); $func->SendPrivateMessage("From-Mike", "To-John", "Subject-Welcome to the site", $msg); ?>[/code]on test.php though, i keep getting: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 'From, To, Subject, Message, Date_Sent) VALUES('From-Mike', 'To-J Quote Link to comment Share on other sites More sharing options...
Barand Posted November 23, 2006 Share Posted November 23, 2006 I suggest to think up a different name for the "From" column.FROM is a mysql reserved word as in "SELECT * FROM .... " Quote Link to comment Share on other sites More sharing options...
pouncer Posted November 23, 2006 Author Share Posted November 23, 2006 ok i did that. i changed it to From_i changed the code too.still same error :s Quote Link to comment Share on other sites More sharing options...
Barand Posted November 23, 2006 Share Posted November 23, 2006 Guess what, "TO" is also reserved Quote Link to comment Share on other sites More sharing options...
pouncer Posted November 23, 2006 Author Share Posted November 23, 2006 Awesome, that nailed it. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.