Jump to content

Php Help


kaz
 Share

Recommended Posts

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/deathea/public_html/khaleel/html/userarea.php on line 76

 

Line 76 Reads

 

><font face='Verdana' size='1'>Welcome Back <?php print $_SESSION['user']; 
     // Print out admin links
     if($_SESSION['permission'] > 1){
     <a href = 'modUser.php'>mod user</a>|<a href = 'delUser.php'>del user</a>|<?php
     }
     ?></font>

 

I need help with this, can anyone help me please?

Link to comment
Share on other sites

I don't know about the error specifically, but right now the PHP has a second opening tag in the middle of it and the html within the brackets isn't set up to actually do anything--the PHP engine is trying to render it as PHP and not HTML, I think. Which could be enough to trigger that error.

 

Try:

 

><font face='Verdana' size='1'>Welcome Back <?php print $_SESSION['user'];

if ($_SESSION['permission'] > 1) {

echo "<a href='modUser.php'>mod user</a>|<a href='delUser.php'>del user</a>";

} ?>
</font>

 

One word of warning--the way it's set right now, it would be possible for someone to randomly set up a permission value of, say 1000, and it would print out this bit of menu. If you know the actual permission values of your admin users, it would be better to set up something like

 

>if ($_SESSION'permission'] == (1|2|3)) {

 

I'm not certain that's the exact syntax, but something like that would be more secure--look for an exact permissions match, instead of "any number greater than 1."

Link to comment
Share on other sites

In your original code, you just missed the first closing PHP tag (right before the HTML string):

<font face='Verdana' size='1'>Welcome Back <?php print $_SESSION['user'];

    // Print out admin links

    if($_SESSION['permission'] > 1){

    ?>

    <a href = 'modUser.php'>mod user</a>|<a href = 'delUser.php'>del user</a>|<?php

    }

    ?></font>

Link to comment
Share on other sites

Did not fix all of the code, problem was example

 

><?php
echo'<a href="page.asp?go=shop">Go the shop</a>';
// as you can see, the quotes are " and should be '
?>

 

It should be

 

><?php
echo"<a href='Page.aspx?Go=Shop'>Go the shop</a>";
// quotes are fine and work they should be '
?>

 

Done :) thanks all anyways

Link to comment
Share on other sites

Actually, Kaz, changing the quotes from " to ' in your HTML is not correct, although it will work on many or perhaps most web browsers.

 

What you want to do is type in /" when you are typing a string to be output to the browser and need to have a quote. The backslash is the "escape code" -- it tells PHP "No, this isn't the end of my string; I want to put an ACTUAL quote mark INSIDE the string, please!"

 

><?php
echo "<a href=\"Page.aspx?Go=Shop\">Go the shop</a>";
?>

 

See this link for more complete info on how to format PHP strings: PHP Manual page on string data

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...