PHP if does not work
-
I’m trying to implement a if statement to execute a script based on the author’s id and it does not work. The PHP engine says that there’s an unxepected < (the one that starts the script).
Here’s the code:
<?php
$atr=get_the_author_ID();
if ($atr==6)
{
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “https://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-697623-9”);
pageTracker._initData();
pageTracker._trackPageview();
</script>}
elseif ($atr==4)
{
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “https://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-697623-19”);
pageTracker._initData();
pageTracker._trackPageview();
</script>}
?>How can I insert a script in a if statement?
Thanks,
- The topic ‘PHP if does not work’ is closed to new replies.