PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, all I was wondering is it possible to include javascript info in a php file' cos when I try and do something like this it spits out an error and my javascript code doesn't work->
The error I get is something to do with my javascript code. In effect what it really is; is that the javascript code is looking for an apostrophe but when writing something in php you need to use this -> ' . Is there any way to fix it?
The problem you are experiencing is because you are using single quotes around your HTML attributes instead of double quotes like you're supposed to and this is then messing up your Javascript because when the page is displayed the browser thinks that the opening quote in your Javascript is the closing quote for the mouseover attribute.
In your PHP you can now either escape out of PHP (by putting a ?> before and a <?php after the code) to add the HTML or use single quotes around your block (use the escape character \ to escape the single quotes in the JS) or use heredoc format. For more info: echo() and http://www.php.net/manual/en/language.types.string.php