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=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 |
+-++-++--++


-- 
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=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 |
> +-++-++--++
> 
> 
> 
> 
> --
> 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




[PHP] PHP and MySQL queries

2002-12-18 Thread Beauford.2002
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 |
+-++-++--++




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




[PHP] PHP and MySQL queries

2001-10-23 Thread Jason

As of yet I have tried all sorts for date formating for the search field to
work.  I.E. 2001-10-23, 10/23/2001, 10/%/2001, 10%, %10%, etc.  The date
field in the database is stored as 10/23/2001 and yet when a user enters the
date and clicks the search button it does not display the results.  I am
almost certain that as the user clicks the submit button the php script is
parsing the search string (i.e. 10/23/2001) incorrectly.  I believe it is
parsing the sting as 10&nsb;23&nsb;2001 or something to that effect.  If
anyone has some more information on this please let me know.  I am pretty
sure I have exhausted my resources.

"Jason" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I am having a hard time setting up a form for users to enter a date in the
> format of 00/00/ (of course they would use an actual date).  My form
is
> as follows...
> 
>   *I.E. - Format is 04/01/2001*
>   Search for Ads by date:
> 
>   
>   
>  value="Submit">
> 
>   
> 
> 
> On my search.php page I have the following MySQL connection and search
> parameters...
> 
> mysql_connect ("db_hostname", "db_username", "db_password");
>
> mysql_select_db ("db_name");
>
> if ($date == "")
> {$date = '%';}
>
> $result = mysql_query ("SELECT
>
fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,crmo,cryr,w
> eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time
>   FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 ");
> $count = -1;
> if ($row = mysql_fetch_array($result)) {
> $count ++;
> do {
> echo "Name: ";
> printf(mysql_result($result,$count,"fname"));
> echo " ";
> printf(mysql_result($result,$count,"lname"));
> echo "\n";
>
> echo "Address: ";
> printf(mysql_result($result,$count,"address"));
> echo "\n";
>
> echo "City: ";
> printf(mysql_result($result,$count,"city"));
> echo "\n";
>
> echo "State: ";
> printf(mysql_result($result,$count,"state"));
> echo "\n";
>
> echo "Zip: ";
> printf(mysql_result($result,$count,"zip"));
> echo "\n";
>
> echo "Phone: (";
> printf(mysql_result($result,$count,"phonea"));
> echo ") ";
> printf(mysql_result($result,$count,"phone"));
> echo "\n";
>
> echo "Email: ";
> printf(mysql_result($result,$count,"email"));
> echo "\n";
>
> echo "Credit Type: ";
> printf(mysql_result($result,$count,"crty"));
> echo "\n";
>
> echo "Credit Number: ";
> printf(mysql_result($result,$count,"crnum"));
> echo "\n";
>
> echo "Credit Card Date: ";
> printf(mysql_result($result,$count,"crmo"));
> echo " ";
> printf(mysql_result($result,$count,"cryr"));
> echo "\n";
>
> echo "Weeks: ";
> printf(mysql_result($result,$count,"weeks"));
> echo "\n";
>
> echo "town1: ";
> printf(mysql_result($result,$count,"town1"));
> echo "\n";
>
> echo "town2: ";
> printf(mysql_result($result,$count,"town2"));
> echo "\n";
>
> echo "town3: ";
> printf(mysql_result($result,$count,"town3"));
> echo "\n";
>
> echo "IP Address: ";
> printf(mysql_result($result,$count,"ipaddress"));
> echo "\n";
>
> echo "Ad: ";
>
> $ad[$count] = (mysql_result($result,$count,"ad"));
>
> $ad[$count] = ereg_replace ("&a&", "'", $ad[$count]);
> $ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]);
> $ad[$count] = ereg_replace ("&p&", "%", $ad[$count]);
> $ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]);
>
>
> echo $ad[$count];
> echo "\n";
>
> echo "Total: ";
> printf(mysql_result($result,$count,"total"));
> echo "\n";
>
> echo "Ad Number: ";
> printf(mysql_result($result,$count,"num"));
> echo "\n";
>
> echo "Date: ";
> printf(mysql_result($result,$count,"date"));
> echo "\n";
>
> echo "Time: ";
> printf(mysql_result($result,$count,"time"));
> echo "\n";
>
> } while($row = mysql_fetch_array($result));
>
> } else {print "Sorry, no records were found!";}
>
> ?>
> So far I have come to the conclusion that the input from the user is
> probably where my problem is because I am assuming it is taking the "/" in
> the date they enter and doing something I don't want it to.  In any event
if
> someone could give me a clue as to how to resolve this issue it would be
> greatly appreciated.
>
>





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]