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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.