I am having trouble printing out results using your tutorial php format. I can't see any errors of copying but they must be there somewhere! The database 'mail' has only one table: 'info' with four entries, one of which has 'good' in the 'opinion' field.
My php file is:
<html>
<head><title> How to Grab your MySQL Data </title></head>
<body bgcolor="#FFFFF F">
<php?
/* declare some relevant variables */
$DBhost = "localhost" ;
$DBuser = "root";
$DBpass = "";
$DBName = "mail";
$table = "info";
mysqli_connect( $DBhost,$DBuser ,$DBpass) or die("Unable to connect to database");
@mysqli_select_ db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table WHERE opinion = 'good'";
$result = mysqli_query($s qlquery);
$number = mysqli_num_rows ($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>The re Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thename = mysqli_result($ result,$i,"name ");
$theemail = mysqli_result($ result,$i,"emai l");
<p><b>Name:</b><?php $thename?><br /><b>E-Mail:</b><?php>$theema il?></p>";
$i++;
}
}
?>
</BODY></HTML>
The result:
$i) { $thename = mysqli_result($ result,$i,"name "); $theemail = mysqli_result($ result,$i,"emai l");
Name:
E-Mail:$theemail? >
"; $i++; } } ?>
There are no log errors in Apache22.
My php file is:
<html>
<head><title> How to Grab your MySQL Data </title></head>
<body bgcolor="#FFFFF F">
<php?
/* declare some relevant variables */
$DBhost = "localhost" ;
$DBuser = "root";
$DBpass = "";
$DBName = "mail";
$table = "info";
mysqli_connect( $DBhost,$DBuser ,$DBpass) or die("Unable to connect to database");
@mysqli_select_ db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table WHERE opinion = 'good'";
$result = mysqli_query($s qlquery);
$number = mysqli_num_rows ($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>The re Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thename = mysqli_result($ result,$i,"name ");
$theemail = mysqli_result($ result,$i,"emai l");
<p><b>Name:</b><?php $thename?><br /><b>E-Mail:</b><?php>$theema il?></p>";
$i++;
}
}
?>
</BODY></HTML>
The result:
$i) { $thename = mysqli_result($ result,$i,"name "); $theemail = mysqli_result($ result,$i,"emai l");
Name:
E-Mail:$theemail? >
"; $i++; } } ?>
There are no log errors in Apache22.
Comment