View previous topic :: View next topic |
Author |
Message |
Johnny5 -
Joined: 20 May 2009 Posts: 3
|
Posted: Wed May 20, 2009 2:27 am Post subject: Strange thing with php / mysql |
|
|
Hello,
I'm new here, I'm looking for an answer for my curious problem.
Here is it :
I have a tiny PHP script, with a mysql_query command inside, like :
Code: | <h1>Hello world</h1>
<?php
$dd = fopen("debug.txt", "w+");
fwrite($dd, "Hello world\n");
$query = "SELECT * FROM snapshot ORDER BY directory";
$result = mysql_query($query);
fwrite($dd, "Good Bye World\n");
fclose($dd);
?>
<h1>Good Bye World</h1> |
Maybe there are some pb here, because I translated some part, but it works, believe me.
So there is not a scripting bug.
So, this thing WORKS, I have both the debug.txt file and the messages in my webbrowsers.
If I replace
$query = "SELECT * FROM snapshot ORDER BY directory";
with
$query = "SELECT * FROM snapshot ORDER BY directory, filename";
Then the debug.txt file is good, that means that the php script is fully executed (I put a time marker, so I know it's not an older version).
But I got a 500 error in my webbrowser (both FFox3 and IE7).
This SQL query is ok if I execute it in phpmyadmin (adding limit 10000, 0 at the end).
My table has 60.000 entries, and it works fine with phpmyadmin.
If you have any ideas, thanks :) |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Wed May 20, 2009 2:03 pm Post subject: |
|
|
Put a simple limit on the results. Maybe it's too much information for PHP to work with. What are your memory limitations in your PHP.ini file?
Set your limit to 30 and let us know if that works. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
Johnny5 -
Joined: 20 May 2009 Posts: 3
|
Posted: Wed May 20, 2009 5:27 pm Post subject: |
|
|
No need to make a sql limit in php : php script is fully executed.
The SQL query returns about 60.000 entries, and a foreach loop after that on those results, and everything is ok, but I still no have text in webbrowser.
I repeat :
I make a sql selection which return 60.000 entries
I make a loop on this entries :
Code: | while ($row = mysql_fetch_assoc($result))
$result[] = $row; |
I make a foreach loop :
Code: | foreach ($result as $key => $array)
$thing[] = $array['filename']; |
After the loops, I put :
Code: | echo "Script ending";
fwrite($dd, "script ending"); |
I have the "script ending" wrote in the file AND, in the same time, a 500 error in my webbrowser.
I can make a
Code: | fwrite ($dd, print_r($thing,1)); |
and it works. But if I make a
Code: | echo print_r($thing, 1); |
it fails.
(I wrote this things for the board, maybe they are some syntaxe errors here, but in fact, it's ok in my php script. I know this script is dumb, it's just an exemple). |
|
Back to top |
|
|
Johnny5 -
Joined: 20 May 2009 Posts: 3
|
Posted: Thu May 21, 2009 1:18 am Post subject: |
|
|
I think my problem is like this one :
http://www.aprelium.com/forum/viewtopic.php?t=10676
I have, in the fastcgi.log, this things :
Code: | 21/May/2009:01:56:29 +0200 SUID: 2 PUID: 2 RUID: 0 URI: Reading 0 bytes failed = Broken pipe
21/May/2009:01:56:29 +0200 SUID: 2 PUID: 2 RUID: 0 URI: timeout-header2!
21/May/2009:01:56:57 +0200 SUID: 2 PUID: 2 RUID: 1 URI: /admin/xxxx.php Reading 8 bytes failed = Broken pipe
21/May/2009:01:59:44 +0200 SUID: 2 PUID: 2 RUID: 1 URI: /admin/xxxx.php Reading 8 bytes failed = Broken pipe
|
I think AWS stops waiting for php result.
Any idea of what causes crashes ? |
|
Back to top |
|
|
DonQuichote -
Joined: 24 Dec 2006 Posts: 68 Location: The Netherlands
|
Posted: Thu May 21, 2009 8:10 pm Post subject: Error logging! |
|
|
First, I firmly want to suggest you put on error logging. There are just too much things you leave to be "automagically" fixed by PHP.
Also, the $variable[] syntax does not put the array into the $variable, but adds it to the array (again, leaving it to PHP to automagically initialize an array for you. Yuck!). So you are stacking every single piece of data in memory and wonder why the page pulls too many resources...
Again, switch on error logging and the warnings will tell you what really happens. |
|
Back to top |
|
|
abnoffflamy -
Joined: 03 Oct 2009 Posts: 1 Location: England
|
Posted: Sat Oct 10, 2009 8:13 pm Post subject: Strange thing with php / mysql |
|
|
well im having trouble here. i have a number that i want to put in the number_format so it has a thousand separator. i only know of 2 ways to do this:
in mysql use the FORMAT function. this does the trick, but then i cant sort the number.
the other is in php, using the number_format; the problem is that the number i want to use this function on is in an array.
any ideas on how to do this?
thanks _________________ Enjoy Anonymous Browsing |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|