[GLLUG] Retrieving a row from mysql

Seth Bembeneck sbdataspiller at sbcglobal.net
Mon Feb 16 15:19:19 EST 2004


I'm working on my database project (See 'MySql: Database inside of a
Database').
 
It was suggested that I have an account number in each table.
 
So now for example my table is
(The real table has a lot more info, but hopefully this demonstrates
what I'm trying to do)
 
Table name: players
name - accountnum - blah -blah
Seth   -- 12              -- y      - n
You   --- 34             --- y     -k
Blah - N                -- more -- no
 
I have a query like this in php:
 
$name = 'Seth';
$accnum= 12;
$tablename = 'players'
query = mysql_query("SELECT * FROM $tablename WHERE name= '$name' AND
accountnum= $accnum");
 
 
When I run this, I get a message saying that I have an error in my
syntext and to check the manuel for my version of MySql for the right
syntext to use near " at line 1.
 
Why?
 
I specified accountnum in the table creation script as
 
accountnum int(10) unsigned NOT NULL
 
Thanks,
 
Seth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.egr.msu.edu/mailman-archives/linux-user/attachments/20040216/2038e719/attachment.htm


More information about the linux-user mailing list