Jump to content



Photo
- - - - -

Deprecated after updating to PHP 5.3


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

#1   xoxx

xoxx
  • Members
  • 39 posts

Posted 08 November 2011 - 20:00

I changed hosts which updated me to PHP 5.3 from 5.2

I got a million Deprecated errors and I manually installed this addon http://www.oscommerc...tributions,7394

It fixed almost everything expect for a few errors.
I cannot checkout+add an item to my cart.

This is the error I get during checkout

Deprecated: Function split() is deprecated in /home/XXXX/public_html/XXXX.com/includes/functions/general.php on line 1061
Warning: Cannot modify header information - headers already sent by (output started at /home/XXXX/public_html/XXXXX/includes/functions/general.php:1061) in /home/XXXXX/public_html/XXXXXX/includes/functions/general.php on line 38

Any ideas what is causing this error?


Thanks

#2   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 08 November 2011 - 21:49

Either the mod's author missed one, or you have a mod added to your installation. Either way,
split('pattern', $string)
needs to be changed to
preg_split('/pattern/', $string)
Note that if the pattern contains / already, you could use another character such as #, or you can escape the /'s inside the pattern with \ (\/).

#3   xoxx

xoxx
  • Members
  • 39 posts

Posted 09 November 2011 - 01:55

Ok I think I figured out what the issue was, I incorrectly edited my general.php file, I simply uploaded theres.
I am only finding 1 more Error.
When browsing my products this will show up at the top of the product list ONLY on page 2+

Deprecated: Function ereg() is deprecated in /home/XXXX/public_html/XXXXX/index.php on line 291

any idea what it is?

#4   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 09 November 2011 - 02:24

Go to http://php.net and look up the function "ereg". It will point you to a recommended replacement, "preg_match". The arguments to the call are the same, except that you have to put / / or # # around the pattern string (see my previous posting). Now you will know the principles and will be able to fix all these things yourself.

#5   xoxx

xoxx
  • Members
  • 39 posts

Posted 09 November 2011 - 03:57

Go to http://php.net and look up the function "ereg". It will point you to a recommended replacement, "preg_match". The arguments to the call are the same, except that you have to put / / or # # around the pattern string (see my previous posting). Now you will know the principles and will be able to fix all these things yourself.


Thank you so much for leading me in the right direction, I found information about converting them at these two links:
http://devthought.co...rors-in-php-53/
.http://www.php.net/m...ttern.posix.php


Thanks Again!

#6   xoxx

xoxx
  • Members
  • 39 posts

Posted 09 November 2011 - 04:26

Well nvm, I have been able to fix all of them but this one:

in banner manager(admin)

Parse error: syntax error, unexpected '{' in /home/XXXXX/public_html/XXXXXXX/XXXXXXXX/includes/classes/phplot.php on line 782

line 782 in that file if (eregi($asked, $accepted)) {

Ive tried to do all of the following and still get errors
if (preg_match($asked, $accepted)) {
if (preg_match('/$asked, $accepted/'i)) {
if (preg_match('/$asked/', $accepted)) {
if (preg_match('/$asked/i', $accepted)) {
if (preg_match('/$asked, $accepted/i')) {
if (preg_match('/$asked, $accepted)/') {
if (preg_match('/$asked, $accepted))/' {
if (preg_match('/$asked, $accepted))/i' {
if ( preg_match('{' . $asked . '}i', $accepted) ) {
if (preg_match('/' . $asked .'/i', $accepted)) {

Am I doing something fundamentaly wrong or looking in the wrong place?

Edited by xoxx, 09 November 2011 - 04:37.


#7   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 09 November 2011 - 17:52

Yes, you're doing something fundamentally wrong. Your pattern is a variable $asked, and a variable is not substituted within a single quoted ' string. You need to use double quotes (quotation marks) " .
if (preg_match("/$asked/i", $accepted)) {

Note: if $asked might ever contain a slash / , this will break. Either use some other character (e.g., # or &) to delimit the pattern, or process $asked to change / to \/ (that's backslash-slash, not a Vee).

I suggest that you learn some basic PHP before attempting to edit code.

#8   web-project

web-project
  • Members
  • 4,320 posts

Posted 09 November 2011 - 18:03

so many modules and topics are available on this website, simply search for it and you will find it. As I personally wrote the topic about and show the exactly lines which need to corrected.
Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!
8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.
Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.
Any issues with oscommerce, I am here to help you.

#9   xoxx

xoxx
  • Members
  • 39 posts

Posted 10 November 2011 - 01:08

Thanks for the replies.
I have searched this exact phrase on google and found where they offered a replacement code. It still didn't work for me, that's why I'm asking.

#10   Nikolai

Nikolai
  • Members
  • 70 posts

Posted 10 November 2011 - 11:03

PCI compliance pushes us towards an upgrade to PHP 5.3.8. Obviously, none of the above errors could have been fixed at the time of the final osC 2.3.1 release. Therefore, I am wondering whether there is a tool that brings a clean osC 2.3.1 installation up to date with PHP 5.3.8 to avoid all the suggested "handwork".

#11   stickypod

stickypod
  • Members
  • 85 posts

Posted 14 November 2011 - 18:57

I don't know if you solved your problems, but I had the same issues and posted everything I did here: http://forums.oscomm...ereg-solutions/

I upgraded to PHP 5.3.8 and that will create problems for you since it looks like you're using PHP4.
Anyone can buy a camera... it's what you do with it that counts!
Sticky Pod
www.stickypod.com

#12   Taipo

Taipo
  • Members
  • 794 posts

Posted 14 November 2011 - 19:58

Bill,
Can you paste in the entire phplot.php code thanks. It may make it easier to determine the source of the error.

Also when you tried those variations, did you get the same error or did the error change?
- Stop Oscommerce hacks dead in their tracks with osC_Sec (see discussion here)
- Another discussion about infected files ::here::
- A discussion on file permissions ::here::
- Site hacked? Should you upgrade or not, some thoughts ::here::
- Fix the admin login bypass exploit here
- Pareto Security: New security addon I am developing, a remake of osC_Sec in PHP 5 with a number of fixes
- BTC:1BkbNA1tK3q7ZRkCJj6f1ELK2A152eEtoW

#13   Taipo

Taipo
  • Members
  • 794 posts

Posted 14 November 2011 - 20:03

From osC 2.2RC1
function SetPlotType($which_pt) {
  $accepted = "bars,lines,linepoints,area,points,pie,thinbarline";
  $asked = trim($which_pt);
  if (eregi($asked, $accepted)) {
   $this->plot_type = $which_pt;
   return true;
  } else {
   $this->DrawError('$which_pt not an acceptable plot type');
   return false;
  }
 }
From osC 2.3.1
 function SetPlotType($which_pt) {
  $accepted = "bars,lines,linepoints,area,points,pie,thinbarline";
  $asked = trim($which_pt);
  if (preg_match('/' . $asked .'/i', $accepted)) {
   $this->plot_type = $which_pt;
   return true;
  } else {
   $this->DrawError('$which_pt not an acceptable plot type');
   return false;
  }
 }

- Stop Oscommerce hacks dead in their tracks with osC_Sec (see discussion here)
- Another discussion about infected files ::here::
- A discussion on file permissions ::here::
- Site hacked? Should you upgrade or not, some thoughts ::here::
- Fix the admin login bypass exploit here
- Pareto Security: New security addon I am developing, a remake of osC_Sec in PHP 5 with a number of fixes
- BTC:1BkbNA1tK3q7ZRkCJj6f1ELK2A152eEtoW

#14   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 16 November 2011 - 03:07

if (eregi($asked, $accepted)) {
and
if (preg_match('/' . $asked .'/i', $accepted)) {
and for that mattter,

if (preg_match("/$asked/i", $accepted)) {
are identical in function (provided that $asked does not contain slashes / ).
All of these will work in PHP 4 and 5. As of PHP 5.3, you will get lots of annoying warning messages with the eregi() version. At some point in the future, the eregi() will stop working.

#15   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 16 November 2011 - 03:26

if (eregi($asked, $accepted)) {
and
if (preg_match('/' . $asked .'/i', $accepted)) {
and for that mattter,

if (preg_match("/$asked/i", $accepted)) {
are identical in function (provided that $asked does not contain slashes / ).
All of these will work in PHP 4 and 5. As of PHP 5.3, you will get lots of annoying warning messages with the eregi() version.

#16   adam smith

adam smith
  • Members
  • 6 posts

Posted 16 November 2011 - 19:11


Posted 08 November 2011, 21:49


Either the mod's author missed one, or you have a mod added to your installation. Either way,

split('pattern', $string)
needs to be changed to

preg_split('/pattern/', $string)
Note that if the pattern contains / already, you could use another character such as #, or you can escape the /'s inside the pattern with \ (\/).


#17   MrPhil

MrPhil
  • Members
  • 5,186 posts

Posted 17 November 2011 - 01:41

Why are you copying, without attribution, my post of November 8th?