Jump to content

[SOLVED] INSERT INTO error


George Botley

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

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.