Forum Moderators: coopster
I have searched up and down on this site for ideas on how to fix this, however I just cant seem to find an answer.
I want to take a form and POST to a script and return rows from a sql database. From what I am quering on, it has duplicate entry's however, they are not primary.
<html>
<body>
<form name="wifi" method="POST" action="results.php">
<p> SSID: <input name="ssid" type="text" id="ssid">
<p><input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?
$host = "localhost";
$user = "username";
$pass = "password";
$dbname = "database";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$sql = "select * from tablename where SSID = " . $_POST['SSID'] . "'";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<p>",$row['SSID'],": ",$row['BSSID'];
}
?>
When I input something in the textbox and hit submit, I just get a blank screen. I did have an echo as seen in a previous post, and it shows the echo, but nothing else.
Please, any help would be appreciated.....
So $_POST['SSID'] should be undefined, so PHP will treat is as an empty string, but that shouldn't return all records unless the SSID column is in fact empty in the data.
Echo out your $SQL var to see what query you're actually sending to the DB server.
To change error reporting, search for error_reporting in your php.ini and change it to E_ALL on your development computer. It will make life much easier in the long run.
Tom