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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post mssql_fetch_array($rs) Not working

    I'm using php and MS SQL, getting error on mssql_fetch_array:
    msg:[ Warning: mssql_fetch_object() expects parameter 1 to be resource, boolean given in ]

    my code is below:

    $rs = mssql_query("SET ANSI_NULLS ON");
    $rs = mssql_query("SET ANSI_WARNINGS ON");
    $query1 = mssql_init("Eng_Traffic_Analysis_Summary", $conn);
    mssql_bind($query1, "@carrierid", $carrier, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@vendorid", $vendor, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@sdate1", $fstartdate, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@edate1", $fenddate, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@fhh1", $fh1, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@fhh2", $fh2, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@sdate2", $sstartdate1, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@edate2", $senddate1, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@shh1", $sh1, SQLVARCHAR, FALSE);
    mssql_bind($query1, "@shh2", $sh2, SQLVARCHAR, FALSE);

    $rs = mssql_execute($query1);

    $result = array();

    while($row = mssql_fetch_array($rs)){
    array_push($result, $row);
    }

    can some one please help?

  • #2
    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
    Sounds to me like you're execute has failed.
    PHP Code:
     $rs mssql_execute($query1) or die(mssql_get_last_message()); 
    You should consider upgrading as well; mssql extension is no longer available as of 5.3.0.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Sounds to me like you're execute has failed.
    PHP Code:
     $rs mssql_execute($query1) or die(mssql_get_last_message()); 
    You should consider upgrading as well; mssql extension is no longer available as of 5.3.0.
    I'm getting result in $rs but

    mysql_fetch_array($rs) is giving error ...

  • #4
    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
    The only thing that would make sense then is that the procedure doesn't return a resultset.
    The error clearly specifies that the result of a boolean, likely false. That tells me that the procedure has failed or it simply returns only true/false. In either case you cannot fetch a resultset from a non-resource.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $rs = mssql_execute($query1) or die(mssql_get_last_message());


    Hi,
    Fou-Lu

    not getting any error msg from query result.

  • #6
    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
    Again, if it results in no message and proceeds with the remaining code execution and fails on the fetch, than the resultset simply doesn't exist as a result of the stored procedure execution.
    This would also imply that the result of the $query1 execution is true.
    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
    •