www.webdeveloper.com
Results 1 to 7 of 7

Thread: Help Needing In Weeding Out Errors In PHP

  1. #1
    Join Date
    Jul 2014
    Posts
    4

    Help Needing In Weeding Out Errors In PHP

    Hello, I'm unable to find out a solution to some 'Unindexed Notice' & 'Unindexed Variable' errors in some of the pages of my website(although I solved some by using 'isset' function as advised on various sites on internet). I'm including the code of both the pages,the page I'm executing & the page the Unindexed errors are pointed to.

    Here are the Pastebin links for the two pages(not able to paste code here because it is more than allowed number of characters).

    Search.php, this is the file I'm executing(upon which I'm getting errors)

    Search.class.php, this is the file to which the errors are pointed to. The error is pointed to Line No.152(Undefined Index: conf_currency_symbol) & the second error is pointed to Line No.312(Undefined Variable: child_flag).

    (Note: this is a reservation management system that I'm personalizing some of it's aspects to my needs, so I'm not the original coder. And I'm completely noob to PHP or to any web programming languages).

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    660
    You are getting legitimate php errors? Aren't they pretty self-explanatory? Show us the code pertaining to each error message - no pastebins please. Don't know what "unindexed notice" means. Is that really the exact text of the message?
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


    at the top of ALL php code while you develop it!

  3. #3
    Join Date
    Jul 2014
    Posts
    4
    Quote Originally Posted by ginerjm View Post
    You are getting legitimate php errors? Aren't they pretty self-explanatory? Show us the code pertaining to each error message - no pastebins please. Don't know what "unindexed notice" means. Is that really the exact text of the message?
    Hey sorry for messing up with the post, I meant to say Undefined Index & Undefined Variable. I've solved some of the similar errors by using 'isset' but couldn't do on these two mentioned instances. I can't paste all the code here because it exceeds maximum number of allowed characters and I don't think if I post the particular error line will help to get a solution from people. Any way following is the particular section(if you need full code you can find this from lines 150 in the search.class.php pastebin link in the original post).
    PHP Code:
    public function getAvailableRooms($roomTypeId$roomTypeName$capcityid){
            global 
    $bsiCore;
            
    $currency_symbol $bsiCore->config['conf_currency_symbol']; //Undefined Index: conf_currency_symbol Error//        
            
    $searchresult = array('roomtypeid'=>$roomTypeId'roomtypename'=>$roomTypeName'capacityid'=>$capcityid'capacitytitle'=>$this->multiCapacity[$capcityid]['captitle'], 'capacity'=>$this->multiCapacity[$capcityid]['capval'], 'maxchild'=>$this->childPerRoom); 
    By the way how can I edit my original post, I can't see any edit button.
    Last edited by NogDog; 07-12-2014 at 12:06 PM. Reason: changed [quote] tags to [php] tags around code

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,241
    It's telling you that the array $bsiCore->config does not have an element with a key (index) named "conf_currency_symbol"; so now your job is to determine whether it's a case of typing it wrong in that function, or if it's something worse like the array element or even the array itself is undefined at that point when that method is being executed -- and likely reinforcing one of the arguments against using global variables when at all avoidable.

    If you want to see the current status of that array when it fails, try something like this:
    PHP Code:
        public function getAvailableRooms($roomTypeId$roomTypeName$capcityid)
        {
            global 
    $bsiCore;
            if(!isset(
    $bsiCore->config['conf_currency_symbol'])) {
                throw new 
    Exception("No 'conf_currency_symbol:".PHP_EOL.var_export($bsiCoretrue));
            }
            
    $currency_symbol $bsiCore->config['conf_currency_symbol']; //Undefined Index: conf_currency_symbol Error//        
            
    $searchresult = array(
                
    'roomtypeid'=>$roomTypeId,
                
    'roomtypename'=>$roomTypeName,
                
    'capacityid'=>$capcityid,
                
    'capacitytitle'=>$this->multiCapacity[$capcityid]['captitle'],
                
    'capacity'=>$this->multiCapacity[$capcityid]['capval'],
                
    'maxchild'=>$this->childPerRoom
            
    );
        } 
    Last edited by NogDog; 07-12-2014 at 12:20 PM.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jul 2014
    Posts
    4
    Quote Originally Posted by NogDog View Post
    It's telling you that the array $bsiCore->config does not have an element with a key (index) named "conf_currency_symbol"; so now your job is to determine whether it's a case of typing it wrong in that function, or if it's something worse like the array element or even the array itself is undefined at that point when that method is being executed -- and likely reinforcing one of the arguments against using global variables when at all avoidable.

    If you want to see the current status of that array when it fails, try something like this:
    PHP Code:
        public function getAvailableRooms($roomTypeId$roomTypeName$capcityid)
        {
            global 
    $bsiCore;
            if(!isset(
    $bsiCore->config['conf_currency_symbol'])) {
                throw new 
    Exception("No 'conf_currency_symbol:".PHP_EOL.var_export($bsiCoretrue));
            }
            
    $currency_symbol $bsiCore->config['conf_currency_symbol']; //Undefined Index: conf_currency_symbol Error//        
            
    $searchresult = array(
                
    'roomtypeid'=>$roomTypeId,
                
    'roomtypename'=>$roomTypeName,
                
    'capacityid'=>$capcityid,
                
    'capacitytitle'=>$this->multiCapacity[$capcityid]['captitle'],
                
    'capacity'=>$this->multiCapacity[$capcityid]['capval'],
                
    'maxchild'=>$this->childPerRoom
            
    );
        } 
    Thank You for replying me, I tried your code, I've received a Fatal Error, below is what I got. Please note that I've edited some personal details in the error & replaced with 'X' symbols.

    Fatal error: Uncaught exception 'Exception' with message 'No 'conf_currency_symbol: bsiHotelCore::__set_state(array( 'config' => array ( 'conf_hotel_name' => 'XXXXX', 'conf_hotel_streetaddr' => 'XXXXXX', 'conf_hotel_city' => 'Your City', 'conf_hotel_state' => 'Your State', 'conf_hotel_country' => 'USA', 'conf_hotel_zipcode' => '11018', 'conf_hotel_phone' => 'XXXXXXX', 'conf_hotel_fax' => 'XXXXXXX', 'conf_hotel_email' => 'XXXXXX@XXX.com', 'conf_tax_amount' => '10', 'conf_dateformat' => 'mm/dd/yy', 'conf_booking_exptime' => '1000', 'conf_enabled_deposit' => '1', 'conf_hotel_timezone' => 'XXXXXXX', 'conf_booking_turn_off' => false, 'conf_min_night_booking' => '1', 'conf_notification_email' => 'XXXXXXX@XXXX.com', 'conf_price_with_tax' => false, 'conf_maximum_global_years' => '730', 'conf_payment_currency' => false, 'conf_invoice_currency' => false, 'conf_currency_updat in E:\xampp\search.class.php on line 159
    I don't know what that error means. Any way I want to point out two things here, I tried to see if 'conf_currency_symbol' is declared or mentioned in other pages(mainly class files), I found a reference of it in the main class file(admin.class.php). The following code is the particular section from the main class file, in which the 'conf_currency_symbol' is declared(I don't know if it can be called so).

    PHP Code:
    public function global_setting_post(){
            global 
    $bsiCore;
            if(isset(
    $_POST['price_inclu_tax'])){
                
    $pincludetax=1;
            }else{
                
    $pincludetax=0;
            }
            
    //echo "htmlentities('".$_POST['currency_symbol']."','ENT_COMPAT','utf-8')";
            
    $this->configure_update('conf_notification_email',  mysql_real_escape_string($_POST['email_notification']));
            
    //$this->configure_update('conf_currency_code',  mysql_real_escape_string($_POST['currency_code']));
            //$this->configure_update('conf_currency_symbol',  htmlentities(mysql_real_escape_string($_POST['currency_symbol']),ENT_COMPAT,'utf-8'));        
            
    $this->configure_update('conf_booking_turn_off',  mysql_real_escape_string($_POST['booking_turn'])); 
    If you see there by default the line which contains 'conf_currency_symbol' is commented, so I un-commented it & in order to get that value to reflect in search.class.php, I've used
    Code:
    include("includes/conf.class.php");
    in the search.class.php(in which I'm getting 'Undefined Index' error for 'conf_currency_symbol'). But it isn't done any good in removing the error. And second thing I want to point out is that, I tried this
    Code:
    $currency_symbol = ['conf_currency_symbol']
    , just removed "$bsiCore->config" from the error line and it worked, no more 'Undefined Index' errors on this line. But is that right thing to do(correct solution to the issue)?, I even don't know what this
    Code:
    $currency_symbol = ['conf_currency_symbol']
    mean. Hence, I decided to take some expert's advice over here.

    I hope this post making some sense to you, if not I'm sorry but I'm absolutely beginner with all this stuff. By the way can you please make the necessary correction to these words 'Unindexed Notice' & 'Unindexed Variable' in the first post of this post(my original post), they were supposed to be 'Undefined Index' & 'Undefined Variable'.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,241
    Well, looks like this line would try to define it, except it has been commented out, so it's not being executed:
    PHP Code:
            //$this->configure_update('conf_currency_symbol',  htmlentities(mysql_real_escape_string($_POST['currency_symbol']),ENT_COMPAT,'utf-8')); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jul 2014
    Posts
    4
    Quote Originally Posted by NogDog View Post
    Well, looks like this line would try to define it, except it has been commented out, so it's not being executed:
    PHP Code:
            //$this->configure_update('conf_currency_symbol',  htmlentities(mysql_real_escape_string($_POST['currency_symbol']),ENT_COMPAT,'utf-8')); 
    Oh!, ok, thanks for confirming that. But as I pointed in my previous reply, I did try to get that definition(index or whatever it is supposed to be called) to reflect in the file that the errors are pointed to. I tried this way:

    Code:
    public function getAvailableRooms($roomTypeId, $roomTypeName, $capcityid){
    		global $bsiCore;
    		include_once("includes/admin.class.php");
    		$currency_symbol = $bsiCore->config['conf_currency_symbol'];		
    		$searchresult = array('roomtypeid'=>$roomTypeId, 'roomtypename'=>$roomTypeName, 'capacityid'=>$capcityid, 'capacitytitle'=>$this->multiCapacity[$capcityid]['captitle'], 'capacity'=>$this->multiCapacity[$capcityid]['capval'], 'maxchild'=>$this->childPerRoom);
    		$room_count = 0;
    ........
    But as I pointed out in my previous reply, it didn't have any effect as I'm still getting same error. Is that above method right way of doing it?.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles