Update from php 5.2 to 5.3 errors

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sjakalen
Forum Newbie
Posts: 13
Joined: Sat Feb 06, 2010 7:48 pm

Update from php 5.2 to 5.3 errors

Post 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.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Re: Update from php 5.2 to 5.3 errors

Post 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.
sjakalen
Forum Newbie
Posts: 13
Joined: Sat Feb 06, 2010 7:48 pm

Re: Update from php 5.2 to 5.3 errors

Post 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.
sjakalen
Forum Newbie
Posts: 13
Joined: Sat Feb 06, 2010 7:48 pm

Re: Update from php 5.2 to 5.3 errors

Post 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?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Re: Update from php 5.2 to 5.3 errors

Post 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.
sjakalen
Forum Newbie
Posts: 13
Joined: Sat Feb 06, 2010 7:48 pm

Re: Update from php 5.2 to 5.3 errors

Post 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;}
Post Reply