1

I am unable to concatenate HERE it would be great if somebody can point out my mistake and let me know what I am doing wrong and how it should be done.

<?php
.
.
while ($query_row = mysql_fetch_assoc($query_run)){             

$id=$query_row['id'];
$firstname=$query_row['firstname'];

echo '<a class="profile" href="profile.php?id=<?php echo $id.' ">'ucfirst' ($firstname);?></a>'; // HERE
.
.
.       
?>

2 Answers 2

2

You are in a <?php (line 1), so you can't use an other tag inside it (in your echo). It should look this way :

echo '<a class="profile" href="profile.php?id='.$id.'">'.ucfirst($firstname).'</a>';
Sign up to request clarification or add additional context in comments.

8 Comments

/profile.php?id=$id thats what my url says but it should say a number not $id
in a php string, $id will be interpreted. so it will be href="profile.php?id=12345"
echo '<a class="profile" href="profile.php?id='.$id.'">'.ucfirst($firstname).'</a>'; i have changed it to this now it works
i will mark this is correct since i only figured half of it and you guys told me how to do the rest and thanks for pointing out what i did wrong
Yes it is, it it mostly the same. just change them, and see if you got errors when launching the code, you'll see if there is a missing/wrong parameter...
|
2

You use php tag inside php tag without close it and your ucfirst treated as a string.

echo '<a class="profile" href="profile.php?id='.$id.'">'.ucfirst($firstname).'</a>'; // HERE

Note:- mysql is deprecated instead use mysqli or pdo

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.