<?php
$servername = "localhost" //你的连接地址,可以是ip
$username = "username" //你的用户名
$password = "password" //你的密码
$dbname = "myDB" //你要连接数据库的名字
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname)
// 检测连接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error)
}
echo "连接成功"
学习可以参考:http://www.runoob.com/php/php-mysql-select.html
$con=mysqli_connect("localhost","my_user","my_password","my_db")if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error()
}
mysqli_query($con,"SELECT * FROM Persons")
mysqli_query($con,"INSERT INTO Persons (FirstName,LastName,Age)
VALUES ('Glenn','Quagmire',33)")
mysqli_close($con)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)