Hi everyone. I need help. : )
This is my code:
function dispdata($host) {
mysql_connect("localhost", "root", "");
mysql_select_db("Serverinv");
$query = "SELECT * FROM serverinvmain";
$query .= "WHERE hostname=$host ";
if (!($result = mysql_query($query))) {
print("error: " . mysql_error() . "\n");
exit();
}
print ("$result\n");
$row = mysql_fetch_object($result, MYSQL_ASSOC);
foreach ($row as $key=>$data) {
print("<CENTER>\n");
print("$key, $data");
print("</CENTER>\n");
}
}
This is the error I receive:
error: You have an error in your SQL syntax near '=sonic.sparklist.com ' at line 1
It is reading $host correctly. I'm rather new at this and I'm not sure what's wrong with the syntax. I have tried using
WHERE hostname LIKE $host and many other combinations. The result being the same. Please help.
Thanks,
Mindy
This is my code:
function dispdata($host) {
mysql_connect("localhost", "root", "");
mysql_select_db("Serverinv");
$query = "SELECT * FROM serverinvmain";
$query .= "WHERE hostname=$host ";
if (!($result = mysql_query($query))) {
print("error: " . mysql_error() . "\n");
exit();
}
print ("$result\n");
$row = mysql_fetch_object($result, MYSQL_ASSOC);
foreach ($row as $key=>$data) {
print("<CENTER>\n");
print("$key, $data");
print("</CENTER>\n");
}
}
This is the error I receive:
error: You have an error in your SQL syntax near '=sonic.sparklist.com ' at line 1
It is reading $host correctly. I'm rather new at this and I'm not sure what's wrong with the syntax. I have tried using
WHERE hostname LIKE $host and many other combinations. The result being the same. Please help.
Thanks,
Mindy