Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
Steveo31
- Forum Contributor
- Posts: 416
- Joined: Sun Nov 23, 2003 9:05 pm
- Location: San Jose CA
Post
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?
Last edited by
Steveo31 on Fri Mar 26, 2004 5:35 pm, edited 1 time in total.
-
andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
Post
by andre_c »
take out the quotes around the field name
Code: Select all
$userInfo = 'INSERT INTO '.$location.' ( name ) VALUES (`Steve`)';
Last edited by
andre_c on Fri Mar 26, 2004 3:46 pm, edited 1 time in total.
-
Steveo31
- Forum Contributor
- Posts: 416
- Joined: Sun Nov 23, 2003 9:05 pm
- Location: San Jose CA
Post
by Steveo31 »
I'll giver a try once I get home. Thanks.
-
Chambrln
- Forum Commoner
- Posts: 43
- Joined: Tue Dec 02, 2003 10:45 am
- Location: Oregon
Post
by Chambrln »
I thought the ` was only used around the table name and ' was used around values. I could be wrong though.
-
Steveo31
- Forum Contributor
- Posts: 416
- Joined: Sun Nov 23, 2003 9:05 pm
- Location: San Jose CA
Post
by Steveo31 »
Yep.. you got it Chambrln. I had to use an escape to get the '.