Problem with PHP and SQL [duplicated]

0

Error:

  

Fatal error: Uncaught Error: Call to undefined function mysql_connect () in C: \ xampp \ htdocs \ connectionion.php: 7 Stack trace: # 0 C: \ xampp \ htdocs \ index.php (3): include_once ( ) # 1 {main} thrown in C: \ xampp \ htdocs \ conexion.php on line 7

Code:

<?php
// datos para la conexion a mysql
define('DB_SERVER','localhost');
define('DB_NAME','*****');
define('DB_USER','*****');
define('DB_PASS','*****');
$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME,$con);
?>
    
asked by sergio 18.05.2018 в 13:59
source

2 answers

-1

What version of PHP do you use? The mysql_connect () driver is obsolete since PHP 5.5.0 and removed from PHP 7.0.0. You should use the mysqli_connect driver.

link

    
answered by 18.05.2018 / 14:01
source
0

You must change every instruction you have in mysql php by mysqli. This is because the "mysql" type instructions are obsolete since PHP 5.5 and deleted from PHP 7.0

I leave your code with the corrections to make it work:

<?php
// datos para la conexion a mysql
define('DB_SERVER','localhost');
define('DB_NAME','*****');
define('DB_USER','*****');
define('DB_PASS','*****');
$con = mysqli_connect(DB_SERVER,DB_USER,DB_PASS, DB_NAME);

?>

To learn more about the topic, I recommend you review obsolete PHP 5.5 features and look in more detail as a connection is made to mysqli as an example you can check mysqli_connect

    
answered by 18.05.2018 в 14:03