<?php 
/* declar some relevant variables */
$Host = "localhost"; //location of mySQL on server
$User = "michael"; //my username
$Pass = "koolaide"; //my password
$Name = "phpaccess"; //name of the database to be used
$Table = "info"; //name of the table within the database
 
		 mysql_connect ($Host, $User, $Pass, $Name, $Table) or die ("unable to connect to database");
		 mysql_select_db("$Name") or die ("unable to select DB");
		 $sqlquery = "SELECT * FROM $table WHERE opinion = 'is greate'";
		 $result = mysql_query($sqlquery);
		 $number = mysql_num_rows($result); //LINE NUMBER 23
 
$i = 0;
if ($number < 1) 
{
	echo "<center><p>There were no results for your search</p></center>";
}
else 
{
	while ($number > $i) 
	 {
	 $thename = mysql_result ($result, $i, "name");
	 $theemail = mysql_result ($result, $i, "email");
	 echo "<p><b>Name:</b></p> $thename<br /><b>E-Mail:</b>$theemail</p>";
		 $i++;
	 }
}
?>

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\www\databaseconnect.php on line 23
i get that error, ive commented line number twentythree. this is just a database tutorial that im working on and i hope that maybe someone can tell me whats goin on.

o and dont worry about the username password stuff, this server will never go online, this is all practice stuff.

(line twenty three is in reference to the entire php file, this is only part of it, i left out the <html> tags part)

You defined the variable "$Table" with a capital T, yet you try to interpolate it in the querystring with a lower case "t." PHP is case sensitive for user defined variables.

wow thanks that fixed it, but im not sure if i got the output i am supposed to get. though i plan on working on this a little more. thanks for the help i didnt even notice that. maybe from now i should just try to work with my variables in lowercase.

That's usually best. Saves a lot of hassle.

now im very happy! i have a submit form which writes to a database, a submitted form which displays what has just been submitted, and a database forms which displays all information that has been submitted.

i plan on posting it in the snipits area.

wow thanks that fixed it, but im not sure if i got the output i am supposed to get. though i plan on working on this a little more. thanks for the help i didnt even notice that. maybe from now i should just try to work with my variables in lowercase.

Glad you were able to get it working! Yeah, I usually keep my variables lower case. The only place I use capital letters are in classes.

i plan on posting it in the snipits area.

Yes, definitely. I'm sure people will find it helpful! :cool:

I am having the same problem
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Abyss Web Server\htdocs\getrecord.inc on line 6
how ever this is my code


<?php
// version 1.1
$qstr = "SELECT * from members where id = '1' ";
$result = mysql_query($qstr);

if (mysql_num_rows($result)) // check login info is correct
{
$username = mysql_result($result,0, "username");
$password = mysql_result($result,0, "password");
echo "<b>The username:</b> $username<br>";
echo "<b>The password:</b> $password<br>";
}
else echo "ERROR - unable to find current username and password!";
mysql_close();
?>

please someone help me

I have this problem and i am new so please go slow...

error on page

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 17

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 13

--------

<?php
//
// TYPES:
//
// CDS DVDS CLOTHING KEYRINGS/BOTTLEOPENERS FLAGS OFFERS TICKETS
//
// 1 2 3 4 5 6 7
//
$query = "SELECT * FROM config WHERE id=3";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$query = "SELECT * FROM items WHERE id=".$row." ORDER BY id DESC Limit 0,1";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row;
$name = $row;
$desc = $row;
$price = $row;
$img = $row;
$menu = $row;
$frase = $desc;
$char = 180;
$desc = checklenght($frase, $char);

$content = $namet.$name.$desct.$desc.$pricet.'£'.$price;

?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" rowspan="2" class="image" align="center"><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_enlarge.gif" border="0" /></a><br/><br/><img src="products/<?php print $img; ?>" width="95" height="95" border="0" /></td>
<td valign="top" class="item-main"><b><?php print $content; ?></b></td>
</tr>
<tr>
<td valign="top"><img src="images/item_order1.gif" border="0" /><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_order2.gif" border="0" /></a></td>
</tr>
</table>
<br />
<?php
}
}
?>
<b>Welcome...</b></span>
<br />
<br />
<span style="font-size: 14px; ">
<?php
$query = "SELECT * FROM config WHERE id=1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$introtext = $row;
$introtext = nl2br($introtext);
print $introtext;
?>
</span></b>


hope someone can help

lexi

I am having the same problem
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Abyss Web Server\htdocs\getrecord.inc on line 6
how ever this is my code


<?php
// version 1.1
$qstr = "SELECT * from members where id = '1' ";
$result = mysql_query($qstr);

if (mysql_num_rows($result)) // check login info is correct
{
$username = mysql_result($result,0, "username");
$password = mysql_result($result,0, "password");
echo "<b>The username:</b> $username<br>";
echo "<b>The password:</b> $password<br>";
}
else echo "ERROR - unable to find current username and password!";
mysql_close();
?>

please someone help me

you should check the id field type is it int or varchar ???

For those who got a error with the num rows, I suggest you add the error dispaly for the sql error message.

if(!$result){die(mysql_error();}

Stick that below the query, it will give a specific message about what is wrong with the query. There isn't a problem with the num_rows function usually, but with the actual query itsself.

Recap on above Post.

If your having an error with mysq_num_rows($res).
Basically you need to verify that your query worked ok.
Code for having error checking setup is.

$ret = mysql_query($query) or die(mysql_error());

This will output the error that is being caused at the query stage.

Same applies to Lexid2002.
you're getting an error on fetch_assoc(), as theres a problem at the query stage.
This can be identified by doing the above code.. adding ' or die(mysql_error()); to the end of the line.

Once you have sorted the query, the mysql_fetch_assoc, will have a valid resource, and you'll not get this error.

I always forget about the "or die..." thing.

Hopefully it should point out whether it was just a simple sql or connection problem.

Adding or die(mysql_error()) after a query is a poor way to back out. It would be better to call a function to handle the error than to simply kill the page (possibly even loading a separate error page and/or an automated error reporting system). Besides, do you want someone to see what table names, column names, etc.. you were using in your query?

Wow, wow Infarction calm down.
You're jumping the gun a little for these guys.
They're not ready for advanced error handling techniques.
They're just getting to grips with mySQL techniques.
Need to give them a chance to understand how things work, before you can introduce new techniques to them.

Keep plodding along guys, it will make more sense in time. ;)

I have this problem and i am new so please go slow...

error on page

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 17

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/loyalist/public_html/shop/pages/0.php on line 13

--------

<?php
//
// TYPES:
//
// CDS DVDS CLOTHING KEYRINGS/BOTTLEOPENERS FLAGS OFFERS TICKETS
//
// 1 2 3 4 5 6 7
//
$query = "SELECT * FROM config WHERE id=3";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$query = "SELECT * FROM items WHERE id=".$row." ORDER BY id DESC Limit 0,1";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row;
$name = $row;
$desc = $row;
$price = $row;
$img = $row;
$menu = $row;
$frase = $desc;
$char = 180;
$desc = checklenght($frase, $char);

$content = $namet.$name.$desct.$desc.$pricet.'£'.$price;

?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" rowspan="2" class="image" align="center"><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_enlarge.gif" border="0" /></a><br/><br/><img src="products/<?php print $img; ?>" width="95" height="95" border="0" /></td>
<td valign="top" class="item-main"><b><?php print $content; ?></b></td>
</tr>
<tr>
<td valign="top"><img src="images/item_order1.gif" border="0" /><a href="#" onclick="window.open('info.php?id=<?php print $id ?>&menu=<?php print $menu; ?>', '_info', 'HEIGHT=500,resizable=no,WIDTH=430,scrollbars=1');"><img src="images/item_order2.gif" border="0" /></a></td>
</tr>
</table>
<br />
<?php
}
}
?>
<b>Welcome...</b></span>
<br />
<br />
<span style="font-size: 14px; ">
<?php
$query = "SELECT * FROM config WHERE id=1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$introtext = $row;
$introtext = nl2br($introtext);
print $introtext;
?>
</span></b>


hope someone can help

lexi

You forgot to setup a connection??? hehehe

:)

Hi all,
im new 2 all this tring 2 work this 1 out but is not workin. Can u chek this and tell me why this does't enter customer and order details into mysql:

<?php
$xn = $HTTP_POST_VARS['n'];
$xd = $HTTP_POST_VARS['d'];
$xc = $HTTP_POST_VARS['c'];
$xq = $HTTP_POST_VARS['q'];
$xf = $HTTP_POST_VARS['f'];
$hostname_local = "localhost";
$database_local = "database";
$username_local = "username";
$password_local = "password";
$local = mysql_pconnect($hostname_local, $username_local, $password_local) or die(mysql_error());
mysql_select_db($database_local, $local);
$sql = "SELECT `id` FROM `customers` WHERE bname='".$HTTP_POST_VARS['BName']." and baddress='".$HTTP_POST_VARS['BStreet']; 
$Recordset1 = mysql_query($sql, $local);
  $id1 = mysql_result($Recordset1,0,"id");
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 if ($totalRows_Recordset1 > 0) {$sql = "INSERT INTO `customers` ( `id` , `bname` , `baddress` , `bcity` , `bstate` , `bzip` , `bcountry` , 
`bphone` , `bfax` , `bemail` , `sname` , `saddress` , `scity` , `sstate` , `szip` , `scountry` , `sphone` , `sfax` ) VALUES ( '', '".
$HTTP_POST_VARS['BName']."', '".$HTTP_POST_VARS['BStreet']."', '".$HTTP_POST_VARS['BCity']."', 
'".$HTTP_POST_VARS['BState']."', '".$HTTP_POST_VARS['BZip']."', '".$HTTP_POST_VARS['BCountry']."', '".$HTTP_POST_VARS['BPhone']."',
'".$HTTP_POST_VARS['BFax']."', '".$HTTP_POST_VARS['BEmail']."', '".$HTTP_POST_VARS['Name']."', '".$HTTP_POST_VARS['Street']."',
'".$HTTP_POST_VARS['City']."', '".$HTTP_POST_VARS['State']."', '".$HTTP_POST_VARS['Zip']."', '".$HTTP_POST_VARS['Country']."',
'".$HTTP_POST_VARS['Phone']."', '".$HTTP_POST_VARS['Fax']."' )"; 
$Recordset1 = mysql_query($sql, $local);
}
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){ 
if ($xn[$i] != "" ){$my_body .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
//insert into the order database
$sql = "INSERT INTO `orders` VALUES ( '','$id1', '$my_body', '".$HTTP_POST_VARS['total']."', '".$HTTP_POST_VARS['shiptotal']."', '".date("F j, Y, g:i a")."' )"; 
$Recordset1 = mysql_query($sql, $local);}
 $my_body = "";
error_reporting(E_ALL ^ (E_NOTICE)); 
$my_body = "";
$MailFrom = "From:". $HTTP_POST_VARS['BEmail']."\n";
$my_body .= "****************************************************************\n";
$my_body .= "The Order is as follows (the number shown is the quantity ordered)\n";
$my_body .= "Ordered on ".date("F j, Y, g:i a") ."\n";
$my_body .= "****************************************************************\n";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){ if ($xn[$i] != "" )$my_body23 .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
$my_body .= strip_tags($my_body23);
$my_body .= "************************************\n";
$my_body .= "Sales Tax= " . $HTTP_POST_VARS['saletotal'] . "\n";
$my_body .= "Total Cost:= " . $HTTP_POST_VARS['total'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "****************************************************************\n";
$my_body .= "Shipping Information\n";
$my_body .= "****************************************************************\n";
if( $HTTP_POST_VARS['SameAsBill'] ){$my_body .= "Same as Billing Address". "\n";}
$my_body .= "Name= " . $HTTP_POST_VARS['Name'] . "\n";
$my_body .= "Address= " . $HTTP_POST_VARS['Street'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['City'] . "\n";
$my_body .= "State= ".  $HTTP_POST_VARS['State']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['Zip'] . "\n";
$my_body .= "Country=" .  $HTTP_POST_VARS['Country'] . "\n";
$my_body .= "Phone= " . $HTTP_POST_VARS['Phone']. "\n";
$my_body .= "Fax= " . $HTTP_POST_VARS['Fax']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Users Comments= " . $HTTP_POST_VARS['theComments']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Billing Information\n";
$my_body .= "****************************************************************\n";
$my_body .= "Name= " . $HTTP_POST_VARS['BName'] . "\n";
$my_body .= "Street= " . $HTTP_POST_VARS['BStreet'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['BCity'] . "\n";
$my_body .= "State= ".  $HTTP_POST_VARS['BState']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['BZip'] . "\n";
$my_body .= "Country=" . $HTTP_POST_VARS['BCountry']. "\n";
$my_body .= "Phone= " .  $HTTP_POST_VARS['BPhone'] . "\n";
$my_body .= "Fax= " .  $HTTP_POST_VARS['BFax'] . "\n";
$my_body .= "email= " .  $HTTP_POST_VARS['BEmail'] . "\n";
$my_body .= "Company= " .  $HTTP_POST_VARS['BCompany'] . "\n";
$my_body .= "Payment Method= " .   $HTTP_POST_VARS['Bill_Type'] . "\n";
$my_body .= "Credit Card Number= " .  $HTTP_POST_VARS['CCnumber'] . "\n";
$my_body .= "Credit Card Expiration= " .  $HTTP_POST_VARS['CCdate'] . "\n";
$my_body .= "Credit Card Security Code= " .  $HTTP_POST_VARS['CCpass'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "This Order was created using eOrdering Professional by LAJ Design\n";
$my_body .= "****************************************************************\n";
mail("admin@mysite.com","order","$my_body", "$MailFrom" );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
 
<html>
<head>
<title>Insert title</title>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
</head>
 
<body class="BodyHtml" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" Alink="#000000">
 
 
<div align="center">
 
<p>
<SCRIPT language="JavaScript" SRC="includes/above.js"></SCRIPT>
 
</div>
<br>
 
<p align="center">
<?php 
$my_body1 = "";
$my_body1 .= "Ordered on ".date("F j, Y, g:i a") ."\n"."<br>"."<br>";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){if ($xn[$i] != "" )$my_body31 .= "Product ".$xn[$i] . " ".$xd[$i]." @ cost ". $xc[$i]. " with ".$xq[$i] . " ordered"."\n<br>";}
print  $my_body1. str_replace( "\\\"", "\"",$my_body31);
?>
<br><br>  Thank you for your order!<br>We will be contacting you to confirm.<br>In five seconds you will be redirected to the main page.<br>If not then <a href="index.php">Click Here</a>
 
<div align="center"> 
 
<p>
<SCRIPT  language="JavaScript"  SRC="includes/below.js"></SCRIPT>
</p>
<br>  
<table  class="LogoTable" border= "1" width="250" align="center">  <tr><td><a href="<A href="http://www.lajdesignsw.com"><img">http://www.lajdesignsw.com"><img src="wcreated.jpg" width="250" height="75" border="0" ></a></td>
</tr> </table> 
 
 
  <p>&nbsp;</p>
</div>
</body>
</html>

I'm having error's:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 29
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 31

try doing this dude

$Bname = $HTTP_POST_VARS['BName'] ;
$BStreet = $HTTP_POST_VARS['BStreet'];
$sql = "SELECT `id` FROM `customers` WHERE bname='
$Bname' and baddress='$BStreet'".;

try doing this dude

$Bname = $HTTP_POST_VARS['BName'] ;
$BStreet = $HTTP_POST_VARS['BStreet'];
$sql = "SELECT `id` FROM `customers` WHERE bname='
$Bname' and baddress='$BStreet'".;

i have done what u suggest and now i'm havin this error:

Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /path 2/process.php on line 36

and also out of all images i have had in shopping cart they all come up in mysql as one same record repeated 5 times, for instance i have 5 records of image 02.jpg instead of image 02.jpg, image 03.jpg and so on and none of the records inside customers table.

Well at least w_3rabi has fixed your initial mysql_num_rows() error !.

It's onto a new error now.

Yup, i hope somebody will come up with something cose it's giving me a headache!
Tryied everythin but with no result.

Thank you all!

Ok maybe someone can see something im missing (its driving me in sane)

$query = mysql_query("UPDATE user SET meso='1' WHERE uid='$this->user'");
    $nrows = mysql_num_rows($query);
    $ret = mysql_query($query) or die(mysql_error()); [/inlinecode] [/code]

this returns:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Applications/MAMP/htdocs/worldjam/wjm.php on line 16

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

what am I doing wrong?
Thanks in advanced
Tom

Ok maybe someone can see something im missing (its driving me in sane)

$query = mysql_query("UPDATE user SET meso='1' WHERE uid='$this->user'");
        $nrows = mysql_num_rows($query);
        $ret = mysql_query($query) or die(mysql_error());

this returns:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Applications/MAMP/htdocs/worldjam/wjm.php on line 16
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

what am I doing wrong?
Thanks in advanced
Tom

Try storing your query in a string. like the following.

$sql = "SELECT x FROM y";
$ret = mysql_query($sql) or die(mysql_error());
$numrows = mysql_num_rows($ret);

theres an error in your query, which is not returning a valid result resource to your $query variable.
That is why your num_rows function is giving error.

Put your query into a string, and echo the string, so you can see if your variables are working ok.. and so on.

If you're still having bother, tell us what your query echo displays.

Cheers.
Drag.

<?php
// First set the form strings, which will be displayed
//in various cases below
$thisfile = $_SERVER; //Have to set this for heredoc
$reg_form = <<< EOREGFORM
<P>We must ask for your name and email address to ensure that no
one votes more than once, but we do not associate your personal
information with your rating.</P>
<FORM METHOD="post" ACTION="$thisfile">
Name: <INPUT TYPE="text" SIZE=25 NAME="name"><BR><BR>
Email: <INPUT TYPE="text" SIZE=25 NAME="email">
<INPUT TYPE="hidden" NAME="stage" VALUE="register">
<BR><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>
EOREGFORM;
$rate_form = <<< EORATEFORM
<P>My boss is:</P>
<FORM METHOD="post" ACTION="$thisfile">
<INPUT TYPE="radio" NAME="rating" VALUE=1>
Driving me to look for a new job.<BR>
<INPUT TYPE="radio" NAME="rating" VALUE=2>
Not the worst, but pretty bad.<BR>
<INPUT TYPE="radio" NAME="rating" VALUE=3>
Just so-so.<BR>
<INPUT TYPE="radio" NAME="rating" VALUE=4>
Pretty good.<BR>
<INPUT TYPE="radio" NAME="rating" VALUE=5>
A pleasure to work with.<BR><BR>
Boss’s name: <INPUT TYPE="text" SIZE=25 NAME="boss"><BR>
<INPUT TYPE="hidden" NAME="stage" VALUE="rate">
<BR><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>
EORATEFORM;
if (!$_POST) {
// First time, just show the registration form
$message = $reg_form;
} elseif ($_POST == 'Submit' && $_POST ==
'register') {
// Second time, show the registration form again on error,
// rating form on successful INSERT
if (!$_POST || $_POST == "" ||
strlen($_POST > 30) || !$_POST ||
$_POST == "" || strlen($_POST > 30)) {
$message = '<P>There is a problem. Did you enter a name and
email address?</P>';
$message .= $reg_form;
} else {
// Open connection to the database
mysql_connect("localhost", "user", "password")
or die("Failure to communicate with database");
mysql_select_db("test");
// Check to see this name and email have not appeared before
$as_name = addslashes($_POST);
$tr_name = trim($as_name);
$as_email = addslashes($_POST);
$tr_email = trim($as_email);
$query = "SELECT sub_id FROM raters
WHERE Name = '$tr_name'
AND Email = '$tr_email'
"
or die(mysql_error());
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
error_log(mysql_error());
$message = 'Someone with this name and password has
already rated . If you think a mistake was made, please email
help@example.com.';
} else {
// Insert name and email address
$query = "INSERT INTO raters (ID, Name, Email)
VALUES(NULL, '$tr_name', '$tr_email')
";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
$message = $rate_form;
} else {
error_log(mysql_error());
$message = '<P>Something went wrong with your signup
attempt.</P>';
$message .= $reg_form;
}
}
}
} elseif ($_POST == 'Submit' && $_POST ==
'rate') {
// Third time, store the rating and boss’s name
// Open connection to the database
mysql_connect("localhost", "user", "password")
or die("Failure to communicate with database");
mysql_select_db("test");
// Insert rating and boss’s name
$as_boss = addslashes($_POST);
$tr_boss = trim($as_boss);
$rating = $_POST;
$query = "INSERT INTO ratings (ID, Rating, Boss)
VALUES(NULL, '$rating', '$tr_boss')
";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
$message = '<P>Your rating has been submitted.</P>';
} else {
error_log(mysql_error());
$message = '<P>Something went wrong with your rating
attempt. Try again.</P>';
$message .= $rate_form;
}
}
?>
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
BODY, P {color: black; font-family: verdana;
font-size: 10 pt}
H1 {color: black; font-family: arial; font-size: 12 pt}
-->
</STYLE>
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>
<TR>
<TD BGCOLOR="#F0F8FF" ALIGN=CENTER VALIGN=TOP WIDTH=17%>
</TD>
<TD BGCOLOR="#FFFFFF" ALIGN=LEFT VALIGN=TOP WIDTH=83%>
<H1>Rate your boss anonymously</H1>
<?php echo $message; ?>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>


Hey guys, I new member here, just joined..The problem I have Is that I get this message after
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\rate_boss.php on line 65
So I was wondering why this script isn´t working, I did axactly how the ebook example was... (password and user on database, changed)

put your markup in code tags please

[ code ]

[ /code ]

$query = "SELECT sub_id FROM raters
WHERE Name = '$tr_name'
AND Email = '$tr_email'
"
or die(mysql_error());
$result = mysql_query($query);

1.
your query should be

$query = "select sub_id from raters where name = '$tr_email' and email = '$tr_email'"

2.
your query execution statement should be

if(mysql_query($query)){//do stuff
}else{die("Could not execute");}

You can even use boolean, its really the same in the end.
But the basic mysql_query is usually

mysql_query($query) or die();

Try storing your query in a string. like the following.

$sql = "SELECT x FROM y";
$ret = mysql_query($sql) or die(mysql_error());
$numrows = mysql_num_rows($ret);


theres an error in your query, which is not returning a valid result resource to your $query variable.
That is why your num_rows function is giving error.

Put your query into a string, and echo the string, so you can see if your variables are working ok.. and so on.

If you're still having bother, tell us what your query echo displays.

Cheers.
Drag.

the problem with that query is his use of a class object in the query $this->user this should be at the very least sanitised to avoid query issues.

But then again...

okey, that helped me not to get the error thing, instead a have now empty page after inserting name and email to the imput zones...

my questions are now..
1. Have I had to do already tables and shit on the db called "test" or the script does them self?

2. How can I make this scrip work properly so that insteas of the empy page I got the boss rating thing.. I think my query isn´t working, am I right?

Thanks for those who have helped me so far...

okey, that helped me not to get the error thing, instead a have now empty page after inserting name and email to the imput zones...

my questions are now..
1. Have I had to do already tables and shit on the db called "test" or the script does them self?

2. How can I make this scrip work properly so that insteas of the empy page I got the boss rating thing.. I think my query isn´t working, am I right?

Thanks for those who have helped me so far...

Can you post your initial post please?
I can't see the initial post you're referring to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.