pure_skill_2000 Posted December 19, 2007 Share Posted December 19, 2007 Hi This is a really simple php question I am sure but I am new to php and no matter what I do or where I look I cannt seem to make the code work, all I want is a simple search to allow a user to enter there forname and it be searched to return the results, below is the code I have which will not work <!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" /> <title>Week 7 Ex 3</title> </head> <body> <FORM NAME="searchphone" METHOD="post" ACTION="results.php"> Enter First Name: <input name="Array[Forname]" type="text" id="Array[Forname]"><BR> <input type="submit" name="Submit" value="Submit"> </FORM> </body> </html> results.php <!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" /> <title>Untitled Document</title> </head> <body> <?php $Array["Forname"] =trim ($Array["Forname"]); $Host=""; $User=""; $Password=""; $DBName=""; $TableName=""; $Link = mysql_connect($Host, $User, $Password); $Query="SELECT * from $TableName Where Forname = $Array[Forname]"; $Result = mysql_db_query($DBName, $Query, $Link) or die(mysql_error()); while($row = mysql_fetch_array($result)){ print (" Name:$Row[surname], $Row[Forname] Phone: $Row[Telephone]<BR> "); } mysql_close ($Link); ?> </body> </html> Of course in my code I have put in the connection details but I do not want to display them on the internet Many thanks Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 19, 2007 Share Posted December 19, 2007 $Query="SELECT * from $TableName Where Forname = $Array[Forname]"; Is the casing correct in that statement? MySQL is Case sensitive allso, I would add ` around tablename and Forname Example: $Query="SELECT * from `$TableName` Where `Forname` = $Array[Forname]"; Quote Link to comment Share on other sites More sharing options...
pure_skill_2000 Posted December 19, 2007 Author Share Posted December 19, 2007 I have tried this, however it didnt seem to make any difference 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.