NagiosWeb mysql_fetch_array() Error

Chris
2006-12-21
2013-04-15
  • Chris
    Chris
    2006-12-21

    HELP!!

    Getting this error:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/share/nagios2/htdocs/nagiosweb/hostlist.php on line 13

    I'm trying to install and get it running on Ubuntu/Debian with Apache/2.0.55, PHP/5.1.6, mod_ssl/2.0.55 OpenSSL/0.9.8b Server.  Nagios was installed using the "nagios2" package and is running A-OK!  the "nagiosweb" database is created and the mysql user is permissioned.  There were absolutely no errors generated when running the nagiosweb.sql script. PHP is running as a module.

    This is my dbconfig.php:
    <?php

    // Database connectivity
    $nagiosweb='nagiosweb';
    $db = mysql_connect("localhost", "mysql", "mysql");
    mysql_select_db($nagiosweb);

    // $prefix is the path to where nagios is installed
    $prefix='/etc/nagios2';
    $etcprefix = $prefix;

    // Path to htdocs directory
    $htdocsdir='/usr/share/nagios2/htdocs';

    // Full path to php binary, include php
    $phppath='/usr/sbin/php';

    // Hostname of your nagios server i.e. nagios.yourname.com
    $nagioshostname='blah.blah.com';

    // Administrator Contact Info

    // Attempt at removing global_variables requirement
    extract($_POST);

    ?>

    I have verified that "register_globals = On" is present in php.ini.  I am not sure how or when this setting is invoked, so as a precaution I forced a restart of apache2 and still got same error.  I looked at the previous threads talking about my error and I got nowhere (the problem didn't seem to be with the PRIMARY KEY directives).

    I'm not entirely sure about the various paths in the above file.  I assume $prefix should be the path to the .cfg files.  The nagios2 binary executable is in /usr/sbin, but the cfg files are in the path noted above. The php binary executable is in /usr/sbin, however the php.ini file resides in /etc/php5/apache2.

     
    • Josh Konkol
      Josh Konkol
      2006-12-22

      I'm guessing the .sql import didn't work as well as you thought.  One test you can run is use your favorite mysql query analyzer and run:

      SELECT host_id, host_name, alias, address FROM hosts ORDER BY host_name

      That's exactly what line 13 is trying to do.

      Good Luck

      Josh

       
    • Chris
      Chris
      2006-12-22

      Actually, I'm retarded -- the README doc refers to the SQL DB as "nagiosweb-dist" and the default dbconfig.php refers to "nagiosweb".   As soon as I noticed and corrected that, all was a-ok!

      Thanks!