0

I want display my button if it have isset($_GET). I am trying to do like this.

<?php if(isset($_GET['project_id'])){
                echo '<div class="add_btn_primary"> <a href="manage_project_users.php?project_id=<?php echo $_GET['project_id'];?>">Project Users</a> </div>';
                }?>

its giving me error like

 Parse error: syntax error, unexpected 'project_id' (T_STRING), expecting ',' or ';' in C:\xamppp\htdocs\mayank\add_project.php on line 101

I am not getting idea what I should do for echo project_id in div. Let me know if someone can help me for that. Thanks

1
  • I typically find that errors looking for , or ; are found before the line flagged in the error call. We would need more of your code to find it, but look at your lines carefully first. If you have a color coded editor, you may find a clue in improperly colored lines. Commented Mar 31, 2019 at 18:13

2 Answers 2

1

Thats incorrect to use echo inside another echo and how can you start a new php tag without closing the first. The correct way is to concatenate the variable along the string passed in echo, here is how

<?php if(isset($_GET['project_id'])){
            echo '<div class="add_btn_primary"> <a href="manage_project_users.php?project_id='.$_GET['project_id'].'">Project Users</a> </div>';
            }?>

instead of breaking the php tags break the ' quotes to concatenate the value in the string.

Sign up to request clarification or add additional context in comments.

Comments

1

Why do you need again tag inside echo just use it as below:

<?php 

if(isset($_GET['project_id']))
{
  echo ('<div class="add_btn_primary"><a href="manage_project_users.php?project_id='.$_GET["project_id"].'>Project Users</a></div>');
}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.