SitePoint Sponsor

User Tag List

Results 1 to 24 of 24

Thread: warning!!

  1. #1
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    warning!!

    what cause the problem when i get this kind of warning:

    Warning: Supplied argument is not a valid MySQL result resource in /usr/local/plesk/apache/vhosts/certifyexpress.com/httpdocs/exam/test/index.php on line 145

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mm, could you provide us your code? It will be more easy to find the reason.

    Paul

  3. #3
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is line 145 from index.php:

    PHP Code:
    $result mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '0' ORDER BY quiz_name");
        if (
    mysql_num_rows($result) > 0) {
            for (
    $i=0;$i<mysql_num_rows($result);$i++) {
                list(
    $quiz_id$quiz_name$quiz_desc) = mysql_fetch_row($result);
                list(
    $ttl_taker) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM quirex_record WHERE quiz_id = '$quiz_id'"));
                if (
    $ttl_taker 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder "$language[na]";}
                
                print 
    "<tr>";
                print 
    "<td bgcolor=$table_color_2 align=right><input type=radio name=quiz value=\"$quiz_id\"></td>";
                print 
    "<td bgcolor=$table_color_2 width=90%><font face=\"$font_face\" color=\"$font_color\" size=2><b>$quiz_name</b><br><font size=1>$quiz_desc</font></font></td>";
                if (
    $show_record) {
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=recent\">$ttl_taker</a></font></td>";
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=top\">$record_holder</a></font></td>";
                    }
                print 
    "</tr>\n";
                
                }
                
            }

        
    $result mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '1' ORDER BY quiz_name");
        if (
    mysql_num_rows($result) > 0) {
            print 
    "<tr><td bgcolor=$table_color_1 colspan=$colspan><font face=\"$font_face\" color=\"$font_color\" size=3><b><i>$level_name_1</i></b></font></td></tr>\n";
            print 
    "<tr><td>&nbsp;</td></tr>";
            for (
    $i=0;$i<mysql_num_rows($result);$i++) {
                list(
    $quiz_id$quiz_name$quiz_desc) = mysql_fetch_row($result);
                list(
    $ttl_taker) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM quirex_record WHERE quiz_id = '$quiz_id'"));
                if (
    $ttl_taker 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder "$language[na]";}
                
                print 
    "<tr>";
                print 
    "<td bgcolor=$table_color_2 align=center><input type=radio name=quiz value=\"$quiz_id\"></td>";
                print 
    "<td bgcolor=$table_color_2 width=90%><font face=\"$font_face\" color=\"$font_color\" size=2><b>$quiz_name</b><br><font size=1>$quiz_desc</font></font></td>";
                if (
    $show_record) {
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=recent\">$ttl_taker</a></font></td>";
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=top\">$record_holder</a></font></td>";
                    }
                print 
    "</tr>\n";
                }
            }

        
    $result mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '2' ORDER BY quiz_name");
        if (
    mysql_num_rows($result) > 0) {
            print 
    "<tr><td>&nbsp;</td></tr>";
            print 
    "<tr><td bgcolor=$table_color_1 colspan=$colspan><font face=\"$font_face\" color=\"$font_color\" size=3><b><i>$level_name_2</i></b></font></td></tr>\n";
            print 
    "<tr><td>&nbsp;</td></tr>";
            for (
    $i=0;$i<mysql_num_rows($result);$i++) {
                list(
    $quiz_id$quiz_name$quiz_desc) = mysql_fetch_row($result);
                list(
    $ttl_taker) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM quirex_record WHERE quiz_id = '$quiz_id'"));
                if (
    $ttl_taker 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder "$language[na]";}
                print 
    "<tr>";
                print 
    "<td bgcolor=$table_color_2 align=center><input type=radio name=quiz value=\"$quiz_id\"></td>";
                print 
    "<td bgcolor=$table_color_2 width=90%><font face=\"$font_face\" color=\"$font_color\" size=2><b>$quiz_name</b><br><font size=1>$quiz_desc</font></font></td>";
                if (
    $show_record) {
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=recent\">$ttl_taker</a></font></td>";
                    print 
    "<td bgcolor=$table_color_2 align=center><font face=\"$font_face\" color=\"$font_color\" size=1><a href=\"$script?quiz=$quiz_id&show=top\">$record_holder</a></font></td>";
                    }
                print 
    "</tr>\n";
                }
            }
        
    $result mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '3' ORDER BY quiz_name"); 
    the whole script is too long, so i just paste part of it.

  4. #4
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    call me crazy, but that looks like more than one line
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  5. #5
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry....
    the warning is from line 145 to line 204. so i cut the whole thing out.

    and i missed out something, when i include a php header inside this index.php, this warning will only appear. if i include a normal header, then no warning!!

  6. #6
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, that's too much code
    Ok, try this

    $result = mysql_query('SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level =0 ORDER BY quiz_name');

    if (!$result)
    echo mysql_error();

    By the way if quiz_leves is a numeric field you don't need to quote the value.
    Let me know if that give you an error message from mysql.

  7. #7
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your SELECT query on line 145 must be getting the wrong pointer... i had that problem before but i didn't know how to solve it...

    PHP gurus some help please?

  8. #8
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by joyce
    when i include a php header inside this index.php, this warning will only appear. if i include a normal header, then no warning!!
    what do you mean by header? I don't get it.

  9. #9
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by redemption
    your SELECT query on line 145 must be getting the wrong pointer... i had that problem before but i didn't know how to solve it...
    Actually I got this error once, it turned out my table was damaged. But I could fix it. Although I'm not sure is this is the only reason for this problem

  10. #10
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i include a file called header.php...and this error appear.

    when i include header.shtml, then everything is ok.

  11. #11
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    weird, what do you have in that file, could you list it here?

  12. #12
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in my header.php, i've include all these files:

    PHP Code:

    include ("../../forum/homelogin.php");
             
     include (
    "http://www.certifyexpress.com/forum/registered.php");

    include (
    "http://www.certifyexpress.com/forum/online3.php");

    $random_poll 1;
    require(
    "/usr/local/plesk/apache/vhosts/certifyexpress.com/httpdocs/poll/booth.php"); 
    i tried ur code, paul..
    i still have the warnings....and also this:

    Table 'poll.quirex_list' doesn't exist.

    i've checked my table 'quirex_list'. i dont' have any record in it..and i dont' have poll either..

  13. #13
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, poll is the name of the database, you have it, haven't you?

    Ok, let me see if I understand this. You are selecting rows from quirex_list but it's empty.
    Sounds like your table is damaged.
    Do you have access with telnet to your database?

  14. #14
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no...the name of my database is 'testexam'.
    i've insert one record in my database, but the error stil there.
    i dont' see the word 'poll' in my database.

  15. #15
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, just to be clear you have a database called testexam, inside this there's your quirex_list table.
    i've insert one record in my database, but the error stil there.
    You only can insert records into your table, which are inside the database.

  16. #16
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry...wat i mean is i insert one record in the table quirex_list .

  17. #17
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, this is only a idea, which database you are selecting? Before the queries,

    look for the code mysql_select_db()
    Maybe inside header.php you have selected other database.

  18. #18
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in all the include files i have in header.php, each of them selecting different database. and in this, i select database called testexam.

    will it overwrite each other?

  19. #19
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, then before line 145 (after incluiding the header file) write

    mysql_select_db(you_database_where_quirex_list_lives);

  20. #20
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm...i've did that.....
    still cannot..

  21. #21
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you still getting the same error message?

  22. #22
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    paul: i've solved the problem already. seems that the way i include the header.php is wrong, and caused all these warnings. thanks paul!! for helping..

  23. #23
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm glad to hear that, so where was exactly the problem?

  24. #24
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm..i include the header.php after the mysql_select_db(); therefore, i have errors, because the header.php overwrite my database.

    i have to include the header.php before the mysql_select_db()..then my databse won't overwrite.


Bookmarks

Posting Permissions

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