Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    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.

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Ahhh, there we go.

    Thanks.

  • #4
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    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

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •