【问题标题】:entering datas of php page to database将php页面的数据输入数据库
【发布时间】:2011-03-04 06:59:54
【问题描述】:

我有一个带有两个文本框的 php 表单,我想将文本框的值输入到数据库中。我已经创建了表格(有两列,即 webmeasurementsuite id 和 webmeasurements id)我使用以下语法来创建表格:

CREATE TABLE `radio` (

`webmeasurementsuite id` INT NOT NULL,
`webmeasurements id` INT NOT NULL

);

利用以下链接中的教程,我编写了 php 编码,但不幸的是数据没有输入数据库。我在插入 sql 语法中遇到错误。我检查了它,但我无法找出错误。有人可以纠正我吗?我从http://www.webune.com/forums/php-how-to-enter-data-into-database-with-php-scripts.html得到了编码 $sql = "INSERT INTO $db_table(webmeasurementsuite id,webmeasurements id) 值

('".mysql_real_escape_string(stripslashes($_REQUEST['webmeasurementsuite

id']))."','".mysql_real_escape_string(stripslashes($_REQUEST['webmeasurements id']))."')"; 回声$sql; 我的错误如下: INSERT INTO radio(webmeasurementsuite id,webmeasurements id) values ('','')ERROR: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'id,webmeasurements id) 值 ('','')' 附近使用正确的语法

【问题讨论】:

  • 什么是mysql错误?

标签: php sql


【解决方案1】:

因为您的表名中有一个空格,所以您必须始终用反引号将它们括起来。试试这个查询:

$sql = "INSERT INTO $db_table(`webmeasurementsuite id`,`webmeasurements id`) values ('".mysql_real_escape_string(stripslashes($_REQUEST['webmeasurementsuite id']))."','".mysql_real_escape_string(stripslashes($_REQUEST['webmeasurements id']))."')"; 

查看您的 pastebin,您似乎忘记关闭输入标签:

<input TYPE="text" name="webmeasurementsuite id" 

【讨论】:

    猜你喜欢
    • 2017-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多