|
|
|
|
![]() ![]() |
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: [MODERATOR] Posts: 3,994 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
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? |
|
|
|
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. |
|
|
|
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: [MODERATOR] Posts: 3,994 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
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. |
|
|
|
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. |
|
|
|
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.
|
|
|
|
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: [MODERATOR] Posts: 3,994 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 08:03 PM |