ursula.ug Posted November 30, 2011 Share Posted November 30, 2011 I've got this code and it works fine. All I want to do is, when people click on the x to delete something they submitted erroneously, I want a confirmation...really want to delete this? (sometimes that x is too tempting you know) But I *think* I'm having trouble escaping the line (near bottom): onsubmit='".return confirm('Really Delete');."' I'm not sure if it will work anyhow...but right now it doesn't. Thanks for any suggestions. <code> <?php include '../php/config_conn.php'; $querysum = "SELECT SUM(total_time) FROM `coop_hours` where user = '".$_SESSION['user_name']."'"; $resultsum = mysql_query($querysum); $arr = mysql_fetch_row($resultsum); $resulthours = $arr[0]; $querytime = "SELECT * FROM `coop_hours` WHERE user = '".$_SESSION['user_name']."' ORDER BY `date_completed`"; $result = mysql_query($querytime); $num = mysql_num_rows($result); mysql_close(); echo "<table width='1000' cellpadding='0' cellspacing='0' border='0'><tr> <td width='200'><strong>Coop Job</strong></td> <td align=center width='200'><strong>Date Completed</strong></td> <td align=center width='120'><strong>Total Time</strong></td> <td width='380'><strong>Comments</strong></td> <td width='100'>Delete Entry</td></tr>"; $i=0; while ($i < $num) { $hours_id = mysql_result($result, $i, "hours_id"); $user = mysql_result($result, $i, "user"); $coop_job = mysql_result($result, $i, "coop_job"); $date_completed = mysql_result($result, $i, "date_completed"); $start_time = mysql_result($result, $i, "start_time"); $end_time = mysql_result($result, $i, "end_time"); $total_time = mysql_result($result, $i, "total_time"); $comments = mysql_result($result, $i, "comments"); echo "<tr><td>$coop_job</td> <td align=center>$date_completed</td> <td align=center>$total_time</td> <td>$comments</td> <td align=center valign='middle'> <form action='".php/del.php."' method='".post."' onsubmit='".return confirm('Really Delete');."'> <input type='".hidden."' name='".hours_id."' value='".$hours_id."'> <input TYPE='image' SRC='images/del.png' width='11' height='11' border='0' alt='Delete'> </form> </td> </tr>"; $i++; } echo "<tr><td colspan=5><hr></td></tr>"; echo "<tr><td></td><td align=right>Total hours:</td><td align=center>$resulthours</td><td></td></tr>"; echo "<table>"; ?> </code> Quote Link to comment https://forums.phpfreaks.com/topic/252159-escaping-error-i-think/ Share on other sites More sharing options...
requinix Posted November 30, 2011 Share Posted November 30, 2011 The HTML should look like onsubmit='return confirm("Really Delete");' (or swap the quotes). So put that in your string. But because you're using "s in the PHP you need to escape the "s in the HTML. "onsubmit='return confirm(\"Really Delete\");'" Quote Link to comment https://forums.phpfreaks.com/topic/252159-escaping-error-i-think/#findComment-1292811 Share on other sites More sharing options...
ursula.ug Posted December 1, 2011 Author Share Posted December 1, 2011 Thanks, I got it to work (I'm excited). But I had to change that whole line to be: <form action='php/del.php' method='post' onsubmit='return confirm(\"Really?\");'> I kept getting a dividing by 0 error otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/252159-escaping-error-i-think/#findComment-1293149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.