Jump to content

stupid insert query wont work, beyond me.


cstegner

Recommended Posts

A super simple insert query that I have used at least 2 million times, wont work. let me know if you can see why.

[code]
if(isset($_POST['send_message'])){
  $q_send_message = mysql_query("INSERT INTO messages (to, from, subject, message, date) values ('$id', '$user_id', '$subject', '$message', '$today')");
  echo "
    <div id=\"middle\">
        <br /><br />
        <div class=\"body_header\">Send Message</div>
        <p class=\"body_text\" />
        <b>Your message has been sent!</b><br /><br />
        Return to <a href=\"/userpage/index.php\">User Page</a>.
    </div>
  ";
  include($_SERVER['DOCUMENT_ROOT'].'/inc/home_bottom.php');
  exit();
}
[/code]

the table name is definitley messages. I also tried setting all the values directly in the query rather then variables, to see if they were the problem. It would still not work. I have also tested all the variables they all work. Every thing in the if runs correctly other then the insert query.

thanks for the help.
Link to comment
Share on other sites

Just a thought. "FROM" and "TO" are MySQL reserved words and shouldn't be used as a column name. Backticks might save you:
[code]"INSERT INTO messages (`to`, `from`, subject, message, date) values ('$id', '$user_id', '$subject', '$message', '$today')"[/code]

It that doesn't do it, add a sensible mysql error message to the query to see if an sql error exists.
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.