Hi there.

I'm very very new to php. :o so i hope i'm posting in the right forum.
and i really can't figure this out. probably really simple but i need to place a url into:

while ($row = mysql_fetch_array($result)) {
echo $row;
echo "&nbsp;" . $row . "<br>";

everytime i place <a href= etc i get errors. :sad:

I need the login to link to the user's profile page.

Please could anybody help??

Kind Regards

Suppose you have the code:

echo "$value";

Everything within the quotes is printed out. However, now take the following code:

echo "<a href="$value">";

PHP gets confused where you have quotes within quotes. Therefore, if you want to print out a real quote inside an echo statement, you have to escape the " character with a backlash. Like this ...

echo "<a href=\"$value\">";

:confused: so it would be something like:

echo "<a href=member.php?mid=$m[id]\"$row\">";


said i'm new at this, sorry :o

Thanks for the quick reply

Kind Regards

:sad: unfortunatly none of the ways i try seem to work.

i don't think i'm cut out for this php thing.


Practice makes perfect.

echo "<a href=\"member.php?mid=$row[mid]\">$row[login]</a>";

I'm not exactly sure what $m[id] is ? Where are you fetching that $m[] array from?

generally when u pull it from mysql you would reference the item you want by column number, so....
if your query was something to this effect:

$result = mysql_query("SELECT login,age FROM some_table WHERE user_name='".$user.'");
$row = mysql_fetch_row($result);

$login = $row[0];
$age = $row[1];

$link = "<a href=\"members.php?mid=".$login."\">".$age."</a>

Hello. thanks for all your help, both of you, :D

what i currently have is:

$result = mysql_query("select P.id
     , M.login
     , dayofmonth(P.birthdate) as birth_day
     , month(P.birthdate)      as birth_month
     , year(current_date) 
      -year(P.birthdate)       as age
  from profiles  as P
  join members as M
    on P.id = M.id  
 where dayofmonth(current_date) = dayofmonth(P.birthdate)
   and month(current_date)      = month(P.birthdate)") or die("Query failed: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
echo "<a href=\"member.php?mid=$row[mid]\">$row[login]</a>";
echo "&nbsp;" . $row['age'] . "<br>";


which does give me the linked login name that i was after ;)
but the link doesnt point to the users profile :sad:

I wanted it as a todays birthdays list with login name and age, but the tables for login and birthdate was in seperate locations so i ended up with the above.

can you see what i am doing wrong here? :cry:

Kind Regards

i don't know, maybe it's a problem with your sql query?
can you login via ssh/telnet and double check to see if that works?

if not here is a PHP interface:

<!-- Program Name: mysql_send.php
     Description: PHP program that sends an SQL query to the
                  MySQL server and displays the results.
<title>SQL Query Sender</title>

 /* Section that executes query */
 if (@$form == "yes")
   $query = stripSlashes($query) ;
   $result = mysql_query($query);
   echo "Database Selected: <b>$database</b><br>
          Query: <b>$query</b>
   if ($result == 0)
      echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");

   elseif ( <email protected>($result) == 0)
      echo("<b>Query completed. No results returned.</b><br>");
     echo "<table border='1'>
             for ($i = 0; $i < mysql_num_fields($result); $i++)
                 echo("<th>" . mysql_field_name($result,$i) . "</th>");
     echo " </tr>
             for ($i = 0; $i < mysql_num_rows($result); $i++)
                echo "<tr>";
                $row = mysql_fetch_row($result);
                for ($j = 0; $j < mysql_num_fields($result); $j++)
                  echo("<td>" . $row[$j] . "</td>");
                echo "</tr>";
             echo "</tbody>
   echo "<hr><br>
         <form action=$PHP_SELF method=post>
          <input type=hidden name=query value=\"$query\">
          <input type=hidden name=database value=$database>
          <input type=submit name=\"queryButton\" value=\"New Query\">
          <input type=submit name=\"queryButton\" value=\"Edit Query\">

 /* Section that requests user input of query */
 @$query = stripSlashes($query);
 if (@$queryButton != "Edit Query")
   $database = " ";
   $query = " ";

<form action=<?php echo $PHP_SELF ?>?form=yes method="post">
   <td align="right"><b>Type in database name</b></td>
     <input type=text name="database" value=<?php echo $database ?> >
   <td align="right" valign="top"><b>Type in SQL query</b></td>
  <td><textarea name="query" cols="60" rows="10"><?php echo $query ?></textarea>
   <td colspan="2" align="center"><input type="submit" value="Submit


this has always proved a big help in my dire times of need with SQL debugging

you saved my life with this thread, , thanks !

you can use this tested ok

echo '<a href="'."/yourlink.php?id=".$row['id'].'">'.$row['type'].'</a>';
commented: I'm sure they've been just salivating waiting your response for the last 4.5-years. Check thread dates before you post. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.