我在将数组转换为字符串时出错。我认为我正确地完成了所有操作并循环了变量,但它仍然给我通知。
<li>
<a title="">Full Time</a>
<?php
$db = mysqli_connect('localhost', 'db', '12345678', 'db');
$logado = $_SESSION['id_utilizador'];
$result = mysqli_query($db, "SELECT modulo FROM disciplinas WHERE id_utilizador = '$logado' ORDER BY iddisciplinas DESC LIMIT 1");
while ($row = mysqli_fetch_array($result)) {
echo "<a>$row</a>"; //Error in this line
}
?>
</li>
是的。它只是显示通知。预先感谢您的帮助。
答案 0 :(得分:0)
首先 print_r($ row)并检查您是否正在获取价值,然后在$ row [“ modulo”]中获得预期结果后,请检查以下提到的代码段(如果可以)解决您的查询-
<?php
$db = mysqli_connect('localhost', 'db', '12345678', 'db');
$logado = $_SESSION['id_utilizador'];
$result = mysqli_query($db, "SELECT modulo FROM disciplinas WHERE id_utilizador = '$logado' ORDER BY iddisciplinas DESC LIMIT 1");
while ($row = mysqli_fetch_array($result)) {
print_r($row);
/***/
/* Check here if you get any thing in $row, then use as @Zachary mentioned*/
/* uncomment this line if you get value from print_r($row) */
//echo $row["modulo"];
/****/
// echo "<a>".$row['row']."</a>"; //Error in this line
}
?>