PHP and MySQL queries
| From: | Beauford.2002 | Date: | Thu, 19 Dec 2002 04:28:00 +0000 |
| Subject: | PHP and MySQL queries | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128800@lists.php.net to get a copy of this message | ||
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 |
+-----+--------+-----+--------+----------+--------+