simple mysql query not returning corretcly
Posted: Tue Sep 30, 2003 10:06 pm
I'm fairly new to php but have done asp and a bit of database work in the past...I have this simple query/code that testing out atm...
<?php
$con = mysql_connect("server", "user", "pass") or die("Connect Error: ".mysql_error());
echo 'connection successful<p>';
$db="test";
mysql_select_db($db, $con);
$sql = "SELECT author FROM t_news";
$result = mysql_query($sql);
echo $result;
// close the connection
mysql_close($con);
?>
Now the problem is when I open up the php page with this code in I get the following:
connection successful
Resource id #2
?? What is "Resource id #2" meant to mean? that is what it's returning as my query result and that is definately not what should be returned, any help would be appreciated thanks.
NB. There is only one record in the database at the moment which is why I haven't added anything else to the query, as I'm just "testing".
<?php
$con = mysql_connect("server", "user", "pass") or die("Connect Error: ".mysql_error());
echo 'connection successful<p>';
$db="test";
mysql_select_db($db, $con);
$sql = "SELECT author FROM t_news";
$result = mysql_query($sql);
echo $result;
// close the connection
mysql_close($con);
?>
Now the problem is when I open up the php page with this code in I get the following:
connection successful
Resource id #2
?? What is "Resource id #2" meant to mean? that is what it's returning as my query result and that is definately not what should be returned, any help would be appreciated thanks.
NB. There is only one record in the database at the moment which is why I haven't added anything else to the query, as I'm just "testing".