By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.php";

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

$moderator_check_query = "SELECT * FROM moderator WHERE category=$cat AND user=$myid";
$moderator_check_exec = mysql_query($moderator_check_query);
$moderator_result = mysql_num_rows($moderator_check_exec);

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

else {
$moderator = 0;
}

if ($moderator == 1) {
$replydelete_query="DELETE FROM reply WHERE id ='$id'";
mysql_query($replydelete_query) or die(mysql_error());
$topicmineen_query="UPDATE topic SET replies='replies -1' WHERE id='$topic'";
mysql_query($topicmineen_query) or die(mysql_error());
echo "<script>location.href='index.php?cat=".$cat."&top ic=".$topic."&page=".$page."'</script>";

}

else {
echo "<script>location.href='index.php?cat=".$cat."&top ic=".$topic."&page=".$page."'</script>";
}}
?>



What i did wrong?
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Try this in line 10

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

Jul 17 '05 #2

P: n/a
[ Followup-To comp.lang.php ]

Arjan wrote:
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>

[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($sql) or die(mysql_error());
// ________________________^^^^^^^^^^^^^^^^^^^^^^_
// ...
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3

P: n/a
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
Jul 17 '05 #4

P: n/a
Ok

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

should be

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

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

Kman

"Plasson" <an****************************@email.it> wrote in message
news:aR*********************@news2.tin.it...
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

Jul 17 '05 #5

P: n/a
Thanx!

"Kman" <km*********@yahoo.com> schreef in bericht
news:U0******************@news20.bellglobal.com...
Ok

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

should be

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

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

Kman

"Plasson" <an****************************@email.it> wrote in message
news:aR*********************@news2.tin.it...
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


Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more PHP Questions on Bytes