mysql_num_rows(): supplied argument is not a valid MySQL result resource

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arjan

    mysql_num_rows(): supplied argument is not a valid MySQL result resource

    I've got the following error:
    Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/wbdfdart/public_html/wbdfforum/verwijder.php on line 13

    verwijder.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    <?php
    include "connect.ph p";

    if (isset ($cat) AND isset ($topic) AND isset ($message)) {
    $query = "SELECT user FROM reply WHERE id='$message'";
    $exec = mysql_query($qu ery);
    $result = mysql_fetch_arr ay($exec);
    $owner = $result["user"];

    $moderator_chec k_query = "SELECT * FROM moderator WHERE category=$cat AND user=$myid";
    $moderator_chec k_exec = mysql_query($mo derator_check_q uery);
    $moderator_resu lt = mysql_num_rows( $moderator_chec k_exec);

    if ($moderator_res ult == 1 OR $owner == $myid) {
    $moderator = 1;
    }

    else {
    $moderator = 0;
    }

    if ($moderator == 1) {
    $replydelete_qu ery="DELETE FROM reply WHERE id ='$id'";
    mysql_query($re plydelete_query ) or die(mysql_error ());
    $topicmineen_qu ery="UPDATE topic SET replies='replie s -1' WHERE id='$topic'";
    mysql_query($to picmineen_query ) or die(mysql_error ());
    echo "<script>locati on.href='index. php?cat=".$cat. "&topic=".$topi c."&page=".$pag e."'</script>";

    }

    else {
    echo "<script>locati on.href='index. php?cat=".$cat. "&topic=".$topi c."&page=".$pag e."'</script>";
    }}
    ?>



    What i did wrong?
  • Lars Raube

    #2
    Re: mysql_num_rows( ): supplied argument is not a valid MySQL result resource

    Try this in line 10

    $moderator_chec k_query = "SELECT * FROM moderator WHERE category='$cat' AND user='$myid'";

    Comment

    • Pedro Graca

      #3
      Re: mysql_num_rows( ): supplied argument is not a valid MySQL result resource

      [ Followup-To comp.lang.php ]

      Arjan wrote:[color=blue]
      > Content-Type: text/html;
      > charset="iso-8859-1"
      > Content-Transfer-Encoding: quoted-printable
      >
      ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      ><HTML><HEAD>[/color]
      [big snip]

      This does not look like php to me.


      check the return value from mysql_query().

      <?php
      $sql = "select col1, col2 from table where col3='XYZ'";
      $result = mysql_query($sq l) or die(mysql_error ());
      // _______________ _________^^^^^^ ^^^^^^^^^^^^^^^ ^_
      // ...
      ?>
      --
      --= my mail box only accepts =--
      --= Content-Type: text/plain =--
      --= Size below 10001 bytes =--

      Comment

      • Plasson

        #4
        Re: mysql_num_rows( ): supplied argument is not a valid MySQL result resource

        What i did wrong?

        Many things, probably.



        Let me know if it worked - untested.

        A.

        --
        My homepage


        My portfolios





        Comment

        • Kman

          #5
          Re: mysql_num_rows( ): supplied argument is not a valid MySQL result resource

          Ok

          $moderator_chec k_query = "SELECT * FROM moderator WHERE category=" . $cat .
          " AND user=" . $myid;

          should be

          $moderator_chec k_query = "SELECT * FROM moderator WHERE category=" . $cat .
          " AND user='" . $myid."'";

          or more simply
          $moderator_chec k_query = "SELECT * FROM moderator WHERE category=' $cat' AND
          user=' $myid' ";

          Kman



          "Plasson" <antonio.bonann oSTOSPAMMHAROTT O@email.it> wrote in message
          news:aRyDb.2188 45$hV.8559841@n ews2.tin.it...[color=blue]
          > What i did wrong?
          >
          > Many things, probably.
          >
          > http://nopaste.php.cd/5795
          >
          > Let me know if it worked - untested.
          >
          > A.
          >
          > --
          > My homepage
          > http://antoniobonanno.debris.it/
          >
          > My portfolios
          > http://www.debris.it/whois.php?i=6
          > http://www.usefilm.com/photographer/19053.html
          > http://www.photosig.com/go/users/view?id=99395
          >
          >[/color]


          Comment

          • Arjan

            #6
            Re: mysql_num_rows( ): supplied argument is not a valid MySQL result resource

            Thanx!

            "Kman" <kman_career@ya hoo.com> schreef in bericht
            news:U0SEb.5761 $vT2.36643@news 20.bellglobal.c om...[color=blue]
            > Ok
            >
            > $moderator_chec k_query = "SELECT * FROM moderator WHERE category=" . $cat[/color]
            ..[color=blue]
            > " AND user=" . $myid;
            >
            > should be
            >
            > $moderator_chec k_query = "SELECT * FROM moderator WHERE category=" . $cat[/color]
            ..[color=blue]
            > " AND user='" . $myid."'";
            >
            > or more simply
            > $moderator_chec k_query = "SELECT * FROM moderator WHERE category=' $cat'[/color]
            AND[color=blue]
            > user=' $myid' ";
            >
            > Kman
            >
            >
            >
            > "Plasson" <antonio.bonann oSTOSPAMMHAROTT O@email.it> wrote in message
            > news:aRyDb.2188 45$hV.8559841@n ews2.tin.it...[color=green]
            > > What i did wrong?
            > >
            > > Many things, probably.
            > >
            > > http://nopaste.php.cd/5795
            > >
            > > Let me know if it worked - untested.
            > >
            > > A.
            > >
            > > --
            > > My homepage
            > > http://antoniobonanno.debris.it/
            > >
            > > My portfolios
            > > http://www.debris.it/whois.php?i=6
            > > http://www.usefilm.com/photographer/19053.html
            > > http://www.photosig.com/go/users/view?id=99395
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...