[GLLUG] Retrieving a row from mysql

Seth Bembeneck sbdataspiller at sbcglobal.net
Tue Feb 17 10:58:48 EST 2004


(Sorry if people receive this again. Got a message saying my email was
too long so I shortened it)
 
I did the echo suggestion:
 
$accnum=1;
$query= "SELECT * FROM <tablename> WHERE accnum= $accnum"; echo 'query';
 
The out put was:
SELECT * FROM <tablename> WHERE accnum= 1.
 
Will that space in front of the 1 confuse the query? When I saw that, I
changed every thing to char's instead of int.
 
I'm close, real close to getting this thing working. Thanks to every
ones help and suggestions.
 
Also, that table that I used in my last email was just an example.
 
Here is one real query:
 
 
$player_query = mysql_query("SELECT player_name AS player_name,
                             total_games AS total_games,
                             squad_id AS squad_id
                             FROM $stats_table
                             WHERE id='$id' AND accnum='$accnum'
                             LIMIT 1") or die(mysql_error());
 
 
All I did to the above query was to add the AND accnum='$accnum' to the
WHERE clause. That is all I have done through out the whole
Application, and modified the table structures (see below). Before I
added all the stuff for accnum, this worked perfectly.
 
Seth
 
There are 9 tables total, this is just one of them. All I did to the
others was to add the accnum field.
 
STATS TABLE (taken from a php script):
 
$query = mysql_query("CREATE TABLE $stats_table (  id smallint(5)
unsigned NOT NULL auto_increment,
  player_name varchar(16) NOT NULL default '',
 ...
 ...
 ...
 ...
  last_played datetime NOT NULL default '0000-00-00 00:00:00',
  squad_id int(11) NOT NULL default '0',
  accnum char(10) NOT NULL default '',
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
  KEY id_2 (id)
);") or die(mysql_error());
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.egr.msu.edu/mailman-archives/linux-user/attachments/20040217/5a33b270/attachment-0001.htm


More information about the linux-user mailing list