#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0

    The active result for the query contains no fields


    Hi guys, i am getting the following error : The active result for the query contains no fields

    Below is my code

    PHP Code:
    <?php
    session_start
    ();
    include
    'dbconnect_three.php';
    include
    'dbconnect.php';
    include 
    'dbconnect_two.php';

    $uname=$_SESSION['user'];
    $email=$_SESSION['email'];
    $message_id=$_POST['mess_id'];
    $maxseq=$_POST['maxseq'];
    $otheruser=$_POST['otheruser']; 

    //The part below is the one that does the query to retrieve the messages from the database

    [FONT=Arial Black][B][COLOR=Blue]$sql_message_retriver="SELECT message FROM inbox WHERE message_id='$message_id' ";
    $sql_message_retriever_result=sqlsrv_query($conn_three,$sql_message_retriever);[/COLOR][/B][/FONT]


    while(
    $sql_message_result_display=SQLSRV_FETCH_ARRAY($sql_message_retriever_result,SQLSRV_FETCH_ASSOC))
    {
    $message_string=$sql_message_result_display['message'];
    echo 
    "<right>$message_string</right>";
    }

    $seen=2;
    $maxseq=$maxseq+1;

    echo 
    "<form action=// method=post>";
    echo
    "Messageinput type=text name=update>";
    echo 
    "<input type=hidden name=message_id value=$message_id>"// gotta fix this part
    echo "<input type=hidden name=maxseq value=$maxseq>";
    echo 
    "<input type=hidden name=otheruser value=$otheruser>";
    echo 
    "<input type=hidden name=otheremail value=$otheremail>";
    echo 
    "<input type=hidden name=keyes value=$keyes>";
    echo 
    "<input type=submit name=submit value=Reply>";
    echo
    "</form>";

    print_r(sqlsrv_errors());

    ?>
    The exact error i get:Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -28 [code] => -28 [2] => The active result for the query contains no fields. [message] => The active result for the query contains no fields. ) )

    Here is one suggestion i found to solve the problem from other forums: use the sqlsrv_next_result. I used it and it says ODBC function sequence error(something like that).


    Here is something else to note, when i change my sql statement to say like this: $sql_id_two="SELECT message FROM inbox WHERE message_id='$message_id' AND to_email='$email' OR from_email='$email'"; It actually works and displays the message. its weird. someone pls help and also can someone explain what this error means, there is very little explanation on the internet and they are kinda confusing. pls help.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1045
    Last edited by Jacques1; July 13th, 2013 at 03:51 AM.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo