francodc Posted September 25, 2008 Share Posted September 25, 2008 Hi, I am fairly new to PHP and I got an issue which I can not solve, I can realy use some help. I created a form that GETs two input variables and spits to another script that I created which querries, fetches and displays data from a DB. The problem is that if I select my first non empty option from (name="from" and name="to') everything works fine, however if I choose a any other option from name="to" other than "LC & I Berlin..." nothing happens on the querry side. Here is my form. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php include("includes/connect.php"); ?> </head> <body> <form action="test2_php.php" method="GET"> Where are you calling from : <select name="from"> <option></option> <option value="LC & I Berlin Office">LC & I Berlin Office</option> <option value="Germany">Germany</option> </select> Where are you calling to: <select name="to"> <option></option> <option value="LC & I Berlin Office">LC & I Berlin Office</option> <option value="Germany">Germany</option> <option value="LC & I SAS Douarnenez-Office">LC & I SAS Douarnenez - Office</option> <option value="LC & I SAS Levallois-Office">LC & I SAS Levallois - Office</option> <option value="Media5 Europe–Office">Media5 Europe – Office</option> <option value="Canada">Canada</option> <option value="United States">United States</option> <option value="France">France</option> <option value="My Mailbox">My Mailbox</option> </select> <input type="submit" value="Submit"> </form> </body> </html> End of Code Here is my post script running the querry. I've included comments for ease of reading <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php include("includes/connect.php"); ?> </head> <body> <?php // Check to see if the values were seleted, if one of them is missing then display message. if (($_GET["from"] != NULL) AND ($_GET["to"] != NULL)) { echo "You are calling from: "; echo $_GET["from"]; echo "<br />"; echo "You are calling to: " ; echo $_GET["to"] . "<br/>"; } else { echo "Did you forget something! Please go back and fill in the missing details." . "<br />" ; } // Assign the input selection to variables. $infrom = $_GET["from"]; $outto = $_GET["to"]; // Print out the varibales for testing echo "<br /> Variable definition check"; echo "<br />from " . $infrom . "<br />"; echo "to " . $outto. "<br /><br />"; // Fetch the results the voip_lagasse DB for rows outto and infrom $query = "SELECT * FROM voip_lagasse WHERE (outto = '$outto') AND (infrom = '$infrom')"; $result = mysql_query($query); // Test to see if query worked properly if (!$result) { die ("Could not query the database: <br />". mysql_error()); } // Print out the results from the rows instruct, comment and digit while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row[instruct]. '<br />'; echo $row[comment]. '<br />'; echo $row[digit]. '<br />'; } ?> </body> </html> END of Code Thank's for your time... cheers Quote Link to comment https://forums.phpfreaks.com/topic/125829-stumped-as-to-why-i-cant-query-properly-from-a-form/ Share on other sites More sharing options...
CroNiX Posted September 26, 2008 Share Posted September 26, 2008 you forgot the quotes in your associative array in the 2nd file at the bottom: while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['instruct']. '<br />'; echo $row['comment']. '<br />'; echo $row['digit']. '<br />'; } Quote Link to comment https://forums.phpfreaks.com/topic/125829-stumped-as-to-why-i-cant-query-properly-from-a-form/#findComment-650887 Share on other sites More sharing options...
francodc Posted September 26, 2008 Author Share Posted September 26, 2008 Thanks for the info, I included the quotes that I forgot and I am still getting the same result. If you want to see the script in action here is the link ... http://www.m5t.com/lagasse/test_php.php Quote Link to comment https://forums.phpfreaks.com/topic/125829-stumped-as-to-why-i-cant-query-properly-from-a-form/#findComment-651229 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.