Ok, I know their's tons of threads.. with the same problem. But.. every code is different. I'm pretty good with HTML/Css but I havn't had time to catch on with PHP.

So, I have a site I'm setting up. Which requires a SQL/Database. Which is already configured.

I've filled in the (username / password / host) *The required information*

But I keep getting these two errors:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/austin7/public_html/Like/index.php on line 159

&

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/austin7/public_html/Like/index.php on line 184

BOTH line 159 & 184 say the same thing:

$count = mysql_num_rows($select);

Heres the (index.Php code)

<?php
$url = urlencode("http://x0x.in/?like=" . $id);
        $data = <<< _HTML

_HTML;

$msg = preg_replace("/\n/", " ", $msg);

?>


 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 
<title>x0x - The Facebook Like</title>
<meta name="description" content="Want to share anything with your Friends on FACEBOOK? We have this site for you. Come Share the Likes. We also have Many Top liked, Proverbs, Funny Quotes to be Liked." /> 
<meta name="keywords" content="like on facebook,forex,banking, likefb, likeylike, likeportal, facebook like, fblike, like things on facebook, like my things, like, like my views, facebooked likes, thefacebook, google, like on facebook"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" 
href="files/style.css" type="text/css">
<link rel="shortcut icon" href="/images/sitelogo.png" type="image/x-icon">

</head>
<body>
<div id="fb-root"></div>
 
	<script type="text/javascript" src="files/TyntLite.js"></script></head><body><div 
id="container">

	<?PHP
	if($_GET['add']){
		if($_POST['aa'] == ""){
			echo'<script type="text/javascript">window.location = "?"; </script>';
		}else{
		$posted = mysql_real_escape_string($_POST[aa]);
			mysql_query("INSERT INTO `likes` (`title`, `numLikes`) VALUES ('$posted', '0')");
			$select = mysql_query("SELECT * FROM `likes` WHERE `title`='$_POST[aa]' AND `numLikes`='0'ORDER BY `id` DESC  LIMIT 1 ");
			$fetch = mysql_fetch_array($select);
			echo'<script type="text/javascript">window.location = "?id='.$fetch[id].'"; </script>';
			}
		
	}else if($_GET['id']){
		$select = mysql_query("SELECT * FROM `likes` WHERE `id`='$_GET[id]' LIMIT 1");
		$count = mysql_num_rows($select);
		if($count == 0){
			echo'<script type="text/javascript"> window.location = "?"; </script>';
		}else{
			$fetch = mysql_fetch_array($select);
			$count = $fetch[numLikes] + 1;
			$valm = $_GET[id] - 1;
			$valp = $_GET[id] + 1;
			mysql_query("UPDATE `likes` SET `numLikes`='$count' WHERE `id`='$_GET[id]'");
			echo'<meta property="og:title" content="'.$fetch[title].'"/>
 

 

 
	<div id="box_0">
		<div id="head_0">
 
		</div>
		<div id="content_0">

                  <table width=100%><td align="left"><p class="big"><a href="http://www.x0x.in"><font color="white">Facebook Like</font></a></td><td align="right"><font size="5"><a href="?id='.$valm.'">Previous Page</a> | <a href="?id='.$valp.'">Next Page</a></font></td></table></p><BR>
 <center>
<script type="text/javascript"><!--
google_ad_client = "pub-4111169165033977";
/* 468x60, created 6/11/10 */
google_ad_slot = "2533550869";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>



<center>
<b>	<p><font size="5"><font color="#e71818">'.$fetch[title].'</font></font></p></b>

<img src="http://www.x0x.in/images/arrow2.png"><font size="2">Click on Like to Show this On Your Facebook WALL</font>

<p><iframe src="http://www.facebook.com/widgets/like.php?href=http://x0x.in/?id='.$_GET[id].'" scrolling="no" frameborder="0" style="border:none; width:370px; height:80px"></iframe></p>
</center>


<center>
<script type="text/javascript"><!--
google_ad_client = "pub-3805657647131319";
/* 468x60, x0x.in */
google_ad_slot = "8300161717";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


</center>


<center>
<BR><a href="http://www.x0x.in/"><font size="2"><u>Want to Share Anything with your friends to LIKE on FACEBOOK? CLICK HERE</u></font></a></p>
</center>




 
        	</div>
		</div>
		<img src="http://x0x.in/images/motionspace.png" alt="Spacer" border="0">';
		}
	}else{
?>

</center><img src="http://www.x0x.in/x0x.png"></center>
	<div id="commentsparent">
<div id="comments">
		<form method="POST" action="?add=new" name="formLike">
		<textarea cols="50" rows="4" name="aa" class="comments"></textarea>
	</div>
	</div>
	</form>
	<div align="right">
		<a href="#" onClick="javascript:document.formLike.submit();"><img  src="files/like.png" alt="Like" 
type="image" border="0"></a>
	</div>       
	<? } ?> 
 
 
 
 
<div id="bottomboxes">
 
	<div id="box_1">
 
		<div id="head_1">
<font size="48px"><p class="big">Top Likes</p></font>
 
		</div>
 
		<div id="content_1">
					<?PHP
						$select = mysql_query("SELECT * FROM `likes` ORDER BY `numLikes` DESC LIMIT 15");
						$count = mysql_num_rows($select);
                                                
						if($count == 0){
							echo'<font size="2px">• Currently no top likes<br></font>';
						}else{
							while($fetch = mysql_fetch_array($select)){
								echo'<font size="2px">•<a href="?id='.$fetch[id].'">'.$fetch[title].'</a><br></font>';
							}
						}
						?>
						</div>
 
	</div>
 
	<div id="box_2">
 
		<div id="head_2">
 
		   <font size="48px"><p class="big">Recent Likes</p></font>
 
		</div>
 
		<div id="content_2">
<?PHP
						$select = mysql_query("SELECT * FROM `likes` ORDER BY `id` DESC LIMIT 15");
						$count = mysql_num_rows($select);
						if($count == 0){
							echo'<font size="2px">• Currently no likes<br></font>';
						}else{
							while($fetch = mysql_fetch_array($select)){
								echo'<font size="2px">• <a href="?id='.$fetch[id].'">'.$fetch[title].'</a><br></font>';
							}
						}
						?>
		</div>
 
	</div>
 
      </div>
 
 
 
      </div>

</div>
 
</body></html>

If you can help, it would be greatly appreciated. I'm willing to send you like $10 via paypal or something.

-Thanks.

SELECT * FROM `likes`

it should be

SELECT * FROM likes
Member Avatar for rajarajan2017

May be a your query is not executed

$result = MYSQL_QUERY($sql) or die('Query failed: ' . mysql_error() . "<br />\n$sql");

check for errors. And show the error what you have as of now?

such error generally comes when their is some error in sql query.. or when supplied arrguement have some problem.. try to debug your query

$query = "select * from table";
$result = mysql_query($query) or die(mysql_error());

or you rename your id field or table name to something else, one thing is for sure there an error in query

So.. I did make a new database, just to make sure nothing happened in the process of making the previous one (and yea, I updated the sql info on the index. now...

May be a your query is not executed

$result = MYSQL_QUERY($sql) or die('Query failed: ' . mysql_error() . "<br />\n$sql");

check for errors. And show the error what you have as of now?

When I put that, it gives me "Query failed: Query was empty"

such error generally comes when their is some error in sql query.. or when supplied arrguement have some problem.. try to debug your query

$query = "select * from table";
$result = mysql_query($query) or die(mysql_error());

When I put that, it gives me "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 'table' at line 1"

I'm still not sure, what's causing this >__<

Member Avatar for rajarajan2017

Thats right! I expect that only, now its confirmed you have error in your query. you can execute the same query in your phpadmin sql editor and first check whether it returning rows. sure it is the eroor.

this means that you have syntax error in your query..

debug like this

$query = "SELECT * FROM `likes` WHERE `title`='$_POST[aa]' AND `numLikes`='0'ORDER BY `id` DESC  LIMIT 1 ";

echo $query;

this will show real values your are passing in Query...and run that query directly on mysql..

that will show where you are making mistake

Hope this will help.

this means that you have syntax error in your query..

debug like this

$query = "SELECT * FROM `likes` WHERE `title`='$_POST[aa]' AND `numLikes`='0'ORDER BY `id` DESC  LIMIT 1 ";

echo $query;

this will show real values your are passing in Query...and run that query directly on mysql..

that will show where you are making mistake

Hope this will help.

I put that, and at the top of the page it gives me: "SELECT * FROM `likes` WHERE `title`='' AND `numLikes`='0'ORDER BY `id` DESC LIMIT 1"

Again, I'm new to all of this. Sorry >_<

Thats right! I expect that only, now its confirmed you have error in your query. you can execute the same query in your phpadmin sql editor and first check whether it returning rows. sure it is the eroor.

hmmm... in the phpadmin sql, under the database I made for it. the query tab says "No tables found in database."

:/

Member Avatar for rajarajan2017

There is no tables?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.