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