Solved

href inside php

Posted on 2011-03-21
14
408 Views
Last Modified: 2012-05-11
hi i am trying to add an id from a query to link to that users page but keep getting a error in my code unexpected T_STRING its because i cant get this bit to work: '<a href="users.php?id=' . $row['id']. '"></a>'
0
Comment
Question by:helpchrisplz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 1

Author Comment

by:helpchrisplz
ID: 35182623
here is the full code:

$sqlf = "SELECT friends.UserName,friends.id,friends.UserEmail,images.imgSmall FROM friends JOIN images ON images.memberId = friends.friendID
WHERE friends.activate = '1' AND friends.friendPage = '".$_SESSION['MemberID']."'";
$resultf = mysql_query($sqlf)or die(mysql_error());

while($row = mysql_fetch_array($resultf, MYSQL_ASSOC))
{
      $friendPlayerName = "Player Name: <br>";
$Email = "Players Email: <br>";
$title = "Your Accepted Friends: <br>";

$smallImagef = "{$row['imgSmall']}";
//$friendIDf = "{$row['id']}";
$namef = "{$row['UserName']}";
$UsersEmailf = "{$row['UsersEmail']}";


$show_friends_waitingf .= "<td>$title</td><br><td><img src='$smallImagef'></td><br><td>'<a href="users.php?id=' . $row['id']. '"></a>'</td><td>$friendPlayerName</td><td>$namef</td><br><br><td>$Email</td><td>$UsersEmailf</td>";
}
$show_friends_waitingf .= "</table>";
echo $show_friends_waitingf;
mysql_close($connection);
   
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35182649
Replace it with this:

<a href="users.php?id=" . $row['id']. "">

Open in new window


single quotes to double quotes.
0
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 500 total points
ID: 35182671
You seem to have more faults in your string,
the full line should be like this:

$show_friends_waitingf .= '<td>' . $title . ' </td><br><td><img src=\'' . $smallImagef . '\'></td><br><td>\'<a href="users.php?id=' . $row['id']. '"></a>\'</td><td>' . $friendPlayerName . '</td><td>' . $namef . '</td><br><br><td>' . $Email . '</td><td>' . $UsersEmailf . '</td>';

Open in new window

0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Author Comment

by:helpchrisplz
ID: 35182705
ok i get the error still: syntax error, unexpected T_STRING

this is what i have now:
$show_friends_waitingf .= "<td>$title</td><br><td><img src='$smallImagef'></td><br><td><a href="users.php?id=" . $row['id']. ""></td><td>$friendPlayerName</td><td>$namef</td><br><br><td>$Email</td><td>$UsersEmailf</td>";
}
$show_friends_waitingf .= "</table>";
echo $show_friends_waitingf;

 help
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35182717
See my latest reply for the correct version.
0
 
LVL 1

Author Comment

by:helpchrisplz
ID: 35182719
your quick i am looking at your last post now...... thx
0
 
LVL 2

Expert Comment

by:k_romych
ID: 35182729
try it like this
     
     <a href=\"users.php?id=$row['id']\">
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 35182865
try this:

printf('<a href="users.php?id=%s">%s</a>',$row['id'],'The Link Title');
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 35182892
Also... based on your screenshot, it appears the code highlighting is telling you that you have an extra quote far before the line in question.

What are you using? Dreamweaver or npp?
0
 
LVL 1

Author Comment

by:helpchrisplz
ID: 35182923
help

using:
$show_friends_waitingf .= '<td>' . $title . ' </td><br><td><img src=\'' . $smallImagef . '\'></td><br><td>\'<a href="users.php?id=' . $row['id']. '"></a>\'</td><td>' . $friendPlayerName . '</td><td>' . $namef . '</td><br><br><td>' . $Email . '</td><td>' . $UsersEmailf . '</td>';

Every thing is getting added to the table but where the href id is supposed to be there is '' and no link
the table does have content for id and if i add row id to a variable after the query it is populating the variable so am unsure why its showing as ''
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35183120
Check your code to see if $row['id'] gets populated and debug to see where it goes wrong.
0
 
LVL 1

Author Comment

by:helpchrisplz
ID: 35186420
i just removed the table as it was doing my head in

while

echo '<img src='. $row['imgSmall'].'><br>';
echo '<a href="users.php?id='. $row['ID']. '">' . $row['playername'] . '</a><br>';
echo $row['UserEmail'].'<br><br>';
0
 
LVL 8

Expert Comment

by:Rik-Legger
ID: 35188635
Answer given for initial question.
0
 
LVL 1

Author Closing Comment

by:helpchrisplz
ID: 35191089
ok you helped
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question