PHP/MySQL undefined index errors

I have a simple PHP output drawing from a mysql db. The output is supposed to be nothing more than the selected record(name and address fields) from the db- for simplicity, i have assigned the id as ‘3’ in this example. I am getting the desired result in the browser output, but I am getting errors first stating ‘Undefined index’. Why does it tell me this, but then go ahead and output the correct data anyway?

[browser output]
Notice: Undefined index: name in C:\wamp\www\coffeejoint\ est.php on line 37 [See blue text below]

Notice: Undefined index: address in C:\wamp\www\coffeejoint\ est.php on line 37
Spunky Monkey35 NE 20th St

[php code]


<?php
require_once(‘includes/initialize.php’);
require ‘includes/head.html.php’; ?>

<html>
<h1> test page </h1>
<form action = “?” method=“post”>
<input type=“submit” name=“id” value=“3” />
</form>
<html>

<?php
$id = mysql_real_escape_string($_POST[‘id’] , $connection);
$view = " SELECT * FROM shops WHERE ID = $id";
$resulta = mysql_query($view, $connection);
$shopinfo = array();
if(!$resulta)
{
$error = ‘no resultx’ . mysql_error();
include ‘includes/error.html.php’;
exit();
}
while($row = mysql_fetch_assoc($resulta))
{
$shopinfo[] = array(‘name’ => $row[‘Name’], ‘address’ => $row [‘Address’],‘id’ => $row[‘ID’]);
}
?>

<?php foreach($shopinfo as $resultz): ?>

<?php echo htmlspecialchars($resultz[‘name’], ENT_QUOTES, ‘UTF-8’) . htmlspecialchars($resultz[‘address’], ENT_QUOTES, ‘UTF-8’);?>

<?php endforeach;
exit();
?>

The error says ‘name’ not ‘Name’
The line in error is

<?php echo htmlspecialchars($resultz['name'], ENT_QUOTES, 'UTF-8') . htmlspecialchars($resultz['address'], ENT_QUOTES, 'UTF-8');?>

Why? Because you initialize your $shopinfo array like this:

$shopinfo[] = array();

so the first occurrance of $shopinfo is an empty array.
What you want is

$shopinfo = array();

I got this on browser when I tried to open the file :

“Notice: Undefined index: _m in E:\elibrary\index.php on line 8
Notice: Undefined index: _m in E:\elibrary\index.php on line 10
Notice: Undefined index: _m in E:\elibrary\index.php on line 17
Notice: Undefined index: _m in E:\elibrary\index.php on line 23
Notice: Undefined index: _m in E:\elibrary\index.php on line 29
Notice: Undefined index: _m in E:\elibrary\index.php on line 35
Notice: Undefined index: frontend_userid in E:\elibrary\index.php on line 41
Notice: Undefined index: _m in E:\elibrary\index.php on line 99”

Below I includes the codes from my index.php file. What is undefined index? Can someone please help me in this problem? I really newbie in php. Really really a newbie. Please help. Its urgent. Thank you.

<?php
 
session_start();

include "global.inc.php";
  

if ($_GET["_m"] == "blank") { exit; }

if ($_GET["_m"] == "logout")
{
    auditlogFront("Logout", $_SESSION["frontend_userid"]);
    $_SESSION["frontend_userid"] = 0;
    header("location:/");
    exit;
}
if ($_GET["_m"] == "publicuser")
{
    include "modules/login/module_publicuser.php";
    auditlogFront("view publicuser", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "publicuser_search")
{
    include "modules/login/module_publicuser_search.php";
    auditlogFront("search publicuser", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "monograph_info")
{
    include "modules/login/module_monograph_info.php";
    auditlogFront("view monograph info", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "announcement_content")
{
    include "modules/login/module_announcement_content.php";
    auditlogFront("view announcement content", $_SESSION["frontend_userid"]);
    exit;
}
$userid = $_SESSION["frontend_userid"];

$core_permission = array();

$stmt = $db2->prepare("SELECT * FROM patron_user WHERE userid=? AND status='Enable'");
$stmt->execute(array($userid));
if ($row = $stmt->fetch())
{
    $userid = $row["userid"];
    $username = $row["username"];    
    $fullname = $row["fullname"];
    $useremail = $row["email"];
    $isadmin = $row["isadmin"];
    $global_user_info = $row;
    
    // Give user groups
    $sql = "SELECT * FROM core_usergroup WHERE userid='$userid'";
    $stmt = $db2->prepare($sql);
    $stmt->execute();
    $ugroups = array();
    while($row = $stmt->fetch()){
        $ugroups[] = $row['groupid'];
    }

    
    // Give user permissions by groups
    $where = '';
    if(count($ugroups) == 1) { 
        $gid = $ugroups[0];
        $where = "groupid='$gid'";
    } elseif(count($ugroups) > 1){
        $i = 1;
        foreach($ugroups as $groupid) {
            if($i == 1) {
                $where .= "groupid='$groupid'";
            } else {
                $where .= " OR groupid='$groupid'";
            }
            $i++;
        }
    }
    if($userid == '1') { $where = '1=1'; }
    $sql = "SELECT * FROM tudm_permission WHERE $where";
    $stmt = $db2->prepare($sql);
    $stmt->execute();
    $upermissions = array();
    while($row = $stmt->fetch()){
        $permissionid = $row["permissionid"];
        $upermissions[$permissionid] = "on";
        
    }
} else {
    $userid = 0;
    $username = 'system';
}
$stmt = $db2->prepare("INSERT INTO log_site SET requesturi=?, userid=?, datetime=NOW()");
$stmt->execute(array($_SERVER["REQUEST_URI"], $userid));

if ($_GET["_m"] == "login")
{
    include "modules/login/module_login.php";
    exit;
}
if ($userid == 0)
{
    include "modules/login/module_login.php";
    exit;
}
if ($_GET["_m"] == "monograph_info")
{
    include "modules/login/module_monograph_info.php";
    auditlogFront("view monograph info", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "monograph_patron")
{
    include "modules/monograph/module_monograph_patron.php";
    auditlogFront("view monograph patron", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "monograph_summaries")
{
    include "modules/monograph/module_monograph_summaries.php";
    auditlogFront("view monograph summaries", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "monograph_history")
{
    include "modules/monograph/module_monograph_history.php";
    auditlogFront("view monograph history", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "borrowed_history")
{
    include "modules/monograph/module_borrowed_history.php";
    auditlogFront("view borrow history", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "patron_profile")
{
    include "modules/monograph/module_patron_profile.php";
    auditlogFront("view profile", $_SESSION["frontend_userid"]);
    exit;
}
if ($_GET["_m"] == "return_fines")
{
    include "modules/monograph/module_return_fines.php";
    auditlogFront("view return fines", $_SESSION["frontend_userid"]);
    exit;
}

include "modules/login/module_login.php";
exit;

?>

Try adding this (after the session_start() line):

echo '<pre'>
var_dump($_GET);
echo '</pre>';

echo '<pre'>
var_dump($_SESSION);
echo '</pre>';

You’re probably not setting any values for either the session or query string elsewhere.

your global.inc.php probably is supposed to set up the default values for the get array; the index you’ve shown us has no checking to see if it’s set.