phpnoob90 Posted January 29, 2008 Share Posted January 29, 2008 Hi, I have just installed some scripts on my website and have loads of notes like below. I believe it is to do with the new version of php or something, I have had a look around and saw that somebody said changing the php.ini would stop this but i am on a shared server and dont think i can do this. If anybody knows how i can solve this it would be much appreciated. Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/session.php on line 26 Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/session.php on line 48 Notice: Undefined index: owner_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/adminpanel/func.php on line 42 Notice: Undefined index: owner_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/adminpanel/func.php on line 46 Notice: Undefined index: hidaction in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/adminpanel/func.php on line 42 Notice: Undefined index: hidaction in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/adminpanel/func.php on line 46 Notice: Use of undefined constant type - assumed 'type' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 42 Notice: Use of undefined constant type - assumed 'type' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 45 Notice: Use of undefined constant type - assumed 'type' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 42 Notice: Use of undefined constant type - assumed 'type' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 45 Notice: Use of undefined constant status - assumed 'status' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 46 Notice: Use of undefined constant status - assumed 'status' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 46 Notice: Use of undefined constant status - assumed 'status' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 47 Notice: Use of undefined constant type - assumed 'type' in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/owner_class.php on line 42 Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/ Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 is this a multi langual website? if so go to the language file and check if the define() functions exists and matches with the ones on the pages the error is dispayed. Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452501 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 Notice: Use of undefined constant... in line 42 in this line change [type] to ['type'] for Notice: Undefined index:... We must see some relevant code lines (20 - 50) Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452510 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 Undefined index is usually when a ; (semicolon) is missing on the line above loool Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452514 Share on other sites More sharing options...
trq Posted January 29, 2008 Share Posted January 29, 2008 Undefined index is usually when a ; (semicolon) is missing on the line above loool An undefined index occurs when the index does not exist within the array. Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452525 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 valtido, that makes no sense. A missing semi-colon anywhere but the last line before a closing ?> tag will result in a fatal parse error and the code will never run. The undefined index messages are due to code referencing an array element (probably $_POST or $_GET) that is not set. The correction is to use the isset() function. The undefined constant messages might be due to missing constants, but they are more likely due to having no quotes around an array index name. Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452528 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 Here is lines 15-75 of ownerclass.php if it helps at all class owner{ var $Link; var $owner_id; var $fname; var $lname; var $email_add; var $password; var $address_1; var $address_2; var $city; var $state_id; var $country_id; var $zip; var $status; var $phone; var $fax; var $mobile; var $listed_by; var $date_joined; var $OwnerActivation; var $Membership; var $UserError; function owner(){ $sql="select * from ".TABLE_PREFIX."system_info"; if ($rs=mysql_query($sql)){ while ($rows=mysql_fetch_array($rs)){ if ($rows[type] == 'Seller Activation'){ $this->OwnerActivation=$rows[status]; } if ($rows[type] == "Owners"){ $rows[status] = ($rows[status] == 'F')?'A':'P'; $this->bstatus=$rows[status]; } } mysql_free_result($rs); } } function Load(){ $sql="select * from ".TABLE_PREFIX."owner_mst where owner_id='".valid_id($this->owner_id)."'"; if($rs=mysql_query($sql)){ $rows=mysql_fetch_array($rs); $this->fname=$rows[fname]; $this->lname=$rows[lname]; $this->userid=$rows[userid]; $this->email_add=$rows[email_add]; $this->password=$rows[password]; $this->address_1=$rows[address_1]; $this->address_2=$rows[address_2]; $this->city=$rows[city]; $this->state_id=$rows[state_id]; $this->country_id=$rows[country_id]; $this->zip=$rows[zip]; $this->status=$rows[status]; $this->date_joined=$rows[date_joined]; $this->phone=$rows[phone]; $this->fax=$rows[fax]; $this->mobile=$rows[mobile]; $this->listed_by=$rows[listed_by]; mysql_free_result($rs); } Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452537 Share on other sites More sharing options...
trq Posted January 29, 2008 Share Posted January 29, 2008 As has been said, non numerical array indexes need quotes, eg; if ($rows[type] == 'Seller Activation'){ should be.... if ($rows['type'] == 'Seller Activation'){ Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452539 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks a lot! Does this mean that everytime i have a note that starts "Notice: Use of undefined constant type - assumed 'type' ........." i just have to make sure its 'type' instead of type Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452550 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 first part of notices in files session.php and func.php can we see this Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452573 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 session.php lines 15-55 $location1 = ",location='" . EscapeString($_SERVER["REQUEST_URI"]) . "'"; $USER_AGENT=substr($_SERVER['HTTP_USER_AGENT'],0,150); $sql="select addy from ".TABLE_PREFIX."session where addy ='{$_SERVER['REMOTE_ADDR']}'"; //echo $sql; $result = mysql_query($sql) or die($sql." ".mysql_error()); $numrows=mysql_num_rows($result); //echo $numrows; if ($numrows){ mysql_query("UPDATE ".TABLE_PREFIX."session SET sessionhash='".session_id()."', lastactivity='".time()."' ".$location1." WHERE addy ='{$_SERVER['REMOTE_ADDR']}'"); //if ($_COOKIE['id']) { if ($_SESSION['buyer_id']) { //mysql_query("UPDATE session SET userid = '{$_COOKIE['id']}' WHERE sessionhash='".session_id()."'"); mysql_query("UPDATE ".TABLE_PREFIX."session SET buyer_id = '{$_SESSION['buyer_id']}' WHERE sessionhash='".session_id()."'"); } else{ mysql_query("UPDATE ".TABLE_PREFIX."session SET buyer_id = '0' WHERE sessionhash='".session_id()."'"); } } elseif(!$_COOKIE['sesshash']) { mysql_query("INSERT INTO ".TABLE_PREFIX."session (sessionhash,buyer_id,host,useragent,lastactivity,location, addy) VALUES ('".session_id()."','0','".EscapeString($_SERVER["HTTP_HOST"])."','".EscapeString($USER_AGENT)."','".time()."','{$_SERVER["REQUEST_URI"]}','{$_SERVER['REMOTE_ADDR']}')"); setcookie("sesshash", session_id(), time()+ 1800, "/"); } else { $newsess_time = time() - 1800; // one half hour if($getaddy = mysql_query("select addy from session where addy ='{$_SERVER['REMOTE_ADDR']}' and lastactivity < '$newsess_time'")){ $num = mysql_num_rows($getaddy); } if($num <5){ mysql_query("INSERT INTO ".TABLE_PREFIX."session (sessionhash,buyer_id,host,useragent,lastactivity,location, addy) VALUES ('".session_id()."','{$_SESSION['buyer_id']}','".EscapeString($_SERVER["HTTP_HOST"])."','".EscapeString($USER_AGENT)."','".time()."','{$_SERVER['REQUEST_URI']}','{$_SERVER['REMOTE_ADDR']}')"); } } //if ($_COOKIE['id']!=0 and $_COOKIE['id']!=-1) { if ($_SESSION['buyer_id']!=0 and $_SESSION['buyer_id']!= '') { $get_session = mysql_query("select timestamp from ".TABLE_PREFIX."buyer_mst where buyer_id ='{$_SESSION['buyer_id']}'"); $row = mysql_fetch_array($get_session); if ((time() - $row['timestamp']) > 1800) { mysql_query("UPDATE ".TABLE_PREFIX."buyer_mst SET timestamp ='".time()."', ipaddy ='{$_SERVER["REMOTE_ADDR"]}' WHERE buyer_id='{$_SESSION['buyer_id']}'"); } } ?> AND lines 32 to 60 of func.php function valid_id($id){ if (preg_match ("/^([0-9]+)$/", $id)){ return $id; } else { return '0'; } } function getVal($a){ if($_POST[$a]){ $ret=$_POST[$a]; } else{ $ret=$_GET[$a]; } return $ret; } function DetectLongString($aboutme){ $text = explode(" ", EscapeString($aboutme)); $totalwords = count($text); for ($x = 0; $x < $totalwords; $x++) { if (strlen($text[$x]) > 75){ $text[$x] = wordwrap($text[$x], 75, "<br />",1); } } and thanks for the advice on type to 'type' i really do appreciate all the help! Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452583 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 line 25 if ($_SESSION['buyer_id']) { change to if (isset($_SESSION['buyer_id']) and $_SESSION['buyer_id']) { etc. Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452597 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 Okay ive sorted about 70% of my notices now. Not quite sure about these ones though Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/include_left_index.php on line 16 Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/include_left_index.php on line 19 Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/include_left_index.php on line 20 include_left_index.php lines 15 to 23 $Buyer=new Buyer(); $Buyer->buyer_id=$_SESSION['buyer_id']; $Buyer->Load(); $Buyer_name=$Buyer->fname." ".$Buyer->lname; $saveSearchCount=$Buyer->countSaveSearch($_SESSION['buyer_id']); $saveListingsCount=$Buyer->saveListingsCount($_SESSION['buyer_id']); unset($Buyer); include_once(FULL_PATH."/templates/leftside.html.php"); ?> hopefully i should have all of these sorted by this evening, all this codes giving me headache lol Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452600 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 line 16: $Buyer->buyer_id= isset($_SESSION['buyer_id']) ? $_SESSION['buyer_id'] : ''; line 19: $saveSearchCount=$Buyer->countSaveSearch(isset($_SESSION['buyer_id']) ? $_SESSION['buyer_id'] : ''); line 20: $saveListingsCount=$Buyer->saveListingsCount(isset($_SESSION['buyer_id']) ? $_SESSION['buyer_id'] : ''); Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452607 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 sasa, you are my savior lol your last post fixed Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/session.php on line 26 but Notice: Undefined index: buyer_id in /home/fhlinux153/h/houseswitch.co.uk/user/htdocs/session.php on line 48 is still showing sorry if im not changing something obvious i have very little php knowledge Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452612 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 lines 16,19,20 fixed :) Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452621 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 $ret= isset($_GET[$a]) ? $_GET[$a] : ''; Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452622 Share on other sites More sharing options...
phpnoob90 Posted January 29, 2008 Author Share Posted January 29, 2008 sorry, was that line 48? need to make sure, i really dont want to be messing this up anymore Thank You Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452628 Share on other sites More sharing options...
sasa Posted January 29, 2008 Share Posted January 29, 2008 i don't have hole file but i'm 90% shure that it is line 48 Quote Link to comment https://forums.phpfreaks.com/topic/88418-solved-undefined-constants-variables-etc/#findComment-452633 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.