Jump to content

confusion at problem ?


Porkie

Recommended Posts

im confused with the problem i get here?

 

<?php
if ($stuff['type'] == 'Administrator'){
echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br/><br/>';
echo '<a href="admin.php">Main Site Admin</a><br/><br/>';
echo '<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk'></SCRIPT>';
echo '<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk'></SCRIPT>';
}
?>

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/myuklive/public_html/details.php on line 36

 

i dont see a problem with it?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/172592-confusion-at-problem/
Share on other sites

many problems. mainly that you have to escape your single quotes if your entire string is encased in them

 

if ($stuff['type'] == 'Administrator'){
echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br/><br/>';
echo '<a href="admin.php">Main Site Admin</a><br/><br/>';
echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk\'></SCRIPT>';
echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk\'></SCRIPT>';
}

 

conversely, instead of escaping them "\'" you could just use double quotes

Link to comment
https://forums.phpfreaks.com/topic/172592-confusion-at-problem/#findComment-909814
Share on other sites

This is wrong

echo '<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk'></SCRIPT>';
echo '<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk'></SCRIPT>';

 

You need to use " around your html attribute values.

echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk"></SCRIPT>';
echo '<SCRIPT type="text/javascript" language="JavaScript" src="http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk"></SCRIPT>';

Link to comment
https://forums.phpfreaks.com/topic/172592-confusion-at-problem/#findComment-909815
Share on other sites

*EDIT*

 

You could also alternatively use heredoc.

 

<?php

if ($stuff['type'] == 'Administrator'){
echo <<<HTML
<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br/><br/>
<a href="admin.php">Main Site Admin</a><br/><br/>
<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk'></SCRIPT>
<SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk'></SCRIPT>
HTML;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/172592-confusion-at-problem/#findComment-909817
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.