Jump to content

Undefined Variable


Recommended Posts

Hey folks,
I am getting the following error, any ideas why this would happen?

Hack: 1615340154.58800 --- Duration: 419 µs [ERROR - NOT CACHED]
INSERT INTO `cc6_CubeCart_system_error_log` (`message`,`time`) VALUES ('[<strong>Notice</strong>] /var/www/clients/client1/web3/web/includes/functions.inc.php:221 - Undefined variable: get','1615340154');


Link to comment
Share on other sites

The CubeCart programmers have adopted the programming style of not declaring a variable before using it. This is perfectly legit in PHP.

However, PHP will also log a Notice in the error log (unless specifically told to ignore such situations) when attempting to use a variable it knows nothing about -- yet.

Such notices serve as a clue to the programmers that this variable name needs to be checked as it could be a misspelling of some other variable name.

Also, "Hack" refers to a "time hack", as from a stop-watch, to indicate the universal time when this statement was executed.

Edited by bsmither
Link to comment
Share on other sites

Doing this is an exercise in futility. There will be hundreds of instances of these kinds of Notices.

But, in the file /includes/functions.inc.php:

Near line 202 find:

function currentPage($excluded = null, $included = null, $remove_excluded = true)

A few lines later, find:

$get = $_GET;

Change that to:

$get = (array)$_GET;

Please let us know the exact version of CubeCart you are using. The error message is indicating line number 221, and yet, the line that has $get in it is line number 219 (for CC642).

Link to comment
Share on other sites

We'll i'll be :-)

You just fixed my logout problem. I was get a csrf error when I tried to logout. Genius ** Salute **

Thanks B


another quick question while I got you here.

When ever I submit a form in the backend the page will load, and then it tries to start auto scrolling to the top of the page.

Any idea what would cause it to try and auto scroll to the top of the page?

Link to comment
Share on other sites

Nice, found the -81, awesome, thank you sir.

I'm using the latest version 6.4.2. Ahhh, didn't notice that, that makes a difference. the line it is referring to is

    if (is_array($get) && count($get) > 0) {
        $params = array_merge($params, $get);

Specificcly the $params = array_merge($params, $get); part

I also get this notice at the top of my page

 Notice: Undefined variable: _GET in /var/www/clients/client1/web3/web/includes/functions.inc.php on line 208


Link to comment
Share on other sites

If the "superglobal" variable $_GET is not known to PHP - which it would be very strange if not - that means something is not set right with the PHP INI file regarding the variables_order setting (https://www.php.net/manual/en/ini.core.php#ini.variables-order) - which now you are getting an error: Undefined variable: _GET.

If the regular variable $get is not getting defined when skipped over because $_GET is not empty, then there might be problems later over an undefined $get.


Link to comment
Share on other sites

In CubeCart's admin, PHP Info, scroll to the bottom of the Core table. Find the 'variables_order' directive. The values should be GPCS. The G stands for $_GET and if that letter is in the group, PHP will create that variable and make whatever it contains available to any script code, anywhere.

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...