我有這樣的錯誤:警告:mysql_fetch_array()預計參數1是資源,布爾在C中給出:\ XAMPP \ htdocs中\ projeto \ BD \上線proj_detalhes.php 25SQL,PHP,子查詢
<?php
$bd = "crowdfunding";
$connection = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db($bd) or die(mysql_error());
$sql = "SELECT projeto.id, nome, limite, projeto.descricao FROM projeto,(SELECT valor, recompensa.descricao FROM recompensa, projeto WHERE projeto.id = id_projeto)";
$res = mysql_query($sql);
?>
<html>
<head>
<title>Projects</title>
</head>
<body>
<h1>Details<br /></h1>
<table>
<tr>
<td><strong>ID</strong></td>
<td><strong>Name</strong></td>
<td><strong>Final data</strong></td>
<td><strong>Description</strong></td>
<td><strong>Value</strong></td>
<td><strong>Reward Description</strong></td>
</tr>
<?php
while($dados = mysql_fetch_array($res)){
$id = $dados['id'];
$nome = $dados['nome'];
$data = $dados['limite'];
$descricao_proj = $dados['projeto.descricao'];
$valor = $dados['valor'];
$descricao_rec = $dados['recompensa.descricao'];
echo "<tr>
<td>$id</td>
<td>$nome</td>
<td>$data</td>
<td>$descricao_proj</td>
<td>$valor</td>
<td>$descricao_rec</td>
</tr>";
}
?>
</table><br /><br />
<form action="menu1.php" method="get">
<center><input name="button" type="submit" value="Back"/></center>
</form>
</body>
</html>
我的第一個變量不是英文,試着理解它。但我在這裏的目標是從項目表中顯示我的ID名稱和說明,並從我的獎勵表中顯示值和說明(僅當項目中的id等於我創建的project_id中的變量時)
不要使用mysql_ *功能了!他們已棄用! 嘗試改用PDO或SQLi。 – jankal
如果沒有錯誤,'mysql_query'的結果是可以在'mysql_fetch_array'中使用的資源。您不應該假設每個函數調用都不會返回錯誤。 – Tristan
嗯,我有一個表叫projeto與這些變量(英文項目): ID 諾姆(英文名) descricao(介紹) LIMITE(截止日期,類型爲DATE) –