p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: error using "mysql_connect()" function


Message #1 by "Aaron" <aj.huber@h...> on Mon, 29 Jan 2001 15:15:25 -0000
Can someone help me please!!!  I was working in chapter 13 with the

access_logger.php file. I set auto_prepend_file in the php.ini file to

prepend my access_logger.php.  I got lots of function redefinition errors

so I changed back the php.ini file.  However I cant use the

mysql_connect() function anymore for some reason.  Every page that uses

mysql_connect() (ie from common_db.inc) says :



Fatal error: Call to undefined function: mysql_connect() in

/var/www/include/common_db.inc on line 16



HERE are the lines of my .inc file for the db_connect() function:



function db_connect($dbname='')

{

  global $dbhost, $dbusername, $dbuserpassword, $default_dbname;

  global $MTSQL_ERRNO, $MYSQL_ERROR;



  //THE FOLLOWING LINE IS LINE 16

  $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);

  if(!$link_id)

  {

    $MYSQL_ERRNO = 0;

    $MYSQL_ERROR = "Connection failed to the host $dbhost.";

    return 0;

  }

  else if(empty($dbname) && !mysql_select_db($default_dbname))

  {

    $MYSQL_ERRNO = mysql_errno();

    $MYSQL_ERROR = mysql_error();

    return 0;

  }

  else if(!empty($dbname) && !mysql_select_db($dbname))

  {

    $MYSQL_ERRNO = mysql_errno();

    $MYSQL_ERROR = mysql_error();

    return 0;

  }

  else return $link_id;

}






  Return to Index