Jump to content

I can't get past this link statement


ajoo

Recommended Posts

Hi,

 

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

 

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

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.

 

Thanks.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/285278-i-cant-get-past-this-link-statement/
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>
</tr>";

// OR Concatenate

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

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>
</tr>";

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.