I have some PHP code that I'm trying to add a delete confirmation. But is causing an error...
$arr_data[$array_pos][] = 'a href="delete.php?pid='.$row['pid'].'"
onclick="return confirm('Are you sure want to delete')">delete<';
The onclick
code is causing the problem. With my very limited (zero!) knowledge, I cannot find a fix, so any help would be appreciated.
onclick="return confirm('Are you sure want to delete')"
(I removed the hyperlink HTML code so it will display)
You need to escape the single quotes.
$arr_data[$array_pos][] = '<a href="delete.php?pid=' . $row['pid'] . '" onclick="return confirm(\'Are you sure you want to delete?\')">Delete</a>';