Home > DeveloperSection > Forums > Show the result from query database php
Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    May-15-2013 8:11 AM

 PHP PHP 
Ratings:


 1 Reply(s)
 1158  View(s)
Rate this:
Hi Mindstickians!

I have a code like this:

$genre = 'jazz';
$what_genre = mysql_real_escape_string($genre);
$query = mysql_query("SELECT song.id, song.title, genre.genre FROM song INNER JOIN genre ON song.id_genre=genre.id_genre WHERE genre.genre = '" .$what_genre. "' ORDER BY id");

if(mysql_num_rows($query) > 0)
{
    while($result = mysql_fetch_array($query))
    {
        echo $result['id'];
        echo $result['title'];
        echo $result['genre'];
    }
}
I want to show the result, but it failed. The system give me an error report:

A PHP Error was encountered

Severity: Warning

Message: mysql_num_rows() expects parameter 1 to be resource, boolean given

What should I do?
Thanks in advance! 



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-15-2013 8:54 AM

Hi Jayden!

Change your query from id to song.id like this

"SELECT song.id, song.title, genre.genre FROM song INNER JOIN genre ON song.id_genre=genre.id_genre WHERE genre.genre = '" .$topiknya. "' ORDER BY song.id";


Don't want to miss updates? Please click the below button!

Follow MindStick