I'm relatively new to the database world, so please excuse me for a simple question...
I have a MySQL database set up on my web server, and a php script to search the database. It outputs everything perfectly. When I try to run it locally, my results page only shows the variables that were defined, not the info from the database. It looks like this...
Name: $lname, $fname $mi
...instead of...
Name: Public, John Q
like it does when I run it online.
I have tried it running WAMPServer and xampp, but I get the same results either way. Can someone please tell me what I'm missing?
Search Page:
HTML Code:
<!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>Admin List</title>
<link href="admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header"><h1>Search the Admin List</h1></div>
<div id="contents">
<div id="search">
<form method="post" action="search.php">
<label for="search">Name:</label><input type="text" id="status" name="search" size=25 maxlength=25>
<input type="Submit" name="Submit" value="Search">
</form>
</div>
</div>
</body>
</html>
Results Page:
PHP Code:
<!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> <link href="output.css" rel="stylesheet" type="text/css" /> </head> <body> <input type=button value="Back" onClick="history.go(-1)"> <div id="output"> <? mysql_connect("localhost","*username*","*pw*");
mysql_select_db("*db*");
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM name WHERE lname LIKE '%$search%'");
while($r=mysql_fetch_array($result)) {
$lname=$r["lname"]; $fname=$r["fname"]; $mi=$r["mi"]; $admin=$r["admin"]; $floor=$r["floor"]; echo "<b>Name:</b> $lname, $fname $mi <br><b>Admin/Dept:</b> $admin <br><b>Floor/Building:</b> $floor <br><hr>"; } ?> </div> </body> </html>
|