在localhost上运行时获取错误消息

时间:2017-09-04 11:17:12

标签: php mysql

我在localhost上运行时收到错误消息。跟随msg我得到了。我也添加了数据库连接代码。

( ! ) Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\common\conf\database.conf.php on line 51
Call Stack
#	Time	Memory	Function	Location
1	0.0470	142760	{main}( )	..\index.php:0
2	0.4050	634848	require_once( 'C:\wamp\www\common\conf\database.conf.php' )	..\index.php:16
3	0.4060	635416	mysql_connect ( )	..\database.conf.php:51


Database connection code

<?php
   /*******************************************************
    *  File name: database.conf.php
    *
    *  Purpose: this file is used to store database
    *           table name constants and it also starts
    *           the database connection
    *
    *  CVS ID: $Id$
    *
    ********************************************************/

   // If main configuration file which defines VERSION constant
   // is not loaded, die!
   if (! defined('VERSION'))
   {
      echo "You cannot access this file directly!";
      die();
   }

  // Please note:
  // in production mode, the database authentication information
  // may vary.
 
 
   define('DB_USER', 'root');
   define('DB_PASS', '');
    //           
    define('DB_NAME', 'myrentbd-db');
    define('DB_HOST', 'localhost');
    
  /**
  * Common Table Constant
  */
  // Common Tables
  define('APP_INFO_TBL',                 DB_NAME . '.app_info');
  define('APP_LANGUAGE_TBL',             DB_NAME . '.app_language');
  define('APP_MESSAGE_TBL',              DB_NAME . '.app_message');
  define('APP_META_TBL',                 DB_NAME . '.app_meta');
  define('APP_PROFILE_TBL',              DB_NAME . '.app_profile');

  define('COUNTRY_LOOKUP_TBL',           DB_NAME . '.country_lookup');
  define('US_STATE_TBL',                 DB_NAME . '.us_states');

  define('DOCUMENT_TBL',                 DB_NAME . '.document');

  define('GROUP_TBL',                    DB_NAME . '.group');
  
  if (AUTO_CONNECT_TO_DATABASE)
  {
      $dbcon = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Could not connect: " . mysql_error());
      mysql_select_db(DB_NAME, $dbcon) or die("Could not find: " . mysql_error());
  }

?>

1 个答案:

答案 0 :(得分:1)

使用mysqli函数

在php 5.5中显示mysql_connect()的警告消息:不推荐使用mysql扩展

php 7中的

已完全删除