Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> Php Version Differences? Or Not?, between the trap and XAMPP???
jlhaslip
post Feb 20 2006, 01:27 AM
Post #1


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,994
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



The Trap uses php version 4.4.1 and I have downloaded and installed the XAMPP php Local Server configuration which includes php version 5.1.1 and mysql and perl etc, but this question relates to the php because that is where I am currently having difficulties.

This is the script I am having problems with locally: http://www.trap17.com/forums/script-build-...nks-t33362.html

Both places have the same identical files, code and data. Both are folders in the root directory. I have used phpinfo function to confirm the server root is what it should be (public_html and htdocs) on each of them.
It isn't doing the 'explode' on the data. Is there any difference between the new line seperators? That is what I use to 'explode' the file data.

It seems that there are some pretty major differences beteen the versions.
Does anyone know where I can start to figure this out?
Go to the top of the page
 
+Quote Post
Spectre
post Feb 20 2006, 04:07 AM
Post #2


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



There aren't that many differences between PHP4 and PHP5. Mostly, PHP5 just has new functions and features added, as well as bug fixes and enhancements to the language; to my knowledge, the fundamental usage of any existing functions has not been changed (in order to keep it backward-compatible). It would be quite dangerous for them to do so.

As such, I'm going to suggest that it's either a problem with the script or the data being used. About 99.9% of scripts created for PHP4 should work on PHP5. I've only very quickly looked over the script, but there does seem to be a few enhancements that could be made.
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 20 2006, 07:07 AM
Post #3


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,994
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Spectre,
Thanks for the reply.
I got it working, but does this make sense to you? Seems that the local version needs "\r" as the new-line seperator and Trap17 needs "\n". (Windows98se) So first I found that problem and then there must have been something dropped in the download, because after re-downloading and making that small fix as noted , the logic worked? (the file opens were giving warnings and failing, so the read and close were also issuing warnings)
I have no confirmation that the download was bad because (Oops!) I overwrote the first copy.
And, yes, there are some enhancments to make in that script (like error checking) and tuning. As I learn some more php functions, I'll get them looked after. A spare time project and a learning / practise script.
Go to the top of the page
 
+Quote Post
Spectre
post Feb 20 2006, 09:01 AM
Post #4


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



Windows uses \r\n (CRLF) as the new-line delimiter, and UNIX-like systems just use \n (I think Mac uses just \r, but I don't know).

As a quick fix, trying replacing:

CODE
$fp = fopen($folder_file,'r');        // open flat file for reading
if (!$fp) {print 'ERROR: Unable to open file'; echo '<br />';echo $folder_file;echo '<br />';exit;}// error if no handle found for flat file
$line= fread($fp,1024); // increase this length if required
$f_array=explode("\n",$line);


With:

CODE
$line = @file_get_contents($folder_file);
if( !$line ){
   print 'ERROR: Unable to open file';
   echo '<br />';
   echo $folder_file;
   echo '<br />';
   exit();
}
$line = str_replace("\r\n","\n",$line);
$f_array=explode("\n",$line);


Hope that's helpful.
Go to the top of the page
 
+Quote Post
Hamtaro
post Feb 21 2006, 03:50 AM
Post #5


Super Member
*********

Group: Members
Posts: 372
Joined: 14-October 04
Member No.: 1,736



I've never had any trouble at all with using newlines (\n) using XAMPP, or any other method of using PHP on Windows. PHP just needs the \n even on Mac, which does use \r. You may have some sort of configuration set that requires that, but I'm not for sure. That's all that I would be able to tell you, so sorry I'm not that much help.
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 21 2006, 06:06 AM
Post #6


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,994
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Or replace it with this:
CODE

$line = @file_get_contents($folder_file);
if( !$line ){
   print 'ERROR: Unable to open file';
   echo '<br />';
   echo $folder_file;
   echo '<br />';
   exit();
}
$line = str_replace("\r\n","\n",$line);
$line = str_replace("\r","\n",$line);
$f_array=explode("\n",$line);

That should work for all cases: Unix, Windows and Mac.

Hamtaro: I have the Default version of XAMPP. I haven't altered the config or settings at all.

Just to clear this matterup, I might have an explanation for the variance. I have two computers. One Windows and one Mac. I may have created one data file with the Mac. Not certain, but possible.
At any rate, both versions work on the appropriate machines.
I'll have to remember to only make the data files with one or the other machines from now on.
Notice from jlhaslip:
Closing Topic.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. The Name Trap(17)
  2. Xampp How Can I Generate "automatic Start Sites"(6)
  3. Suggestions For Version 3 Of The Credit System(23)
  4. Free Full Version Screensaver Maker(2)
  5. Garage Band! Windows Version?(10)
  6. What Will Be The Side Effects If We Can Move And Think On The Speed Of Light(4)
  7. Skype / Xampp Port Conflict(5)
  8. Flippingbook Html Edition(0)
  9. Why Dont Have Burnout Games For Pc?(12)
  10. How To Use Xampp To Test Php(3)
  11. Next Halo(3)
  12. Ie And Firefox Layout Differences(11)
  13. Opaque And My Experience Here On Trap(2)
  14. How I Got Here.(6)
  15. Google Earth Plus Version(19)
  1. Myspace Theme(11)
  2. Linux Version 8.04 Out(5)
  3. Teamspeak 2 Vs Ventrilo(10)
  4. How to use xampp?(14)
  5. Buddhism...(3)
  6. Canadian Dcma-type Bill Introduced(1)
  7. Language Version(2)
  8. Who Thinks Trap 17 Is Th Best Server?(6)
  9. Synthesis Kernel(1)
  10. Problem With Firefox, Latest Version, Not Loading Pages(4)
  11. Where Does That Noise Come From?(6)
  12. Age Differences Of Friends(8)
  13. Hello Trap 17 :)(4)
  14. Growing My Own Venus Fly Trap!(24)
  15. My Trap-day!(5)


 



- Lo-Fi Version Time is now: 6th September 2008 - 08:03 PM