Warning: in_array() []: Wrong datatype for second argument in C:\AppServ\www\library\templates\nav_right.tpl.php on line 62

Posted on 2009-06-29
Last Modified: 2012-08-13
Hello Experts,
   I try to code php program for recently view items. and it can show the last items that user watched, but when i load this page the first time it will show error message as followed:

Warning: in_array() []: Wrong datatype for second argument in C:\AppServ\www\library\templates\nav_right.tpl.php on line 62

I attached code. Please help me... Many thanks in advance.


// insert codes to retrive title from gal_item_id


		# Mode SQL Command : Select data in condition

		$sql = " SELECT * from gallery_item where gal_item_id='$gal_item_id' ";

		$res['select_item'] = $conn_mysql->query($sql);		

		# Loop data in to variable : Fetch a result row as an associative array

		$arr['detail_item'] = $conn_mysql->fetch_row($res['select_item']);

			# Define variable for use easy

			$gal_item_title = $arr['detail_item']['gal_item_title'];



   $item_link="<a href='?module=gallery&action=info_item&gal_item_id=$gal_item_id'>$gal_item_title</a>";

if (! in_array($item_link, $_SESSION['articles']))

$_SESSION['articles'][] = "$item_link";

// Output list of requested articles

echo "<ul>";

foreach($_SESSION['articles'] as $doc) echo "<li>$doc</li>";

//echo "<p>$gal_item_title</p></p>";

echo "</ul>";


Open in new window

Question by:dsuthany
  • 2

Accepted Solution

szewkam earned 500 total points
Comment Utility
warning shows because for the first time you don't have declared $_SESSION['articles'] array. To avoid it put at the beginning:
if (!isset($_SESSION['articles'])) $_SESSION['articles'] = array();

Author Comment

Comment Utility
Many thanks szewkam ;-) Now i can slove the problem..Yahoo

Author Closing Comment

Comment Utility
I can slove the problem now. Thank you very much

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 26
Wordpress Query 1 31
PHP Script - Am I missing anything here? 8 35
Return data with AJAX, JQUERY and PHP 13 26
Using Quotation Marks in PHP This question ( seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to count occurrences of each item in an array.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now