Undefined index within a PHP path - php

Newbie here to OpenCart extension development. I am currently developing a 99Bill (Chinese payment method) payment extension.
Currently, I've added new files to the MVC directories (so, I added files under admin, catalog, etc, where I named my extension bill99, since PHP doesn't allow names that start with numbers).
I was trying to test my extension, but on my OpenCart home page, I get the following error:
Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20Notice: Undefined index: mobile_description in /vagrant/opencart/upload/catalog/model/catalog/product.php on line 20
I am not quite sure how I triggered it, since I never edited or touched the product.php file before. The error appears even if I disable/uninstall my 99Bill extension.
When I navigate to product.php, line 20 simply says:
'description' => $query->row['mobile_description']
I have a feeling my error has nothing to do with the product.php file, since I never touched it before, and likely relates to my 99Bill extension. I may have not initialized a class somewhere.
For someone that's had this error before, could you help me understand this?

Well: line 20 accesses an array index, doesn't it? Suppose the index doesn't exist, wouldn't the error message you get make sense then? try dumping the contents of $query->row or replace what you have now with:
'description' => isset($query->row['mobile_description']) ? $query->row['mobile_description'] : null,
As far as why you get this notice: This answer explains that, and contains some snippets that could help you refactoring your code

Related

can not save product while adding discount price in opencart

I am working with opencart and I am learning right now.
When I add discount price in product and save it then I received notice like :
Notice: Undefined index: points in /home/eyelens/public_html/admin/model/catalog/product.php on line 131Notice: Undefined index: points in /home/eyelens/public_html/admin/model/catalog/product.php on line 177Notice: Undefined index: weight in /home/eyelens/public_html/admin/model/catalog/product.php on line 177Notice: Undefined index: weight_prefix in /home/eyelens/public_html/admin/model/catalog/product.php on line 177Warning: Cannot modify header information - headers already sent by (output started at /home/eyelens/public_html/admin/index.php:80) in /home/eyelens/public_html/system/library/response.php on line 12
Here, I got error because my array is full so it can not return point and weight therefor it gives an error. So how can I increase array size ?
Undefined index : Even though php does not need variables to be declared first you must have some values in it before using a variable. So it is recommended that you should initialise the variables or use isset(variablename) before using the variable.
Inorder to solve headers already sent error, you should not print any output before using functions that modify headers like header() session_start()
I have write below two variable in php.ini file
max_input_vars = 30000;
max_post_size = 30000;
and its working perfect.

Notice on line 0

I am using AJAX Quick Checkout for open cart 1.5.5.1.
I receive following notice while I integrate it with CCAvenue.
Live Link
Notice: Undefined index: comment in /home/eklavya/public_html/pitara/catalog/controller/payment/ccavenuepay.php on line 0
Notice: Undefined index: comment in/home/eklavya/public_html/pitara/catalog/controller/payment/ccavenuepay.php on line 0
I also replaced my ccAvenue version it still sows this notice. My ccavenuepay.php is encoded as shown in image if i edit it shows 'File is corrupt message'.

I'm trying to manage common variable between PHP modules using the $_SESSION using INCLUDE files in each of the modules

I have four PHP modules/forms which use common variables. I'm trying to use include files with Session Start and $_SESSION to pass with same data between modules. But when I use it I get
Notice: Undefined index: Cot in C:\xampp\htdocs\xampp\Ironman2014Test\includes\Session_to_Variable_PHP.inc.php on line 3
Notice: Undefined index: Tent_Time_In in C:\xampp\htdocs\xampp\Ironman2014Test\includes\Session_to_Variable_PHP.inc.php on line 4
Notice: Undefined index: Tent_Time_Out in C:\xampp\htdocs\xampp\Ironman2014Test\includes\Session_to_Variable_PHP.inc.php on line 5
I can not seem to make these errors go away.
Try this way:
if(!empty($_SESSION['Cot']))
{
echo $_SESSION['Cot'];
}
or
if(isset($_SESSION['Cot']))
{
echo $_SESSION['Cot'];
}

php Undefined variable: _session_register issue

There is one php project made in fully core php. Now my work is to change some style issues. So I just downloaded all the files with the database. I just configured all the database name,username,password over my localhost(LAMP). When I browsed the page it is showing the page but there are some errors with it. It is showing error like
Notice: Undefined variable: _session_register in path to the folder/session.php on line 8
Notice: Undefined variable: _session_register in path to the folder/session.php on line 9
Notice: Undefined variable: _session_register in path to the folder/session.php on line 10
Notice: Undefined variable: _session_register in path to the folder/session.php on line 11
Notice: Undefined variable: _session_register in path to the folder/session.php on line 12
Notice: Undefined variable: _session_register in path to the folder/session.php on line 13
The code for the session.php is like this
<?php
$_SESSION['example']="yes";
ini_set("url_rewriter.tags","");
ini_set('session.use_trans_sid', 0);
ini_set("session.cookie_domain", ".localhost");
session_start();
ob_start();
$_session_register["easb2b_username"];
$_session_register["easb2b_userid"];
$_session_register["easb2b_memtype"];
$_session_register["easb2b_adv_id"];
$_session_register["easb2b_adv_email"];
$_session_register["lang"];
?>
So can someone kindly tell me how to solve this issue. The project has around thousand of files. So its really hard to go through all the files and check them. Any help and suggestions will be really appreciable. Thanks....
<?php
// Use of session_register() is deprecated
$new_sessionvar = "Some value.";
session_register("new_sessionvar");
But you can still use
session_start();
$_SESSION['new_sessionvar'] = "Some value"
In order to use it you need to turn on register_global in php.ini
Note that I have the session_start() function right above initialization. In your code you may want to add it at the top of your script to prevent the Headers already sent by PHP message.

cakePHP Blog error messages

I am trying to set up a cakePHP blog. Following the steps at:
http://www.marcofolio.net/webdesign/building_a_blog_with_cakephp_part_1_getting_started.html
but when I get to the stage of creating 'article.ctp' in order to view the 'Read More' part of the blog. I get the following error messages:
Notice (8): Undefined index: id = 1 [CORE/Cake/Model/Model.php, line 2519]
Notice (8): Undefined index: id = 1 [CORE/Cake/Model/Model.php, line 2495]
Notice (8): Undefined variable: articles [APP/View/Blog/article.ctp, line 1]
Sadly this is hosted on my test server locally in MAMP so I can't show you the live error I am getting. But just thought id check and see if anyone has had similar issues with this (I believe its a common beginner tutorial for learning to use cakePHP)
That's an ancient tutorial, try out the cakephp 2.x blog tutorial from the official site:
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html
And your error is quite simple, the variable $articles does not exist in your view, so you haven't set the variable in your controller with $this->set('articles', 'value');

Categories