1

I am trying to use onclick in PHP echo , I arrived at this error

Parse error: syntax error, unexpected 'OpenPopupCenter' (T_STRING) in C:\xampp\htdocs\e-vms\securitydashboard.php on line 229

My code looks like this

<?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die ('Cannot connect, Reason: '.mysqli_error());
$sql = "select * from new_reservation ";
$result = mysqli_query($con,$sql) or die ('Failed Query , Reason : '.mysqli_error($con));
while($row = mysqli_fetch_array($result)){

    $showData = "<TR valign=top>
<TD width=106 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp;&nbsp; {$row['visit_date']}</font></div>
</div>
</TD>
<TD width=134 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp; {$row['login_time']}</font></div>
</div>
</TD>
<TD width=148 height=26><div class=wpmd>
<div><font face=Verdana size=1><BR></font></div>
<div><font face=Verdana size=1>&nbsp;&nbsp;&nbsp; {$row['fullname']}</font></div>
</div>
</TD>
<TD width=160 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp;&nbsp; {$row['whom_tosee']}</font></div>
</div>
</TD>
<TD width=138 height=26><div class=wpmd>
<div>&nbsp;</div>
<div align=center><font face=Verdana><input type=image src=images/show_detailsbtn.png width=124 height=26 onclick="OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);" ></font></div>
</div>
</TD>
<TD width=163 height=26><div class=wpmd>
<div><BR></div>
<div>&nbsp;<font face=Verdana size=2>
    <input type=image src=images/signout_visitor.png width=121 height=27></font></div>
</div>
</TD>
</TR>
";
    echo $showData;

}
?>

What do i appear to be missing? Should I make some little adjustments it wont even open the window.

2
  • Possible duplicate of PHP parse/syntax errors; and how to solve them? Commented Oct 22, 2019 at 8:57
  • And go read up on some basics, please. php.net/manual/en/language.basic-syntax.phpmode.php There is no real need here to assemble this content in a variable first, only to then do nothing else but outputting it directly afterwards. You wouldn’t have that many problems with string delimiters and escaping in the first place without it. Commented Oct 22, 2019 at 8:59

1 Answer 1

1

Add \before ".

Replace

onclick="OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);"

by

onclick=\"OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);\"
Sign up to request clarification or add additional context in comments.

2 Comments

Perfect! Works as I expected. Thank you very much!
You're welcome. Accept my answer please, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.