我需要用php连接我的sql并在变量中获取一些数据,这是我的代码:
<?php
$servername = "localhost";
$username = "imsdybug_pappagallo";
$password = "Vasivafa";
// Create connection
$conn = mysqli_connect($servername, $username, $password,"imsdybug_admin");
$result = mysqli_query($conn,"SELECT * FROM profilo_pappagallo;");
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$pappagallo = $row['sesso'];
echo $pappagallo;
}
?>
答案 0 :(得分:1)
您以错误的方式使用mysqli。看起来像你
与已弃用的mysql
混淆,这是正确的方法:
<?php
$servername = "localhost";
$username = "imsdybug_pappagallo";
$password = "Vasivafa";
// Create connection
$conn = new mysqli($servername, $username, $password, "imsdybug_admin");
$result = $conn->query("SELECT * FROM profilo_pappagallo;");
while($row = $result->fetch_assoc()) {
$pappagallo = $row['sesso'];
echo $pappagallo;
}
?>