Pino
Feb 4th, 2005, 08:14 AM
$host="localhost";
$user="me";
$password="you";
$database="hello";
$connection = mysql_connect($host,$user,$password)or die ("Error Conecting To DB");
$db = mysql_selectdb($database,$connection) or die ("bad table\db data");
$query = "SELECT * FROM tblnews";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
for ($i=0;$i<$nrows;$i++)
{
$row = mysql_fetch_array($result);
echo $row;
}
?>
and the error i am getting is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in path/index.php on line 15
Any ideas on how to fix this?
also if i just wanted to select 3 coloums from the db how would i put my query
$query = "SELECT one two three FROM tblnews"; would that be right?
$user="me";
$password="you";
$database="hello";
$connection = mysql_connect($host,$user,$password)or die ("Error Conecting To DB");
$db = mysql_selectdb($database,$connection) or die ("bad table\db data");
$query = "SELECT * FROM tblnews";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
for ($i=0;$i<$nrows;$i++)
{
$row = mysql_fetch_array($result);
echo $row;
}
?>
and the error i am getting is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in path/index.php on line 15
Any ideas on how to fix this?
also if i just wanted to select 3 coloums from the db how would i put my query
$query = "SELECT one two three FROM tblnews"; would that be right?