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
Ross

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
Ross

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

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

Ross

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:

<?php
$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
inner
  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
Ross

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.
-->
<html>
<head>
<title>SQL Query Sender</title>
</head>
<body>
<?php
 $user="root";
 $host="localhost";
 $password="";

 /* Section that executes query */
 if (@$form == "yes")
 {
   mysql_connect($host,$user,$password);
   mysql_select_db($database);
   $query = stripSlashes($query) ;
   $result = mysql_query($query);
   echo "Database Selected: <b>$database</b><br>
          Query: <b>$query</b>
          <h3>Results</h3>
          <hr>";
   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>");
   else
   {
     echo "<table border='1'>
           <thead>
            <tr>";
             for ($i = 0; $i < mysql_num_fields($result); $i++)
             {
                 echo("<th>" . mysql_field_name($result,$i) . "</th>");
             }
     echo " </tr>
           </thead>
           <tbody>";
             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>
                  </table>";
   }
   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\">
         </form>";
   unset($form);
   exit();
 }

 /* 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">
 <table>
  <tr>
   <td align="right"><b>Type in database name</b></td>
   <td>
     <input type=text name="database" value=<?php echo $database ?> >
   </td>
  </tr>
  <tr>
   <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>
  </tr>
  <tr>
   <td colspan="2" align="center"><input type="submit" value="Submit
Query"></td>
  </tr>
 </table>
</form>

</body>
</html>

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.