-1

Below mentioned PHP code was perfect on vertrigo_222 (and also on livehost).
Now I am trying to upgrade my localhost to vertrigo_230.
I am facing following undefined variable error or warning: enter image description here Here is code (line # 30 is mentioned):

<?php
ob_start();
session_start();
include_once("PHP_Code/db_connection.php");
if(isset($_REQUEST['data']))
    $data = $_REQUEST['data'];

//Fetch All Important Information from Database in Variables
if($_SESSION['id'] && $_SESSION['pw'])  //Login Must for This Informatiion
{
    if(isset($_REQUEST['city_id']))
    {
        if($_REQUEST['city_id'])
        {
            $city_id = $_REQUEST['city_id'];
        }
        else
        {
            $query = "SELECT * FROM cities WHERE user_id = '$_SESSION[id]'";
            $c = mysql_query($query) or die(mysql_error()." in query $query");
            $city = mysql_fetch_array($c);
            $city_id = $city['city_id'];
        }
        //Setting Current/Opened City in Session
        $_SESSION['city_id'] = $city_id;
    }
}

//Secure Page
if($data == "")                   //Line # 30
    $data = "loginPage";

Please give me some solution.

Rashid
  • 1,244
  • 3
  • 13
  • 29
  • 1
    possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Epodax Apr 23 '15 at 06:53
  • mysql_* functions are now deprecated. Use mysqli or PDO instead. – Bob Nocraz Apr 23 '15 at 06:55

1 Answers1

1

define the $data as global variable and you have to use mysqli insted because mysql Officially deprecated

  ob_start();
session_start();
include_once("PHP_Code/db_connection.php");
$data = '';
//your code
Osama Jetawe
  • 2,697
  • 6
  • 24
  • 40