duanaozhong0696 2013-07-06 16:28
浏览 38
已采纳

MySQL PHP Noob不需要的警告[关闭]

I don't know why I get this. I am not handling these variables in this web page so I'm not sure why it's being brought up to me.

Ok script added. I think the problem is my function files already run the lines needed to establish the connections so each include is causing it to happen again. Any way to simplify? thanks

Notice: Constant DB_HOST already defined in C:\xampp\htdocs\cw1\db_config.php on line 2

Notice: Constant DB_NAME already defined in C:\xampp\htdocs\cw1\db_config.php on line 3

Notice: Constant DB_USER already defined in C:\xampp\htdocs\cw1\db_config.php on line 4

Notice: Constant DB_PASSWORD already defined in C:\xampp\htdocs\cw1\db_config.php on line 5

Notice: Constant DB_HOST already defined in C:\xampp\htdocs\cw1\db_config.php on line 2

Notice: Constant DB_NAME already defined in C:\xampp\htdocs\cw1\db_config.php on line 3

Notice: Constant DB_USER already defined in C:\xampp\htdocs\cw1\db_config.php on line 4

Notice: Constant DB_PASSWORD already defined in C:\xampp\htdocs\cw1\db_config.php on line 5

?php include 'mefunc.php'; include 'memberfunc.php'; include 'eventfunc.php'; //include the lot they are all needed!


?php include 'mefunc.php'; include 'memberfunc.php'; include 'eventfunc.php'; //include the lot they are all needed!



$db1 = new dbme();
$db1->openDB();
$sql="select mid from member";
$result=$db1->getResult($sql);// get the ids from the tables for the select

$sql1="select ename from event";
$result1=$db1->getResult($sql1);// get the ids from the tables for the select

if (!$_POST) //page loads for the first time
{
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return validateForm(  );">
Select Member ID: <select name="mid">
<?php
while($row = mysql_fetch_assoc($result))
echo "<option value='{$row['mid']}'>{$row['mid']} </option>";
?>
</select>
<br />
Select Event name : <select name="ename">
<?php
while($row = mysql_fetch_assoc($result1))
echo "<option value='{$row['ename']}'>{$row['ename']} </option>";
?>
</select>
<br />

<script language="javascript">
function validateField( fld ) { //validation of all forms. The field will change colour if wrong.

   var field = document.getElementById( fld );

   if( !field ) return true;

   var error = field.value != '';

    if( error ) {
        field.style.backgroundColor = 'White';
    } else {
      field.style.backgroundColor = 'Orange';
    }

   return error;
}

function validateForm(  ) {

   var cont = true;

   if( !validateField( 'total' ) ) cont = false;
   if( !validateField( 'comments' ) ) cont = false;

   return cont;
}
</script>

Enter lifter total:<input type="text" name="total" id="total" /><br />
Enter comment:<input type="text" name="comments" id="comments"/><br />
<input type="submit" value="Save" />
</form>

<?php
}

else//post it into database
{
//$mid = $_POST['mid'];//??
$mid = $_POST['mid'];
$total = $_POST['total'];
$comments = $_POST['comments'];
$ename = $_POST['ename'];
$db1 = new dbme();
$db1->openDB();
$numofrows = $db1->insert_me($mid, $total, $comments, $ename);
echo "Success. Number of rows affected:
<strong>{$numofrows}<strong>";
$db1->closeDB();

}


$db1 = new dbmember();//show members to see
$db1->openDB();
$sql="SELECT * from member";
$result=$db1->getResult($sql);
echo "<table border='1'>";
echo "<tr><th>Member ID</th><th>Name</th>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>{$row['mid']}</td><td>{$row['name']}</td>";
echo "</tr>";
}
echo "</table>";
$db1->closeDB();

$db1 = new dbevent();//now show events to see too
$db1->openDB();
$sql="SELECT * from event";
$result=$db1->getResult($sql);
echo "<table border='1'>";
echo "<tr><th>Event ID</th><th>Event Name</th><th>Date</th>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>{$row['eid']}</td><td>{$row['ename']}</td>";
echo "<td>{$row['date']}</td>";
echo "</tr>";
}
echo "</table>";
$db1->closeDB();

?>
  • 写回答

1条回答 默认 最新

  • douluoqiu4538 2013-07-06 16:30
    关注

    Probably you double-include / require your config file db_config.php

    It would look like this:

    include("db_config.php") ; //Constants are defined here
    
    include("db_config.php") ; //Warnings thrown
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作