hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Wrong datatype for second argument for in_array()
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Wrong datatype for second argument for in_array()

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-27-2011, 05:12 PM
codetr codetr is offline
Newbie
 
Join Date: May 2011
Posts: 5

Wrong datatype for second argument for in_array()


Hello,

I wrote a little function;

PHP Code:
<?php session_start(); ob_start();
$salladim $_SESSION['salla'];
$salladin =  isset($_GET['url'])?$_GET['url']:'' ;
 
if(!
in_array($salladin,$salladim))
{
    
header'refresh: 1; url='.$_SERVER['HTTP_REFERER'].'' );
echo 
'<h2>Hazirlaniyor...</h2>';
    exit();
}
When i run this code, i get the following error :
PHP Code:
PHP Warning:  in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/site/public_html/do.php on line 5 

Reply With Quote


Sponsored Links
  #2  
Old 05-27-2011, 06:45 PM
kjsrs kjsrs is offline
Junior Guru Wannabe
 
Join Date: Jan 2010
Location: MT
Posts: 45
What do you get if you do:
PHP Code:
var_dump($_SESSION['salla']); 
It looks like your session variable is not an array, which it needs to be for the second argument in in_array().

__________________
Shout! Radio Services
Developer of Shout! Radio Automation
Complete cloud-based radio station automation.

Reply With Quote
  #3  
Old 05-28-2011, 07:58 PM
codetr codetr is offline
Newbie
 
Join Date: May 2011
Posts: 5
PHP Code:
var_dump($_SESSION['salla']); 
not working

Reply With Quote
Sponsored Links
  #4  
Old 05-29-2011, 04:30 PM
codetr codetr is offline
Newbie
 
Join Date: May 2011
Posts: 5
how to fix this error

Reply With Quote
  #5  
Old 05-29-2011, 04:31 PM
quantumphysics quantumphysics is offline
MACBOOKS EVERYWHEREEEEEEEEEEEE
 
Join Date: Mar 2009
Posts: 3,804
do you even have a "salla" in your session?

Reply With Quote
  #6  
Old 05-29-2011, 05:34 PM
codetr codetr is offline
Newbie
 
Join Date: May 2011
Posts: 5
Quote:
Originally Posted by quantumphysics View Post
do you even have a "salla" in your session?
this script

PHP Code:
<?php session_start();
function 
kodsalla($uzunluk
{
$karakterler "0123456789"."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$kod "";
  while(
strlen($kod) < $uzunluk
  {
    
$kod .= substr($karakterler, (rand() % strlen($karakterler)), 1);
  }
  return(
$kod);
}
$kodsalla kodsalla(8);

$_SESSION['salla'][] = $kodsalla;

Reply With Quote
  #7  
Old 05-30-2011, 12:17 PM
codetr codetr is offline
Newbie
 
Join Date: May 2011
Posts: 5
how to fix this error pls help me thanks

PHP Code:
var_dump($_SESSION['salla']); 
PHP Code:
array(1) {
  [
0]=>
  
string(8"4AZWX25C"



Last edited by codetr; 05-30-2011 at 12:21 PM.
Reply With Quote
  #8  
Old 06-03-2011, 03:35 PM
sea otter sea otter is offline
the cloud is a lie
 
Join Date: May 2004
Location: NYC
Posts: 793
Your code actually runs fine for me and does not generate any errors.

All I can think is...try putting session_start() after ob_start().

PHP output buffering and session handling is sometimes configured in such a way that it requires ob_start() to come before session_start(). In other cases, the order doesn't matter.

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
[PHP] Wrong datatype for second argument latheesan Programming Discussion 3 04-08-2008 01:29 PM
Wrong datatype for second argument for in_array() latheesan Programming Discussion 9 02-16-2008 12:16 PM
MySQL Datatype Question Ricjustsaid Programming Discussion 6 12-05-2007 02:31 AM
in_array module. horizon Programming Discussion 1 07-16-2006 02:59 PM
Do you store time as UNIX TIMESTAMP or MySQL time datatype? Roy@ENHOST Programming Discussion 3 03-01-2005 06:07 AM

Related posts from TheWhir.com
Title Type Date Posted
Cloud Security Alliance’s 2012 Congress - The Internet and National Security Blog 2012-12-05 12:08:32
Web Host webHOSTING.net Improves Data Backup Using Nimble Storage Array Web Hosting News 2012-03-28 13:14:22
WHD 2012 -- How Web Hosts Can Prepare for the New TLDs with Thorsten Einig of OpenSRS Web Hosting News 2012-03-28 09:07:24
Overcoming security concerns from the desktop to the cloud with Symantec's Dan Nadir Web Hosting News 2012-02-16 15:30:17
WHIR TV - Rick from Neustar Discusses DDOS Threats and Defense Blog 2011-09-23 13:52:45


Tags
argument, in_array(), wrong datatype

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?