Jump to content

Doesn't Work!


Dysan

Recommended Posts

Why doesn't the following code work?, I keep getting greeted with the following error message:

 

Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in C:\Documents and Settings\User\Desktop\Xampp\htdocs\1.php on line 7.

 

<?php

session_start();

if (array_key_exists($_GET['id'], $array))
{
  echo "Already Exists!";
}
else
{
  $_SESSION['ids'][] = $_GET['id'];
  $array = $_SESSION['ids'];
}

print_r($array);

?> 

Link to comment
Share on other sites

What he is trying to say, no where in that code is $array defined before the if statement it is used in. Which is why there is an error. If there is more code you are omitting, please post it. Otherwise where are you getting the values of $array from?

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.