Undefined function mysql_connect()

后端 未结 14 791
庸人自扰
庸人自扰 2020-11-22 10:56

I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error:

Fatal error: Call to undefined

相关标签:
14条回答
  • If someone came here with the problem of docker php official images, type below command inside the docker container.

    $ docker-php-ext-install mysql mysqli pdo pdo_mysql
    

    For more information, please refer to the link above How to install more PHP extensions section(But it's a bit difficult for me...).

    Or this doc may help you.

    https://docs.docker.com/samples/library/php/

    0 讨论(0)
  • 2020-11-22 11:31

    I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error. Then I came to this solution where I changed my code from depreciated php functions to new functions.

    $con=mysqli_connect($host,$user,$password);
    
    mysqli_select_db($con,dbname); 
    //To select the database
    
    session_start(); //To start the session
    
    $query=mysqli_query($con,your query); 
    //made query after establishing connection with database.
    

    I hope this will help you . This solution is correctly working for me .

    EDIT:

    If you upgrade form old php you need to apt-get install php7.0-mysql

    0 讨论(0)
提交回复
热议问题