Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.