hi,
I have a number of variables that i pull from a mysql database. I want 1 of the variables to show as a link to a web page.
i have tried the following code, which displays everything fine, except for the $url bit
echo "<p>$djname $genre $biography <a href='/$url'> Profile</a>"; [/code]
any help would be great
Software/Hardware used:
ASKED:
June 30, 2008 3:21 PM
UPDATED:
June 30, 2008 9:03 PM
What does it output now?
it outputs $djname $genre and $biography fine, but i want a link to be displayed that takes you to their profile. the url ($url)is stored in the table
The code seems okay to me. Are you sure $url has a value? PHP doesn’t require you to pre-declare all values, so if you mistyped $url when you assigned it a value, it could be uninitialized (and thus default to an empty string) here. It could also be a scoping issue; if $url is a global value, remember to declare “global $url” in the function. And if you’re getting the value from a database query, make sure the query is correctly returning a value; if it doesn’t, $row['url'] (or whatever it is) will not be set and will thus default to an empty string. You can test this by doing something like:
Does it output something like this?
If so, I’d check to make sure you’re correctly assigning $url a value. Otherwise, I’ve run out of ideas, sorry. HTH!