Jump to content

if(in_array) BROKEN. Please Help


bumba000

Recommended Posts

Hi All,

        I have a db connection and am getting results here. The problem seems to be with my in_array. I have a table called marks. I have a record in there with the value of 22 in the website_id field. The network_name field of the record has the name Blinklist in it.

Below is an example of my table and a single record. Below that is the code in question. 

As you can see, Blinklist is in the record but I get the echo response "Its Not Here". Why?

Thanks in advance,

                        John

 

MARKS:

     website_id | network_name | date
     22         | Blinklist    | 1220677200

 

 

$webSiteID = $rowGetClient['website_id'];
$getMarksList = mysql_query("SELECT * FROM marks WHERE website_id = 22");
if(!$getMarksList) {
    die("Get List Failed: " . mysql_error());
}?>

<?php
while ($array = mysql_fetch_array($getMarksList)){
if (in_array("Blinklist", $array)) {
echo "Its Here";}else{echo "Its Not Here";}
echo '<br>'."ID=:" . $webSiteID;
}
?>

Link to comment
Share on other sites

When a comparison fails it is always a good idea to display what the actual value(s) are to make sure they are what you expect. I recommend using var_dump() so that you know the length of the data so that things like white-space/non-displayable characters on the end of them can be detected.

Link to comment
Share on other sites

Thanks for that. Here are my results. I'm not sure what to make of them.

 

array(8) { [0]=>  string(2) "22" ["website_id"]=>  string(2) "22" [1]=>  string(9) "BlinkList" ["network_name"]=>  string(9) "BlinkList" [2]=>  string(1) "1" ["partner_id"]=>  string(1) "1" [3]=>  string(10) "1220677200" ["date"]=>  string(10) "1220677200" }

Link to comment
Share on other sites

That didnt work. On the bright side I am only getting results for those website id's that are in the marks table. So I know that the query is functioning properly. My code hasn't changed from above except for the addition of the commented out var_dump($array);.

 

What am I missing here?

 

Thank you,

                John

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.