嗨,我正在尝试使用php将数据添加到我的SQL表中我似乎无法看到我在哪里出错了,我收到以下错误:
Notice: Undefined index: ModuleId in N:\ftp\compc\d11os\Project\addModule.php on line 70
Notice: Undefined index: Title in N:\ftp\compc\d11os\Project\addModule.php on line 70
Notice: Undefined index: CreditLevel in N:\ftp\compc\d11os\Project\addModule.php on line 70
Notice: Undefined index: CreditPoints in N:\ftp\compc\d11os\Project\addModule.php on line 70
Notice: Undefined index: Status in N:\ftp\compc\d11os\Project\addModule.php on line 70
Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in N:\ftp\compc\d11os\Project\addModule.php on line 72
Warning: mysql_query(): A link to the server could not be established in N:\ftp\compc\d11os\Project\addModule.php on line 72
以下是我目前正在使用的代码:
<?php
if (isset($_POST['submit']) && $_POST['submit']=="Submit") {
$con=mysqli_connect("localhost","useername ","password ","databasename");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$insert = "INSERT INTO module (ModuleId, Title, CreditLevel, CreditPoints, Status, Award)
VALUES ('".$_POST['ModuleId']."','".$_POST['Title']."','".$_POST['CreditLevel']."','".$_POST['CreditPoints']."','".$_POST['Status']."','".$_POST['Award']."')";
$add_member = mysql_query($insert);
?>
有人可以帮忙吗? :/
答案 0 :(得分:-1)
您应该在使用mysql_query()
作为开始时使用mysqli_query()
。