PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php try { echo date('Y-m-d H:i:s').PHP_EOL.PHP_EOL; echo'Connect ...'.PHP_EOL.PHP_EOL; $servername = 'localhost:3306' ; //MySQL的host主机名,一般是3306 port $username = 'root' ; //MySQL的用户名,root等级最高,可以用别的 $password = 'root' ; //MySQL的对应用户的密码,自己看 // $conn = new_mysqli( $servername, $username, $password); $conn = $mysqli; if($conn->connect_error){ //检测PHP的连接(connect_error字符串有东西吗) die('Connect Failed:'.$conn->connect_error); //报告错误并结束 } } catch (mysqli_sql_exception $e) { die ("Error!: " . $e->getMessage() . "<br/>"); } echo'Connect success!'; $conn->close(); ?>
Show:  
Copy Clear