I am not sure if I have totally missed something here so I am asking, to hopefully become a better person. So I already now, ask for forgiveness for my stupidity, if any.

I have a client that is hosted by company that now is blaming the website I've build for the client, for "crashing" (or at least making it run very slow) the server over and over again. And no this is not a huge website with any complex script. It is a blog, with comment functions.

They tell me this is the problem, because from logs there seems to be only one problem:

www.xxxxxx.se xxx.xxx.xx.xxx [14/Mar/2011:05:08:02 +0100] fcgi_php_error:PHP Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/t/xxxxx/www/include/php/newsfeed_full.php on line 66, PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/t/xxxxx/www/include/php/newsfeed_full.php on line 68

Line 66:

$sql = "INSERT INTO `newsfeed_comments` (post_id, reply_id, date, name, text) VALUES ('".mysql_real_escape_string($post_id)."', '".mysql_real_escape_string($_POST['reply_id'])."', '".date('YmdHis')."', '".mysql_real_escape_string($_POST['name'])."', '".mysql_real_escape_string($_POST['text'])."')";
mysql_query($sql) or die(mysql_error());

$sql output:

INSERT INTO `newsfeed_comments` (post_id, reply_id, date, name, text) VALUES ('168', '111194', '20110322145339', 'Test 2', 'Test text 2')

Line 68:

$sql = "SELECT * FROM `newsfeed_comments` WHERE `post_id` = '".$post_id."' && `reply_id` IS NULL ORDER BY `date` DESC";
$result = mysql_query($sql);
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
//and so on...

$sql output:

SELECT * FROM `newsfeed_comments` WHERE `post_id` = '168' && `reply_id` IS NULL ORDER BY `date` DESC

Problem is that, I have never seen these error myself from testing. I have never been able to replicate the errors, in any way. So it is obviously working.

My question is, what could be wrong? The hosting company just tells me that I need to make sure my script can handle all the possible errors their server might give out.

Same script runs flawlessly on 10-15 other hosting services without any problems and I have never had any problems with them.

Am I missing anything crucial? Do I have a large knowledge gap when it comes to PHP?

Comments

fcgi_php_error:PHP Warning: mysql_query() [function.mysql-query]: Unable to save result set this sounds very weird and I would be surprised if it's your script's fault. Interested to see what comes up

Written by Pekka

Can you post the output of $sql in order to see how php solves your variables? Moreover if you want to store current datetime you can use now() mysql function.

Written by nick rulez

Googling "unable to save result set" seems to suggest it is caused by corrupt tables or by hitting memory limits.

Written by Hammerite

how does one get corrupt tables? and to prevent it?

Written by jamietelin

I don't know. You might be better off asking on serverfault.com.

Written by Hammerite

This is the output from $sql; 1: INSERT INTO newsfeed_comments (post_id, reply_id, date, name, text) VALUES ('168', '111194', '20110322145339', 'Test 2', 'Test text 2') 2: SELECT * FROM newsfeed_comments WHERE post_id = '168' && reply_id IS NULL ORDER BY date DESC

Written by jamietelin

Accepted Answer

Possibly its a memory allocation error. Could you reboot your MySQL server instance?

Written by biakaveron
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki