mpatel Posted August 19, 2011 Share Posted August 19, 2011 hi guys help needed here as i cant figure out these error as i am new to this Deprecated: Function session_register() is deprecated in C:\xampp\htdocs\index.php on line 3 Notice: Undefined index: id in C:\xampp\htdocs\index.php on line 4 <?php session_start(); session_register("refid_session"); $id=$_GET['id']; if($id !="") { if($_SESSION["refid_session"]=="") { $_SESSION["refid_session"]=$id ; } } include "default.php"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/ Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 change it to... <?php session_start(); $id=$_GET['id']; if(!isset($_SESSION["refid_session"]) && isset($id)) { $_SESSION["refid_session"]=$id ; } include "default.php"; ?> session_register() doesn't exist anymore. Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259334 Share on other sites More sharing options...
mpatel Posted August 19, 2011 Author Share Posted August 19, 2011 thanks for your help but still i cant get rid of this error Undefined index: id on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259335 Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 try... <?php session_start(); if(!isset($_SESSION["refid_session"]) && isset($_GET['id'])) { $_SESSION["refid_session"] = $_GET['id']; } include "default.php"; ?> you need to do some kind of validation on $_GET['id'] Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259336 Share on other sites More sharing options...
mpatel Posted August 19, 2011 Author Share Posted August 19, 2011 first of all thanks for fast reply. my friend told me where ever it is throwing the undefined index error, use the language construct isset() to check if the value for 'id' has been set. you already used isset then also isuue not solved :'( Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259341 Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 if $_GET['id'] isn't always going to be specified, you should either throw an error or set a default value if need be, like so: <?php session_start(); if(isset($_GET['id'])) { if(!isset($_SESSION["refid_session"])) { $_SESSION["refid_session"] = $_GET['id']; } } else { // either error or default value echo "No ID was set!"; } include "default.php"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259344 Share on other sites More sharing options...
mpatel Posted August 19, 2011 Author Share Posted August 19, 2011 i have not set id so i was getting error with your help i was able to find my mistake i have no word to express but thank you very much. :D :D Quote Link to comment https://forums.phpfreaks.com/topic/245182-little-help-needed/#findComment-1259351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.