Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    6

    Unanswered: using In_array getting wrong results

    Hi all

    I am trying to use In_array to check if a result is avalible in the dataase,
    however it only every shows me not found. my code is

    $sid = session_id();
    $sessioncart = odbc_exec($Conn, "SELECT sessionUserID FROM sessionTempTable");
    $scar = odbc_fetch_array($sessioncart);

    if (in_array($sid, $scar))
    {
    echo "found";
    }
    else
    {
    echo"not found";
    }

    Any suggests or idea where I am going wrong

  2. #2
    Join Date
    Apr 2007
    Posts
    24
    Hi,

    in_array syntax is correct, I suggest you, to just change your logic by adding where condition in your sql query:

    $sid = session_id();
    $sessioncart = odbc_exec($Conn, "SELECT sessionUserID FROM sessionTempTable where sessionUserID=".$sid." ");

Posting Permissions

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