热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

插入不适用于SQLitePHP-InsertnotworkingforSQLitePHP

ImtryingtomakeasimplecontactformwithanSQLitedb.我试图用SQLite数据库创建一个简单的联系表单。WhenIsubmit

Im trying to make a simple contact form with an SQLite db.

我试图用SQLite数据库创建一个简单的联系表单。

When I submit the form this message shows up:

当我提交表单时,此消息显示:

Array ( [title] => Mr [fname] => John [lname] => Smith [email] => john@smith.com [phone] => 0123456789 [message] => test ) E-Mail Sent successfully, we will get back to you soon.Array ( [0] => HY000 [1] => 1 [2] => no such column: test )

It hasn't sent an email or inserted the data into the db file.

它尚未发送电子邮件或将数据插入db文件。

php:

PHP:

exec("INSERT INTO contact (title, fname, lname, email, phone, details) VALUES ('$title', '$fname', '$lname', '$email', '$phone', $message);") or die(print_r($db->errorInfo(), true));
  }
}

?>

2 个解决方案

#1


1  

Your current problem is, that you forgot the quotes around $message in the query

您当前的问题是,您忘记了查询中$ message周围的引号

    $db->exec("INSERT INTO contact (title, fname, lname, email, phone, details) VALUES ('$title', '$fname', '$lname', '$email', '$phone', '$message');") or die(print_r($db->errorInfo(), true));

In addition, I would strongly advice you to use prepared statements!

另外,我强烈建议你使用准备好的陈述!

#2


-1  

replace your statement,

取代你的陈述,

$db->exec("INSERT INTO contact (title, fname, lname, email, phone, details) VALUES ('$title', '$fname', '$lname', '$email', '$phone', $message);") or die(print_r($db->errorInfo(), true));

$ db-> exec(“INSERT INTO contact(title,fname,lname,email,phone,details)VALUES('$ title','$ fname','$ lname','$ email','$ phone', $ message);“)或die(print_r($ db-> errorInfo(),true));

with

$db->exec("INSERT INTO contact (title, fname, lname, email, phone, details) VALUES ('$title', '$fname', '$lname', '$email', '$phone', '$message');") or die(print_r($db->errorInfo(), true));

$ db-> exec(“INSERT INTO contact(title,fname,lname,email,phone,details)VALUES('$ title','$ fname','$ lname','$ email','$ phone', '$ message');“)或死(print_r($ db-> errorInfo(),true));


推荐阅读
author-avatar
mobiledu2502891657
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有