Database Error PLEASE HELP ANYONE

I have dug around and around and nothing seems to work any insight I really word appreciate it. When im not logged in and I go to view a profile ex. http://freeducate.com/jundaj I get this error.


Warning: Division by zero in /home/jundaj/public_html/templates/base/scripts/BxBaseProfileView.php on line 516
Error
Database query error

Now when Im logged in this doesnt occur. I have reset the featured members to 14 in the advanced settings like I read but I can not find anything else to solve this problem can you please help me PLEASE.

-Justin

Quote · 3 May 2011

Provide us with full db description here

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 3 May 2011

Here is the DB error that is sent to my email when it occurs.

 

Database error in Freeducate

Query:

SELECT `p`.*, `f`.`ID`, 
				if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL 1 MINUTE ), 1, 0) AS `is_online`,
				UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' 	FROM (
				SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '1' AND `Check` =1
				UNION
				SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '1' AND `Check` =1
			) AS `f`
			INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`
			
            WHERE 1 
			ORDER BY p.`Avatar` DESC
			LIMIT 0, 
Mysql error: 

Found error in the file '/home/jundaj/public_html/inc/profiles.inc.php' at line 385.
Called 'db_res' function with erroneous argument #0.


Debug backtrace:
Array
(
    [1] => Array
        (
            [file] => /home/jundaj/public_html/inc/classes/BxDolDb.php
            [line] => 242
            [function] => error
            [class] => BxDolDb
            [type] => ->
            [object] => BxDolDb Object
                (
                    [error_checking] => 1
                    [host] => localhost
                    [port] => 
                    [socket] => 
                    [dbname] => jundaj_jundaj
                    [user] => *****
                    [password] => *****
                    [link] => Resource id #30
                    [current_res] => 
                    [current_arr_type] => 1
                    [oParams] => BxDolParams Object
                        (
                            [_oDb] => BxDolDb Object
 *RECURSION*
                            [_oCache] => BxDolCacheFile Object
                                (
                                    [sPath] => /home/jundaj/public_html/cache/
                                    [_error] => 
                                )

                            [_sCacheFile] => sys_options_3a05bf847a3e428757538f24e9e3234d.php
                            [_aParams] => [truncated]
                            [_error] => 
                        )

                    [oDbCacheObject] => BxDolCacheFile Object
                        (
                            [sPath] => /home/jundaj/public_html/cache/
                            [_error] => 
                        )

                    [_error] => 
                )

            [args] => Array
                (
                    [0] => Database query error
                    [1] => 
                    [2] => SELECT `p`.*, `f`.`ID`, 
				if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL 1 MINUTE ), 1, 0) AS `is_online`,
				UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' 	FROM (
				SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '1' AND `Check` =1
				UNION
				SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '1' AND `Check` =1
			) AS `f`
			INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`
			
            WHERE 1 
			ORDER BY p.`Avatar` DESC
			LIMIT 0, 
                )

        )

    [2] => Array
        (
            [file] => /home/jundaj/public_html/inc/db.inc.php
            [line] => 43
            [function] => res
            [class] => BxDolDb
            [type] => ->
            [object] => BxDolDb Object
                (
                    [error_checking] => 1
                    [host] => localhost
                    [port] => 
                    [socket] => 
                    [dbname] => jundaj_jundaj
                    [user] => *****
                    [password] => *****
                    [link] => Resource id #30
                    [current_res] => 
                    [current_arr_type] => 1
                    [oParams] => BxDolParams Object
                        (
                            [_oDb] => BxDolDb Object
 *RECURSION*
                            [_oCache] => BxDolCacheFile Object
                                (
                                    [sPath] => /home/jundaj/public_html/cache/
                                    [_error] => 
                                )

                            [_sCacheFile] => sys_options_3a05bf847a3e428757538f24e9e3234d.php
                            [_aParams] => [truncated]
                            [_error] => 
                        )

                    [oDbCacheObject] => BxDolCacheFile Object
                        (
                            [sPath] => /home/jundaj/public_html/cache/
                            [_error] => 
                        )

                    [_error] => 
                )

            [args] => Array
                (
                    [0] => SELECT `p`.*, `f`.`ID`, 
				if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL 1 MINUTE ), 1, 0) AS `is_online`,
				UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' 	FROM (
				SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '1' AND `Check` =1
				UNION
				SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '1' AND `Check` =1
			) AS `f`
			INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`
			
            WHERE 1 
			ORDER BY p.`Avatar` DESC
			LIMIT 0, 
                )

        )
Quote · 4 May 2011

Your mysql query looking wrong  (make ticket on our support page, they will check this):

SELECT `p`.*, `f`.`ID`, 
if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL 1 MINUTE ), 1, 0) AS `is_online`,
UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' FROM (
SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '1' AND `Check` =1
UNION
SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '1' AND `Check` =1
) AS `f`
INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`

WHERE 1
ORDER BY p.`Avatar` DESC
LIMIT 0, There must be another parameter

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 4 May 2011

The actually query looks like that if that matters.

 

$sqlQuery = "SELECT `p`.*, `f`.`ID`,
if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`,
UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg'     FROM (
SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '{$iID}' AND `Check` =1
UNION
SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '{$iID}' AND `Check` =1
) AS `f`
INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`
{$sJoin}
WHERE 1 {$sWhereParam}
{$sOrderBy}
{$sLimit}";

$aFriends = array();

$vProfiles = db_res($sqlQuery);
while ($aProfiles = mysql_fetch_assoc($vProfiles)) {
$aFriends[$aProfiles['ID']] = array($aProfiles['ID'], $aProfiles['TS_DateLastLogin'], $aProfiles['TS_DateReg'], $aProfiles['Rate'], $aProfiles['DateLastNav'], $aProfiles['is_online']);
}

return $aFriends;
}

Quote · 5 May 2011

Hello make a "Technical ticket" on support page with all your access data. They will check this trobule

PS: If possible do not write me personally, please try to ask on the forum first
Quote · 5 May 2011

How was this resolved? Because I have the same error (almost). In my case:

Mysql error: Out of memory (Needed 26843544 bytes)

Found error in the file '/home/---/public_html/inc/profiles.inc.php' at line 385.
Called 'db_res' function with erroneous argument #0.

Line 385 is: $vProfiles = db_res($sqlQuery);

Quote · 29 Apr 2013

 

How was this resolved? Because I have the same error (almost). In my case:

Mysql error: Out of memory (Needed 26843544 bytes)

Found error in the file '/home/---/public_html/inc/profiles.inc.php' at line 385.
Called 'db_res' function with erroneous argument #0.

Line 385 is: $vProfiles = db_res($sqlQuery);

Not the same. Yours is caused because memory for PHP is to low. You need to increase the memory_limit for PHP in your php.ini. If you do not know how to do this, contact your host. Dolphin has specific hosting requirements (http://www.boonex.com/trac/dolphin/wiki/DolTech) that need to be met to run properly. Go into admin then to tools then host tools to see if dolphin detects any other problems with hosting that need to be corrected.


https://www.deanbassett.com
Quote · 29 Apr 2013

Not really, I think, since my memory_limit is 512M. However, I've just noticed, that

$sWhereParam = "AND p.`Status`='Active' " . $sWhereParam;

was missing from my profile.inc.php (in function getMyFriendsEx). Just this morning I had another similar error, connected with function getFriendNumber (error line was return (int)db_value($sqlQuery);). Since I did the same, had a look at profile.inc.php reference file and spotted that line $sqlAdd = "AND p.`Status`='Active'"; originally didn't have the content between "", and I didn't get the morning error again, but this one, I deduce missing "AND p.`Status`='Active' will correct this as well. I hope. :)

Quote · 29 Apr 2013

Although the host tools do say I'm low on max execution time, post_max_size, upload max filesize and with memory limit 128M only. So I thought my php.ini wasn't working. However, my host verified my settings were applied, so now I am here with phpinfo from admin panel, saying memory limit 128M, 128M and verification script from my host saying memory_limit 512M, 512M.

Besides, the correct high settings are always shown there in Variables from phpMyadmin so unless there is some possibility of higher magic beyond my current skills, I think the 'out of memory' part is especially baffling.

Quote · 29 Apr 2013

If dolphin is saying your at 128, then your host is incorrect. You may have a host where php.ini files are needed for every single folder. You will need to have your host test it and verify it. Also on some hosts the cli version of PHP will use a different php.ini config file than the one the web server uses. You can test that also.

the admin folder already contains a script named phpinfo.php but is designed to run in the webserver only. So create a new one named phptest.php. In that file put this.

<?php
phpinfo();
?>

Then call it from the web browser. yoursite.com/administration/phptest.php It will show the settings. Note the memory limit. Should be the same as what dolphin reports.

Then from a shell go to the admin folder and run the script from the shell.

php ./phptest.php

If the results show different values then you know the server is using a different php.ini file for shell and web server. And if it shows 512m then you know your host is reporting that value to you instead of the value the web server sees which is different. It would also indicate the tech that gave you that value is inexperienced and apparently does not realize this.

In any case there is a explanation for it. But you have to go by what dolphin is reporting to you. Not what your host is telling you as they must be obtaining that value using a different test method.


https://www.deanbassett.com
Quote · 29 Apr 2013

Thanks, I shall try that and also had a suspicion there WAS a reason for different values in settings. Hm. :)

Quote · 29 Apr 2013

By the way, the script they gave me to verify that the memory was really 512M (and it shows 512M) contains

<? phpinfo(); ?>

while your syntax is (and really shows 128M, lol)

<?php
phpinfo();
?>

and they placed it inside my public_html/

Could this be the reason their and your (and Dolphin's) php tests differ? And if what they did was wrong, why - so that I can argue with them, i ncase they won't see the problem? :)

Quote · 29 Apr 2013

 

<? phpinfo(); ?>

while your syntax is (and really shows 128M, lol)

<?php
phpinfo();
?>

 
Both syntaxes function exactly the same. And yes. the location can make a difference.

Is public_html where dolphin is located?

I have a fealing your host will require a php.ini file in every folder in dolphin. Which i believe i mentioned as a possible problem.

https://www.deanbassett.com
Quote · 29 Apr 2013

As I was just told, "Indeed, the php.ini file has to be placed in each folder where you need the settings to apply."

The question is, they copied settings from php.ini to the one in public_html/administration (incorrectly, at that, I had to re-edit it, lol), so now when running your script it verifies the settings and they are at the desirable higher values. Hallelujah!

However. Is it enough, if the .ini sits in my admin folder now (actually, there was php.ini before, they just appended to it the settings from the main folder php.ini), or am I to copy the .ini file into every and each folder there is? I presume I don't need to, since the testing shows correct values now, even inside Dolphin host params, but I'm asking just in case. :)

In any case, thanks a lot. This could go on forever, if it wasn't your replies here. :) Hopefully, no more error messages from now on. :)

Quote · 29 Apr 2013

Sorry. Not that simple. Admin shows the proper settings, but if you were to copy the test script to another folder and run it, it will show different value. All of dolphins scripts need to have the proper settings.

You will need to copy it to all folders except for the flash folders and a couple for the forums. You can do it from a shell if you have shell access. From a shell copy the php.ini file to the folder where dolphin is. Then change to that directory and run this. If dolphin is in public_html then you already have a php.ino file there so just go to that folder and run the commands.

find ./ -type d -exec cp php.ini {} ;

Then this one will remove the php.ini from the folders that are not to have one.

rm -rf ./flash/modules/*/skins/php.ini ./flash/modules/*/langs/php.ini ./modules/boonex/forum/install/langs/php.ini ./modules/boonex/forum/integrations/base/langs/php.ini

If you find that to difficult, or you don't have shell access, see if your host can do it for you.



https://www.deanbassett.com
Quote · 29 Apr 2013

Hmm. I've asked them to do it. However, out of curiosity, I copied your test php into boonex/simple_messenger and the setting for memory is showing to be 512M, although other settings (post_max_size for example) equal those recommended ones, not those from earlier or those specified in my php.ini. The same happens when I try your mod, deanos_tools, phptest says the memory limit is 512M, but max_execution_time for example only 300 (recommended setting, yes, but found neither in my php.ini or in the previous host params that were too low). How can be this possible, lol?

 

Alright so I've been told they were unable to understand where exactly do I need the php.ini file and where not. To avoid misunderstandings and deletion of wrong files, it would be best for me to establish an SSH connection to my server and either execute the commands by myself or ask my technician to do it for me.Sigh, it seems I'm going to ask my technician - me - to do it then, lol.

Quote · 29 Apr 2013

The php.ini file is suppose to be in the root folder of your dolphin site. For most people that would be public_html. But many have dolphin installed in a sub folder other than public_html.

Anyhow. the php.ini file should be in the same folder that your dolphin index.php and .htaccess file is in.

https://www.deanbassett.com
Quote · 29 Apr 2013

It is. Actually it was there with index and htaccess all the time. I guess I really need to copy it to all the folders you told me about. Oh well.

Quote · 29 Apr 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.