MegaSack DRAW - This year's winner is user - rgwb
We will be in touch
Having trouble getting php to display the content of a text field
from mySQL
$result = mysql_query($sql);
.
.
.
$row = (mysql_fetch_assoc($result));
.
.
$Content = $row['Content'];
.
.
echo $Content;
Resolved!
used the mysql_result command instead.
Have you checked that you're actually getting something back?
[code]if (mysql_num_rows($result) == 0) {
echo "No rows returned.";
exit;
}[/code]
Nothing leaps out as wrong, but a quick guess would be to replace
[code]$Content = $row['Content'];[/code]
with
[code]$Content = $row["Content"];[/code]
I assume you're only expecting the one result back?
In your first example you need to itterate over the associative array returned by mysql_fetch_assoc e.g.
$query = "select * from blah where something = somethingelse";
$result = mysql_fetch_assoc($query);
foreach ($row in $result) {
echo $row['column_1'];
}
If you want to see the value of any variable in PHP, use the print_r() command. e.g.
print_r($Content);
in your example would have shown you a string representation of your resultset.
$Content = $row['Content'];
with
$Content = $row["Content"];
would only make a difference if the quoted string contained escapes like "\n", which are only translated with double quotes
Or contained variables...
