944,074 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1883
  • PHP RSS
Apr 14th, 2005
0

Whats wrong with this code

Expand Post »
I know there is something wrong with this code because I got an error message but Im not sure exactly what. THis is all on one line within dreamweaver. Here it is:

echo '<a href="?pageState=Database" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('database','','Images/databasebuttonpushed.gif',1)"><img src="Images/databasebutton.gif" name="database" width="200" height="30" border="0"></a>';

Any help is appreciated. Btw it pointed to this line. Im guessing it has something to do with the quotes and apostrophes but Im not sure exactly about the syntax.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alienpyro is offline Offline
2 posts
since Apr 2005
Apr 14th, 2005
0

Re: Whats wrong with this code

Ok. The problem comes when you use ' inside your statement with ' on the outside. So something like this is not good:

echo 'some text 'more text' and more text';

PHP expects 'more text' to be some kind of variable or operator. I think you will need to use " on the outside and \" any " inside of the statement. Something like this:

[PHP]
echo "<a href=\"?pageState=Database\" onMouseOut=\"MM_swapImgRestore()\"
onMouseOver=\"MM_swapImage('database','','Images/databasebuttonpushed.gif',1)\">
<img src=\"Images/databasebutton.gif\" name=\"database\"
width=\"200\" height=\"30\" border=\"0\"></a>";[/PHP]

Its a pain, but I don't know of any way around it.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 14th, 2005
0

Re: Whats wrong with this code

Thanks for the reply, I'll give it a shot.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alienpyro is offline Offline
2 posts
since Apr 2005
Apr 17th, 2005
0

Re: Whats wrong with this code

Yes, that sounds right, but just to clarify. If you quote the whole echo statement with ', then you can use " freely, but must use \' to get the ' to work. And vice versa. Make sense? I noticed you had several ' in the echo which signaled an end of the echo before you were done. \" is not necessary if you use ' on the outside and \' is not necessary if you use " on the outside.

Alcides.
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
Alcides is offline Offline
54 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: parser error saying '='..plz help me...
Next Thread in PHP Forum Timeline: New to PHP and MySQL and help bad!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC