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 Link to comment https://forums.phpfreaks.com/topic/28279-sql-errorz-solved/ 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 .... " Link to comment https://forums.phpfreaks.com/topic/28279-sql-errorz-solved/#findComment-129311 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 Link to comment https://forums.phpfreaks.com/topic/28279-sql-errorz-solved/#findComment-129313 Share on other sites More sharing options...
Barand Posted November 23, 2006 Share Posted November 23, 2006 Guess what, "TO" is also reserved Link to comment https://forums.phpfreaks.com/topic/28279-sql-errorz-solved/#findComment-129319 Share on other sites More sharing options...
pouncer Posted November 23, 2006 Author Share Posted November 23, 2006 Awesome, that nailed it. Thanks. Link to comment https://forums.phpfreaks.com/topic/28279-sql-errorz-solved/#findComment-129324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.