Current location: Hot Scripts Forums » Programming Languages » PHP » Warning: mysql_fetch_row(): HELP!


Warning: mysql_fetch_row(): HELP!

Reply
  #1 (permalink)  
Old 03-30-05, 06:54 AM
SEQUEL SEQUEL is offline
New Member
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Warning: mysql_fetch_row(): HELP!

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /customers/moviemakerz.com/moviemakerz.com/httpd.www/Moviebase/rating/rating/rating.php on line 24

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /customers/moviemakerz.com/moviemakerz.com/httpd.www/Moviebase/rating/rating/rating.php on line 27

I HAve NO idea what this meens!! Could anyone help me!! I really like this PHP but it doesent work!!!
Reply With Quote
  #2 (permalink)  
Old 03-30-05, 07:47 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
99% of the time it is your query statement...if you post it, I may be able to see the problem...

if this is your query:

$query = mysql_query("SELECT * FROM blah blah blah);

then put this afterwards

if (!$query) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}

that will let you know if your query is ok or not...
Reply With Quote
  #3 (permalink)  
Old 03-30-05, 08:02 AM
SEQUEL SEQUEL is offline
New Member
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
This is the PHP... I don't know how it works.. really a Noob in the programming arena

$ratings=Array("- select -", "Poor", "Fair", "Good", "Very good", "Excellent");


if ($_GET[ID]) {
$connection = mysql_connect($host,$db_username,$db_pass);
mysql_selectdb($db_name);
$result = mysql_query("SELECT * FROM rating WHERE ID=$_GET[ID]");
$fields = mysql_fetch_row($result);

if (!$fields[0]) {
$num_rows = mysql_result(mysql_query("SELECT COUNT(ID) FROM rating"),0);
if ($num_rows <= $max_rows) {
mysql_query("INSERT INTO rating VALUES ($_GET[ID],0,0,'0.0.0.0')");
$rating = 0;
$votes = 0;
}
else die("Error: Max rows reached.");
}
else {
$rating = $fields[2];
$votes = $fields[1];
}

if ($_POST[your_rating] > 0 and $fields[3] != $REMOTE_ADDR) {
$your_rating = $_POST[your_rating] * 10;
$votes++;
$rating = ($fields[2]*$fields[1]+$your_rating)/$votes;
mysql_query("UPDATE rating SET votes = $votes, rating = $rating, last_ip = '$REMOTE_ADDR' WHERE ID=$_GET[ID]");
}

$image = (round($rating/50,1)*50)."-star.gif";
$note = number_format($rating/10, 1);

echo "<form action=\"rating.php?ID=".$_GET[ID]."\" method=\"POST\">
<font size=2 face=Verdana><B>Rating:</B></FONT>&nbsp;&nbsp;<img src=\"$image\" alt=\"Rating: $note\" align=\"middle\">&nbsp;<font size=1 face=Verdana color=RED>($note from $votes votes)</font>
&nbsp;&nbsp;&nbsp;
<select name=\"your_rating\" style=\"font-size: 8pt\">
<option value=\"0\" selected>$ratings[0]
";

for ($i=5; $i>=1; $i--) {
echo "<option value=\"$i\">$ratings[$i]\n";
}
}
else die("Error: ID not set!");

?>
</select>
<input type="submit" value="Rate!" style="font-size: 8pt">
</form>
</font>
</center>
</body>
<html>
Reply With Quote
  #4 (permalink)  
Old 03-30-05, 08:16 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
in your query, try this...

$result = mysql_query("SELECT * FROM rating WHERE ID='$_GET[ID]'");

of course all I did is set the $_GET[ID]; in single quotes...
Reply With Quote
  #5 (permalink)  
Old 03-30-05, 08:31 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
...another thing, where you have

$num_rows = mysql_result(mysql_query("SELECT COUNT(ID) FROM rating"),0);

I am assuming you are trying to find the amount of rows right?

1. on php's web site the suggest " Calls to mysql_result() should not be mixed with calls to other functions that deal with the result set."

2. if you are just trying to find the amount of rows, try the mysql_num_rows(); function....

Here is a great page that I am constantly going to when I mess up my queries,
http://us2.php.net/manual/en/function.mysql-result.php
Reply With Quote
  #6 (permalink)  
Old 03-30-05, 09:41 AM
SEQUEL SEQUEL is offline
New Member
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not wery good at this!!

I hoped u could c what is wrong and guide me through it.. I just downloaded the script.. the only thing I know is copy - paste
Reply With Quote
  #7 (permalink)  
Old 03-30-05, 09:43 AM
SEQUEL SEQUEL is offline
New Member
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
And thanks for the rapid reply!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Error: Warning: mysql_fetch_array(): supplied argument not valid MySQL zibykid PHP 10 03-30-05 08:37 AM
An unknown warning Slypher PHP 1 02-12-05 03:24 AM
Competition form dee19802000 PHP 2 01-27-05 02:48 PM
css warning mmmm????? coldclimber CSS 3 12-23-04 04:59 PM
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result ... hukka PHP 1 01-12-04 12:16 AM


All times are GMT -5. The time now is 05:39 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.