Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-25-2005, 08:04 AM
TrainHealthy TrainHealthy is offline
 
Join Date: Oct 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Call to a member function on a non-object...

Hi,

At the bottom of my page i get this:
Code:
Fatal error: Call to a member function on a non-object in /home/content/l/a/w/lawjigga/html/forum/includes/functions.php on line 4308
Line 4308 is:
PHP Code:
$vbulletin->db->unlock_tables(); 
I'm not a guru when it comes to PHP so I can't seem to see the problem.

Here's all the code on my page.

At very top of page:
PHP Code:
//Userpanel.php
chdir("/home/content/l/a/w/lawjigga/html/forum"); 
require(
'./global.php'); 
include(
'./includes/functions_user.php');
chdir("/home/content/l/a/w/lawjigga/html/"); 
In body (fetches news):
PHP Code:
$newsforums 2;
$newsitems 5;
$forumspath "";

chdir("/home/content/l/a/w/lawjigga/html/forum"); 
$connection mysql_connect(**************) or die ("Cannot connect to server.");
$db mysql_select_db("trainhealthy"$connection) or die ("Could not select database.");
$sql "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid = \"$newsforums\" ORDER BY threadid DESC LIMIT $newsitems";
$sql_result mysql_query($sql$connection) or die ("Could not execute query.");

if (!
$sql_result) { 
  echo 
"<p>Could not get record.";


while (
$row mysql_fetch_array($sql_result)) {
   
$threadid $row["threadid"];
   
$title $row["title"];   
   
$forumid $row["forumid"];
   
$replycount $row["replycount"];
   
$postusername $row["postusername"];
   
$postuserid $row["postuserid"];
   
$lastposter $row["lastposter"];
   
$iconid $row["iconid"];
   
$dateline $row["dateline"];

$sql2 "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";
$sql_result2 mysql_query($sql2$connection) or die ("Could not execute query in second sql statement.");

if (!
$sql_result2) { 
  echo 
"<p>Could not get record in second statement.";


while (
$row2 mysql_fetch_array($sql_result2)) {
   
$pagetext $row2["pagetext"];
$dateposted date("D j M Y, g:i A",$dateline);

if (
$replycount==1) {
 
$commenttext "Comment";
 }
else {
 
$commenttext "Comments";
 }

$bericht=$pagetext;


print 
"
<table border=\"0\" width=\"100%\" id=\"table1\" cellspacing=\"0\" cellpadding=\"2\">
    <tr>
        <td width=\"100%\">
<h2><b>
$title</b></h2> - <img border=0 src=\"http://biorust.com/images/qbullets/edit.gif\"><a href=\"http://forums.trainhealthy.com/thread$threadid.html\"><b>$replycount</b> $commenttext</a><br>
:: Posted By <a href=\"http://forums.trainhealthy.com/member.php?s=&action=getinfo&userid=
$postuserid\"><b>$postusername</b></a> at  <i>$dateposted</i></a>
    </tr>
    <tr>
        <td width=\"100%\">
        <p align=\"justify\">"
.$bericht."</td>
    </tr>
</table>
<p>
"
;

}
}

echo 
"<center><a href=\"http://forums.biorust.com/search.php\">Search the News</a> | <a href=\"http://forums.biorust.com/forum3.html\">View All News Posts</a></center>";

mysql_free_result($sql_result);
mysql_close($connection);

chdir("/home/content/l/a/w/lawjigga/html"); 
IN body (non vb login box):
PHP Code:
if ($vbulletin->userinfo['userid'] != 0)
    {
        echo 
"You are logged in as <b>";
        echo 
$vbulletin->userinfo['username'];
        echo 
"</b>.<br /><br />";
        
        
//Lastvisit
        
$currentmonth date("F");
        
$lastvisitedmonth date("F"$vbulletin->userinfo['lastvisit']);
        if(
$currentmonth == $lastvisitedmonth){
        
            
$userlastvisit date("g:i a"$vbulletin->userinfo['lastvisit']);
            
$lastvisitday date("j"$vbulletin->userinfo['lastvisit']);
            
$daytoday date("j");
    
            if(
$daytoday == $lastvisitday){
                
$timesuffix "Today";
            }
            if((
$daytoday -1) == $lastvisitday){
                
$timesuffix "Yesterday";
            }
            echo 
"Last Visit: ".$userlastvisit." ".$timesuffix;
        }
        else {
            
$userlastvisit date("g:i a, F j Y"$vbulletin->userinfo['lastvisit']);
            echo 
"Last Visit: ".$userlastvisit;
        }
        
        
//
        
echo "<br /><br />";
        echo 
"<u>PM Stats</u><br />" ;
        if(
$vbulletin->userinfo['pmunread'] != 0)    {
        
            echo 
"Unread: ";
            if(
$vbulletin->userinfo['pmunread'] <= 1)    {
                echo 
$vbulletin->userinfo['pmunread'];
                echo 
"<br />";
                echo 
"Total:";
            }
        }
        if(
$vbulletin->userinfo['pmunread'] != AND $vbulletin->userinfo['pmunread'] <= AND $vbulletin->userinfo['pmunread'] != 0)    {
    
            echo 
"Unread: ";
            echo 
$vbulletin->userinfo['pmunread'];
            echo 
"<br /><b>Total:</b>";    
            
        }
        
        if(
$vbulletin->userinfo['pmunread'] == 0)    {
        
            echo 
"Unread: ";
            echo 
$vbulletin->userinfo['pmunread'];
            echo 
"<br />Total :";
        
        }
        
        
        echo 
$vbulletin->userinfo['pmtotal'];
        echo 
"<br />";
        echo 
"<br />";
        echo 
"<a href=forum/login.php?$session[sessionurl]do=logout&amp;logouthash=$logouthash";
        echo 
$vbulletin->userinfo['logouthash'];
        echo 
">";
        echo 
" Log Out";
        echo 
"</a>";
            
    }
    
if (
$vbulletin->userinfo['userid'] == 0)
    {
    echo 
"
    <style type=text/css>
     <form action=forum/login.php method=post onsubmit=md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)>
        <script type=text/javascript src=forum/clientscript/vbulletin_md5.js></script>
        <table cellpadding=0 cellspacing=
$stylevar[formspacer] border=0>
        <tr>
            <td >Username:<br />
            <input class=\"textbox\" name=vb_login_username type=text id=navbar_username accesskey=u tabindex=1 onfocus=if (this.value == '
$vbphrase[username]') this.value = ''; size=15 />
            <br />
            Password:<br />
            <input class=\"textbox\" name=vb_login_password type=password accesskey=p tabindex=2 size=15 /><br />
            <label for=cb_cookieuser_navbar><input name=cookieuser type=checkbox id=cb_cookieuser_navbar accesskey=c tabindex=3 value=1 checked=checked />Remember</label><br /><br />
            <input class=\"submit\" type=submit accesskey=s tabindex=4 title=
$vbphrase[enter_username_to_login_or_register] value='Log In' />
            <br />
            <a href=\"http://trainhealthy.com/forum/login.php?do=lostpw\">Lost Password?</a> || 
            <a href=\"http://trainhealthy.com/forum/register.php\">Register</a></td>
        </tr>
        </table>
        <input type=hidden name=s value=
$session[sessionhash] />
        <input type=hidden name=do value=login />        
        <input type=hidden name=vb_login_md5password />
        <input type=hidden name=vb_login_md5password_utf />
    </form>
        <!-- / login form -->"
;

Anyhelp is appreciated!
Reply With Quote
  #2  
Old 10-25-2005, 11:08 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've removed the username and password of your db connection.
be careful not to post such informations when asking for help

as for your question, normally that's because you are calling the db within a function without globalizing that object.

try to add a global $vbulletin; before the errorproducing line.


also try to use better formating of your code, codingstandarts help when it comes to find bugs
Reply With Quote
  #3  
Old 10-25-2005, 12:37 PM
TrainHealthy TrainHealthy is offline
 
Join Date: Oct 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xenon
i've removed the username and password of your db connection.
Thanks, I'll try to watch out next time :nervous:

Quote:
Originally Posted by Xenon
try to add a global $vbulletin; before the errorproducing line.
Do you mean putting $vbulletin before line 4308 in funtions.php?
Reply With Quote
  #4  
Old 10-25-2005, 01:28 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yep, exactl one line before there should be a
PHP Code:
global $vbulletin
Reply With Quote
  #5  
Old 10-25-2005, 03:03 PM
TrainHealthy TrainHealthy is offline
 
Join Date: Oct 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No change
Reply With Quote
  #6  
Old 10-26-2005, 10:32 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The database you are accessing, is this also the database for your forum? If yes, try to use the standard vB functions for accessing the database.

PHP Code:
$connection mysql_connect(**************) or die ("Cannot connect to server."); 
$db mysql_select_db("trainhealthy"$connection) or die ("Could not select database."); 
Here you are probably destroying the vB database connection, resulting in the error you are getting.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03989 seconds
  • Memory Usage 2,283KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete