Jump to content

Recommended Posts

I am being faced with the irritating

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to, from, from_email, subject, message, date, time) VALUES ('','George Botlet',' at line 1

 

 

Below is the code... I have extracted the person I am sending the message to, and then want to manipulate the data to insert it into the messages table....

 

Any ideas as to why I am being given that error?

 

Below is the code...

 

$query = "SELECT * FROM team_members WHERE assignment='$assignment' AND team='$team'"; 

$qry = mysql_query($query)
or die ("Could not match data because ".mysql_error());

while($row = mysql_fetch_array($qry))
  {
  $to_contact = $row['name'];
  $to_email = $row['email'];
  $to_subject = "$q5d";
  $to_message = "$q6";
  $today = date("Y-m-d");
  $time = date("g:i a");
  }
  
//Send Message To Relevant Person

$sql="INSERT INTO team_messages (to, from, from_email, subject, message, date, time) 
VALUES ('$to_contact','$name','$email', '$to_subject', '$to_message', '$today', '$time')";

if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

Link to comment
https://forums.phpfreaks.com/topic/167265-solved-insert-into-error/
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.