0

php code:

 1. if (isset($data['city_id']))   
 2. {
 3.    $city_id = "city_id='". $data['city_id']. "', ";
 4. }

And I get:

Notice: Undefined index: city_id on line 3

How can this be?

u_mulder
  • 54,101
  • 5
  • 48
  • 64

1 Answers1

0

Just ran your code sample and it works perfectly, I do not get 'undefined index' error - taking us to the big apple

<?php
$data['city_id']='New York';
if (isset($data['city_id']))   
{
 $city_id = "city_id='". $data['city_id']. "', ";
 echo $city_id;
 }

?>

output: city_id='New York',

Surely, without the $data['city_index']='New York'; I just get a blank screen, as the if condition is not met - no errors.

lovelace
  • 1,195
  • 1
  • 7
  • 10