Zen Cart Logo
Forums / Upgrading to 2.x.x / SQLpatch.php Error When Running Any SQL Statement

SQLpatch.php Error When Running Any SQL Statement

Views: 335

Results 1 to 4 of 4
19 Jan 2025, 16:00
#1
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

SQLpatch.php Error When Running Any SQL Statement

I am upgrading my site from v.1.5.8 to v.2.1 and whenever I need to run an SQL statement in the various plugins I get this error and it will not process properly.

As I see the file that error occurring in is a stock Zen Cart file rather than plugin specific, I thought I'd post it here.

This is the error that I receive:

Request URI: /new21/admin/index.php?cmd=sqlpatch&action=execute, IP address: 127.0.0.1, Language id 1
#1 zen_check_config_key() called at [C:\wamp64\www\new21\admin\sqlpatch.php:164]
#2 executeSql() called at [C:\wamp64\www\new21\admin\sqlpatch.php:747]
#3 require(C:\wamp64\www\new21\admin\sqlpatch.php) called at [C:\wamp64\www\new21\admin\index.php:16]
--> PHP Warning: Undefined array key 1 in C:\wamp64\www\new21\admin\sqlpatch.php on line 675.

[16-Jan-2025 13:42:27 UTC] Request URI: /new21/admin/index.php?cmd=sqlpatch&action=execute, IP address: 127.0.0.1, Language id 1
#1 zen_check_config_key() called at [C:\wamp64\www\new21\admin\sqlpatch.php:164]
#2 executeSql() called at [C:\wamp64\www\new21\admin\sqlpatch.php:747]
#3 require(C:\wamp64\www\new21\admin\sqlpatch.php) called at [C:\wamp64\www\new21\admin\index.php:16]
--> PHP Warning: Undefined array key 3 in C:\wamp64\www\new21\admin\sqlpatch.php on line 676.

Could someone give me some ideas on how to fix this?

Thank you....

19 Jan 2025, 16:13
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: SQLpatch.php Error When Running Any SQL Statement

An example of a SQL query that fails would help.

19 Jan 2025, 16:37
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: SQLpatch.php Error When Running Any SQL Statement

Be sure the values in your statement are enclosed in single quotes (not double quotes).

19 Jan 2025, 16:48
#4
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: SQLpatch.php Error When Running Any SQL Statement

Thank you lat 9 and swguy for your replies and help!

The plugin I am currently working on is Instant Search...in which I have installed the most current version. This error happens when you place a plugin in the zc_plugins folder and then try to use the Uninstall or Clean Up button in Admin->Modules->Plugin Manager.

It is obviously trying to run an SQL stmt in it's Install or Uninstall and I am encountering this error.

Thanks for your suggestion as well swguy. The problem code in lines 675 &676 are these:
$title = $values[1];
$key = $values[3];

I have search sqlpatch.php for everything pertaining to $title and $key and don't see where they are defined.

The 10 lines above are the only ones that come close with the $values array. Here are the 10 lines above:

function zen_check_config_key($line) {
global $db;
$values = array();
$values = explode("'", $line);
//INSERT INTO configuration blah blah blah VALUES ('title','key', blah blah blah);
//[0]=INSERT INTO.....
//[1]=title
//[2]=,
//[3]=key
//[4]=blah blah

Does this give you any other ideas on how I can fix this?