Hi this is a very very very basic snippet of code but is causing a very annoying problem.. I am basically doing a lookup on one of our companys servers to check wether or not a customer has virus protection enabled on there account now i can see that it is connected and is pulling the records as when i use mysql_num_rows() on the query i get the num of rows that been returned however when i am trying to display that data (unformatted for now) it doesnt display anything at all the code is below (i have removed table names and host etc etc for security but they are right..
<?php
if (!isset($custid)) {
echo "<h2>Enter Your Search Criteria Below:</h2>";
echo "This tool will help you check wether customers have virus checking enabled on their account<br>";
echo "<form action='$PHP_SELF' method='GET'>";
echo "SEARCH FOR USER : ";
echo "<input type='text' name='custid'> ";
echo "<input type='submit' value='Locate Records'>";
echo "</form>";
}
else {
$mysql_host = "serveraddy";
$accessid = "username";
$accesspwd = "password";
$database = "db_name";
$table = "tbl_name";
$command = "SELECT *FROM $table WHERE customer LIKE '%$custid%'";
$conn = mysql_connect ("$mysql_host", $accessid, $accesspwd);
if (!$conn) {
die ("<b>ERROR</b> : A connection to the MySQL server has failed.<br>");
}
$db = mysql_select_db ("$database", $conn);
if (!$db) {
die ("<b>ERROR</b> : The database could not be selected.<br>");
}
$query = mysql_query ("$command");
if (!$query) {
die ("<b>ERROR</b> : MySQL query has failed.<br>");
}
$num_rows = mysql_num_rows ($query);
echo "<b>Number of rows in result</b> : $num_rows<br><br>";
echo "<h3>RESULTS : <BR></h3>";
while ($data = mysql_fetch_row ($query)) {
foreach ($data as $output);
print "Data output : $output<br>";
}
echo "<h2>Search Again :</h2>";
echo "This tool will help you check wether customers have virus checking enabled on their account<br>";
echo "<form action='$PHP_SELF' method='GET'>";
echo "SEARCH FOR USER : ";
echo "<input type='text' name='custid'> ";
echo "<input type='submit' value='Locate Records'>";
echo "</form>";
mysql_close ($conn);
}
?>
Any ideas ? its like its returning an empty set ??
Cheers
Poolie, π