Fatal error: Cannot redeclare class Video
Jeg får denne fejl og har prøvet at bruge require_once(); uden held.Kode:
index :
<?php
echo '<a href="index.php?page=index2">index2</a>';
switch($_GET['page'])
{
case 'vis_produkt':
include('vis_produkt.php');
//break;
case 'index2':
include('index2.php');
//break;
}
?>
index2.php :
<?php
//include_once 'connect.php';
require_once('connect.php');
class Video {
public $titel;
function udskrivVideo() {
echo "<p>".$this->titel." </p>";
}
}
$test_1 = new Video();
$test_2 = new sql();
$test_2->connect();
$test_2->q("SELECT * FROM navn");
while($array = $test_2->a()){
echo $array["fornavn"]."<br />";
echo $array["efternavn"]."<br /><br />";
echo '<a href="index.php?page=vis_produkt&id='. $array["id"] .'">Link</a><br>';
}
$test_2->close();
$test_1->udskrivVideo();
?>
vis_produkt.php :
<?php
//include_once 'connect.php';
require_once('connect.php');
class Video {
public $titel;
function udskrivVideo() {
echo "<p>".$this->titel." </p>";
}
}
$test_1 = new Video();
$test_2 = new sql();
$test_2->connect();
$test_2->q("SELECT * FROM navn WHERE id='".$_GET['id']."'");
while($array = $test_2->a()){
echo $array["fornavn"]."<br />";
echo $array["efternavn"]."<br /><br />";
}
$test_2->close();
$test_1->udskrivVideo();
unset($test_1);
unset($test_2);
?>
