Code: Select all
<?php
$list_categories2 = mysql_query("SELECT * FROM wp_categories");
while ($row3 = mysql_fetch_row($list_categories2)) {
echo "<li><a href='$row3[3]'>$row3[1]</a></li>";
}
?>Just so you know I'm still new at php/mysql.
Moderator: General Moderators
Code: Select all
<?php
$list_categories2 = mysql_query("SELECT * FROM wp_categories");
while ($row3 = mysql_fetch_row($list_categories2)) {
echo "<li><a href='$row3[3]'>$row3[1]</a></li>";
}
?>Unfortunately, this shouldn't have any baring on the problems hgmmy is experiencing.VladSun wrote:It is maybe the 5th thread about this problem this week ... You can't concatenate array items in the way you do it - you have to use surrounding {} or using the "." operator.
E.g.
"bla-bla {$array['key']} bla-bla"
or
"bla-bla ".$array['key']." bla-bla"
I don't see anything incorrect in your code, although it would be easier for you and others to read and debug your code if you adopted the practice of using mysql_fetch_assoc() instead of mysql_fetch_row(), which returns an array with the associated field names so that you can more easily use the names, something like this:hgmmy wrote:What's wrong with this code?I have almost that exact same thing in another spot, with the only differences being $row3 is $row and $lst_categories is $list_pages, and it works fine. What it should be doing is accessing a data base were there is a list of links to different categories, but it's changing the value of $row3 in the echo section so that it's getting the wrong data.Code: Select all
<?php $list_categories2 = mysql_query("SELECT * FROM wp_categories"); while ($row3 = mysql_fetch_row($list_categories2)) { echo "<li><a href='$row3[3]'>$row3[1]</a></li>"; } ?>
Just so you know I'm still new at php/mysql.
Code: Select all
$list_categories2 = mysql_query("SELECT * FROM wp_categories") or die("Failed: ".mysql_error());
while ($row3 = mysql_fetch_assoc($list_categories2)) {
echo "<li><a href="$row3['url']">$row3['name']</a></li>";Code: Select all
echo $sql;