?
Solved

href inside php

Posted on 2011-03-21
14
Medium Priority
?
411 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 1500 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

719 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