I will point out your errors below, but first.
1. When posting question use the [CODE/] around your code it makes it easier for other people to read your code.
2. Use indents in your code also to make it easier to read. People are less likely to help if they cannot easily read your code.
3. You should stop using mysql and switch to either mysqli or pdo. To change this you need to enable these modules in your php.ini file. That is found where ever you installed your php. They are discontinuing the use of the old mysql.
Now to your specific errors
You have four errors.
1. In creating your query string, you do did not properly format the string. When you join your variables with your literal string, you must use the
. to connect the components. Also when you have multiple items in your
"where" clause you must join them with
and or
or, not a comma
2. In the
if condition you need to capture the
result of the query
3. In the
while condition you need to refer to the
result not the query when retrieving your data.
4. In your final output string again you failed to concatenate the string using the
. between variables and literal strings.
Take a look at the changes I made below. Click the "
expand" to view the code properly. In each case I left (but commented out) your original code. Then I inserted the corrected code below.
-
<?php
-
include("config.php");
-
-
$name= $_POST['name'];
-
$password= $_POST['password'];
-
-
//your incorrect code
-
// $query = mysql_query("SELECT * FROM data WHERE name='$name', password='$password' ");
-
-
$query = mysql_query("SELECT * FROM data WHERE name=".$name." and password=".$password);
-
-
-
// your incorrect code
-
// if(mysql_num_rows($query))
-
if($result = mysql_num_rows($query))
-
{
-
-
//your incorrect code
-
// WHILE ($rows = mysql_fetch_array($query)):
-
WHILE ($rows = mysql_fetch_array($result)):
-
echo "<center>";
-
$name = $rows['name'];
-
$password = $rows['password'];
-
$age = $rows['age'];
-
$email = $rows['email'];
-
$contact = $rows['contact'];
-
$address = $rows['address'];
-
$course = $rows['course'];
-
$education = $rows['education'];
-
-
//your incorrect code
-
// echo "$name<br>$password<br>$age<br>$email<br>$contact< br>$address<br>$course<br>$education<br>";
-
-
echo $name."<br>".$password."<br>".$age."<br>".$email."<br>".$contact."<br>".$address."<br>".$course."<br>".$education."<br>";
-
-
echo "</center>";
-
-
endwhile;
-
-
}else{
-
-
echo"Error!!";
-
}
-
?>
-