yoki Posted October 23, 2008 Share Posted October 23, 2008 Hi, Please look at the following code. I am getting a parsing error in mysql query...I'm fairly new to php so would appreciate your help. <form id="form1" name="form1" method="post" action="test.php"> <?php $username = "bogus"; $password = "bogus"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $area_code = $_POST['Area_Code']; $phone = $_POST['Phone']; if (isset($_POST['Submit'])) { $selected = mysql_select_db("dncl",$dbh) or die("Could not select MySQL Database."); $result = mysql_query("SELECT Telephone.Area_Code,Telephone.Phone FROM Telephone WHERE Telephone.Area_Code = '$area_code' AND Telephone.Phone = '$phone'"); while($row = mysql_fetch_array($result)) { $i = 1; echo $i . "." . $row['Area_Code'] . " " . $row['Phone']; echo "<br />"; $i++; } } ?> Area Code: <select name="Area_Code"> <option value="204">204</option> <option value="226">226</option> <option value="250">250</option> <option value="289">289</option> <option value="306">306</option> <option value="403">403</option> <option value="416">416</option> <option value="418">418</option> <option value="438">438</option> <option value="450">450</option> <option value="500">500</option> <option value="506">506</option> <option value="514">514</option> <option value="519">519</option> <option value="581">581</option> <option value="587">587</option> <option value="600">600</option> <option value="604">604</option> <option value="613">613</option> <option value="647">647</option> <option value="705">705</option> <option value="709">709</option> <option value="778">778</option> <option value="780">780</option> <option value="807">807</option> <option value="819">819</option> <option value="867">867</option> <option value="902">902</option> <option value="905">905</option> </select> <? mysql_close($dbh); ?>Phone Number: <input name="Phone" type="text" size="6" maxlength="7" /> <input type="submit" name="Submit" value="Search" /> </form> <p> </p> Quote Link to comment https://forums.phpfreaks.com/topic/129807-simple-parsing-error/ Share on other sites More sharing options...
yoki Posted October 23, 2008 Author Share Posted October 23, 2008 Anyone? :'( Quote Link to comment https://forums.phpfreaks.com/topic/129807-simple-parsing-error/#findComment-673054 Share on other sites More sharing options...
PFMaBiSmAd Posted October 23, 2008 Share Posted October 23, 2008 Posting the error message would help someone to help you. How do you expect someone to be able to help, when you don't post all the relevant information about the problem that you see in front of you when you run your code. Quote Link to comment https://forums.phpfreaks.com/topic/129807-simple-parsing-error/#findComment-673186 Share on other sites More sharing options...
fenway Posted October 23, 2008 Share Posted October 23, 2008 Better yet, echo the actual query. Quote Link to comment https://forums.phpfreaks.com/topic/129807-simple-parsing-error/#findComment-673244 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.