www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] MySQL Error

  1. #1
    Join Date
    Jan 2006
    Location
    England UK
    Posts
    200

    resolved [RESOLVED] MySQL Error

    Hi!

    I got a little problem hopefully easy to solve.

    In my admin i have coded that when an administrator adds a new artist they can choose to either make a phpbb forum section for the artist automatically or dont make one, just a checkbox tick to add forum... dont tick no forum. I am sure you get the picture.

    I have created 3 artists as a test, 2 with forums sections and 1 without.

    Artist 1: Has a topic in there forum section.
    Artist 2: Does not have a topic in there forum section.
    Artist 3: Has no forum section.

    Ok so on the artist page in the website, i want to it show the latest 5 topics, now for artist 1 this works no problem. Artist 2 doesnt have a topic so nothing shows which is correct. Artist 3 causes a mysql error... why does it not just show nothing like artist 2?

    Heres my code:

    PHP Code:
    <?

            $resulta 
    mysql_query("SELECT * FROM tartists_forums WHERE artistid = $id");
            
    $rowa mysql_fetch_array($resulta);
            
    $forumid $rowa['forumid'];

            
    $resultb mysql_query("SELECT * FROM phpbb_topics WHERE forum_id = $forumid");
            
    $rowb mysql_num_rows($resultb);  //<<<< Error 1
            
    $c $rowb;
            

            if (
    $c != '0') {

            
    ?>

        <br/><br/><br/><span class="news_title">Forums</span><br/><br/>

            <span class="news_info">You need to be registered on our forums to view these topics.</span><br/><br/>

            <?
            $i
    =1;
            
    $resultc mysql_query("SELECT * FROM phpbb_topics WHERE forum_id = $forumid ORDER BY topic_id ASC LIMIT 0,5");

                while (
    $rowc mysql_fetch_array($resultc)) { //<<<< Error 2

                
    $topicid $rowc['topic_id'];
                
    $topictitle $rowc['topic_title'];

                echo 
    '<span class="news_info">'.$i.': </span> <a href="/forums/viewforum.php?f=' $topicid '" target="_blank" class="view_link">' $topictitle "</a><br>\n";            
                
    $i++;

                }

            }

            
    ?>
    The two errors i am getting are (i have arrowed in the php code where the errors are pointing):

    Code:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
    resource in /home/grand/public_html/test/artists.php on line 525
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
    resource in /home/grand/public_html/test/artists.php on line 541
    Any help would be very greatful

    Thanks
    Aaron
    Last edited by LiL|aaron; 03-12-2008 at 05:39 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    England UK
    Posts
    200
    Hi!

    I worked it out

    PHP Code:
    <?

            $resulta 
    mysql_query("SELECT * FROM tartists_forums WHERE artistid = $id");
            
    $rowa mysql_fetch_array($resulta);
            
    $forumid $rowa['forumid'];

            if (isset(
    $forumid)) {

            
    $resultb mysql_query("SELECT * FROM phpbb_topics WHERE forum_id = $forumid");
            
    $rowb mysql_num_rows($resultb);  
            
    $c $rowb;
            

            if (
    $c != '0') {

            
    ?>

        <br/><br/><br/><span class="news_title">Forums</span><br/><br/>

            <span class="news_info">You need to be registered on our forums to view these topics.</span><br/><br/>

            <?
            $i
    =1;
            
    $resultc mysql_query("SELECT * FROM phpbb_topics WHERE forum_id = $forumid ORDER BY topic_id ASC LIMIT 0,5");

                while (
    $rowc mysql_fetch_array($resultc)) { 

                
    $topicid $rowc['topic_id'];
                
    $topictitle $rowc['topic_title'];

                echo 
    '<span class="news_info">'.$i.': </span> <a href="/forums/viewforum.php?f=' $topicid '" target="_blank" class="view_link">' $topictitle "</a><br>\n";            
                
    $i++;

                }
              }
            }

            
    ?>
    Thanks anyways!

    Aaron

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles