我有这三个文件: index.php:
<div class="tweet_bx">
<form method="post" name="m_gigs" id="m_gigs" enctype="multipart/form-data" action="index.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Filter gigs by</strong></td>
<td class="<?php echo $class1; ?>" width="8%" align="center" ><a class="cuuuent" href="index.php?gigs=latest" >Latest</a></td>
<td class="<?php echo $class2; ?>" width="15%" align="center"><a href="index.php?gigs=popular">Most Popular</a></td>
<td class="<?php echo $class3; ?>" width="15%" align="center"><a href="index.php?gigs=rating" >Best Ratings</a></td>
</tr>
</table>
<table>
<?php
include('Sql.php');
$c = new connexion();
$videos= $c->getVideos();
for($i=0;$i<sizeof($videos); $i++)
{
?>
<tr><td colspan = "2"><img src="<?php echo $videos[$i]['image']; ?> " /></td>
<td><label color="blue"><?php echo $videos[$i]['titre']; ?></label></td>
</tr>
<tr>
<td><label color="blue"><?php echo $videos[$i]['description']; ?></label></td>
</tr>
<?php
}
?>
</table>
</form>
</div>
<div class="tweet_bx">
<?php
?>
</div>
</div>
<?php include('right.php'); ?>
</div>
文件 right.php:
<div class="right_box">
<div class="right_box_center">
<ul>
<?php
include('Sql.php');
$c = new connexion();
$categories = $c->getCategories();
for($i=0;$i<sizeof($categories) ; $i++){
?>
<li><a href="index.php?categorie=<?php echo $categories[$i]['categorie'];?>"><?php echo $categories[$i]['categorie'];?></a> </li>
<?php
}
?>
</ul>
</div>
<img align="middle" src="images/img.jpg" />
<a href="javascript:popup()"> <img align="middle" src="images/invite.jpg" style="padding-left:32px;" /></a>
</div>
最后是文件 sql.php:
<?php
class connexion {
function __construct(){
$HOST_DB ="mysql11.000webhost.com";
$NAME_DB="a1638637_fiverr";
$USER_DB ="a1638637_afif";
$PWD_DB="azerty2012";
$connect = mysql_connect($HOST_DB,$USER_DB,$PWD_DB) or die();
$db=mysql_select_db($NAME_DB);
}
//Registration part
function register($email,$login,$pass){
$verif_email= $this->exists($email,0);
$verif_user = $this->exists($user,1);
if(!$verif_email && !$verif_user){
$requete_insert_tem ="INSERT INTO member (`email`,`user`,`password`) VALUES ('".$email."', '".$login."','".$pass."'); ";
mysql_query($requete_insert_tem) or die();
return true;
}
else return false;
}
function exists($attribut,$number){
if($number==0){
$Log_query=mysql_query("SELECT * FROM member WHERE email ='$attribut'") or die(mysql_error());
if ($Log_query == true && mysql_num_rows($Log_query) >0)return true;
else return false;
}
if($number==1){
$Log_query=mysql_query("SELECT * FROM member WHERE user ='$attribut'") or die(mysql_error());
if ($Log_query == true && mysql_num_rows($Log_query) >0)return true;
else return false;
}
}
//login part
function login($attr, $pass){
$verif_email= $this->exists($attr,0);
$verif_user = $this->exists($attr,1);
if($verif_email){
$Log_query=mysql_query("SELECT * FROM member WHERE email ='$attr' AND password = '$pass'") or die(mysql_error());
if ($Log_query == true && mysql_num_rows($Log_query) >0) {
$p=0;
while ($Res_user = mysql_fetch_array($Log_query) ) {
$marques[$p] = $Res_user;
$p++;
}
}
return $marques;
}
if($verif_user){
$Log_query=mysql_query("SELECT * FROM member WHERE user ='$attr' AND password = '$pass'") or die(mysql_error());
if ($Log_query == true && mysql_num_rows($Log_query) >0) {
$p=0;
while ($Res_user = mysql_fetch_array($Log_query) ) {
$marques[$p] = $Res_user;
$p++;
}
}
return $marques;
}
return null;
}
function getCategories(){
$Log_query=mysql_query("SELECT distinct(categorie) FROM video ") ;
if ($Log_query == true && mysql_num_rows($Log_query) >0) {
$p=0;
while ($Res_user = mysql_fetch_array($Log_query) ) {
$marques[$p] = $Res_user;
$p++;
}
}
return $marques;
}
function getVideos(){
$Log_query=mysql_query("SELECT * FROM video ") ;
if ($Log_query == true && mysql_num_rows($Log_query) >0) {
$p=0;
while ($Res_user = mysql_fetch_array($Log_query) ) {
$marques[$p] = $Res_user;
$p++;
}
}
return $marques;
}
}
?>
我有这个错误:Fatal error: Cannot redeclare class connexion in /home/a1638637/public_html/Sql.php on line 2
。但我没有重新声明班级联系!
我认为问题出在 right.php 文件中,因为:
- 正确的部分不起作用
- 出现错误
以修复此错误我需要知道 - 错误是什么?
- 我该如何解决?