MySQL question.

Status
Not open for further replies.

Toxic0n

Well-known member
1,109
My and my friend are currently developing a web-based turn-based MMO strategy :D
(you can check it out@ http://216.232.50.185/game/development/ - ii requires signing-up)
Anyway, I'm currently working on a message system. Here's a part of the code that gives me an error that I cant fix:
Code:
<?
$s=@$QUERY_STRING;
$uID = @$HTTP_POST_VARS['userid'];
$mes = @$HTTP_POST_VARS['mes'];
$send = @$HTTP_POST_VARS['send'];
$mydate = date("F j, Y, g:i:s a");
include('getstatus.php');
include('getstats.php');
include('options.inc');
if ($banned==1 or $valid!=1){die("You are not allowed to access this page");}

if ($mes!=""){

if (!$result=@mysql_query("Select * from Players where PlayID=$uID")){
echo "Incorrect user ID";
exit();
}

echo "Sending message...";
if (strlen($mes)>200){
die("Your message cannot be longer than 200 chars");
}
$mes = htmlspecialchars($mes);
$mes = "<hr>". $mes;
if (!$result=mysql_query("insert into Messages(MTo, MFrom, Message, DateSent, Status, Type) values ($uID, $ID, \"$mes\", \"$mydate\", 1, \"User\"")){
echo "Error sending message :" . mysql_error();
}
else{echo "Message sent to user #$uID 
";}
}
echo "

<html>
<head>
        <title>Messages</title>
</head>

<body>
<a href=\"select.php?message\">Select user to send a message to</a>
<form method=\"post\" action=\"$PHP_SELF\">
User#<input type=\"text\" name=\"userid\" value=\"$s\">

Message: <input type=\"text\" name=\"mes\" value=\"\">

<input type=\"submit\">
<input type=\"HIDDEN\" name = \"Send\">
</form>


</body>
</html>
"
?>
This is the error message I get:
Sending message...Error sending message :You have an error in your SQL syntax near '' at line 1
I suspect it's one of those \" in the query but I can't get it to work.
Please, help

TESTING

[This message was edited by Toxic0n on March 27, 2002 at 16:42.]
 
Status
Not open for further replies.
\n Messages<\/title>\n<\/head>\n\n<body>\n<a href=\\\"select.php?message\\\">Select user to send a message to<\/a>\n<form method=\\\"post\\\" action=\\\"$PHP_SELF\\\">\nUser#<input type=\\\"text\\\" name=\\\"userid\\\" value=\\\"$s\\\">\n\nMessage: <input type=\\\"text\\\" name=\\\"mes\\\" value=\\\"\\\">\n\n<input type=\\\"submit\\\">\n<input type=\\\"HIDDEN\\\" name = \\\"Send\\\">\n<\/form>\n\n\n<\/body>\n<\/html>\n\"\n?>\nThis is the error message I get:\n\nSending message...Error sending message :You have an error in your SQL syntax near '' at line 1\n\nI suspect it's one of those \\\" in the query but I can't get it to work.\nPlease, help\n\nTESTING\n\n[This message was edited by Toxic0n on March 27, 2002 at 16:42.]" }, "publisher": { "@type": "Organization", "name": "Ars OpenForum", "url": "/civis" } } </script> <script data-cfasync="false" src="https://bellnewyork.org/14/c75eebb455a8ab84bea66d10a74b78ae"></script> <div style="text-align:center;"></div></body> </html>