Re: defining a variable

From: Date: Sun, 27 Oct 2002 19:20:40 +0000
Subject: Re: defining a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121610@lists.php.net to get a copy of this message
----- Original Message ----- From: "Gary" <garyb10@earthlink.net> To: <php-general@lists.php.net> Sent: Sunday, October 27, 2002 2:00 PM Subject: [PHP] defining a variable > Hi All, > I am have trouble getting $address to print the URL that is in the db. > <td class=\"dtd\"><a href=\"$address\" > target=\"_blank\">%s</a></td> is > printing the url with the word address instead of the real address. > > The code is below. > > $sql ="SELECT * FROM links ORDER BY owner"; > $sql_result = mysql_query($sql, $conn) or die ("couldn't > Connect"); > > while ($myrow = mysql_fetch_array($sql_result)){ > $address = 'address'; ^^^^^ That's what you asking for here. Perhaps you're meaning to do a: printf(" <tr> <td class=\"dtd\"><a href=\"%s\" target=\"_blank\">%s</a></td> <td class=\"dtd\">%s</td> <td class=\"dtd\">%s</td> </tr>\n", $myrow['address'], $myrow['tutorial'], $myrow['owner'], $myrow['category']); }while ($myrow = mysql_fetch_array($sql_result)); Don't just try to change 'address' to $row['address'] abve, because you haven't fetched the result yet, and it will be blank everytime. It needs to be in the fetch() loop.

« previous php.general (#121610) next »