Jump to content


Photo

Inserting variables into SQL?


  • Please log in to reply
2 replies to this topic

#1 AncientSage

AncientSage
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 02 August 2006 - 06:30 PM

Hello,

I'm attempting to put variables into a column, but it appears to be giving me problems:

INSERT INTO file (id, song_filename, song_name, song_author, song_genre) VALUES ('', $file, $name, $type, $description);

Yeah, it's telling me "unknown column *putvalueof$filehere* in"

It's thinking the variables are columns, how would I get around this?

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 02 August 2006 - 06:41 PM

If they are string variables you need to enclose them in quotes.
INSERT INTO file (id, song_filename, song_name, song_author, song_genre) VALUES ('', '$file', '$name', '$type', '$description');

Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 AncientSage

AncientSage
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 02 August 2006 - 07:22 PM

Ah, that would explain it. Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users