RE: [PHP] PHP and MySQL queries
| From: | Rich Gray | Date: | Thu, 19 Dec 2002 18:31:21 +0000 |
| Subject: | RE: [PHP] PHP and MySQL queries | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128834@lists.php.net to get a copy of this message | ||
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:beauford.2002@rogers.com]
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=TRUE&name=1&from=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 |
+-----+--------+-----+--------+----------+--------+