【发布时间】:2014-09-25 09:36:20
【问题描述】:
这是我第一次使用 PHP 和 MSSQL。我基本上想将名称、电子邮件从 PHP 表单发送到 MSSQL 数据库,但我收到标题错误。
我的代码如下
index.php
<title></title>
</head>
<body>
<form action="connection.php" name="frmAdd" method="post">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Name</div></th>
<th width="160"> <div align="center">Email</div></th>
</tr>
<tr>
<td><input type="text" name="Name" size="20"></td>
<td><input type="text" name="Email" size="20"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
和connection.php
<?php
$Name = $_POST['Name'];
$Email= $_POST['Email'];
$dbc = mssql_connect('localhost','**','**.','**')or die('Error connecting to the SQL Server database.');
$query = "INSERT INTO dbo.customers (customerName,customerEmail) VALUES ('$Name','$Email')GO";
$result = mssql_query($dbc,$query)or die('Error querying MSSQL database');
mssql_close($dbc);
?>
【问题讨论】:
-
GO在('$Name','$Email')GO";中做什么?删除它。 -
删除插入语句中的GO。还要告诉我们您遇到的确切错误
标签: php sql sql-server