10 Replies - 1064 Views - Last Post: 26 September 2012 - 03:05 PM

#1 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 12:09 PM

Hey guys,
When my insert into function executes I receive this 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 'Mr.', 'BK-11125', 'Lol', '40788' '', '')' at line 2! With that said, I am reading a spreadsheet with PHPExcel and I am inserting data from the spreadsheet cells into a remote db.

$dbc = mysql_query("INSERT INTO coverages ( Name, Comments, Premium, Effective_Date, Expiration_Date, Broker_First_Name , Broker_Middle_Initial, Broker_Last_Name, Broker_Suffix, Broker_License_Number,  DateCreated)
                VALUES ('$rw1', '$rw2', '$rw3', '$rw4', '$rw5, '$rw6', '$rw7', '$rw8', '$rw9' '$rw10', '$rw11')") or die (mysql_error());


Any thoughts as to what causes this error?

Is This A Good Question/Topic? 0
  • +

Replies To: You have an error in your SQL syntax check the manual that correspond

#2 adolf625  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 161
  • Joined: 22-November 08

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 12:11 PM

Are all of the values supposed to be strings of data, or are some of them dates and ints, if they are that is probably your error is you are passing in all values as strings.
Was This Post Helpful? 1
  • +
  • -

#3 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 12:19 PM

Yes some of them are dates and ints.
Was This Post Helpful? 0
  • +
  • -

#4 adolf625  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 161
  • Joined: 22-November 08

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 12:32 PM

Remove the quotes around the ones that are around the ints, and that should fix it. When the quotes are around it is passing it in as a string or varchar instead of an int and throwing an error.
Was This Post Helpful? 1
  • +
  • -

#5 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 01:40 PM

Thanks! Now with that said, for some reason my name cell is inserting as a number!!?? Why is this happening?
Was This Post Helpful? 0
  • +
  • -

#6 adolf625  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 161
  • Joined: 22-November 08

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 01:48 PM

If you are using it as the first column in the table it is probably setting its self up as a unique key to identify the row of data with. It is int because it will auto increment itself to ensure it is unique.Hopefully that makes sense, since I probably described it in a crappy way.
Was This Post Helpful? 0
  • +
  • -

#7 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 02:13 PM

It is not the first column in my table. My first column is called id.
Was This Post Helpful? 0
  • +
  • -

#8 adolf625  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 161
  • Joined: 22-November 08

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 02:34 PM

I would check what type you have set name to then, if you have PHPmyadmin just look it up that way and change it if necessary, because it sounds like a type issue.
Was This Post Helpful? 0
  • +
  • -

#9 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 02:41 PM

It is varchar.
Was This Post Helpful? 0
  • +
  • -

#10 adolf625  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 161
  • Joined: 22-November 08

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 02:44 PM

Echo $rw1 and see what it gives you.
Was This Post Helpful? 0
  • +
  • -

#11 BarNunBoi  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 232
  • Joined: 28-March 12

Re: You have an error in your SQL syntax check the manual that correspond

Posted 26 September 2012 - 03:05 PM

I have to go back to the drawing board! When I echo $rw1...it doesn't display the data for that particular cell. I will keep you guys updated!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1