Jump to content

Recommended Posts

Seems to be outputting an error, I have no other problems with my querys formatted like this, anyone got an idea?

 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\includes\config.php on line 163

 

$connection			=	mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name, $connection);

function Search($x) { // Search Ringtones Functions
$s					=	$_POST['s'];
$q					=	"SELECT * FROM ringtones WHERE artist = ".$s."";
$numresults=mysql_query($q);
$numrows=mysql_num_rows($numresults); // This is line 163
$result = mysql_query($q) or die("Couldn't execute query");

if ($numrows == 0) {
echo "No Results Found ):";
}

while ($row = mysql_fetch_array($result)) {
$id					=	$row["id"];
$artist				=	$row["artist"];
$name				=	$row["name"];
$views				=	$row["views"];
$rating				=	$row["rating"];

echo "<tr><td><a href='view.php?ringtone=".$artist."-".$name."'>".$artist."</a></td><td><a href='view.php?ringtone=".$artist."-".$name."'>".$name."</a></td><td>".$views."</td><td>".$rating."</td></tr>";
}
}

Link to comment
https://forums.phpfreaks.com/topic/183724-mysql_num_rows-error/
Share on other sites

Most likely mysql_query() in the line above returns false (it fails).

Try like this:

$result=mysql_query($q) or die(mysql_error().": $q");
$numrows=mysql_num_rows($result); 

 

I'm gueassing you should change your query to:

$s = mysql_real_escape_string($_POST['s']);
$q = "SELECT * FROM ringtones WHERE artist = '$s'";

Link to comment
https://forums.phpfreaks.com/topic/183724-mysql_num_rows-error/#findComment-969703
Share on other sites

Hmm seems to have removed the sql error issue but now I'm faced with SQL errors:

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 'Spears' at line 1: SELECT * FROM ringtones WHERE artist = Britney Spears

 

Unknown column 'Brokencyde' in 'where clause': SELECT * FROM ringtones WHERE artist = Brokencyde

 

24n2vev.png

Link to comment
https://forums.phpfreaks.com/topic/183724-mysql_num_rows-error/#findComment-969705
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.