kalid24 Posted January 15, 2013 Share Posted January 15, 2013 HI, this coding is killing me and I'm sure it is something really simple. I am still learning PHP so please be nice! I have created a database in mysql (1 table ) with about 5 columns, I am trying to write a php script that will perform an sql query but based on the input a user puts in to search. <form action="<?PHP echo $_SERVER['PHP_SELF'];?>"> <p><b> <label for="domain">filter:</label> </b> <input type="text" name="filter" id="filter" value="<?PHP echo $_REQUEST['filter'];?>"> </p> </form> <?PHP Include "DB-connect.php"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; if(isset($_REQUEST['filter'])) { // do somthing with value: $_REQUEST['filter'] // somthing like $result = mysql_query("SELECT * FROM ".$db_name."severity_matrix WHERE 'network'= '".$_REQUEST['filter']."'"); //fetch tha data from the database while ($row = mysql_fetch_array($result)) { echo "link:".$row{'link'}." network:".$row{'network'}."line_rate: ". $row{'line_rate'}."<br>"; } } else { echo "no data found."; } //close the connection mysql_close($dbhandle); ?> ----------------------- When i load the script it shows the filter test with a text box for me to enter a search in and below it says connected my mySQL, no data found before I even get to search. That said, when i search a text that I know exists in the table under column 'network' it does not give me anything back, not even the "no data found" as per the loop. Please help!!!! Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted January 15, 2013 Share Posted January 15, 2013 (edited) i think your problem is at your query: $result = mysql_query("SELECT * FROM ".$db_name."severity_matrix WHERE 'network'= '".$_REQUEST['filter']."'"); after FROM the column name should be indicated, which is I suppose severity_matrix. Unless all your column name's start which the database name? where is this $db_name btw initialised? Also, what's in your DB-connect.php? since you make your connection under the include. Edited January 15, 2013 by stijn0713 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.