Everything was working on the site until this morning - I made no changes, nor did my client. I am completely lost as to why it is coming up with - Fatal error: Call to a member function query() on a non-object in /lst_rcd.php on line 6

The following code is the list code:
<?php
require_once('./include/db_cnct.php');// begin reading the table to output results the the screen.

$sql = 'SELECT * FROM branches ORDER BY date_entr';

if( !$rssrslt = $db->query($sql) ) {
message_die(GENERAL_ERROR, "table read error", "",LINE, FILE, $sql);
}

while ($arr = $rssrslt->fetchrow()) {
$row[]=$arr;
}
$max_elements = count($row);
for ($i = 0; $i < $max_elements; $i++) {
$blstng = ($row[$i]['branchname']);

$el_line .= (($i+1).'.) '.$blstng.'<br/>');
}

echo ('<div id="records"><p>'.$el_line.'</p></div>');
It needs to load the list not an rssfeed. It was working no changes made and now it errors out. THIS IS URGENT....Client needs fixed by 5/15/09.
Thank you for your help.

    as the error says $db is not an object i would assume the issue lies in db_cnct.php

      Here is the db_cnct code
      <?php

      $db_host = 'mysqlhost';
      $db_engine = 'mysql';
      $db_user = 'user'; // Database username
      $db_pass = 'pass'; // Database password
      $db_name = 'd60592092'; // Database name

      $db=mysql_connect($db_host, $db_user, $db_pass);
      mysql_select_db($db_name) or die ("Unable to connect to MySQL");

      ?>

        something is missing, you have calls to $db and $rssrslt neither of witch are defined

          I am still learning PHP. I am not sure what is $rssrslt is. What I need the lst_rcd.php to call is the branch database. Would it need to $db_branch instead of $db_name? It just need to load a list of names.

            sounds dangerous to implement php for a client (i asume who is paying) when you don't know php. You should have a file with "class db {..}" in it somewhere.

              I know PHP and did this database. It was working, functioning, everything great then this morning it just on it owns came up with this error. I am also used to programming for GoDaddy servers not Netfirms.
              So what your saying is the class db {..} needs to be the $db_name? What I need to know is why is not calling the list and what I need to change so it will call the list as it was doing it.

                LisaD1983;10914496 wrote:

                So what your saying is the class db {..} needs to be the $db_name?

                No. The class named db is missing.

                  Would this be the class? $db = DB::connect($datasource, TRUE);

                    That would at least open the possibility for $db to be an object after that line, yes.

                    The code you posted above uses the [man]mysql[/man] library, an older, deprecated (or soon-to-be, at least - don't recall ATM) that doesn't have an OOP approach (like the [man]mysqli[/man] library).

                      Write a Reply...