Jump to content



Photo
- - - - -

Need help to resolve problem in general.php


This topic has been archived. This means that you cannot reply to this topic.
26 replies to this topic

#1   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 20:12

Can't seem to get this working. Need help to resolve code problem in catalog/includes/functions/general.php

To work in new PHP 5.3 former code "ereg" needs to be changed to "preg-match".

Changed 2 of the three lines:

Here is the code:

if ($type == 'mixed') {
if (preg_match('^[a-z0-9]$', $char)) $rand_value .= $char;
} elseif ($type == 'chars') {
if (preg_match('^[a-z]$', $char)) $rand_value .= $char;
} elseif ($type == 'digits') {
if (eregi('^[0-9]$', $char)) $rand_value .= $char;
}
}

But when I change the 3rd one which is "eregi" with the extra "i" to "preg_match" which is suppose to be changed the same change as "ereg"
I get this error:

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /includes/functions/general.php on line 1043

Appreciate any help to resolve this.

#2   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 20:41

can you post your modified code ?

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#3   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 20:43

ereg becomes preg
eregi becomes preg_match

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#4   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 20:49

or try this:

	    if (preg_match('/^[a-z0-9]$/i', $char)) $rand_value .= $char;

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#5   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 20:56

sorry, ignore my last post - posted the wrong line - these are the 3 modified lines:

	    if (preg_match('/^[a-z0-9]$/i', $char)) $rand_value .= $char;
	  } elseif ($type == 'chars') {
	    if (preg_match('/^[a-z]$/i', $char)) $rand_value .= $char;
	  } elseif ($type == 'digits') {
	    if (preg_match('/^[0-9]$/', $char)) $rand_value .= $char;

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#6   bktrain

bktrain
  • Members
  • 2,108 posts

Posted 13 January 2012 - 21:14

Did you think about upgrading osC 2.3.1?

Try the link below. It should help you out.

Click Me

Edited by bktrain, 13 January 2012 - 21:16.

Remember to backup database, files and pictures.

I have a problem for your solution
I reject your reality and substitute my own
My mind not only wanders, it sometimes leaves completely
The problem with the gene pool is that there is no lifeguard
Everyone’s entitled to my opinion


Links
Security
SSL Help
Basics for design V2.3+

#7   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 21:55

sorry, ignore my last post - posted the wrong line - these are the 3 modified lines:

		if (preg_match('/^[a-z0-9]$/i', $char)) $rand_value .= $char;
	  } elseif ($type == 'chars') {
		if (preg_match('/^[a-z]$/i', $char)) $rand_value .= $char;
	  } elseif ($type == 'digits') {
		if (preg_match('/^[0-9]$/', $char)) $rand_value .= $char;


Thank youi so much Heather! That did it!

#8   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 22:05

No Problem - I went through the same thing a few days ago - see my post on the subject probably on the 2nd or 3rd page of general support by now - I documented the changes as I made them

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#9   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 22:07

Trying to complete check out. Maybe you can help me with this one.

The error I get is: Warning: preg_replace() [function.preg-replace]: No ending delimiter '+' found in /includes/functions/general.php on line 61

Here is the code: $string = preg_replace(' +', ' ', trim($string));

I tried put a / in and around the ' +' but nothing worked so far.

#10   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 22:12

Trying to complete check out. Maybe you can help me with this one.

The error I get is: Warning: preg_replace() [function.preg-replace]: No ending delimiter '+' found in /includes/functions/general.php on line 61

Here is the code: $string = preg_replace(' +', ' ', trim($string));

I tried put a / in and around the ' +' but nothing worked so far.


Try
$string = preg_replace(' /+/', ' ', trim($string));

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#11   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 22:19

I think you need to read the previous post I made on my crisis with PHP 5.3 - Dunweb posted a link to me of all the changes needed for the "Core" Rc2.2 files - general php is covered in that

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#12   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 22:20

Try

$string = preg_replace(' /+/', ' ', trim($string));


Now the error changed still the same line: Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /includes/functions/general.php on line 61

In the dark as to waht that may mean.

#13   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 22:22

Maybe something to do with the next line:

function tep_sanitize_string($string) {
$string = preg_replace(' /+/', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);
}

#14   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 22:24

This is the link to my thread - go to the link posted on Dunwebs first answer.

http://forums.oscomm...-php-53-crisis/

A lot of what you are asking is covered

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#15   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 22:45

Hi Heather

I already downloaded and install the drop in update PHPs.
I have 2 stores and the one I did the drop in updates, I cannot load anything into the shopping cart at all, nothing appears, it remains empty.
I have no idea if these updates are the cause but the other store is getting close to processing. Items appear in the cart. So far the checkout does not
recognize me a s a customer. I'v went through and read your posts a page or 2 back.

I still have this error: as in my last post: Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /includes/functions/general.php on line 61

Appreciate any help

#16   geoffreywalton

geoffreywalton

    Available for Hire

  • Community Sponsor
  • 8,206 posts

Posted 13 January 2012 - 22:55

Did you just drop in the complete files or amend the specific lines?

If you replaced entire files, any changes already made will be lost and things will stop working.

Restore the files and just change the lines that need to be replaced.

HTH

G
Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

Virus Threat Scanner
My Contributions
Basic install answers.
Click here for Contributions / Add Ons.
UK your site.
Site Move.
Basic design info.

For links mentioned in old answers that are no longer here follow this link Useful Threads.

If this post was useful, click the Like This button over there ======>>>>>.

#17   Mort-lemur

Mort-lemur
  • Members
  • 1,949 posts

Posted 13 January 2012 - 23:00

Hi,

Use the Read Me section of the contribution and do the changes line by line

Now running on a fully modded 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.


#18   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 13 January 2012 - 23:26

I get it now. Thanks! I changed an error line in languages.php using the new code line in the update.
Now I'm unable to add anything to the cart just as in the other store.
Any ideas as what to do would be appreciated!

#19   geoffreywalton

geoffreywalton

    Available for Hire

  • Community Sponsor
  • 8,206 posts

Posted 13 January 2012 - 23:48

Did you just drop in the complete files or amend the specific lines?

If you replaced entire files, any changes already made will be lost and things will stop working.

Restore the files and just change the lines that need to be replaced.


Restore the files to the state before you dropped in the files, ifthat makes sense

G
Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

Virus Threat Scanner
My Contributions
Basic install answers.
Click here for Contributions / Add Ons.
UK your site.
Site Move.
Basic design info.

For links mentioned in old answers that are no longer here follow this link Useful Threads.

If this post was useful, click the Like This button over there ======>>>>>.

#20   ecgbyme

ecgbyme
  • Members
  • 242 posts

Posted 14 January 2012 - 00:28

Restore the files to the state before you dropped in the files, ifthat makes sense

G


Hi Geoffery
I never dropped the files into the 2nd store as a precaution to see what would happen. The cart was working until I changed the one line:

Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in /includes/functions/general.php on line 61

I only changed 1 line copied out of the update general.php file and lost my cart ability to put products in it.
Could admin files have anything to do with it as I don't think I've edited any of those yet.