Whats wrong with this code

Reply

Join Date: Apr 2005
Posts: 2
Reputation: alienpyro is an unknown quantity at this point 
Solved Threads: 0
alienpyro alienpyro is offline Offline
Newbie Poster

Whats wrong with this code

 
0
  #1
Apr 14th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Whats wrong with this code

 
0
  #2
Apr 14th, 2005
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.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 2
Reputation: alienpyro is an unknown quantity at this point 
Solved Threads: 0
alienpyro alienpyro is offline Offline
Newbie Poster

Re: Whats wrong with this code

 
0
  #3
Apr 14th, 2005
Thanks for the reply, I'll give it a shot.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 54
Reputation: Alcides is an unknown quantity at this point 
Solved Threads: 0
Alcides's Avatar
Alcides Alcides is offline Offline
Junior Poster in Training

Re: Whats wrong with this code

 
0
  #4
Apr 17th, 2005
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.
Vapor One
----------
http://www.vaporone.com (THE LEGEND)
http://www.candycola.com (FREE MUSIC)
http://www.pdunderground.com (THE UNDERGROUND)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC