English 中文(简体)
PHP MySQL 外地名单不明栏目
原标题:PHP MySQL Unknown column address in field list

在类似问题上,有几个职位,但我仍然无法对我的法典,即PHP和MySQL的组合作出明确的回答。 我在提交表格后总是收到错误信息。 具体地说,它与yn有关。 有趣的是,我的sql没有抱怨,我也没有说过,而是在我的浏览器(火).)上。

$add_master_sql = "INSERT INTO master_name (date_added, date_modified, f_name, l_name)
VALUES (now(), now(),  ".$_POST["f_name"]." ,  ".$_POST["l_name"]." )";
$add_master_res = mysqli_query($mysqli, $add_master_sql) or die(mysqli_error($mysqli));

我的MYSQL法典是:

CREATE TABLE master_name (
  id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  date_added DATETIME,
  date_modified DATETIME,
  f_name VARCHAR (75),
  l_name VARCHAR (75)
);

某些因素可能与引证有关,但我把对口的检查增加一倍,罚款。 谁能帮助我去做?

问题回答

More important is to use pdo prepared queries to avoid possible sql injection.

<?php
// configuration
$dbtype     = "sqlite";
$dbhost             = "localhost";
$dbname     = "test";
$dbuser     = "root";
$dbpass     = "admin";

// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);

// new data
$dateAdded = getdate();
$dateModified = getdate();
$f_name = $_POST["f_name"];
$l_name = $_POST["l_name"];

// query
$sql = "INSERT INTO master_name (date_added, date_modified, f_name, l_name) VALUES (:f_name, :l_name, :dateAdded, :dateModified)";
$q = $conn->prepare($sql);
$q->execute(array( :dateAdded =>$dateAdded ,
                   :dateModified =>$dateModified,
                   :f_name =>$f_name,
                   :l_name =>$l_name));    

?>

外地清单中未知栏目

Find the query that is using column address in field list .
The one you posted here is apparently not the one issuing this error.
Change your die(mysqli_error($mysqli)); to

trigger_error(mysqli_error($mysqli));

for all the queries on the page
and see certain place where the error occurred.

还指出,你应当利用<密码>mysqli_real_einski_string <<>/code>,从问询中提取的每一变数。 (并保护从Kall注入中产生的所有其它变量)或将其列为编制的声明。

如果贵书没有告诉你——烧掉!





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签