Not to mention the code is almost entirely redundant - a wrapper to a mysql library that doesn’t really add anything other than what appears to be an early attempt at a parameterized query that has long since been integrated (in a better way) into the standard mysqli and PDO libraries.
I’m still struggling to see why it throws that error specifically. I know the code isn’t great, and it uses the old mysql_ functions so a modern version of PHP would be upset with those, but why that specific error on that seemingly-innocuous line of code?
That said, I’ve never used the & character as it holds too many (bad) memories of dabbling with C. Could the function &SQL_Query() be clashing with the class SQL_Query even though the former is preceded by an & ?
The property initializer is redundant so you could try removing it:
# Change
private $query = "";
# To
private $query;
However, I don’t think that will help. The real problem (based on the error message) is that there is a spurious } someplace. My IDE does not detect it. I suspect your actual code does not match the link you posted. You probably edited the file locally and accidentally added an extra } someplace.
I don’t recall visibility being implemented in PHP 4.
(If you’re wondering why we’re having such trouble with this, PHP5 was released in 2004. It’s been a decade and a half since your version of PHP was obsolete.)
I do believe you are correct. I could not find an absolute reference with a quick search but I am pretty sure that the visibility modifiers were part of 5.0 new object model. On the other hand, all of those ampersands are definitely an indication of 4.x code.
Should be easy enough to test:
// Replace
class SQL_Query {
private $query = "";
private $params = array();
// With
class SQL_Query {
var $query = "";
var $params = array();
I did not. If properties were meant to be private or protected they were prefixed with an _ in the property name, like var $_db. That was meant as a signal to other developers it was private, PHP itself didn’t care.
@ahundiak I think that the error may be shown only under certain PHP version, but in other versions it works, that is why your IDE returned OK.
Somehow i see blank page now despite i added
error_reporting(‘E_ALL’);
to main functions.php file, database details file and enabled it in hosting account configuration. + the error log in hosting does not show up any error and no error_log file.
After changed PHP from 4.4 to 5.3 then it started showing the things correctly , no errors anywhere (does not mean these are not hidden i suppose)
all of those ampersands are definitely an indication of 4.x code. Should be easy enough to test:
// Replace
class SQL_Query {
private $query = "";
private $params = array();
// With
class SQL_Query {
var $query = "";
var $params = array();
under PHP 5.3 the change does not seem to have any effect on what i see on site and no errors in logs.
So no longer problem on my side after changing PHP version. But if anyone is curious what was the problem i can try other things under PHP 4.4.
private was introduced in 5.x. So my suggestion of changing private to var would probably get you past that particular error on 4.4. However it is clear that the code was modified for 5.x so there are probably other 4.4 errors. Stick to 5.x if it is working. In fact try to go to 5.6 as that version is still semi-supported.
But if you are using this code for anything important then it is probably time to get a developer to upgrade you. Probably have plenty of security issues.