Jump to content

Blank page?


mlummus

Recommended Posts

When viewing this program in a browser, I'm getting nothing - no html, no php, no source whatsoever - just white. The page is coming up blank. Any idea why?

 

<html>
<head>
<title> Student Delete </title>
</head>
<body>
<h1>Student Delete Form </h1>
<h2>Select a Student</h2>

<?php
$db = mysqli_connect("dbserver.com", "user", "password");
if (!db) {echo "Error: Could not connect to database."; 
exit;}
mysqli_select_db("dbname");

$query = "SELECT id from student";
$result = mysqli_query($query);
$num_results = mysqli_num_rows($result);

echo "<p> Number of students found: ".$num_results."</p>";
echo "<form method='post' action='studentfind.php'>";
echo "ID:" <select name = 'id'>";

for ($i=0; $i < $num_results; $i++)
{
$row=mysqli_fetch_array($result);
$id = $row["id"];
echo "<option value = "$id"> $id </option>";
}

echo "<input type='submit' value='delete' />";
echo "</form>";

mysqli_close("$db");
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/201787-blank-page/
Share on other sites

there are a couple of error in the code you pasted

 

echo "ID:" <select name = 'id'>";

for ($i=0; $i < $num_results; $i++)
{
$row=mysqli_fetch_array($result);
$id = $row["id"];
echo "<option value = "$id"> $id </option>";
}

echo "<input type='submit' value='delete' />";
echo "</form>";

 

should be

 

echo "ID: <select name = 'id'>";

for ($i=0; $i < $num_results; $i++)
{
$row=mysqli_fetch_array($result);
$id = $row["id"];
echo "<option value = ".$id."> ".$id." </option>";
}

echo "<input type='submit' value='delete' />";
echo "</form>";

 

you have to pay attention to the strings

Link to comment
https://forums.phpfreaks.com/topic/201787-blank-page/#findComment-1058456
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.