...

View Full Version : Error Help



Kev0121
03-06-2009, 06:13 PM
Well heres my code



<?php
$con = mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('blog',$con);

$query = "SELECT * FROM `content` WHERE ID = `1`";
$res = mysql_query($query);

$post = mysql_num_rows($res);

echo "<h1>" . $post['title'] . "</h1>";
echo "<h3>" . $post['date'] . "</h3>";
echo "<p>" . $post['content'] . "</p>";

?>


and heres my error



Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\tests\Variables.php on line 8

Kevin

kokjj87
03-06-2009, 06:33 PM
Change the quote of the 1 to regular single quote.


$query = "SELECT * FROM `content` WHERE ID = '1'";

Kev0121
03-06-2009, 06:44 PM
Hey thanks, how im getting


Warning: Wrong parameter count for mysql_num_rows() in C:\wamp\www\tests\Variables.php on line 8

Kevin

kokjj87
03-06-2009, 06:47 PM
Because the query has fail, so $res would not be a valid result set..

Place a die statement and you can see the query fail


$res = mysql_query($query) or die(mysql_error());



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum