Waarom kan ik niet includen op de volgende manier?
Admin.php:

$id = $row['id'];
$var = include('display_image.php?id=3');
$result = mysqli_query($conn,$sql) or die ("Error in query: $query. ".mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {  
    echo "<table class='bart' height=100px width=500px>";	
    while($row = mysqli_fetch_array($result))      {
echo "<tr>";
echo $var;


display_image.php:

<?php
 include "conf.php";
 // just so we know it is broken
 error_reporting(E_ALL);
 // some basic sanity checks
 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
     //connect to the db
     $link = mysql_connect("$host", "$user", "$pass")
     or die("Could not connect: " . mysql_error());

     // select our database
     mysql_select_db("$db") or die(mysql_error());

     // get the image from the db
     $sql = "SELECT image FROM test_image WHERE id=" .$_GET['id'] . ";";

     // the result of the query
     $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

     // set the header for the image
     header("Content-type: image/jpeg");
     echo mysql_result($result, 0);

     // close the db link
     mysql_close($link);
 }
 else {
     echo 'Please use a real id number';
 }
?>


[size=xsmall]Toevoeging op 29/06/2016 12:38:16:[/size]

HIj geeft dan de error:

Warning: include(display_image.php?id=3) [function.include]: failed to open stream: No error in C:\xampp\htdocs\PHProject\admin.php on line 108

Warning: include() [function.include]: Failed opening 'display_image.php?id=3' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\PHProject\admin.php on line 108
Je geeft een GET parameter mee. Dat gaat niet op die manier.

?id=3 moet je dus weglaten.

[size=xsmall]Toevoeging op 29/06/2016 12:41:36:[/size]

Een GET parameter verkrijg je via de browser en niet intern.
Wat moet ik er dan van maken dat hij wel gewoon de ID kent (zonder id vind Display_image de foto niet)
Waar komt die ID vandaan?
Je kunt dit script niet gebruiken door deze te includen in je huidige script. Volgens mij had ik dit in een ander topic al duidelijk gemaakt: deze moet verwerkt worden in een img tag.
<?php
$id = $row['id'];
$var = include('display_image.php?id=3');
$result = mysqli_query($conn,$sql) or die ("Error in query: $query. ".mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {
echo "<table class='bart' height=100px width=500px>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo $var;
?>
De toevoeging ?id=3 bij de include() moet weg.
In de include() kan je gewoon $id gebruiken, die bestaat daar omdat je die voor de include() hebt aangemaakt.
Als je include() in een $var wilt zetten moet de include eindigen met: return $inhoud (= wat de include als output heeft)
Ben, dat had ik eerst. Eerst had ik dat display_image.... in een imgtag maar een van de mensen waarmee ik dit project doe zei dat dat niet werkte, ik kreeg namelijk toen ook al verscheidene errors.
SSanthe is zal is kijken of het werkt.
Je probeert nu dus opnieuw binaire data te echoën in je HTML. Dat is iets dat gegarandeerd niet werkt. De img tag is de oplossing, en andere errors die er eventueel uit voortvloeien los je daarna op.

Daarnaast: een van de mensen zei het. Zei diegene ook waarom niet? Wat er fout aan is? Of een foutmelding die diegene kreeg? Of was het gewoon ongehinderd door enige kennis van zaken?

$id = $row['id'];
$var = include('display_image.php?id=$id');
$result = mysqli_query($conn,$sql) or die ("Error in query: $query. ".mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {  
    echo "<table class='bart' height=100px width=500px>";	
    while($row = mysqli_fetch_array($result))      {
echo "<tr>";
return $var;
echo "<td><b>



Warning: include(display_image.php?id=$id) [function.include]: failed to open stream: No error in C:\xampp\htdocs\PHProject\admin.php on line 109

Warning: include() [function.include]: Failed opening 'display_image.php?id=$id' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\PHProject\admin.php on line 109



[size=xsmall]Toevoeging op 29/06/2016 13:13:10:[/size]

whut. Vanochtend werkte display_image in image tag niet. Nu ineens wel.
Wat ik dan vanochtend fout deed weet ik ook niet. But it works.

Een tweede vraag: Hoe fix ik een Headers Already Sent error?
<?php
$id = $row['id'];
$var = include('display_image.php');
$result = mysqli_query($conn,$sql) or die ("Error in query: $query. ".mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {
echo "<table class='bart' height=100px width=500px>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo $var;
?>
<?php
include "conf.php";
// just so we know it is broken
error_reporting(E_ALL);
// some basic sanity checks
if(isset($id) && is_numeric($id)) {
//connect to the db
$link = mysql_connect("$host", "$user", "$pass")
or die("Could not connect: " . mysql_error());

// select our database
mysql_select_db("$db") or die(mysql_error());

// get the image from the db
$sql = "SELECT image FROM test_image WHERE id=" .$id . ";";

// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

// set the header for the image
header("Content-type: image/jpeg");
return mysql_result($result, 0);

// close the db link
mysql_close($link);
}
else {
return 'Please use a real id number';
}
?>
Gaat waarschijnlijk niet werken doordat er een header() in zit.
wijzigen.php


<!doctype html>
<?php
// Start the session
session_start();?>
<html>
<head>
<meta charset="utf-8">
<title>Naamloos document</title>
<link rel="stylesheet" type="text/css" href="Wijzigen.css" />
</head>

<body>
<?php
$host        =    'localhost';
$user        =    'root';
$password    =    'superbart';
$database    =    'phpopdracht';
$conn        =    mysqli_connect($host,$user,$password, $database) or die('Server Information is not Correct');

if (!$conn) {
        echo "<div>";
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        echo "</div>";
}
?>

<header>
		<div id="logoWrapper">
		
			<img src="images/logo.png" id="logo" />
            <h1 id="headerTitle">adresboek</h1>
			
		</div>
		
		<div id="beamWrapper">
		
			<div id="beam"></div>
			
		</div>
	</header>
    
    <main>
<?php 
{
	echo"<form action='Updatequery.php' method='post'>";
echo "<table width='690' border='0'>";
echo "<tbody>";

echo "<tr>";
echo "<td>Voornaam:</td>"; 
echo "<td> <input type='text' name='Vnaam' style='width:300px;' value='";
echo $_SESSION["Voornaam"];
echo "'> </td>"; 
echo "</tr>";

echo "<td>Achternaam:</td>"; 
echo "<td> <input type='text' name='Anaam' style='width:300px;' value='";
echo $_SESSION["Achternaam"];
echo "'> </td>"; 
echo "</tr>";

echo "<td>gebruikersnaam:</td>"; 
echo "<td> <input type='text' name='Anaam' style='width:300px;' value='";
echo $_SESSION["Gebruiker"];
echo "'> </td>"; 
echo "</tr>";
echo "<tr>";
echo"<td>Straat en huisnummer:</td>";
echo"<td><input type='text' name='Straat' style='width:300px;' value='";
echo $_SESSION["Straat"];
echo "'> <input type='text' name='Huisnummer' style='width:40px;' value='";
echo $_SESSION["Huisnummer"];
echo "'></td>";
echo "</tr>";

echo "<td>Postcode:</td>"; 
echo "<td> <input type='text' name='Postc' style='width:300px;' value='";
echo $_SESSION["Postcode"];
echo "'> </td>"; 
echo "</tr>";


echo "<td>Plaats:</td>"; 
echo "<td> <input type='text' name='Plaats' style='width:300px;' value='";
echo $_SESSION["Plaats"];
echo "'> </td>"; 
echo "</tr>";



echo "<td>Opmerking:</td>"; 
echo "<td> <textarea name='Opmerking' style='width:300px; height:150px; value='";
echo "'>". $_SESSION["Opmerking"]."</textarea>"; 
echo "</tr>";

echo "<tr>";
echo"<td></td>";
echo"<td><input type='submit' value='wijzigen' class='button'></td>";  
echo "</tr>";
echo "</tbody>";
echo "</table>";
echo "</form>";
}

?>

</main>

<footer>

	
	<p>Team naamloos &copy;</p>
	
	</footer>
    
<?php 
$conn->close();
?>
</body>
</html>


Je komt op de wijzigen pagina via de admin pagina:


<?php
session_start();
if(isset($_GET['id']))
{ 
  $id = intval($_GET['id']);
  // getting info from db
}
?><!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="admin.css" />
    <script type="text/javascript" src="../totaal php/tinybox.js"></script>
</head>
<?php include 'style.css'?>
<body>
<?php
$host        =    'localhost';
$user        =    'root';
$password    =    'superbart';
$database    =    'phpopdracht';
$conn        =    mysqli_connect($host,$user,$password, $database) or die('Server Information is not Correct');
?>
<header>
		<div id="logoWrapper">
		<img src="images/logo.png" id="logo" />
	<h1 id="headerTitle">adresboek</h1>
	</div>
	<div id="beamWrapper">
	<div id="beam"></div>	
		</div>
	</header>
	<main>
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
        <table width="690" border="0">
  <tbody>
    <tr>
      <td>Voorletters, Voornaam:</td>
      <td><input type="text" name="txtVletters" id="txtVletters" style="width:75px;">
	  <input type="text" name="txtVnaam" id="txtVnaam" style="width:300px;"></td>
    </tr>
    <tr>
      <td>Achternaam:</td>
      <td><input type="text" name="txtAnaam" id="txtAnaam" style="width:383px;"></td>
    </tr>
    <tr>
      <td>Straat, Huisnummer:</td>
      <td><input type="text" name="txtStraat" id="txtStraat" style="width:300px;">
	  <input type="text" name="txtHuisnummer" id="txtHuisnummer" style="width:75px;"></td>
    </tr>
    <tr>
      <td>Postcode:</td>
      <td><input type="text" name="txtPcode" id="txtPcode" style="width:150px;"></td>
    </tr>
    <tr>
      <td>Plaats:</td>
      <td><input type="text" name="txtPlaats" id="txtPlaats" style="width:383px;"></td>
    </tr>
	<tr>
	<td>Zoeken op:</td>
	<td>
<select name="Names">
  <option value="Voornaam" name="Voornaam">Voornaam</option>
  <option value="Achternaam" name="Achternaam">Achternaam</option>
  <option value="Straat" name="Straat">Straat</option>
  <option value="Postcode" name="Postcode">Postcode</option>
  <option value="Plaats" name="Plaats">Plaats</option>
</select>
  </td></tr></tbody>
</table>
<button onclick="TINY.box.show({url:'GebruikerToevoegen.php',width:1000,height:500})" class="toevoegenButton" id="add">Toevoegen</button>
<button onClick="clearFields()" class="leegButton">Leegmaken</button>
<button class="zoekButton" id="zoek" name="zoek">Zoeken</button>
</form>
<script type="text/javascript">
function clearFields() {
    document.getElementById("Vnaam").value=""
    document.getElementById("Vvg").value=""
	document.getElementById("Anaam").value=""
	document.getElementById("Straat").value=""
	document.getElementById("Huisnummer").value=""
	document.getElementById("PCodeNummer").value=""
	document.getElementById("PCodeLetters").value=""
	document.getElementById("Plaats").value=""
}
			</script><?php
			if(isset($_POST['zoek']))
		{
			$value = $_POST['Names']; 
$sql = "SELECT id, Voornaam, Voorvoegsels, Achternaam, Straat, Huisnummer, Postcode, Opmerking, Leeftijd, Plaats FROM gebruikers ";
if($value == 'Achternaam') {
    $sql.= "WHERE Achternaam = '".$conn->real_escape_string($_POST['txtAnaam'])."' ";
}
if($value == 'Voornaam') {
    $sql.= "WHERE Voornaam = '".$conn->real_escape_string($_POST['txtVnaam'])."' ";
}
if($value == 'Straat') {
    $sql.= "WHERE Straat = '".$conn->real_escape_string($_POST['txtStraat'])."' ";
}
if($value == 'Postcode') {
    $sql.= "WHERE Postcode = '".$conn->real_escape_string($_POST['txtPcode'])."' ";
}
if($value == 'Plaats') {
    $sql.= "WHERE Plaats = '".$conn->real_escape_string($_POST['txtPlaats'])."' ";
}

$result = mysqli_query($conn,$sql) or die ("Error in query: $query. ".mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {  
    echo "<table class='bart' height=100px>";	
    while($row = mysqli_fetch_array($result))      {
		$_SESSION["id"] = $row['id'];
$_SESSION["Voornaam"] = $row['Voornaam'];
$_SESSION["Leeftijd"] = $row['Leeftijd'];
$_SESSION["Achternaam"] = $row['Achternaam'];
$_SESSION["Opmerking"] = $row['Opmerking'];
$_SESSION["Straat"] = $row['Straat'];
$_SESSION["Huisnummer"] = $row['Huisnummer'];
$_SESSION["Postcode"] = $row['Postcode'];
$_SESSION["Plaats"] = $row['Plaats'];
$_SESSION["Gebruiker"] = $row['gebruikersnaam'];
$id = $row['id'];
echo "<tr  class='plaatje'>";
echo "<td><img src='display_image.php?id=3' height='250px' width='250px'/>";
echo "</tr><tr class='tabletd' >";
echo "<td ><b><center>" . $row['Voornaam'] . " " . $row['Achternaam'] . "</center></b></td>"; 
echo "</tr><tr>";
echo "<td><b><center>" . $row['Leeftijd'] . " Jaar</center></b></td>"; 
echo "</tr><tr>";
echo "<td><b><center>" . $row['Straat'] . " " . $row['Huisnummer'] . "</center></b></td>"; 
echo "</tr><tr>";
echo "<td><b><center>" . $row['Postcode'] . "</center></b></td>";
echo "</tr><tr>";
echo "<td><b><center>" . $row['Plaats'] . "</center></b></td>"; 
echo "</tr><tr>";
echo "<td><b><center><a href='VerwijderGebruiker.php?id=" . $row['id'] . "'><button class='verwijderButton' id='verwijderen' name='verwijderen'>Verwijderen</button></a></center></b></td>"; 
echo "</tr>";
echo "</tr><tr class='laatstetr'>";
echo "<td><b><center><a href='Wijzigen.php?id=" . $row['id'] . "'><button class='verwijderButton' id='verwijderen' name='verwijderen'>Wijzigen</button></a></center></b></td>"; 
echo "</tr>";
}
echo "</table>";
} 
else {
    echo "De persoon die u zoekt is niet gevonden.";
}
$conn->close();
		}?></main>
		<article></article>
		<footer><p>Team naamloos &copy;</p></footer>
	</body>
</html>

Reageren