/iUs', $contents, $match); mysql_connect("localhost", "root", "root") or die("無法連結主機"); mysql_select_db("testdb") or die("無法連結資料庫"); mysql_query("SET NAMES utf8"); $SQL = "INSERT INTO stock VALUES('{$match}')"; mysql_query($SQL);
mysqlinsert ------解决方案-------------------- $match应该是个数组类型,而你的 $SQL = "INSERT INTO stock VALUES('{$match}')"; 把它当成了字符串类型。 鉴于你的匹配模式 s ,[\s\S]* 和 .* 表达的是一个意思,且 .* 效率会高一点
<br />preg_match_all('/<table class="marketdatatable"(.*)<\/table>/iUs', $contents, $match);<br />// ...<br />$SQL = "INSERT INTO stock VALUES('{$match[1]}')";<br />mysql_query($SQL) or die(mysql_error());
------解决方案--------------------
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn