美文网首页
测试 PHP 连接 MySQL

测试 PHP 连接 MySQL

作者: 43daf5f8181f | 来源:发表于2016-09-19 16:08 被阅读87次
    <?php
    $dbname = "testphp";
    $password = 'allen_8pw';
    $servername = 'localhost';
    $username = 'allen';
    
    if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
        echo 'do not have mysqli!!!!';
    } else {
        echo 'have it!!!';
    };
    
    $conn = new mysqli($servername, $username, $password);
    
    if ($conn->connect_error) {
        die('Connection failed:' . $conn->connect_error);
    }
    echo 'Connected successfully';
    ?>
    

    相关文章

      网友评论

          本文标题:测试 PHP 连接 MySQL

          本文链接:https://www.haomeiwen.com/subject/zfrnettx.html