Error with the connection [duplicated]

-1

enter the code here I am creating an autocompletable search with json, mysql and php but it shows me this error:

  

Fatal error: Uncaught Error: Call to undefined function mysql_connect () in C: \ xampp \ htdocs \ Times \ pages \ log1.php: 2 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ Schedules \ pages \ register1.php on line 2

the consultation is fine, I appreciate your help.

<?php
    $con  = mysql_connect("localhost", "root", "");
    mysql_select_db("cursos", $conxion);
    $result = mysql_query("SELECT * FROM usuarios WHERE tipousuario='Docente' ORDER BY nombre ASC", $con);
    $array = array();
    if($result){
        while ($row = mysql_fetch_array($result)) {
            $equipo = utf8_encode($row['nombre']);
            array_push($array, $equipo);
        }
    }
?>
    
asked by Miguel Clavijo 07.01.2018 в 23:22
source

1 answer

0

The error tells you that the function is not defined .

If the call to the function is well written, and since it is a native function, the problem may be because you are calling it under a namespace, change the call to: $ con = \ mysql_connect ("localhost", "root", "");

Another possibility is that you use PHP 7 or higher, if you look at the PHP documentation of the function you have a message that starts like this:

  

Warning

     

This extension was declared obsolete in PHP 5.5.0 and deleted in PHP   7.0.0.

Follow the recommendations in the documentation and stop using mysql , which has been deprecated for years and has been removed.

    
answered by 07.01.2018 в 23:37