If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > using In_array getting wrong results

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-09, 10:50
TommyGunn TommyGunn is offline
Registered User
 
Join Date: Jul 2009
Posts: 6
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
Reply With Quote
  #2 (permalink)  
Old 08-18-09, 03:53
Vikrant_M Vikrant_M is offline
Registered User
 
Join Date: Apr 2007
Posts: 23
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." ");
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On