insert命令中的问题 [英] problem in insert command
本文介绍了insert命令中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我是php新手。我无法将数据插入mysql表。并且没有错误提示下面是我的代码。请帮助我。
<?php
include_once ' ../ inc / header.php';
if (isset($ _ POST [' 提交'])&& $ _POST [' submit']!= < span class =code-string> )
{
$ name = $ _POST [ name];
$ address = $ _POST [ 地址跨度>];
$ tel = $ _POST [ tel 跨度>];
$ fax = $ _POST [ fax 跨度>];
$ email = $ _POST [ email 跨度>];
$ website = $ _POST [ website 跨度>];
$ type = $ _POST [ type 跨度>];
尝试
{
$ sql = INSERT INTO bk_customer(id,name,address,tel,fax,email,type,website)
VALUES('$ name','$ address','$ tel','$ fax , '$电子邮件', '$网站', '$类型')跨度>;
$ result = mysqli_query($ con,$ sql);
exit();
}
catch (例外$ ex)
{
echo $ e-> getMessage()。 \ n;
file_put_contents(' PDOErrors.txt',$ e-> getMessage(),FILE_APPEND );
exit();
}
}
mysqli_close($ con);
?>
解决方案
_POST [' submit'])&&
_POST [' submit']!= )
{
name =
hi
I am new in php. I could not insert the data into mysql table. and there is no error prompt Below is my code. Pls help me.
<?php
include_once '../inc/header.php';
if (isset($_POST['submit']) && $_POST['submit'] != "" )
{
$name = $_POST["name"];
$address = $_POST["address"];
$tel = $_POST["tel"];
$fax = $_POST["fax"];
$email = $_POST["email"];
$website = $_POST["website"];
$type = $_POST["type"];
try
{
$sql="INSERT INTO bk_customer (id,name,address,tel,fax,email,type,website)
VALUES ('$name','$address','$tel','$fax','$email','$website','$type')";
$result = mysqli_query($con,$sql) ;
exit();
}
catch (Exception $ex)
{
echo $e->getMessage() . "\n";
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
exit();
}
}
mysqli_close($con);
?>
解决方案
_POST['submit']) &&
_POST['submit'] != "" ) {
name =
这篇关于insert命令中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文