RE: [PHP] PHP and MySQL queries

2002-12-19 Thread Rich Gray
Does it work if you put quotes around the array keys as follows...

echo $line['idn'];
echo $line['total'];
echo $line['idp'];
echo $line['position'];
echo $line['points'];

Rich

-Original Message-
From: Beauford.2002 [mailto:[EMAIL PROTECTED]]
Sent: 18 December 2002 20:28
To: PHP General
Subject: [PHP] PHP and MySQL queries


Hi,

I am having a real problem with variables in PHP and trying to query my
MySQL database. I have a form that a user inputs information and then that
info is used to query my database, but it's not working. I don't get any
errorrs and it appears every thing worked, but nothing gets displayed (see
code below). I know the info is getting passed from the form as it appears
correct in the address bar of my browser. The query below also works if I
use the command line in MySQL and hard code the information.

Any help is appreciated.

http://etc/etc?FromTrade=TRUEname=1from=2

$query = select tmanager.idn, tmanager.total, troster.idp, user, position,
points from troster join treference
join tmanager where tmanager.idn=treference.idn and
treference.idp=troster.idp and tmanager.name like '$name' and
troster.player like '$from';

$results = mysql_query($query) or die(Query failed);

while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) {

 echo $line[idn];
 echo $line[total];
 echo $line[idp];
 echo $line[position];
 echo $line[points];

This just displays an empty page. So it appears the query found nothing, but
like I said, it works from the command line and there should be one entry
(see below). So I have to assume it is a problem with the variables.

+-++-++--++
| idn | total  | idp | user | position | points |
+-++-++--++
|   1 | 746.75 |   2 | Trevor  | F|  45.00 |
+-++-++--++


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] PHP and MySQL queries

2002-12-18 Thread John W. Holmes
So print out $query before you execute it and see what you're actually
sending to MySQL. You're apparently sending a valid query, but it's not
matching any rows...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

 -Original Message-
 From: Beauford.2002 [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 18, 2002 11:28 PM
 To: PHP General
 Subject: [PHP] PHP and MySQL queries
 
 Hi,
 
 I am having a real problem with variables in PHP and trying to query
my
 MySQL database. I have a form that a user inputs information and then
that
 info is used to query my database, but it's not working. I don't get
any
 errorrs and it appears every thing worked, but nothing gets displayed
(see
 code below). I know the info is getting passed from the form as it
appears
 correct in the address bar of my browser. The query below also works
if I
 use the command line in MySQL and hard code the information.
 
 Any help is appreciated.
 
 http://etc/etc?FromTrade=TRUEname=1from=2
 
 $query = select tmanager.idn, tmanager.total, troster.idp, user,
 position,
 points from troster join treference
 join tmanager where tmanager.idn=treference.idn and
 treference.idp=troster.idp and tmanager.name like '$name' and
 troster.player like '$from';
 
 $results = mysql_query($query) or die(Query failed);
 
 while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) {
 
  echo $line[idn];
  echo $line[total];
  echo $line[idp];
  echo $line[position];
  echo $line[points];
 
 This just displays an empty page. So it appears the query found
nothing,
 but
 like I said, it works from the command line and there should be one
entry
 (see below). So I have to assume it is a problem with the variables.
 
 +-++-++--++
 | idn | total  | idp | user | position | points |
 +-++-++--++
 |   1 | 746.75 |   2 | Trevor  | F|  45.00 |
 +-++-++--++
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php