Jump to content


Photo

[fixed]Need help with insert syntax


  • Please log in to reply
3 replies to this topic

#1 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 30 August 2006 - 04:07 AM

I would like to insert into my Mysql database information related to the logged in user....

here is the code I created, but there are problems....

("INSERT INTO cars (name, registered, registry_id, make, color, markings, mfg_date, purchase_price, purchase_date, sell_price, sell_date, addnotes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) WHERE username='{$_SESSION[loginUsername]}'"


Problems:
  • If I remove the WHERE statement data is inserted in the cars table, but its not tied to the logged in user ID and username
  • If I use the WHERE statment I get this message - You have an error in your SQL syntax

Any thoughts/ and education would be great to get me over this hump :-\

FIXED - ("INSERT INTO cars (username, name, registered, registry_id, make, color, markings, mfg_date, purchase_price, purchase_date, sell_price, sell_date, addnotes) VALUES ('{$_SESSION[loginUsername]}', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" ;D

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 30 August 2006 - 01:33 PM

So is this solved?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 31 August 2006 - 03:44 AM

Yes. Thank you for asking...  That is why I put [fixed] in the summary and added the fix to the bottom of the post

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 31 August 2006 - 03:56 AM

No problem.. I'm used to seeing "SOLVED".
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users