Hi all
I have this pesky bug in my system and i'll try to explain it briefly.
I pull out data from the database and via PHP/HTML output a list of user accounts.
In some cases some of the data in the customer account contains a single quote, e.g:
Mr Joe Bloggs
12 My Street's Name
My Town
My City
Now I run a javascript function via the onclick event of that HTML table row in my page and I pass the customer details to another script. This is my function (broken down for simplicity) from the HTML page:
onclick='useContactDetails("<?php echo mysql_real_escape_string($firstname); ?>","<?php echo mysql_real_escape_string($lastname); ?>","<?php echo mysql_real_escape_string($row['address1']); ?>");'
Now this breaks my javascript and the error console message I get is as follows:
Error: SyntaxError: unterminated string literal
Source Code:
useContactDetails("Mr","Joe","Bloggs","12 My Street\
How can I get around this problem?
Many Thanks for reading.
Kris