Page 1 of 1
Update from php 5.2 to 5.3 errors
Posted: Sat Feb 06, 2010 8:00 pm
by sjakalen
Hi there all php freaks...
I have some problems after my host updated my php to 5.3
It give me some errors regarding ereg, I have bin reading and changing many ereg functions with help from
php.net/manual/en/function.ereg.php
But I am no expert and I need some help, for starters with these 2 codes.
Code: Select all
if (($character_after_place_holder === false) || ereg('[ ,)"]', $character_after_place_holder)) {
$this->sql_query = substr_replace($this->sql_query, $value, $pos, $length);
Code: Select all
if ($this->cache_read === false) {
if (eregi('^SELECT', $this->sql_query)) {
$this->db_class->freeResult($this->query_handler);
I hope someone can help me changeing this.
Re: Update from php 5.2 to 5.3 errors
Posted: Sat Feb 06, 2010 9:26 pm
by redmonkey
For the first one...
Code: Select all
if (($character_after_place_holder === false) || strcspn($character_after_place_holder, ' ,)"') !== false) {
... should suffice.
For the second one...
Code: Select all
if (stripos($this->sql_query, 'select') === 0) {
... should do the trick.
Re: Update from php 5.2 to 5.3 errors
Posted: Sun Feb 07, 2010 6:57 am
by sjakalen
I am on a small island in Indonesia, and I have asked this q in so many forums this is the first help i get after one week.
I did not try it yet, but I hope it will work, thanks so very very mutch.
Re: Update from php 5.2 to 5.3 errors
Posted: Mon Feb 08, 2010 8:53 am
by sjakalen
Yes it works! so nice thank's
I do still have one more problem I can't seem to find out
I get an error after the php 5.2 - 5.3 update regarding this
function &query($query) {
$osC_Database_Result =& new Database_Result($this);
$osC_Database_Result->setQuery($query);
any help on this?
Re: Update from php 5.2 to 5.3 errors
Posted: Mon Feb 08, 2010 10:59 am
by redmonkey
In most cases it's also helpful if you provide some details of the actual error message rather than just posting some code stating that it gives you an error.
In this case I'd guess the error message is something about assigning the return value of new as a reference being deprecated? If that's the case then it should be a simple case of removing the ampersand from the second line of code so...
Code: Select all
$osC_Database_Result =& new Database_Result($this);
... should be changed to...
Code: Select all
$osC_Database_Result = new Database_Result($this);
It is no longer necessary to explicitly assign the return value of new as a reference due to changes with PHP5's object model from previous versions.
Re: Update from php 5.2 to 5.3 errors
Posted: Sat Feb 13, 2010 5:22 am
by sjakalen
So nice support, it worked, thanks again.
I have 2 more errors and I hope that will be the last of it

The error is
1.
PHP Deprecated: Function ereg() is deprecated in products.php on line 35
2.
PHP Deprecated: Function ereg() is deprecated in cart_add.php on line 23
1 code
Code: Select all
foreach ($_GET as $key => $value) {
if ( (ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
$id = $key;
}
2 Code
Code: Select all
foreach ( $_GET as $key => $value ) {
if ( (is_numeric($key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
$id = $key;}