user1004207
user1004207

Reputation: 13

How do I solve a "Wrong datatype" error in my PHP script?

Full Error:

in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /var/www/vhosts/example.com/httpdocs/sites/example.com/themes/example/page.tpl.php on line 22.

Relevant Code:

if (($_GET['nid']) && ($_GET['uid'] != '5')) :
    $arr = array("7916","7917","7996","7918","7990","7919","7921","7924","7925","7923","7922","8011");
    reset($arr);
    $nid = $_GET['nid'];
    // settype($nid, "integer"); 
elseif(($_GET['uid'] == '5') && ($is_front)):
    include("include_ad_front.php");    
endif;

if((in_array($nid, $arr)) && ($is_front) && (!$_GET['uid'])) {
    //code continues below...

Lines 3 and 5 were just my attemts to fix the problem. Line 10 is actually line 22 in this error and the one throwing the error.

Upvotes: 1

Views: 93

Answers (1)

Nexerus
Nexerus

Reputation: 1088

I think I see your problem.

You have the in_array stuff being called after you've done your first set of if..else checks. Now the first part of your if...else has the array being created, but not the second.

Try moving the array somewhere before your first if...else instead of inside it.

Upvotes: 2

Related Questions