-2

I am getting error msg while running on localhost. following msg i am getting. i added the db connection code also.

( ! ) 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());
  }

?>
  • 3
    The mysql PHP extension is dead -- Stop using the mysql PHP extension. It is old, deprecated since PHP 5.5 and completely removed in PHP 7.0. Use mysqli or PDO_mysql instead. And don't mix them – AutoTester213 Sep 04 '17 at 11:18
  • Mysql_* funtions are deprecated. Further, they are insecure [Deprecated features in PHP 5.5.x](http://php.net/manual/de/migration55.deprecated.php). You should rather use mysqli_ functions or better PDO with prepared statements. – BenRoob Sep 04 '17 at 11:19

1 Answers1

1

use a mysqli function

in php 5.5 show warning message for mysql_connect(): The mysql extension is deprecated

in php 7 has completely removed

  • sorry to say, i am not an expert of writing code. can you please suggest where particularly i have to change? – Akash Avi Sep 04 '17 at 11:46
  • you have to change on database connection like mysql_connect(DB_HOST, DB_USER, DB_PASS) to mysqli_connect("localhost","my_user","my_password","my_db") and other CRUD operation – Lalabhai Patel Sep 04 '17 at 11:49