0

我有一些 PHP 代码正在尝试添加删除确认。但是导致错误...

$arr_data[$array_pos][] = 'a href="delete.php?pid='.$row['pid'].'"
    onclick="return confirm('Are you sure want to delete')">delete<';

onclick代码导致了问题。以我非常有限(零!)的知识,我找不到修复程序,因此将不胜感激。

onclick="return confirm('Are you sure want to delete')"

(我删除了超链接 HTML 代码以便显示)

4

1 回答 1

2

您需要转义单引号。

$arr_data[$array_pos][] = '<a href="delete.php?pid=' . $row['pid'] . '" onclick="return confirm(\'Are you sure you want to delete?\')">Delete</a>';
于 2013-01-30T18:43:04.193 回答