我连接的是数据库,一个页面有很多内容,所以我只分享在php中没有返回值但在MySQL中有返回值的部分
这是代码;
$query = "SELECT firstname FROM users WHERE id = '17'";
$query_run = mysql_query($query);
$row = mysql_fetch_row($query_run);
echo $row[0];
最佳答案
Changing the code I shared first to this, solved the problem. Thanks to anyone who tried to help.
$query = "SELECT firstname FROM users WHERE id = '17'";
$query_run = mysqli_query($conn, $query);
$row = mysqli_fetch_row($query_run);
echo $row[0];
And made bit changes to the connect.inc.php which I also shared in comment.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "notsitesi";
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error) {
die("Connection failed");
}
?>
关于php - mysql不能返回一行结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37624691/