Page 1 of 1

[Solved] Variable not parsing or something...

Posted: Fri Mar 26, 2004 2:47 pm
by Steveo31
This is easy... I have done this hundreds of times, but for some reason this isn't working...

Code: Select all

$userInfo = 'INSERT INTO `'.$location.'` ( `name` ) VALUES (`'.$name.'`)';
With the error:

InsertUserInfo Unknown column 'Steve' in 'field list'
('Steve' is the name that I entered.)

$name is a $_GET['name'] var. If I take the $name part out and make that part of the string just a word, like this:

Code: Select all

$userInfo = 'INSERT INTO `'.$location.'` ( `name` ) VALUES (`Steve`)';
.. it works.

Any ideas?

Posted: Fri Mar 26, 2004 3:01 pm
by andre_c
take out the quotes around the field name

Code: Select all

$userInfo = 'INSERT INTO '.$location.' ( name ) VALUES (`Steve`)';

Posted: Fri Mar 26, 2004 3:08 pm
by Steveo31
I'll giver a try once I get home. Thanks.

Posted: Fri Mar 26, 2004 3:43 pm
by Chambrln
I thought the ` was only used around the table name and ' was used around values. I could be wrong though.

Posted: Fri Mar 26, 2004 4:46 pm
by Steveo31
Yep.. you got it Chambrln. I had to use an escape to get the '.