PHP和Mysqli查询返回错误?
我试图将数组中的信息插入MySQL表。这是我的密码:PHP和Mysqli查询返回错误?,php,mysqli,Php,Mysqli,我试图将数组中的信息插入MySQL表。这是我的密码: include "db_conx.php"; $transactionid = array(); //stores our output 因此,首先我们从url获取结果,然后使用preg_match_all查找我们要查找的标记: $url = file_get_contents("https://blockchain.info/address/1CRBDxjEQV317Q9DZZ13kVE23d2iY9Brqg?filter=2"); p
include "db_conx.php";
$transactionid = array(); //stores our output
因此,首先我们从url获取结果,然后使用preg_match_all查找我们要查找的标记:
$url = file_get_contents("https://blockchain.info/address/1CRBDxjEQV317Q9DZZ13kVE23d2iY9Brqg?filter=2");
preg_match_all('#<a class="hash-link" href="/tx/([a-zA-Z0-9]*)">([a-zA-Z0-9]*)</a>#Uis', $url, $matches);
这是我用来记录结果的循环:
for($i = 0; $i < count($transactionid); $i++){
$iresult .= $transactionid[$i];
}
编辑:因此,在阅读下面的三个答案后,它现在插入一个空行,而不是信息。您忘记了使用
句点运算符将$sql语句中的不同字符串连接起来。更改以下代码:
$iresult = mysqli_query("INSERT INTO bitcoin (transaction) VALUES ("$transactionid[$i]")");
根据本守则:
$iresult = mysqli_query("INSERT INTO bitcoin (transaction) VALUES (".$transactionid[$i].")");
您忘记了使用
句点运算符连接$sql语句中的不同字符串。更改以下代码:
$iresult = mysqli_query("INSERT INTO bitcoin (transaction) VALUES ("$transactionid[$i]")");
根据本守则:
$iresult = mysqli_query("INSERT INTO bitcoin (transaction) VALUES (".$transactionid[$i].")");
我认为你必须使用这样的东西:-
$con=mysqli_connect("localhost","my_user","my_password","my_db");
$iresult = mysqli_query($con, "INSERT INTO bitcoin (transaction) VALUES (".$transactionid[$i].")");
我认为你必须使用这样的东西:-
$con=mysqli_connect("localhost","my_user","my_password","my_db");
$iresult = mysqli_query($con, "INSERT INTO bitcoin (transaction) VALUES (".$transactionid[$i].")");
好吧,这让我有所收获。现在它输入一个空白行。好吧,这让我找到了地方。现在它输入一个空行。