Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.