New to the game and hoping someone can help me. I have a simple mysql database. Tring to build a one column table of hostnames in a web page frame. The table is built fine but instead of the hostname, I get Resource id #x in each of the table cells.
Here is my simple db:
+------------+----------+-------------+-----------+-----------+
| machine_id | hostname | ip_addr | os | dbms |
+------------+----------+-------------+-----------+-----------+
| 1 | aurora | 1.2.3.4 | Win2KAS | Oracle9.2 |
| 2 | sahara | 51.52.53.54 | Win2KAS | DB2 7.2 |
| 3 | cznaix | 11.12.13.14 | AIX 4.3.3 | DB2 7.2 |
+------------+----------+-------------+-----------+-----------+
Here is my code:
<?php
//Connect to the database server
$dbcnx = @mysql_connect("raindrop","root"
if (! $dbcnx) {
echo( "<P>Unable to connect to the " . "database server at this time.</P>" );
exit();
}
// Select the database
if (! @mysql_select_db("machines" ) {
echo( "<P>Can not connect to the machines db</P>" );
exit();
}
$result = mysql_query("SELECT * FROM machines", $dbcnx);
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
if ($i == 0) echo ("<table width='100%' tableborder='YES' border='1'>"
echo ("<tr>"
$sql = "select hostname from machines where machine_id = '$i'";
$result = mysql_query($sql, $dbcnx);
echo ("<td ALIGN=center BGCOLOR='#99CCFF'>$result</td>"
echo ("</tr>"
if ($i == $num_rows-1) echo ("</table>"
}
?>
Here is my simple db:
+------------+----------+-------------+-----------+-----------+
| machine_id | hostname | ip_addr | os | dbms |
+------------+----------+-------------+-----------+-----------+
| 1 | aurora | 1.2.3.4 | Win2KAS | Oracle9.2 |
| 2 | sahara | 51.52.53.54 | Win2KAS | DB2 7.2 |
| 3 | cznaix | 11.12.13.14 | AIX 4.3.3 | DB2 7.2 |
+------------+----------+-------------+-----------+-----------+
Here is my code:
<?php
//Connect to the database server
$dbcnx = @mysql_connect("raindrop","root"
if (! $dbcnx) {
echo( "<P>Unable to connect to the " . "database server at this time.</P>" );
exit();
}
// Select the database
if (! @mysql_select_db("machines" ) {
echo( "<P>Can not connect to the machines db</P>" );
exit();
}
$result = mysql_query("SELECT * FROM machines", $dbcnx);
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
if ($i == 0) echo ("<table width='100%' tableborder='YES' border='1'>"
echo ("<tr>"
$sql = "select hostname from machines where machine_id = '$i'";
$result = mysql_query($sql, $dbcnx);
echo ("<td ALIGN=center BGCOLOR='#99CCFF'>$result</td>"
echo ("</tr>"
if ($i == $num_rows-1) echo ("</table>"
}
?>