-5

我的 php 没有插入数据库:我真的不知道为什么:请我需要帮助,我无法找出问题所在:

<form action="insertfixture.php" method="post">

<tr><td>Date</td><td><input type = "text" name = "match_date" ></td></tr>
<tr><td><input type = "submit" name = "submit" value="update"></td></tr>
</form>
<?php 
include_once("connect.php");?>
$match_date=(isset($_POST['match_date']))? trim($_POST['match_date']): '';

$sql="INSERT INTO fixture(match_date)
VALUES ('$match_date')";
$result = mysql_query($sql); 
#if something goes wrong then tell the user 
if($result){
echo "New fixture Successfully added</br>";

}
else {
echo "We are sorry no Fixture inserted ";
}
 ?>
4

2 回答 2

3

您已经在 include_once 函数之后关闭了您的 php 关闭标记。这应该是问题。

<form action="insertfixture.php" method="post">

<tr><td>Date</td><td><input type = "text" name = "match_date" ></td></tr>
<tr><td><input type = "submit" name = "submit" value="update"></td></tr>
</form>
<?php 
include_once("connect.php");
$match_date=(isset($_POST['match_date']))? trim($_POST['match_date']): '';

$sql="INSERT INTO fixture(match_date) VALUES ('$match_date')";
$result = mysql_query($sql) or die("<br>Error:" .mysql_error()); 
#if something goes wrong then tell the user 
if($result){
echo "New fixture Successfully added</br>";

}
else {
echo "We are sorry no Fixture inserted ";
}
 ?>
于 2013-04-29T14:59:31.253 回答
2
include_once("connect.php");?>

有一个额外的 PHP 结束标记不应该存在。将行替换为:

include_once("connect.php");
于 2013-04-29T15:00:16.083 回答