Jump to content

PHP fatal error


sareea

Recommended Posts

Hello,

I am trying to run a script on my site ,

 

The script is this :

https://github.com/simplecoin/simplecoin

and I am getting these errors

 

[sat Aug 13 11:47:01 2011] [error] [client 84.228.254.88

] PHP Fatal error:  Call to a member function fetch() on

a non-object in /var/www/includes/stats.php on line 42,[/code]

 

] PHP Warning:  Invalid argument supplied for foreach()
in /var/www/includes/stats.php on line 89

 

and

] PHP Warning:  Invalid argument supplied for foreach()
in /var/www/stats.php on line 75

I run ubuntu 11 vps .


Some one told me that

[quote]Probably this query is not returning a value, so it gives an error.
[code]$sql = "SELECT count(id) FROM shares WHERE id > $lastwinningshare AND our_result='N'";

Most likely it will go away as soon as it returns something.

from the file

/includes/stats.php

 

I really need to fix this problem , is there any module i need to install or the code is incorrect ?

If you want i can give you a link to php info of my vps .

Thanks a lot for the help !

Link to comment
https://forums.phpfreaks.com/topic/245745-php-fatal-error/
Share on other sites

Yes

function currentstales() {
global $read_only_db;
$currentshares = 0;
$lastwinningshare = $this->lastWinningShareId();
if (!($currentshares = getCache("pool_stales"))) {
$sql = "SELECT count(id) FROM shares WHERE id > $lastwinningshare AND our_result='N'";
$result = $read_only_db->query($sql);
if ($row = $result->fetch()) {
$currentshares = $row[0];
setCache("pool_stales", $currentshares, 300);
}
}
return $currentshares;
}

 

From this file :

https://github.com/simplecoin/simplecoin/blob/master/includes/stats.php

 

Thanks !

 

Edit: and this is my php info

http://wemine.co.in/testphp.php

Link to comment
https://forums.phpfreaks.com/topic/245745-php-fatal-error/#findComment-1262193
Share on other sites

Try:

function currentstales() {
global $read_only_db;
$currentshares = 0;
$lastwinningshare = $this->lastWinningShareId();
if (!($currentshares = getCache("pool_stales"))) {
$sql = "SELECT count(id) FROM shares WHERE id > $lastwinningshare AND our_result='N'";
$result = $read_only_db->query($sql);
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$currentshares = $row[0];
setCache("pool_stales", $currentshares, 300);
}
}
return $currentshares;
}

Link to comment
https://forums.phpfreaks.com/topic/245745-php-fatal-error/#findComment-1262214
Share on other sites

Hello,

Now it calls the error to be in this function ...

function usersharecount($userId) {
global $read_only_db;
$totalUserShares = 0;
$workers = Array();
$lastwinningshare = $this->lastWinningShareId();
if (!($totalUserShares = getCache("user_shares_".$userId))) {
$workers = $this->workers($userId);
$sql = "SELECT count(id) as id FROM shares WHERE id > $lastwinningshare AND username in ('".implode("','",$workers)."')";
$currentSharesQ = $read_only_db->query($sql);
if ($currentSharesR = $currentSharesQ->fetch()) {
$totalUserShares = $currentSharesR[0];
setCache("user_shares_".$userId, $totalUserShares,3);
}
}
return $totalUserShares;
}

If i enter my site wemine.co.in , it enters, after i try to login it returns this error ...

 

Warning: array_key_exists() expects parameter 2 to be array, boolean given in /var/www/includes/stats.php on line 239 Fatal error: Call to a member function fetch() on a non-object in /var/www/includes/stats.php on line 276 

 

Thanks for the help ! :)

Link to comment
https://forums.phpfreaks.com/topic/245745-php-fatal-error/#findComment-1262219
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.