Skip to content Skip to sidebar Skip to footer

Quotation Marks Causing Error On Page

I really hope someone can help me. I've been banging my head against the wall with this one :(. I have the following code that is driving me nuts In my PHP file I have entered the

Solution 1:

There is discrepancy between what you have in your code and the ouput should give you :

Your code :

href="javascript:showonlyone('<?php echo $LetterLinkLbL ?>');"

is bound to render :

href="javascript:showonlyone('ListLetter3');"

but you state it renders (with a double quotation mark at the start and a single one at the end) :

href="javascript:showonlyone("ListLetter3');"

The php code you give should not create an error at all as it is correct. Are you sure you did not give us the output from another trial ?

The rule to insert a quotation inside a PHP/javascript string using that same quotation to enclose it is simply to add a \ before it :

$Value = "Hello Johnny \"PHP\" Boy !!";

or

$Value = 'Hello Johnny \'PHP\' boy !';

Solution 2:

Why don't you check out functions like htmlspecialentities(), which will escape and convert these ambiguous characters. also do check your text editor's charset encoding and escape quotes if necessary by applying preceding backslashes() to the single quote.

if you're escaping quotes, this will also work in PHP:

href="javascript:showonlyone(\"<?php echo $LetterLinkLbL ?>\");">

btw as an aside: <?php echo ... ?> can be written in shorthand and reduced to <?= ... ?> without even the ending semicolon(;)


Post a Comment for "Quotation Marks Causing Error On Page"