Jump to content

odd white space, running out of options


aebstract

Recommended Posts

I am not sure what is wrong. I've got a huge file, like 15k lines. Firstly, are there any limits to a php file size in line length, character amount, or file size? I'm getting a white page and the server isn't logging any errors. My host took it and ran it from command line and here is his response:

I'm not sure at this point. If it exhausted the memory it would log it.

Running it from the command line produces several notices and an error

message regarding SQL syntax. Running it through Apache results in that

process exiting with no message.

Should I post the code here? Basically what I noticed was I had something I was replacing in textpad. There were probably a couple hundred of the line. I do this for like 50ish lines. I went and undid a bunch of it, since textpad stores a good bit of memory to backup to. Uploaded and it was fine. Went forward some and it whited. I did this until I eliminated it down to one line that when I did it, it caused the white page. Looking at the line there was absolutely nothing wrong with it at all. The replace is doing the exact same thing to the exact same line in each spot of the file, so only checking one location should be fine.

 

Should I post the line that starts the error? The entire script? Does a white page without any errors mean anything?

 

Link to comment
Share on other sites

There is no "line-limit" per se and I don't see anything out of the ordinary of your task, I've personally worked with 100MB+ files, but even if you're on a shared host it should not be a problem.

 

If there is something preventing the code from even running (IE. a fatal parse error, preventing the code to parse/debug), then PHP would not even get a chance to run error coding checks; so you must switch it error reporting on via .htaccess/php.ini/httpd.conf and it should give a better clue on why this is happening.

Link to comment
Share on other sites

This is happening when I changed this line:

 

} else { if ($r2[12] != 'x') { $content .= "<li class=\"score\" style=\"margin-top: 0px;\">"; if($r2rt[12] < '0') { $content .= "$r2[12] @ $r2s[12]</li>\n"; } else { $content .= "$r2rt[12] | $r2[12] @ $r2s[12]</li>\n"; } } else { $content .= "<li class=\"score\" style=\"margin-top: 0px;\"> </li>\n"; }}

 

to this line:

 

} else { if ($r2[12] != 'x') { $content .= "<li class=\"score\" style=\"margin-top: 0px;\">"; if($r2rt[12] < '0') { $content .= "<span style=\"color: red;\">$r2rt[12]</span> | $r2[12] @ $r2s[12]</li>\n"; } else { $content .= "$r2rt[12] | $r2[12] @ $r2s[12]</li>\n"; } } else { $content .= "<li class=\"score\" style=\"margin-top: 0px;\"> </li>\n"; }}

 

Did this to the one previous to it, except the 12s were 11s and there is no problem, when I get to this one I have a problem. The host said something about SQL syntax, could any sort of mysql have a problem with this ^?

 

Adding this to my .htaccess:

 

php_flag display_errors on
php_value error_reporting 7 

 

Didn't display any error message, still white.

Link to comment
Share on other sites

Try setting error reporting at the beginning of the script:

  error_reporting(2147483647);
  ini_set('log_errors', 1);
  ini_set('display_errors', 1);

 

could any sort of mysql have a problem with this ^

 

You note MySQL but where is the SQL syntax in there? All I see is HTML and PHP. If you have SQL syntax then make sure you check if mysql_error has anything or not.

Link to comment
Share on other sites

Okay I just kind of upset myself, I added the error reporting in at the top but I was back to that line. I had done like 40 other lines just needed to redo them before trying the error reporting now I can't :( Regardless, I put the one line back the way it should be and the page is white again, with the code you gave me at the top. Nothing is displayed. There is SQL but it isn't in anything that is being changed between the two trys. It's just after I do the change above it get white page.

Link to comment
Share on other sites

Does the page display anything before it is blank, or does the code just not display anything because of that line? I can't quote if the syntax is correct as you have it all on one line, but it makes more sense that something is wrong in the SQL and one of the statements than just some random code.

 

I'd recommend placing this at the end of mysql_query just to cover all bases.

..mysql_query($sql) or die(mysql_error());

 

 

Link to comment
Share on other sites

I've got error reporting for all of my queries and nothing is showing up. I'm just getting a white page and the actual server isn't logged any problems either. It's just white. Remember, the only reference to an sql syntax problem was from command line. Also, the queries are working fine before I add that line so I don't see why it should throw them off.

 

Okay, I just tried skipping 12 and doing 13, same white page.

 

Now, I went back down to 12 where the page displays fine. I went up and added an echo "some dummy text"; but like 2 sentences long to cover the amount of characters just for tests sake and everything returned fine. I'm really lost right now.

Link to comment
Share on other sites

Okay it's doing it when I make the change stated a few posts back to any location in the file similar to that. (so for each round and in each case, it doesn't matter where.. just seems to be a magic number of them that were able to change over until it stops) So, it would sound as if it was some sort of timing out or too big or something like that, though no errors produce saying such and it dies pretty quick versus how long it takes to load on a fresh load.

Link to comment
Share on other sites

It's really looking like some sort of memory, run time, etc issue. I was doing okay, did a replace all on something completely different than what I was working on and it white paged as well. I know I did hit a memory issue once but it produced an error on the server's log and was fixed when I added

php_value memory_limit 1000M

to the .htaccess.

Link to comment
Share on other sites

I'm here to rain on your parade, sorry :P

 

It scares me that you needed to up your memory limit to that. In all honesty, I'd highly advise you to restructure and rewrite that script. Yes, all 15k lines. I don't understand why you're running phpBB if you don't even want to follow their coding standards (which make creating an application/separate pages a lot easier.) A lot of your code is really repetitive, writing the same thing for each round - when you could easily create a function that does the same thing with just a few arguments. Doing so would help cut down on the amount of code (get more people to help you) and cut down on the number of errors/easier to find those errors

Link to comment
Share on other sites

I'll second that.

 

Due to the repetition in the code, you easily have 4-5 times more code than necessary.

 

The code also has virtually no validation logic or error checking, error reporting, error recovery logic in it to get it to tell you what it is doing when there is a problem, so it is no wonder it blows up when anything unexpected occurs and you cannot pin down where the problem is even occurring at.

Link to comment
Share on other sites

I would love to slim it down to something very simple like you said, but the way the pairings are set up I couldn't figure it out. I had asked the person having me to do this to explain to me how the pairings are generated and he didn't know either. For that reason I wouldn't know any way to do it if I don't know where each qualify position is suppose to fall along with the byes. So I had to hard code each one to fill it in correctly.

 

Beyond that, there is no reason why making a completely valid change from one line to the next should cause the page to go white and no errors to be displayed anyway. Everything is okay code. If you uploaded a file that just had echo "hello"; in it and it worked and just added another line that said echo "hello2"; and it then white paged, you would be in the same situation.

Link to comment
Share on other sites

Here is just one example of the repetitious code we are talking about. Your existing falsestart code that toggles the correct value in your participants table (~73 lines of code) is the equivalent to the following (6 lines of code), which I actually created data for and tested  -

 

if(isset($_POST['falsestart'])){
$i = (int)$_GET['round']; // 1 - 6
if($i >= 1 && $i <= 6){
	mysql_query("UPDATE participants SET r{$i}j = NOT r{$i}j WHERE regid = '{$_GET['user']}' && eventid = '{$_GET['event']}'") or DIE(mysql_error());
}
}

 

Your symptom of simply adding lines of code to your source file and it results in no output is indicative of a corrupted source file (perhaps you copy/pasted from a file that had other character encoded in it) or of a system that is using output buffering and the amount of output exceeded the buffer size.

 

Does your code work on your development system and not on the live server or does it not work on your development system either?

 

Edit: Also if this only occurs when you upload to a live server, have you downloaded the file and compared it with the original as you might be experiencing an upload error (the source file is greater than 1Mbyte) or some other problem with your FTP client/server.

Link to comment
Share on other sites

You should be getting error messages or warnings.  In the first few lines of code you are using falsestart as an array key.  It is not in quotes, so PHP is looking for a named constant.  If it does not find one, it reports a warning and treats it as a string.  If you set error_reporting(E_ALL); you should be seeing these error messages.

 

When you get the white page, use the View Source feature in your browser and see if there is any output at all.  If there is some output that starts with an angle-bracket ('<') the browser would consider it an unknown HTML tag and NOT display everything inside the brackets.

Link to comment
Share on other sites

Nothing in the source, just blank. I know everyone keeps mentioning the falsestart bit but that was actually taken out completely. I've switched hosts and everything is working fine now, I've added in to it quite a bit as well. I think it was a hardware issue.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.