-3

我在插入数据时遇到问题,它没有向我的 phpmyadmin 输入任何数据我有问题

<?php
if (isset($_POST['submit'])){
$LastName=$_POST['LastName'];
$FirstName=$_POST['FirstName'];
$MiddleInitial=$_POST['MiddleInitial'];
$Age=$_POST['Age'];
$Gender=$_POST['Gender'];
$Birthday=$_POST['Birthday'];
$Address=$_POST['Address'];
$EmailAddress=$_POST['EmailAddress'];

mysql_query("insert into studentsrecords(LastName,FirstName,MiddleInitial,Age,Gender,Birthday,Address,EmailAddress)
values('$LastName','$$FirstName','$MiddleInitial','$Age','$Gender','$Birthday','$Address','$EmailAddress',NOW())
")or die(mysql_error());
?>

<script type="text/javascript">
alert('You are Successfully Register Thank You');
window.location="index.php";
</script>

<?php
}
?>

这是我的 config.php

4

2 回答 2

3

您的代码中的一些常见错误。修好这些。

  • 在您的 mysql 查询中更改'$$FirstName'为。'$FirstName'

  • 您没有与数据库建立连接。提议者antyrat

  • NOW()从您的 mysql 查询中删除。提议者andrewsi

于 2013-10-30T18:45:42.553 回答
0

将 '$$FirstName' 替换为 '$FirstName' 检查您的表单方法是否为“post”,检查您的配置文件。您可以通过以下方法创建数据库连接

$user = "xxxx"; //Database Username here
    $pass = "xxxx"; //Database Password here
    $db = "xxxx"; //Database Name here
    $localhost = "xxx"; //Database Server


$link = mysql_pconnect($localhost, $user, $pass);
if ( ! $link )
    die( "Couldn't connect to MySQL" );
mysql_select_db( $db)
    or die ( "Couldn't open $db: ".mysql_error() );
于 2013-10-30T18:57:28.087 回答