Jump to content

I can't get past this link statement


Recommended Posts



I am stuck trying to get the link/href statement to work. I have tried so many variations but i get a very persistent error. Kindly help


        $count = $count+1;
        $field[$count] = $rows['Member_ID'];
        echo "<tr>
              <td> &nbsp ".$rows['fname'].' '.$rows['lname']."</td> 
              <td> < a href = "$_SERVER['PHP_SELF']?id = $count "> Update </a> </td>

It results in this error

"Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in D:\xampp\htdocs\xampp\MagicLogin\includes\fra_register1.php on line 84".


I have tried the following variations:

           < a href = "$_SERVER['PHP_SELF']? id = <? echo $count; ?> "> Update </a>

            < a href = "$_SERVER['PHP_SELF']?id = <? echo $count; ?> "> Update </a>

            < a href = "$_SERVER['PHP_SELF']? id = <?php echo '.$count.'; "> Update </a>

            < a href = "$_SERVER['PHP_SELF']? id = <? echo '$count'; "> Update </a>   

and maybe a few more I did not keep track of but the error persists and I can't figure it out. Please note that there is no actual variable like "id" that i am using in the statement ($_SERVER['PHP_SELF']? id= ) . So far as I know that only used to pass a value back to the program. This could be very stupid but could someone help me out.






Link to comment
Share on other sites

You need to concatenate the $_SERVER['PHP_SELF'] variable into the string, or wrap it within curly braces

// wrapped in curly braces
echo "
<td> <a href={$_SERVER['PHP_SELF']}?id=$count>U pdate </a></td>

// OR Concatenate

echo "
<td> <a href=".$_SERVER['PHP_SELF']."?id=$count>U pdate </a></td>

Also if you want to output a double quote you need to escape it (\")

echo "
<td> <a href=\"".$_SERVER['PHP_SELF']."?id=$count\">U pdate </a></td>
Edited by Ch0cu3r
Link to comment
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.

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.