Hi all,
I am hoping someone can help me with some apostrophe troubles I am having!
I have a form where the user can enter data, that data goes into the database. I have noticed that things break when a user enters an apostrophe into some of these fields: John’s Room, for example.
I have fixed the data going into the database, but reading it from the database is still a problem.
I used the following code , as suggested by a Google search.
[php]
$name = str_replace("’", “’’”, $name);
[/php]
The problem is with the following line of code.
This line should display some database items. The user clicks on them, and textboxes are populated with db information. It will only display up to an apostrophe- ‘John’ instead of ‘John’s Room’, for example.
[php]
echo “”;
[/php]
This is the second line I am having trouble with is:
[php]
eval(“object” + i + “.addEventListener(‘click’, function () {select_event(’” + event_name + “’)});”);
[/php]
event_name is the variable with the apostrophe in it.
I have tried escaping the apostrophe with a /, but that didn’t work.
Can someone suggest a solution?
Thanks!
James.