Forum Moderators: coopster

Message Too Old, No Replies

mysql_fetch_array

         

bizznappy

11:32 pm on Jan 7, 2005 (gmt 0)

10+ Year Member



can anyone tell me why this does not work?

obviously there is more to the script but i believe that this is where my problem is,

$result = mysql_query("SELECT * FROM table WHERE field LIKE 'variable'");

$result2 = mysql_query("SELECT * FROM table WHERE field BETWEEN 'variable' AND 'variable'");

while($r=mysql_fetch_array($result,$result2))

jatar_k

12:31 am on Jan 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would say this is the problem

mysql_fetch_array($result,$result2)

the usage is wrong

array mysql_fetch_array [ca.php.net] ( resource result [, int result_type])

so you can pass, either, $result or $result1 not both at the same time. If you need the return from both, then cycle through one and then cycle through the second once the first is complete.

bizznappy

1:36 am on Jan 8, 2005 (gmt 0)

10+ Year Member



thanks for your reply

i had the $result and $result2 working earlier in the day but i was unable to get it to work again so i just combined the queries

$result = mysql_query("SELECT * FROM table WHERE field LIKE 'variable' AND field2 BETWEEN 'variable2' AND 'variable3'");

while($r=mysql_fetch_array($result))

thanks again

coopster

6:11 pm on Jan 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, bizznappy.

You may also want to use a metacharacter (underscore and/or percent sign) in your LIKE predicate. If you don't, you might as well be using an equality comparison.