[PHP] Re: [SPAM] Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-06-01 Thread Jason Pruim


On May 31, 2007, at 5:43 PM, Richard Lynch wrote:




On Thu, May 31, 2007 2:25 pm, Jason Pruim wrote:

Hi Everyone, I am attempting to setup a search field on a database
application I'm dinking around with and running into problems that
I'm hoping someone might be able to shed some light on.

Here is the code I am using to display the results of the search:

echo ('table border=1');
echo trthFirst Name/ththAuthor/ththPages/th/tr;

$result_row[] = mysql_query($query) or die(mysql_error());


I also have to wonder why you are building an array of query result
resources...

You probably could do this with just one SQL query and some order by
clauses to get what you want, without hitting the DB so much.


To use the newbie scape goat, I don't know how else to do it, and it  
seems to work :)


What would you recommend?

I am always open to find ways to make my code better/faster/more secure.

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



[PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Jason Pruim
Hi Everyone, I am attempting to setup a search field on a database  
application I'm dinking around with and running into problems that  
I'm hoping someone might be able to shed some light on.


Here is the code I am using to display the results of the search:

echo ('table border=1');
echo trthFirst Name/ththAuthor/ththPages/th/tr;

$result_row[] = mysql_query($query) or die(mysql_error());
echo Result_row dump: $result_row BR;
$num=mysql_numrows($result);
echo Num dump: $num BR;
$i= 0;

while($i  $num) {
echo trtd;
echo $result_row[0] . '/tdtd';
echo $result_row[1] . '/tdtd';
echo $result_row[2] . '/td/tr';
$i++;
}

echo (/table);


the problem is instead of printing out the actual results it prints  
out 6 fields that say: Resource id #5


the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current  
WHERE FName like '%jason%' which works in MySQL


I can't find any errors in my log files to even give me a hint as to  
what is going on.


If someone could take a look I would greatly appreciate it.

Jason Pruim

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



Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Davi
Em Quinta 31 Maio 2007 16:25, Jason Pruim escreveu:
 Hi Everyone, I am attempting to setup a search field on a database
 application I'm dinking around with and running into problems that
 I'm hoping someone might be able to shed some light on.

 Here is the code I am using to display the results of the search:

 echo ('table border=1');
 echo trthFirst Name/ththAuthor/ththPages/th/tr;

 $result_row[] = mysql_query($query) or die(mysql_error());
 echo Result_row dump: $result_row BR;
 $num=mysql_numrows($result);
 echo Num dump: $num BR;
 $i= 0;

/*
 while($i  $num) {
*/

$result=$result_row[0];

while($result_row = mysql_fetch_array($result) {

   echo trtd;
   echo $result_row[0] . '/tdtd';
   echo $result_row[1] . '/tdtd';
   echo $result_row[2] . '/td/tr';
   $i++;
   }

 echo (/table);


 the problem is instead of printing out the actual results it prints
 out 6 fields that say: Resource id #5

 the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current
 WHERE FName like '%jason%' which works in MySQL

 I can't find any errors in my log files to even give me a hint as to
 what is going on.

 If someone could take a look I would greatly appreciate it.


HTH

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
Religion, ideology, resources, land,
spite, love or just because...
No matter how pathetic the reason,
it's enough to start a war. 

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Please don't do top-posting, put your reply below the following line.



pgpoZaZKvtBnT.pgp
Description: PGP signature


Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Robert Cummings
On Thu, 2007-05-31 at 15:25 -0400, Jason Pruim wrote:
 Hi Everyone, I am attempting to setup a search field on a database  
 application I'm dinking around with and running into problems that  
 I'm hoping someone might be able to shed some light on.
 
 Here is the code I am using to display the results of the search:
 
 echo ('table border=1');
 echo trthFirst Name/ththAuthor/ththPages/th/tr;
 
 $result_row[] = mysql_query($query) or die(mysql_error());

mysql_query() doesn't return the rows. Go read the manual.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Dave Goodchild

Your problem is this:



$result_row[] = mysql_query($query) or die(mysql_error());



...you are assigning  a query to a variable. What you need to do is
something like this:

$result = mysql_query($query) or die(mysql_error());
while ($result_row = mysql_fetch_array($result)) {
.
}


Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Jason Pruim


On May 31, 2007, at 3:27 PM, Davi wrote:


Em Quinta 31 Maio 2007 16:25, Jason Pruim escreveu:

Hi Everyone, I am attempting to setup a search field on a database
application I'm dinking around with and running into problems that
I'm hoping someone might be able to shed some light on.

Here is the code I am using to display the results of the search:

echo ('table border=1');
echo trthFirst Name/ththAuthor/ththPages/th/tr;

$result_row[] = mysql_query($query) or die(mysql_error());
echo Result_row dump: $result_row BR;
$num=mysql_numrows($result);
echo Num dump: $num BR;
$i= 0;


/*

while($i  $num) {

*/

$result=$result_row[0];

while($result_row = mysql_fetch_array($result) {


Worked perfectly after adding a closing ) Thanks for the tip!




echo trtd;
echo $result_row[0] . '/tdtd';
echo $result_row[1] . '/tdtd';
echo $result_row[2] . '/td/tr';
$i++;
}

echo (/table);


the problem is instead of printing out the actual results it prints
out 6 fields that say: Resource id #5

the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current
WHERE FName like '%jason%' which works in MySQL

I can't find any errors in my log files to even give me a hint as to
what is going on.

If someone could take a look I would greatly appreciate it.



HTH

--  
Davi Vidal

[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
Religion, ideology, resources, land,
spite, love or just because...
No matter how pathetic the reason,
it's enough to start a war. 

Por favor não faça top-posting, coloque a sua resposta abaixo desta  
linha.

Please don't do top-posting, put your reply below the following line.



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



Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Davi
Em Quinta 31 Maio 2007 16:38, Jason Pruim escreveu:
 
  while($result_row = mysql_fetch_array($result) {

 Worked perfectly after adding a closing ) Thanks for the tip!


Forgive me for that!!! #'_'#
I *always* forget the closing )... =P


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
Religion, ideology, resources, land,
spite, love or just because...
No matter how pathetic the reason,
it's enough to start a war. 

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Please don't do top-posting, put your reply below the following line.



pgpH2cHUfJswa.pgp
Description: PGP signature


Re: [PHP] Attempting to search a MySQL database from PHP not working

2007-05-31 Thread Richard Lynch


On Thu, May 31, 2007 2:25 pm, Jason Pruim wrote:
 Hi Everyone, I am attempting to setup a search field on a database
 application I'm dinking around with and running into problems that
 I'm hoping someone might be able to shed some light on.

 Here is the code I am using to display the results of the search:

 echo ('table border=1');
 echo trthFirst Name/ththAuthor/ththPages/th/tr;

 $result_row[] = mysql_query($query) or die(mysql_error());

I also have to wonder why you are building an array of query result
resources...

You probably could do this with just one SQL query and some order by
clauses to get what you want, without hitting the DB so much.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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