Start New Discussion Reply to this Discussion unidentified variable: name
hello! am trying to do a simple search engine, but whenever the user types a search term, the script returns the error: unidentified variable: name. name was the input name in the html code. ie (input name="name"). thanks.
<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("room_p7", $db);
$query = "select name, course from members where name ='$name'";
$result = mysql_query($query);
while($record=mysql_fetch_assoc($result)){
while(list($fieldname, $fieldvalue) = each($record)){
echo $fieldname."\t".$fieldvalue."\t\t\t";
}
echo "<br><br>";
}
?>
collinskawere
Newbie Poster
12 posts since Nov 2011
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0
Where are you defining $name variable before using it? Do you mean something like $name = $_POST("name"); ? Of course using MySQL without validations or/and prepared statements is really a bad way to do things (PHP has PDO).
jkon
Posting Whiz
383 posts since Jan 2009
Reputation Points: 124
Solved Threads: 63
Skill Endorsements: 4
yes! thanks. though i had already figured that out.
collinskawere
Newbie Poster
12 posts since Nov 2011
Reputation Points: 12
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0644 seconds
using 2.66MB