Jump to content

[SOLVED] Help me decode an INSERT error...Stumped


mem0ri

Recommended Posts

I'm running a PHP5 site with a MySQL 4.1 database (yea, I'm asking the provider to update it to 5+)...

 

...I've got several INSERT, SELECT, UPDATE, etc. statements working great through my database classes--so we know the PHP isn't the problem...

 

I have a particularly long SQL statement:

 

$q = "INSERT INTO rentunit (id, name, region, position, rescom, price, prims, kowner, birth, ptype, active, lease, ishout, iauto, interval, t1, t2, t3, t4) 
	      VALUES ('$kobj','$sobj','$sregion','$vpos',0,$price,$prims,'$kowner',$birth,$ptype,0, 0, $shout, $auto, $interval, $t1, $t2, $t3, $t4) 
		  ON DUPLICATE KEY UPDATE name='$sobj', region='$sregion', position='$vpos', price=$price, prims=$prims, kowner='$kowner', ptype=$ptype, lease=0, ishout=$shout, iauto=$auto, interval=$interval, t1=$t1, t2=$t2, t3=$t3, t4=$t4";

 

That is acquiring proper information (I've done a die($q) to read what it translates into):

 

INSERT INTO rentunit (id, name, region, position, rescom, price, prims, kowner, birth, ptype, active, lease, ishout, iauto, interval, t1, t2, t3, t4) VALUES ('objectvalue','Name','Region ','positionvalue',0,1,50,'uservalue',2007-03-08 17:12:27,0,0, 0, 1, 1, 604800, 1, 2, 3, 4) ON DUPLICATE KEY UPDATE name='Name', region='Region ', position='positionvalue', price=1, prims=50, kowner='uservalue', ptype=0, lease=0, ishout=1, iauto=1, interval=604800, t1=1, t2=2, t3=3, t4=4

 

The table:

 

id-->VARCHAR40

name-->VARCHAR100

region-->VARCHAR25

position-->VARCHAR15

rescom-->TINYINT1  NULL

price-->INT5

prims-->INT5  NULL

kowner-->VARCHAR40

sugprice-->INT5  NULL

birth-->DATETIME

death-->DATETIME  NULL

ptype-->TINYINT1

active-->TINYINT1

lease-->INT11  NULL

ishout-->TINYINT1

iauto-->TINYINT1

interval-->INT8

t1-->INT7  NULL

t2-->INT7  NULL

t3-->INT7  NULL

t4-->INT7  NULL

 

 

The 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 'interval, t1, t2, t3, t4) VALUES ('055bbe47-7df4-7037-acab-10eae649da73','CED Re' at line 1

 

Help?  Been wrackin' my brain for over an hour on just this one problem.

Link to comment
Share on other sites

Thank you.  I'll try that out.

 

Actually...it ended up being that the word 'interval' is a reserved word for MySQL...plus the date quote.  FUN...haha!  Thanks for lookin' over that and catching the date quote.  Definitely appreciated.

Link to comment
Share on other sites

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.