mysql php help

Status
Not open for further replies.

WebDevelopmentNewb

Beta member
Messages
1
PHP:
<?phpif($_GET){
	$gender = $_GET['gender'];
	$connect = mysql_connect("localhost","root","");
	if($connect){
		mysql_select_db ("randomData",$connect);
		$query = "SELECT * FROM randomtable WHERE Gender='" . $gender . "'";
		$results = mysql_query($query);
		while($row = mysql_fetch_array($results)){
			echo $row['Name'] . "<br/>" . $row['Surname'] . "<br/>" . $row['Email'] ;
		}
		} else {
	die(mysql_error());
	}
}


?>


<html>


<body>
<form action = "" method = "GET">
find entries that are: <br/>
<input type = "radio" name="gender" value="Male">Male</input><br/>
<input type="radio" name="gender" value = "Female">Female</input><br/>
<input type="submit" value = "go" />


</body>

</html>



i keep getting this warning "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\delete_DONKEY\Tutorial 2 -_Retrieving_Data_NOT_COMPLETE.php on line 9"

i'm trying to follow this video http://www.youtube.com/watch?v=fO50Cv0r7LE&feature=relmfu[h=1]MySQL For Beginners - Tutorial 3 - Searching a Database with PHP[/h]
i've been sitting here maticulously trying to figure out where my syntax is not exactly the same as the video , but i can;t locate the issue , thanks for your help !
 
prolly a issue with the query. php manual says if the query is invalid, then mysql_query returns false


PHP: mysql_query - Manual

Example #1 Invalid Query

The following query is syntactically invalid, so mysql_query() fails and returns FALSE.

<?php
$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
die('Invalid query: ' . mysql_error());
}

?>


ps -- bbcode has php tags which adds color highlighting
 
Status
Not open for further replies.
Back
Top Bottom