<?php
echo "<a href='display_emp.php?employee_id=$rs['emp_id']; onClick=\"return confirm('Are you that you` `want to DELETE this Data?')\" ><FONT COLOR='#F00'>Click To Delete</FONT></a>";
?>
error: Parse error: parse error, expecting T_STRING or T_VARIABLE or T_NUM_STRING'
我是PHP的新手,谁能教我如何解决这个错误? 感谢..
答案 0 :(得分:1)
尝试类似:
echo "<a href='display_emp.php?employee_id=".$rs['emp_id']."' onClick='return confirm(\"Are you that you want to DELETE this Data?\")' ><FONT COLOR='#F00'>Click To Delete</FONT></a>";
我只想说:那是你在那里使用的一些可怕的HTML ... FONT ......真的??
答案 1 :(得分:1)
只需删除围绕emp_id($ rs [emp_id])
的引号即可echo "<a href='display_emp.php?employee_id=$rs[emp_id]; onClick=\"return confirm('Are you that you want to DELETE this Data?')\" ><FONT COLOR='#F00'>Click To Delete</FONT></a>";
答案 2 :(得分:0)
您在字符串中使用双引号(“),这会使字符串过早结束并导致错误。
onClick=\"return
那是你的问题
答案 3 :(得分:0)
这应该有效:
<?php
echo "<a href=\"display_emp.php?employee_id=" . $rs['emp_id'] . "\" onClick=\"return confirm('Are you that you want to DELETE this Data?');\"><FONT COLOR=\"#FF0000\">Click To Delete</FONT></a>";
?>
答案 4 :(得分:0)
当您使用字母索引放置数组变量时,不应使用其他引号。
在这里,这个是正确的:
echo "<a href='display_emp.php?employee_id=$rs[emp_id];' onClick=\"return confirm('Are you that you` `want to DELETE this Data?')\" ><FONT COLOR='#F00'>Click To Delete</FONT></a>";
或Sammaye建议,连接字符串的不同部分。
答案 5 :(得分:0)
这是解决方案
$test = $rs['emp_id'];
$msg = "Are you that you want to DELETE this Data?";
echo "<a href=display_emp.php?employee_id=".$test." onClick='return confirm(\"".$msg."\")' ><FONT COLOR='#F00'>Click To Delete</FONT></a>";