Jump to content

[SOLVED] Insert Error


forumnz

Recommended Posts

Hello,

 

I get this error when executing the below code:

 

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 'desc, keyw, addst, addsu, addci, addre, addpc, userid, ph, ph2, freeph, fax, ema' at line 1

<?php
$buzzname=$_POST['buzzname'];
$sub=$_POST['sub'];
$desc=$_POST['desc'];
$keyw=$_POST['keyw'];
$addst=$_POST['addst'];
$addsu=$_POST['addsu'];
$addci=$_POST['addci'];
$addre=$_POST['addre'];
$addpc=$_POST['addpc'];
$ph=$_POST['ph'];
$ph2=$_POST['ph2'];
$freeph=$_POST['freeph'];
$fax=$_POST['fax'];
$email=$_POST['email'];

$uid = $_SESSION['id'];

include('../dbcon.php');

$sql="INSERT INTO cmads (buzzname, sub, desc, keyw, addst, addsu, addci, addre, addpc, userid, ph, ph2, freeph, fax, email) VALUES ('$buzzname','$sub','$desc','$keyw','$addst','$addsu','$addci','$addre','$addpc','$uid','$ph','$ph2','$freeph','$fax','$email')";

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

?>

 

Whats going on?

 

I have a similar page which works:

<?php
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$buzzname=$_POST['buzzname'];
$buzzaddst=$_POST['buzzaddst'];
$buzzaddsu=$_POST['buzzaddsu'];
$buzzaddci=$_POST['buzzaddci'];
$buzzaddre=$_POST['buzzaddre'];
$buzzpc=$_POST['buzzpc'];
$buzzph=$_POST['buzzph'];
$buzzph2=$_POST['buzzph2'];
$buzzfreeph=$_POST['buzzfreeph'];
$buzzfax=$_POST['buzzfax'];
$uaddst=$_POST['uaddst'];
$uaddsu=$_POST['uaddsu'];
$uaddci=$_POST['uaddci'];
$upc=$_POST['upc'];
$uph=$_POST['uph'];
$uph2=$_POST['uph2'];
$ufax=$_POST['ufax'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];
$password = md5($password);

include('../dbcon.php');

$sql="INSERT INTO cmusers (ufname, ulname, buzzname, buzzaddst, buzzaddsu, buzzaddci, buzzaddre, buzzpc, buzzph, buzzph2, buzzfreeph, buzzfax, uaddst, uaddsu, uaddci, upc, uph, uph2, ufax, email, username, password) VALUES ('$fname','$lname','$buzzname','$buzzaddst','$buzzaddsu','$buzzaddci','$buzzaddre','$buzzpc','$buzzph','$buzzph2','$buzzfreeph','$buzzfax','$uaddst','$uaddsu','$uaddci','$ups','$uph','$uph2','$ufax','$email','$username','$password')";

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


?>

 

Thanks,

Sam.

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