I've been working on a new online game for a few weeks now, an am in the middle of trying to set up a simple messaging system.
Right now I'm using a simple Table with columns for id, to, from, subject, message, timesent, and read.
my problem is that when i try to insert new messages into the table, they simply never are inserted! I've been checking my syntax for a few days now, an I'm baffled as to why this statement wont work...
Here is the portion of the code that isn't working:
if($ready == "Send"){//SEND WAS CLICKED
$check=mysql_query("SELECT * FROM players WHERE id='$to'");
$rowcheck=mysql_fetch_array($check);
if($rowcheck['user'] == ""){
?>
<script language="JavaScript">
<!--
alert("That player does not exist.");
//-->
</script>
<?php
}else{
mysql_query("INSERT INTO messages (to,from,subject,message) VALUES($to,$from,$subject,$message);");
goTown("Message Sent!");
}
}//IF SEND WAS CLICKED
The problem is in the insert statement i believe. I've tested the query_fetch_array, and it is in fact returning the correct user that has been specified in the 'to' field. and the function 'goTown' is working, as it is sending the alert that the message was successfully sent.
Any help would be greatly appreciated!
PS, if you wanna see the code in action, the game I'm working on is actually online, an playable (except the messaging of course )
heres the URL right now:
http://www.videogamenewz.com/LR