Jump to content

mysql_num_rows Problem: PHP or MySQL Error?


kingnutter

Recommended Posts

Hi there,

 

I am trying to JOIN two databases and retrieve the number of rows. I keep getting the error message:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\web\mojo\php-files\edit_mojo_cd.php on line 453

 

Could anyone give the code below a short scan at let me know if the problem might be the MySQL query or the mysql_num_rows line. Or both?

 

Thanks.

KN

 

foreach ($missing_genres as $row)
{
$query="SELECT * FROM genrelinkcd WHERE genrelinkcd.genre_id=genres.genre_id WHERE genres.moj_genre='$row'";

$result = mysql_query($query);
$amount = mysql_num_rows($result);
...

Hi,

Your query is wrong - you have 2 WHERE statements in there.

$query="SELECT * FROM genrelinkcd WHERE genrelinkcd.genre_id=genres.genre_id WHERE genres.moj_genre='$row'";

I can't quite work out what you are trying to do with that query so I can't actually suggest what it should lool like.

 

Chris

I have two tables:

 

1) 'genres' containing moj_genre and genre_id

2) 'genrelinkcd' containing id, genre_id and moj_id

 

Basically. I want to know how many times a moj_genre occurs in 'genrelinkcd' the link being genre_id in both tables.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.