0

I'm trying to send a label error to my input, but I got some apache error. Here is my code:

echo '<script type="text/javascript"> $('#Username').after('<p class="label"> Username already exist.</p>')</script>';

Edit : Parse error: syntax error, unexpected '}', expecting ',' or ';' in c://..... On Line 68 Thats the error, thanks

Regie Baguio
  • 241
  • 5
  • 13
  • Looking at the code you posted it looks have you have nested/unescaped single quotes. However, you do need to post the error message you are getting too, as we cannot speculate without information on the actual error. – Darragh Enright Nov 25 '18 at 08:53
  • Done updating the error please read edit, thanks. – Regie Baguio Nov 25 '18 at 08:59
  • Instead of echoing HTML, you can close PHP tag `?>` just before this HTML and write JS code as is. You can again open PHP tag ` – nice_dev Nov 25 '18 at 09:12
  • I didn't know thats possible, Im afraid because its a long if else php statement. Will try it. Thanks for suggestion. – Regie Baguio Nov 25 '18 at 09:23

1 Answers1

1

Try with this code:

echo '<script type="text/javascript"> $(\'#Username\').after(\'<p class="label"> Username already exist.</p>\')</script>';