Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Character Error

Status
Not open for further replies.

Kennya1

Programmer
Joined
Apr 14, 2002
Messages
15
Location
US
THe following line of code gives me an "invalid character" error in frontpage 2003

I have isolated it to the \' characters however if I chanf ge it to just ' the page will not load when placed on my web site

I get a
Parse error: parse error in /../..//test.html on line 326

error


What is the solution
<?PHP
function printhtml($message) {
.........

echo ' <img border="0" id="img13" src="Images/button69.jpg" height="20" width="100" alt="Support" onmouseover="FP_swapImg(1,0,/*id*/\'img13\',/*url*/\'Images/button6A.jpg\')" onmouseout="FP_swapImg(0,0,/*id*/\'img13\',/*url*/\'Images/button69.jpg\')" onmousedown="FP_swapImg(1,0,/*id*/\'img13\',/*url*/\'Images/button6B.jpg\')" onmouseup="FP_swapImg(0,0,/*id*/\'img13\',/*url*/\'Images/button6A.jpg\')" fp-style="fp-btn: Soft Rectangle 5" fp-title="Support"></a></td> '. "\n";

.......

}
?>
 
What's that newline character doing at the end. Shouldn't that be inside the echo statement?
 
There is no syntax error in the posted line. It is all fine.
However, be aware that the line number given out is the line where the parser quits - the error may be before that! Look up, line by line. You'll find the parse error there.
 
Nope Both This

echo ' <img border="0" id="img6" src="Images/button60.jpg" height="30" width="100" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/\'img6\',/*url*/\'Images/button61.jpg\')" onmouseout="FP_swapImg(0,0,/*id*/\'img6\',/*url*/\'Images/button60.jpg\')" onmousedown="FP_swapImg(1,0,/*id*/\'img6\',/*url*/\'Images/button62.jpg\')" onmouseup="FP_swapImg(0,0,/*id*/\'img6\',/*url*/\'Images/button61.jpg\')" fp-style="fp-btn: Soft Rectangle 5; fp-proportional: 0" fp-title="Home"></a></h3> "\n"';

and even This

echo ' <img border="0" id="img6" src="Images/button60.jpg" height="30" width="100" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/\'img6\',/*url*/\'Images/button61.jpg\')" onmouseout="FP_swapImg(0,0,/*id*/\'img6\',/*url*/\'Images/button60.jpg\')" onmousedown="FP_swapImg(1,0,/*id*/\'img6\',/*url*/\'Images/button62.jpg\')" onmouseup="FP_swapImg(0,0,/*id*/\'img6\',/*url*/\'Images/button61.jpg\')" fp-style="fp-btn: Soft Rectangle 5; fp-proportional: 0" fp-title="Home"></a></h3>';

give the same error message

however The following does not give me an error in Frontpage only when I upload it to my web site

echo ' <img border="0" id="img6" src="Images/button60.jpg" height="30" width="100" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/'img6',/*url*/'Images/button61.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img6',/*url*/'Images/button60.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img6',/*url*/'Images/button62.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img6',/*url*/'Images/button61.jpg')" fp-style="fp-btn: Soft Rectangle 5; fp-proportional: 0" fp-title="Home"></a></h3> '. "\n";


Does not
 
have you checked the code on the webserver to make sure whatever your process for uploading is isn't adding any escape or otherwise special characters?
 
I am editing directly on the server. Since it generates an error statement I cannot view the code I am actually seeing the code for the error statement
 
Instead of escaping inside quotes use the heredoc syntax:
Code:
print <<<END
<img border="0" id="img6" src="Images/button60.jpg" height="30" width="100" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/'img6',/*url*/'Images/button61.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img6',/*url*/'Images/button60.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img6',/*url*/'Images/button62.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img6',/*url*/'Images/button61.jpg')" fp-style="fp-btn: Soft Rectangle 5; fp-proportional: 0" fp-title="Home"></a></h3>
END;
 
Kennya1:
You seem to be focusing on this one particular line.

As DRJ478 has pointed out, the line at which PHP generates a parse error may not necessarily be the line at which the code error exists. When PHP reports a parse error at line 123, it is not report that there is something wrong with line 123. It is, rather, reporting that while it was parsing 123, it realized it was confused. The bad line which actually started the confusion can be many many lines earlier in your code.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top