PHP MySQL Fetch — 500 Internal Server Error
rbanerjee said 1 year, 1 month ago:
Hello,
So I have a weird error where if I fetch more than a certain number of rows from a mysql table, it triggers a 500 Internal Server Error.
I am using Apache Web Server (through GoDaddy) and the offending code is below:
set_time_limit(0);
$this->Connect();
$Output = array();
$search = “SELECT * FROM <table> WHERE user_id = ?”;
if($Statement = $this->MySQLi->prepare($search)){
$Statement->bind_param(“i”, $UserId);
$Statement->execute();
$Statement->bind_result(<result variables>);
$count = 0;
while($Statement->fetch() && $count++ < 70){
ChromePhp::log(<result variables>);
}
$Statement->close();
}
$this->Disconnect();
ChromePhp::log is a way of dumping things to the Javascript Console in your browser from within a PHP script just as a heads-up. So when I set the stop number as 70, everything is fine. If I try to fetch more than that it triggers a 500 internal server error on Apache Server port 443. I have looked through the error logs and can’t figure out the cause but this is almost certainly a server configuration issue? I’d appreciate any feedback, especially anyone familiar with GoDaddy’s hosting services
Thanks
timb said 1 year, 1 month ago:
@rbanerjee
I am not familiar with this issue or why there is a discrepancy with results based on the stop number. What did you find within your error logs? Perhaps another forums user can offer some suggestions with this information.
Tim B
rbanerjee said 1 year, 1 month ago:
So my error logs report the following error:
Apache Error: Premature End of Script Headers
Using this source http://kb.liquidweb.com/apache-error-premature-end-of-script-headers/
I think the problem is a resource error. I don’t think my code is the problem because as I noted, it works up to a certain number and then dies which points towards a server settings issue.
timb said 1 year, 1 month ago:
@rbanerjee
To determine if the cause of the error is due to a resource issue, please contact our Support Team and reference this thread if you have not already done so. I’ll make sure that our support team reviews the issue as quickly as possible.
Tim B
6 min expected wait time