Mixing php,js, html problem
I am writing php program in which at a certain point i need to mix three languages, php, javascript and html in the same line. the output of what im doing is correct but i still get an error on page message in internet explorer.
here is the line of code:
(followed by - but less important)
color=#<? echo "$titlefontcolor" ; ?> face=<? echo "$fonttype" ; ?>>Recent Studies:");
the function fgf just opens the linked page in a new window. I know there isnt much code there to play with but i know the problem is just something like missing " or something. the mixture of 3 languages in causing the problems, cause php has " as a special character. anyone have any suggestions on how to make this line of code work ??
"onlick=fgf = window.open('','gf');" - this part is where im guessing the problem arises cause of the two equals signs... any ideas anyone ?
kb posted this at 12:48 — 25th August 2004.
He has: 1,380 posts
Joined: Feb 2002
ok first off...if you can put your JS in a .js file, then do it, and call the file in the section by <script src="myscript.js" type="text/javascript" language="Javascript"></script>
Second...instead of <? echo "$fontsize"; ?> you need <? echo $fontsize; ?> or even <?=$fontsize?>, same goes for the rest...and in your php file, you can structure it like this:
<?Php
//some php here
?>
<head>
<title></title>
<script src....></script>
</head>
<body>
etc etc
You dont have to do the document write or any of that by echoing from php...
If you think there are problems with quotes, then escape them...so " becomes \"
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.