Jump to content

Recommended Posts

Hi,

 

I've got this script however when I activate it i get an error:

 

  include ("connection.php");
  include ($_SERVER['DOCUMENT_ROOT'] . "/admin/scripts/audit.php");

  $inout = $_POST['inout'];
  $type = $_POST['type'];
  $by = $_POST['by'];
  $user = $_SESSION['username'];
  $candidate_id = $_POST['candidate_id'];
  $content = mysql_real_escape_string($_POST['content']);

$insertsql = "INSERT INTO candidate_coms (candidate_id, type, inout, by, content, user) VALUES ($candidate_id, $type, $inout, $by, $content, $user)";
mysql_query($insertsql) or die(mysql_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 'inout, by, content, user) VALUES (3693, Phone, in, drew, test, drew)' at line 1

 

Any ideas what i missed?

hmmm, I've changed my columns in the DB to make sure no reserved words are in use, and now have:

 

$insertsql = "INSERT INTO candidate_coms ('com_type','com_by','com_user','com_content','com_inout','candidate_id') VALUES ($type, $by, $user, $content, $inout, $candidate_id)";
mysql_query($insertsql) or die(mysql_error());

 

getting the same error...

ugh, this is wierd, i've changed alsorts now!

 

<?php
  include ("connection.php");
  include ($_SERVER['DOCUMENT_ROOT'] . "/admin/scripts/audit.php");

  $coms_user = $_SESSION['username'];

  $coms_inout = $_POST['coms_inout'];
  $coms_type = $_POST['coms_type'];
  $coms_by = $_POST['coms_by'];
  $candidate_id = $_POST['candidate_id'];
  $coms_content = mysql_real_escape_string($_POST['coms_content']);

$insertsql = "INSERT INTO candidate_coms ('com_type','com_by','com_user','com_content','com_inout','candidate_id') VALUES ($coms_type, $coms_by, $coms_user, $coms_content, $coms_inout, $candidate_id)";
mysql_query($insertsql) or die(mysql_error());

//<META HTTP-EQUIV="Refresh" CONTENT="0; URL=../candidate/viewcandidate.php?candidate_no=<?php echo $candid; ">
?>

 

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 ''com_type','com_by','com_user','com_content','com_inout','candidate_id') VALUES ' at line 1

change

$insertsql = "INSERT INTO candidate_coms ('com_type','com_by','com_user','com_content','com_inout','candidate_id') VALUES ($coms_type, $coms_by, $coms_user, $coms_content, $coms_inout, $candidate_id)";
mysql_query($insertsql) or die(mysql_error());

to

$insertsql = "INSERT INTO candidate_coms (`com_type`,`com_by`,`com_user`,`com_content`,`com_inout`,`candidate_id`) VALUES ('$coms_type', '$coms_by', '$coms_user', '$coms_content', '$coms_inout', '$candidate_id')";
mysql_query($insertsql) or die(mysql_error());

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.