简体   繁体   中英

I am using xampp server and trying to run localhost but constantly getting an error in connect.php

hey I am using xampp and trying to run localhost but constantly getting an error in connect.php...error is as follows

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\\xampp\\htdocs\\admin panel\\connect.php:9 Stack trace: #0 C:\\xampp\\htdocs\\admin panel\\index.php(16): include() #1 {main} thrown in C:\\xampp\\htdocs\\admin panel\\connect.php on line 9

my connect.php code is as follows

<?php
$servername = "localhost";
$username = "root";
$password = "";
mysqli_connect($servername,$username,$password) or die('cannot connect to  
the server'); 
?>     

please help me out with this.

Uncomment the line extension=php_mysql.dll in your "php.ini" file and restart Apache. if its not working then update your xampp with latest version.

Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alternatives to this function include:

mysqli_connect()

PDO::__construct()
use MySQLi or PDO

<?php
$con = mysqli_connect('localhost', 'username', 'password', 'database');

check this "Call to undefined function mysql_connect()" after upgrade to php-7

refer this link for mysqli extension help http://www.w3schools.com/php/func_mysqli_connect.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM