PHP MySQL unable to get rows from query -
this question has answer here:
brand new php , i'm going through few tutorials @ moment. have created login.php
file has hostname, database, username, , password. test1.php
page requires login.php
file , attempts connect it.
i select database, attempt query, , store results. here have far:
<?php // test1.php require_once 'login.php'; $db_server = mysqli_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("unable connect mysql: " . mysql_error()); mysqli_select_db($db_server, $db_database) or die("unable select database: " . mysql_error()); $query = "select * classics"; $result = mysqli_query($db_server, $query); if (!$result) die ("database access failed: " . mysql_error()); $rows = mysql_num_rows($result); ?>
the error getting says:
mysql_num_rows() expects parameter 1 resource, object given on line 15
line 15 is:
$rows = mysql_num_rows($result);
what resource looking pass mysql_num_rows()
?
the mysql_num_rows() expects parameter 1 resource
occurs when statement wrong, classics
table not exist.
and use mysqli
instead of mysql
Comments
Post a Comment