Jump to content

[SOLVED] undefined constants, variables, etc


phpnoob90

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);

}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'] : '');

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.