PHP Issue

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Post Reply
User avatar
Grinch
Site Admin
Site Admin
Posts: 2170
Joined: Sat Jan 24, 2004 2:02 pm
Location: Martinsburg, WV

I know nothing about PHP but I have a problem that needs to be fized.

If you go to here you will see the error.

Here is the code, the bolded section is the line in question:

Code: Select all

$category = "";
$getposts = mysql_query("SELECT * FROM $posts_tbl ORDER BY Timestamp DESC LIMIT
    $showposts_is");
    while ($row = mysql_fetch_array($getposts)) {
    $postid = $row[PostID];
    $timestamp = $row[Timestamp];
    $date = date($postdatepattern_is,$timestamp);
    $pagetitle = $row[Title];
    $body = $row[Body];
    $catid = $row[PostCat];
    $catid2 = $row[PostCat2];
    $catid3 = $row[PostCat3];
    $catid4 = $row[PostCat4];
    $comms = mysql_query("SELECT CommID FROM $comments_tbl WHERE PostID=$postid");
    $countcomms = mysql_num_rows($comms);
        if($catid == "") {$category .= "";} else {
            $getcatname = mysql_query("SELECT PostCat, PostCatUrl FROM $postcat_tbl WHERE
                PCatID='$catid'");
            while ($cat = mysql_fetch_array($getcatname)) {
            $category .= "<a href=\"archive.php?cat=$cat[PostCatUrl]\">$cat[PostCat]</a>, ";
            }
        }
        if($catid2 == "") {$category .= "";} else {
            $getcatname = mysql_query("SELECT PostCat, PostCatUrl FROM $postcat_tbl WHERE
                PCatID='$catid2'");
            while ($cat = mysql_fetch_array($getcatname)) {
            $category .= "<a href=\"archive.php?cat=$cat[PostCatUrl]\">$cat[PostCat]</a>, ";
            }
        }
        if($catid3 == "") {$category .= "";} else {
            $getcatname = mysql_query("SELECT PostCat, PostCatUrl FROM $postcat_tbl WHERE
                PCatID='$catid3'");
            while ($cat = mysql_fetch_array($getcatname)) {
            $category .= "<a href=\"archive.php?cat=$cat[PostCatUrl]\">$cat[PostCat]</a>, ";
            }
        }
        if($catid4 == "") {$category .= "";} else {
            $getcatname = mysql_query("SELECT PostCat, PostCatUrl FROM $postcat_tbl WHERE
                PCatID='$catid4'");
            while ($cat = mysql_fetch_array($getcatname)) {
            $category .= "<a href=\"archive.php?cat=$cat[PostCatUrl]\">$cat[PostCat]</a>, ";
            }
        }
        $category = substr($category, 0, -2);
        if($category == "") $category = "no category";
        
    
    $prev_next = NULL;
    $prevlink = mysql_query("SELECT PostID FROM $posts_tbl WHERE Timestamp<'$timestamp' ORDER BY Timestamp DESC LIMIT 1");
    $prevcount = mysql_num_rows($prevlink);
    while ($row = mysql_fetch_array($prevlink)) {$prev = $row[PostID];}
    if($prevcount > 0) {$prev_next .= "<a href=\"permalink.php?PostID=$prev\">Previous Post</a> || ";
    } else {$prev_next .= "Previous Post || ";}
    
    $nextlink = mysql_query("SELECT PostID FROM $posts_tbl WHERE Timestamp>'$timestamp' ORDER BY Timestamp ASC LIMIT 1");
    $nextcount = mysql_num_rows($nextlink);
    while ($row = mysql_fetch_array($nextlink)) {$next = $row[PostID];}
    if($nextcount > 0) {$prev_next .= "<a href=\"permalink.php?PostID=$next\">Next Post</a>";
    } else {$prev_next .= "Next Post";}

    $use_template = array("{TITLE}" => $pagetitle,"{POST_ID}" => $postid,
        "{DATE}" => $date,"{BODY}" => $body,"{COMMENT_COUNT}" => $countcomms,
        "{CATEGORY}" => $category,"{PREV_NEXT}" => $prev_next);
    if ($file = implode('', file("template/blog.htm"))) {
        foreach($use_template as $key => $value) {
            $file=@str_replace($key,$value,$file);
        }
        echo $file;
    }
    
    $category = NULL;

}
This is the line that is causing problems:

Code: Select all

while ($row = mysql_fetch_array($getposts)) {
PHP geniuses please help me.
KrazyKid
A Forum Addict
A Forum Addict
Posts: 69
Joined: Tue May 24, 2005 6:07 am
Location: Ashland, WI
Contact:

Post your problem on webmasterworld.com. Someone will most likely help you there. You aren't allowed to post url there though, so I don't know how that will work out. Good luck
KrazyKid
My new site is up!
thatothersite.net
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Looks ok to me, but sometimes crazy things happen, and I have found that it sometimes fixes it.

Code: Select all

while ($row = mysql_fetch_array($getposts)) {
Replace with:

Code: Select all

while ($row = mysql_fetch_assoc($getposts)) {
Let me know how it goes
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
Grinch
Site Admin
Site Admin
Posts: 2170
Joined: Sat Jan 24, 2004 2:02 pm
Location: Martinsburg, WV

I contacted the creator and he has a new version coming out in a few days so I will wait till then and will check it out.
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Ok, congratulations on your 1500 posts :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

This is almost a close fit to the thread (and I don't think it's a big enough issue to get a new thread):

Battye, didn't you link to a php-based guestbook program a while back that doesn't require a database? I tried searching it, but I don't know where it went.
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Yeah, I made a program called PetitionMX which runs without a database: http://forums.cricketmx.com/viewtopic.php?t=2248

Despite it being made for Petitions, it will work fine for guestbooks.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

Heh, no wonder I couldn't find the thing. I had guestbook stuck in my head.
Post Reply