homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Newbie in need of help with MySQL and PHP

 5:48 pm on Sep 1, 2004 (gmt 0)

Sorry for such a lame question......

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.


<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">

$host = "localhost";
$user = "username";
$pass = "password";
$dbname = "database";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
$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.....



 7:29 pm on Sep 1, 2004 (gmt 0)

Welcome to WebmasterWorld StevieMac,

my wild guess is that the query isn't working try this to help debug

$query = mysql_query($sql) or die(mysql_error());


 1:45 am on Sep 2, 2004 (gmt 0)


Thanks for responding so quickly. I made the change like you suggested and I can't believe that I made that simple of a mistake. However, all I still get is

select * from wifi_ap where SSID ='

On the page. I get that because I put an echo statment in there to also try and debug.



 1:50 am on Sep 2, 2004 (gmt 0)

with what you have above you are missing a ' between SSID = '" . $_POST['


 3:58 am on Sep 2, 2004 (gmt 0)


That was it.... but now it returns every record in that database. Not the one's that I'm searching for.....



 10:50 am on Sep 2, 2004 (gmt 0)

Well I am not to sure on how case snsitive this stuff is since I am lazy and use lower case. In your form you have ssid in your $_POST you have SSID... it is possible that the difference there is causing you to return all records instead of just the one you want.


 2:36 pm on Sep 2, 2004 (gmt 0)

A perfect example of why error reporting should always be set to E_ALL for development. You would get a "undefined index" warning if you turned up error reporting (yes, variables, constants and array indices are case sensitive in PHP, even under Windows).

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.



 9:58 pm on Sep 2, 2004 (gmt 0)


Understandable about the E_All. I do have that on, it it doesn't say anything. Also the echo of the SQL shows:

select * from wifi_ap where ssid =''

Here is my two lines of code.

$sql = "select * from wifi_ap where ssid ='" . $_POST['SSID'] . "'";
echo $sql;



 10:02 pm on Sep 2, 2004 (gmt 0)


I think that I figured it out. Thanks to you all....

I had the post ssid in CAPS. It was lowercase in the form.


$sql = "select * from wifi_ap where SSID ='" . $_POST['ssid'] . "'";


 10:54 pm on Sep 2, 2004 (gmt 0)

That's really curious. Normally with E_ALL you should have gotten a notice or warning for undefined index. Are you sure you aren't suppressing errors or notices?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved