[英]Why is my SQL query not putting data into database?
Ok so Im taking parsed text from webpages and placing it in a column called adtext. 好的,我从网页中提取了解析后的文本,并将其放在称为adtext的列中。 Thescripts runs with no errors and says its putting the data in there, but when I manually check the rows are empty!
脚本运行没有错误,并说将数据放入其中,但是当我手动检查行为空时! I have run a
var_dump
after the return_between()
and the text is there, but its not making it into the DB. 我在
return_between()
之后运行了一个var_dump
,并且文本在那里,但是它没有进入数据库。 Here is the code so far... 这是到目前为止的代码...
mysqli_query($conn, $query1);
$link_result = mysqli_query($conn, $query1);
$result = mysqli_fetch_assoc($link_result);
file_get_contents($result['adlink']);
$text_holder = file_get_contents($result['adlink']);
return_between($text_holder, "postingBody", "<!-- .posting -->", EXCL);
$final_text = return_between($text_holder, "postingBody", "<!-- .posting -->", EXCL);
$query2 = "UPDATE usedcars SET adtext = $final_text WHERE `key` = $x";
mysqli_query($conn, $query2);
echo "<font color='#FFFF00'>Placing text from <font color='#00FF00'>$result[adlink]</font> into database</font><br>";
$x++;
}
What am I missing/forgetting? 我想念/忘记什么?
you are missing single quete around $final_text
, 您缺少
$final_text
周围的单个$final_text
,
$query2 = "UPDATE usedcars SET adtext = '".mysqli_escape_string($conn, $final_text)."' WHERE `key`= $x";
and always notify your self with error In Production . 并始终在生产中告知您的错误。 by using
mysqli_error()
like this 通过像这样使用
mysqli_error()
mysqli_query($conn, $query2) or die(mysqli_error());
mysqli
does not automatically secure your query use bindparam
mysqli
不会使用bindparam
自动保护您的查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.