-1

This line of code currently works:

echo"<td><a href=deleteuser.php?id=".$row['id'].">Delete</a></td>";

And I am trying to add the "onclick="return confirm('Are you sure?');"

However, it is throwing syntax errors where ever I place it.

Thank you

  • 1
    Show the code that's getting the syntax error. I suspect the problem is that you're not escaping the internal `"` characters. – Barmar Apr 10 '18 at 00:37

2 Answers2

0

It should be:

echo "<td><a href='deleteuser.php?id=".$row['id']."' onclick=\"return confirm('Are you sure?')\">Delete</a></td>";

You need to escape the double quotes that are inside the string, so they don't end the string.

Barmar
  • 741,623
  • 53
  • 500
  • 612
0

You need to figure out the best way to use your apostrophes and double quotes when they are nested, and escape some sometimes.

You should also get a decent IDE, as they show syntax highlighting and where you have gone wrong :)

Try this:

echo '<td>
          <a href="deleteuser.php?id='.$row['id'].'" onclick="return confirm(\'Are you sure?\');">Delete</a>
     </td>';
James
  • 4,644
  • 5
  • 37
  • 48
  • I currently use brackets. Do you have a suggestion on what I should use? – GeorgeU Apr 10 '18 at 00:46
  • I use PHPStorm. I've never used brackets (tho it's a code editor rather than IDE) anything with syntax highlighting for small projects is fine. For large project you need an IDE IMO, but each to their own. Once you save the file in brackets you should be able to set the language and syntax highlighting should work. – James Apr 10 '18 at 00:50