Fatal error: non-object ....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seanie
    Member
    • Jun 2003
    • 98

    Fatal error: non-object ....

    Hiya

    I'm trying to make a basic events listing for my disertation/a website i run and have so far managed to get the form to write to the database, however when it comes to pulling off the records from the database I get the following error:

    Fatal error: Call to a member function on a non-object in /home/*/*/gigs.php on line 21

    Here's the code I'm using to connect, I know it connects because the files are on the database, its just pulling them off thats casuing the problem.

    Code:
    ####################################################################
    ################ DATABASE CONFIGURE ##############################
    ####################################################################
    $hostname = "localhost";
    $db_user = "username";
    $db_password = "seanie";
    $db_name ="database";
    $db_table = "gigs";
    
    # STOP HERE
    
    ####################################################################
    # THIS CODE IS USED TO CONNECT TO THE MYSQL DATABASE
    $db = mysql_connect($hostname, $db_user, $db_password) or die ('Error connecting to mysql');
    mysql_select_db($db_name);
    
    $timecutoff = mktime(0,0,0);
    
    	$events = $db->query("SELECT * FROM `gigs` WHERE `gig_date` > $timecutoff  ORDER BY `gig_date` ASC LIMIT 25"); //THIS IS LINE 21

    its an edited version of a script i was using to pull off events from a VB database, but I need to get it working on its own without VB for my dissertation.

    Any guidence would be hugely appreciated!


    Seanie!
  • Lynne
    Former vBulletin Support
    • Oct 2004
    • 26255

    #2
    Please, please edit out your database username and password!

    Do you have mktime defined somewhere?

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools <- awesome site for html/css help

    Comment

    • Boothby
      Member
      • Aug 2002
      • 81
      • 3.8.x

      #3
      $db is not an object, but a recource. Instead of $db->query you must use mysql_query().
      Stefan

      Scott me up, Beamie!

      Comment

      • Seanie
        Member
        • Jun 2003
        • 98

        #4
        Originally posted by U2Lynne
        Please, please edit out your database username and password!

        Do you have mktime defined somewhere?
        thats not my actual db details

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...