当用户登录时,他将转到有表格的页面,表格填充正确,每行都有删除链接。如果我单击删除链接,它将删除该记录,但是当它刷新页面时,该表将不会加载此消息。
Warning: mysql_query(): Access denied for user ''@'host' (using password: NO)
Warning: mysql_query(): A link to the server could not be established in
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given
为什么它会让我第一次填充表格然后再次它不会。这是我的删除代码。
$id_actividades = $_GET['idactividades'];
$stmt = $dbh->prepare("DELETE FROM guaynabodb.actividades WHERE idactividades=:id_actividades");
$stmt -> bindParam(':id_actividades', $id_actividades);
try{
$stmt->execute();
}
catch (PDOException $ex) {
echo $ex->getMessage(),'Cannot delete',"\n";
}
header('Location: actividades.php');//To redirect
exit;
这是我拥有该表的页面的代码。它在您登录后加载但如果我删除一条记录则不会加载。
include('../includes/dbschema.php');
$stmt = $dbh->prepare("SELECT * FROM actividades");
$stmt->execute();
print " <h1 id=\"h2title\">Calendario de Actividades</h1><br/><br/>";//Print the title header
echo "<table id=\"premiacionguaynabo\"> <tr> <th> No. </th> <th> Fecha </th> <th> Torneo </th> <th> Lugar </th> <th> Organizador </th> <th> Opciones </th> </tr>"; //The table and the headers are created
$tno = 0;
$result = $stmt->fetchall(PDO::FETCH_ASSOC);
foreach($result as $line){
$tno = $tno + 1;
$id = $line["idactividades"];
print "<tr class=\"alt2\">";
print "<td id=\"idtorneo\"> $tno </td>";
print "<td class=\"fechatorneo\"> " . $line['fecha_inicial'] . " al " . $line['fecha_final'] . "</td>";
print "<td> <a id=\"plinks\" href=\"$picture\" rel=\"lightbox\" target=\"_top\" title=\"Flyer del Torneo\"> " . $line['ntorneo'] . " </a></td>";
print "<td>" . $line['ltorneo'] . "</td>";
print "<td>" . $line['otorneo'] . "</td>";
print "<td id=\"idtorneo\"> <a id=\"udlinks\" href=\"uactividades.php?idactividades=$id\"> Edit </a> <a id=\"udlinks\" onclick=\"return confirmDelete()\" href=\"dactividades.php?idactividades=$id\"> Delete </a></td>";
print "</tr>";
}
print "</table>";
答案 0 :(得分:0)
提示mysql_query()
的错误消息功能在您发布的代码中不存在。
因此,这些功能要么偶然留在代码中,要么只是发布错误的代码
请阅读您的错误消息。它们非常有用。