Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

notice : undefined index - problem

$
0
0

Hey guys,

 

i am working on my site , and i have a global conditional that is pretty simple in what i want it to do ,

 

i have 4 variables that are not always set, i am writing an if elseif statement to see if whichever variable is used to then continue to its specified query/

 

if ($current_file == 'profile.php') {
    
    $mid = $_GET['male_id'];
    $fid = $_GET['female_id'];
    $serid = $_GET['series_id'];
    $id = $_GET['id'];


    if(isset($mid) === true){


       $query = "SELECT * FROM `content` WHERE `id` = $mid";
    
    }elseif (isset($sid) === true) {


       $query = "SELECT * FROM `content` WHERE `id` = $sid";
   
    }elseif(isset($serid) === true){


       $query = "SELECT * FROM `content` WHERE `id` = $serid";

    }elseif(isset($id) === true){


       $query = "SELECT * FROM `content` WHERE `id` = $id";
    } 

$info = mysql_query($query); while($row = mysql_fetch_assoc($info)){

    extract($row);

     }

}

now the conditional works fine , in terms of the query working and grabbing the desired data and parlaying that data onto the site.

 

My issue is simply , i want to leave error reporting on for my users, so that if there are errors or problems i dont know of , server side , they can report this to me.

 

When i do this, i get :

 

 Notice: Undefined index: movieid in /home/medshare/public_html/include/init.php on line 49

Notice: Undefined index: seriesid in /home/medshare/public_html/include/init.php on line 51

Notice: Undefined index: id in /home/medshare/public_html/include/init.php on line 52

 

any explanation as to why this is happening ?

 

edit: i understand as to "why" , the variable that is the $_GET is now set to $sid , and the 3 other variables are not defined with since they are not in the URL. should i set the variables deeper into the conditional ? are they too global to where the entire if statement which is looking for current file and need to be set in their own if statements ?

 

also , any suggestions on how to alter my code to provide the same results without the notice being portrayed ?

 

much appreciated guys


Viewing all articles
Browse latest Browse all 13200

Trending Articles