Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-22-2010, 07:20 PM   PM User | #1
mOrloff
Regular Coder

 
mOrloff's Avatar
 
Join Date: Nov 2008
Location: The Great Pacific NW, USA
Posts: 421
Thanks: 8
Thanked 6 Times in 6 Posts
mOrloff is an unknown quantity at this point
How am I SUPPOSED to check for !$result ??

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:
PHP Code:
while($row=sqlsrv_fetch_array($rzStockSQLSRV_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

Last edited by mOrloff; 03-22-2010 at 07:24 PM..
mOrloff is offline   Reply With Quote
Old 03-22-2010, 07:24 PM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Code:
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.

Last edited by MattF; 03-22-2010 at 07:26 PM..
MattF is offline   Reply With Quote
Old 03-22-2010, 07:25 PM   PM User | #3
mOrloff
Regular Coder

 
mOrloff's Avatar
 
Join Date: Nov 2008
Location: The Great Pacific NW, USA
Posts: 421
Thanks: 8
Thanked 6 Times in 6 Posts
mOrloff is an unknown quantity at this point
Ahhh, there we go.

Thanks.
mOrloff is offline   Reply With Quote
Old 03-22-2010, 07:26 PM   PM User | #4
DJCMBear
Senior Coder

 
DJCMBear's Avatar
 
Join Date: Mar 2010
Location: United Kindom
Posts: 1,173
Thanks: 14
Thanked 136 Times in 136 Posts
DJCMBear is on a distinguished road
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
DJCMBear is offline   Reply With Quote
Old 03-22-2010, 09:14 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,639
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by DJCMBear View Post
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:14 PM.


Advertisement
Log in to turn off these ads.