MySQL Forums
Forum List  »  PHP

Re: mysql_num_rows(): supplied argument is not a valid MySQL result
Posted by: stef an
Date: May 21, 2012 06:20AM

the skeleton for the website was made by a guy from RenMedia. RenMedia closed down a long time ago and there is no support available.

runQuery is used in the functions.ssi.php file

 function item_to_id($value, $table, $column = 'name', $url_col = '') {
	$value = addslashes($value);
	$sql = "SELECT id FROM $table WHERE $column = '$value' LIMIT 1";
	$result = runQuery($sql);
	if (mysql_num_rows($result)) {
		$row = mysql_fetch_assoc($result);
		return $row['id'];
	} else {
		if ($url_col) {
			$url = nukeUrlSafe($value);
			$sql = "INSERT INTO $table SET $column = '$value', $url_col = '$url'";
			runQuery($sql);
			return mysql_insert_id();
		} else {
			$sql = "INSERT INTO $table SET $column = '$value'";
			runQuery($sql);
			return mysql_insert_id();
		}
	}
}

function pagify_results($sql, $letter, $songs) {
	$result = runQuery($sql);
	if (mysql_num_rows($result)) {
		$per_page = 50;
		if ($_GET['page'] > 0) {
			$page = $_GET['page'] + 0;
		} else {
			$page = 1;
		}
		$total_results = mysql_num_rows($result);
		$total_pages = ceil($total_results / $per_page);
		$first_item = $per_page * ($page - 1);
		$sql .= " LIMIT $first_item, $per_page";
		$result = runQuery($sql);
		$max_this_page = $first_item + $per_page;
		if ($max_this_page > $total_results)
			$max_this_page = $total_results;
	
		echo "<h2>Displaying ".($first_item+1)." to $max_this_page of $total_results Results</h2>\n";
		
		$pre_pagify = "";
		for ($i = 1; $i <= $total_pages; $i++) {
			if ($page == $i)
				$pre_pagify .= "<a href='?page=$i'><strong>$i</strong></a> ";
			else
				$pre_pagify .= "<a href='?page=$i'>$i</a> ";
		}
		$pre_pagify .= "";
		
		$pagify = "<div class='pagify'>";
		if ($page > 1) {
			$pagify .= "<a href='?page=1'>First</a> | <a href='?page=". ($page - 1) . "'>Prev</a> | ";
		} else {
			$pagify .= "First | Prev | ";
		}
		#$pagify .= " <b style='color: #444;'>Page " . $page . " / " . $total_pages . "</b> | ";
		if (!$songs)
			$pagify .= $pre_pagify;
		else
			$pagify .= $page . " / " . $total_pages;
		if ($page < $total_pages) {
			$pagify .= " | <a href='?&page=". ($page +1) . "'>Next</a> | <a href='?page=". ($total_pages) . "'>Last</a>";
		} else {
			$pagify .= " | Next | Last";
		}
		$pagify .= "</div>\n";
		
		
		echo $pagify;
?>

and in the index.php file:
 		<ul>
			<?php
			$sql = "SELECT s.name AS song_name, s.url AS song_url, s.submit_name, s.submit_time, a.name AS artist_name, a.url AS artist_url FROM song AS s, artist AS a WHERE s.artist_id = a.id ORDER BY s.id DESC LIMIT 20";
			$result = runQuery($sql);
			while ($row = mysql_fetch_assoc($result)) {
			?>
			<li><a href="lyrics-<?=$row['artist_url']?>-<?=$row['song_url']?>.htm"><?=trimmer($row['artist_name'] . " - " . $row['song_name'],30)?></a></li>
			<li>By <em><?=$row['submit_name']?></em> approx <?=tPass(strtotime($row['submit_time']))?> ago</li>
			<?php
			}
			?>
		</ul>

runQuery is not used anywhere else. I checked all the files and the database

Options: ReplyQuote


Subject
Written By
Posted
Re: mysql_num_rows(): supplied argument is not a valid MySQL result
May 21, 2012 06:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.