Hi i have been using this php echo statement
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(/Are you sure, you want to delete?/)'>Delete</a>";
The statement is working i am seeing this message /Are you sure, you want to delete?/ instead of this Are you sure, you want to delete?
Hi i have been using this php echo statement
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(/Are you sure, you want to delete?/)'>Delete</a>";
The statement is working i am seeing this message /Are you sure, you want to delete?/ instead of this Are you sure, you want to delete?
Share Improve this question edited Sep 7, 2012 at 11:49 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Sep 7, 2012 at 11:08 h_hh_h 1,2314 gold badges28 silver badges47 bronze badges3 Answers
Reset to default 6Your quote nesting is a little messed up. Try to follow these rules:
- Outer quote =
"
(This marks the beginning and end of the string) - Inner quote =
\"
(Escaped as to not flag "beginning/end of string") - Third-tier quote =
'
(Literal quote) - Fourth-tier quote =
\'
(Literal quote that will be generated as an escaped outer quote)
Result:
echo "<a href=\"message_delete_script_outbox.php?id=".$row['id']."\"onclick=
\"return confirm('Are you sure, you want to delete?')\">Delete</a>";
More info about quote nesting: http://blog.opensourceopportunities./2007/10/nested-nested-quotes.html
You enclose the message in quotes, and those quotes need to be escaped to avoid confusing the PHP script:
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
Just add double quotes and escape them
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."' onclick='return confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
I am not sure if you added a new line when you posted here, but you should know you cannot have that script on 2 lines.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744166621a4561334.html
评论列表(0条)