我想用php將數據添加到Mysql數據庫。我已連接到數據庫,但數據未被插入到表中。這是我的代碼,並且提前感謝你!在php中插入數據到mysql
<?php
ob_start();
include("db.php");
if(isset($_POST['send'])!="")
{
$sql = "INSERT INTO `Scouting`(`Team #`,`High Goal Made`,`High Goal Missed`)
VALUES(`$username`,`$usermail`,`$usermobile`)";
$username=mysql_real_escape_string($_POST['Team #']);
$usermail=mysql_real_escape_string($_POST['High Goal Made']);
$usermobile=mysql_real_escape_string($_POST['High Goal Missed']);
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
if($update)
{
$msg="Successfully Updated!!";
echo "<script type='text/javascript'>alert('$msg');</script>";
header('Location:index.php');
}
else
{
$errormsg="Something went wrong, Try again";
echo "<script type='text/javascript'>alert('$errormsg');</script>";
header('Location:index.php');
}
}
ob_end_flush();
?>
什麼是$更新refeer?如果它是空的或不是isset,所以數據不會被插入,這是正常的 – PacMan
請顯示您的HTML代碼。 –
錯誤的標識符限定符和混合apis –