5 Replies - 2449 Views - Last Post: 14 November 2009 - 02:16 PM Rate Topic: -----

#1 oaluyi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 04-November 09

You have an error in your SQL syntax

Posted 14 November 2009 - 01:23 PM

How can I get rid of this syntax?

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 'from,skills,dsdlocation,country) VALUES ('oaluyi234','soweto234','oaluyi@yah' at line 1

<?php
extract ($_POST);
		 include 'config.php'; 
		include 'opendb.php';
		$query="INSERT INTO uploadcv (username,pwd,email,phone,from,skills,dsdlocation,country) 
		VALUES ('$username','$pwd','$email','$phone','$from','$skills','$dsdlocation','$country')";
if ( !( $res = mysql_query($query))){
		   die(mysql_error());
}
?>
<?php
include 'closedb.php';			  
?>




Is This A Good Question/Topic? 0
  • +

Replies To: You have an error in your SQL syntax

#2 BGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 84
  • Joined: 01-April 09

Re: You have an error in your SQL syntax

Posted 14 November 2009 - 01:49 PM

(username,pwd,email,phone,from,skills,dsdlocation,country)

-->
(`username`,`pwd`,`email`,`phone`,`from`,`skills`,`dsdlocation`,`country`)


There are reserved words in mysql like FROM. Escape them with `
Was This Post Helpful? 1
  • +
  • -

#3 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: You have an error in your SQL syntax

Posted 14 November 2009 - 01:54 PM

Whenever there are syntax issues, I always want to visually verify the output of what the sql values are & compare them to what I think they are.
<?php
extract ($_POST);
		 include 'config.php';
		include 'opendb.php';
		$query="INSERT INTO uploadcv (username,pwd,email,phone,from,skills,dsdlocation,country)
		VALUES ('$username','$pwd','$email','$phone','$from','$skills','$dsdlocation','$country')";
if ( !( $res = mysql_query($query))){
		   die("<P>SQL Failed : ".$query."</p><p>".mysql_error());
}
?>
<?php
include 'closedb.php';			  
?>


Was This Post Helpful? 0
  • +
  • -

#4 oaluyi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 04-November 09

Re: You have an error in your SQL syntax

Posted 14 November 2009 - 02:03 PM

Thank you, it is inserting into the tables, but I now get this message

Duplicate entry '2147483647' for key 'PRIMARY'


I think the error has to do with my tables.

What do I do?
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: You have an error in your SQL syntax

Posted 14 November 2009 - 02:08 PM

Look for the value '2147483647' in your table. I'm not sure which column that's placing it into, but because the column is set to PRIMARY KEY, that means each value placed into that column must be unique. Either change the value in the database, or change the value that you are inserting. Alternatively you could also just update what's in the database, but again, the value '2147483647' is in a unique field & they must all be unique.
Was This Post Helpful? 1
  • +
  • -

#6 oaluyi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 04-November 09

Re: You have an error in your SQL syntax

Posted 14 November 2009 - 02:16 PM

Yea, you are right. Finally everything is working. Thank Y'all so much. PHP can be frustrating at times. Its rules are just too strict.

I so much appreciate. Let me carry on with the other codes.

Cheers mate.

:-)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1