...

View Full Version : How am I SUPPOSED to check for !$result ??



mOrloff
03-22-2010, 07:20 PM
I want some feedback when there aren't any matches found, and I know I've done it in the past, but I'm not getting it right now.

This is where I'm at:


while($row=sqlsrv_fetch_array($rzStock, SQLSRV_FETCH_ASSOC)){
$stockPN=$row['pn']; // grab the part number
$select='pn,description';
$from='table';
$where="pn=\"$stockPN\"";
$result=qryFunc($select,$from,$where);
}
if(!$result){
echo " - No match found for $stockPN.<br/>"; // for testing
}else{
$array=mysql_fetch_assoc($result);
echo '<pre>'; print_r($array); echo '</pre>'; // for testing
}


I never get No match found echoed, but when there is a match, I do get the array printed back successfully.

Where am I going off ?

~ Mo

MattF
03-22-2010, 07:24 PM
if (!mysql_num_rows($result)){



Edit: Why do you have three different formats for DB query functions? Change the above mysql_ to whichever function name is relevant for your scenario.

mOrloff
03-22-2010, 07:25 PM
Ahhh, there we go.

Thanks.

DJCMBear
03-22-2010, 07:26 PM
From what it looks like you looking in one table to get the part number and then looking in the other table for the part information, I personaly would use a mysql table join so you only use one query but it looks in two different tables

Fou-Lu
03-22-2010, 09:14 PM
From what it looks like you looking in one table to get the part number and then looking in the other table for the part information, I personaly would use a mysql table join so you only use one query but it looks in two different tables

We've actually been over this one a little while ago; the problem is one is an SQLServer and the other is a MySQL server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum