| | |
Whats wrong with this code
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2005
Posts: 2
Reputation:
Solved Threads: 0
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.
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.
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.
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.
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.
Alcides.
Vapor One
----------
http://www.vaporone.com (THE LEGEND)
http://www.candycola.com (FREE MUSIC)
http://www.pdunderground.com (THE UNDERGROUND)
----------
http://www.vaporone.com (THE LEGEND)
http://www.candycola.com (FREE MUSIC)
http://www.pdunderground.com (THE UNDERGROUND)
![]() |
Similar Threads
- new window? target="_blank" ? (JavaScript / DHTML / AJAX)
- How do you reverse string elements (C++)
- Please help me figure out whats wrong with my code (C++)
- Whats wrong with my computer??? (Viruses, Spyware and other Nasties)
- Prefix expressions(recursion) (C++)
- Whats wrong with this class??? (C++)
- merged:nesting loops (C++)
Other Threads in the PHP Forum
- Previous Thread: parser error saying '='..plz help me...
- Next Thread: New to PHP and MySQL and help bad!
| Thread Tools | Search this Thread |
# .htaccess 5.2.10 access alexa apache api array beginner broken cakephp checkbox class clean clients cms code convert cron curl database date directory display dissertation dropdown dynamic echo$_get[x]changingitintovariable... email encode error fairness file folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla legislation limit link local login mail memberships menu methods multiple multipletables mysql mysqlquery network newsletters oop open passwords paypal pdf persist php provider query radio random redirect remote script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube





