Jump to content

[SOLVED] Not entering into database


Ryuujin

Recommended Posts

Hello,

I have been trying to figure this out for about 3 hours now and I can't fix it for nothing.

Here is the code were it inserts into the database:

if ($page =='messages' & $action == 'sendmessage2')
{
$sentto = mysql_real_escape_string($_POST['sentto']);
$from = $_SESSION[username];
$senton = 'NOW()';
$title = mysql_real_escape_string($_POST['title']);
$message = mysql_real_escape_string($_POST['message']);

mysql_query("INSERT INTO messages (sentto, from, senton, title, message) VALUES ('$sentto', '$from', '$senton', '$title', '$message')");
echo "Message Sent, <a href=index.php?page=messages>Continue</a>";
}

 

Ok, I think that is the origin of the problem. If you need the form just tell me. Now, the database table has all those so I don't think it is the database.

 

Any help is greatly appreciated.

 

Thanks,

-Ryuujin

Link to comment
https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/
Share on other sites

ok lets do this one by one...

 

is the table messages contain only the fields sentto, from, senton, title, message?

assign the query to another variable first and test if it got the right string...like this

$strQuery = "INSERT INTO messages (sentto, from, senton, title, message) VALUES (" . $sentto . "," . $from . ", ' . $senton "," . $title . "," . $message . ")";
echo $strQuery;

then post the output...is it the query you want?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.