Log in

View Full Version : mysql error


AN-net
11-06-2004, 12:54 AM
need some help with this one, ive been tinkering and still cant get it to work>_<


Database error in vBulletin 3.0.3:

Invalid SQL: INSERT INTO chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (, '', , '', 1099709379, , )
mysql error: 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 ' '', , '', 1099709379, , )' at line 1

mysql error number: 1064

Date: Friday 05th of November 2004 09:49:39 PM
Script: http://www.animationation.net/community/chat.php?do=getmsgs&ch=1
Referer: http://www.animationation.net/community/chat.php
Username: Antonbomb22


query:

$DB_site->query("INSERT INTO ".TABLE_PREFIX."chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (".$msginsert['ch'].", '".addslashes($msginsert['chatter'])."', ".$msginsert['chatter_id'].", '".addslashes($msginsert['message'])."', ".TIMENOW.", ".$msginsert['receiver'].", ".$msginsert['private'].")");

EvilLS1
11-06-2004, 03:21 AM
What kind of value will be inserted for receiver? An ID or a username?
Try this:

$DB_site->query("INSERT INTO ".TABLE_PREFIX."chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (" . intval($msginsert['ch']) . ", '".addslashes($msginsert['chatter'])."'," . intval($msginsert['chatter_id']) . ", '".addslashes($msginsert['message'])."', ".TIMENOW.", '$msginsert[receiver]', '$msginsert[private]')");

AN-net
11-06-2004, 03:24 AM
What kind of value will be inserted for receiver? An ID or a username?
Try this:

$DB_site->query("INSERT INTO ".TABLE_PREFIX."chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (" . intval($msginsert['ch']) . ", '".addslashes($msginsert['chatter'])."'," . intval($msginsert['chatter_id']) . ", '".addslashes($msginsert['message'])."', ".TIMENOW.", '$msginsert[receiver]', '$msginsert[private]')");

an id;)

EvilLS1
11-06-2004, 03:27 AM
an id;)

Try this then:

$DB_site->query("INSERT INTO ".TABLE_PREFIX."chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (" . intval($msginsert['ch']) . ", '".addslashes($msginsert['chatter'])."'," . intval($msginsert['chatter_id']) . ", '".addslashes($msginsert['message'])."', ".TIMENOW.", " . intval($msginsert['receiver']) . ", '$msginsert[private]')");

AN-net
11-06-2004, 04:19 AM
fixed it:D

AN-net
11-06-2004, 04:25 AM
ok well it runs the query but my function isnt working :(

here is my code:

if($_POST['action']=="msginsert")
{
globalize($_POST, array(
'message' => TEXT,
'ch' => INT
));
require_once('./includes/functions_chat.php');
parse_commands($message);
$DB_site->query("INSERT INTO ".TABLE_PREFIX."chat_messages (channel_id,chatter,chatter_id,chat_msg,msg_dateli ne,receiver,msg_private) VALUES (" . intval($msginsert['ch']) . ", '".addslashes($msginsert['chatter'])."'," . intval($msginsert['chatter_id']) . ", '".addslashes($msginsert['message'])."', ".TIMENOW.", " . intval($msginsert['receiver']) . ", ".intval($msginsert[private]).")");
}


and functions_chat.php i have attached:)

AN-net
11-08-2004, 03:03 PM
anyone.....