Hi there, I am getting the following error. Could you review my code and help me as to why? I am using the mod_rewrite extention also.

Notice: Undefined index: in /var/www/incpages/mylines.php on line 48

<?php
if( basename( __FILE__ ) == basename( $_SERVER['PHP_SELF'] ) )
{
  exit();
}

include("includes/config.php");

if ($maintancemode == "true") { 

if ($access == "3") { die("Sorry site is under maintance please try again later."); }


}

// create db connection

mysql_connect("$dbhost", "$dbusername", "$dbpassword")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$page = $_GET['go'];                    // THIS IS LINE 48

$page = stripslashes($page);
if (!$page) { $page = "news"; }
$ext = "php";

include("includes/pagesallowed.php");

// system check login

if(!isset($_SESSION)) 
{ 
session_start(); 
}  
if(isset($_SESSION['username'])){
//if (array_key_exists('username' , $_SESSION)){
//if(session_is_registered('username')){
$logged = "yes";


   // user vars
   $SQLtext = "SELECT * FROM members where username = '$_SESSION[username]' ";
   $result = mysql_query($SQLtext);
   $row = mysql_fetch_row($result);
    $myid = $row[0];
   $uname = $row[1];
   $email = $row[3];
   $paypal = $row[4];
   $mobile = $row[5];
   $access = $row[6];
   $state = $row[7];
   $disc1m = $row[10];
   $disc3m = $row[11];
   $disc6m = $row[12];
   $disc12m = $row[13];
if ($access == "0") { $access == "3"; }


} else {
$logged = "no";
}
?>

Can you confirm there is a value in fourth column of members table for id that is set?

Better to use mysql_fetch_assoc and text indices. Then if your table is modified you don't have to re-write the numeric indices. Pretty sure even for a NULL field, you should not get an 'undefined index'.

Member Avatar for diafol

As above, but also consider moving to mysqli or PDO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.