Skip navigation links

MySQL Forums :: PHP :: mysql_num_rows(): supplied argument is not a valid MySQL result


Advanced Search

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
mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/14/2012 07:08AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result laptop alias 05/14/2012 07:55AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/14/2012 08:46AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Peter Brawley 05/14/2012 10:20AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result laptop alias 05/14/2012 11:21AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/16/2012 07:43AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Rick James 05/16/2012 08:51AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/16/2012 05:50PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result laptop alias 05/16/2012 11:40AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/16/2012 05:32PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/19/2012 04:19AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Rick James 05/20/2012 08:55PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/21/2012 06:20AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result laptop alias 05/21/2012 06:51AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/21/2012 12:15PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Barry Galbraith 05/21/2012 06:07PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Peter Brawley 05/21/2012 02:33PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/21/2012 02:50PM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result Peter Brawley 05/22/2012 09:35AM
Re: mysql_num_rows(): supplied argument is not a valid MySQL result stef an 05/22/2012 12:28PM


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.