我的表中有很多行。其中一列被称为name
。我还有一个名为blog_id
的新专栏。我想使每个blog_id
这样的:更新每一行的列到新列
$blog_id = strtolower(preg_replace('/-+/', '-', preg_replace('/[^\wáéíóú]/', '-', $name)));
我已经试过这样:
$con=mysqli_connect("localhost","foo","bar","blog");
$fetch = mysqli_query($con,"SELECT name
FROM entries");
foreach($fetch as $name2){
$id = strtolower(preg_replace('/-+/', '-', preg_replace('/[^\wáéíóú]/', '-', $name2)));
$result = mysqli_query($con,"INSERT INTO entries (blog_id)
VALUES ('$id')");
}
mysqli_close($con);
但我得到的错误strtolower() expects parameter 1 to be string, array given
我在做什么错?
你能分辨出错误怎么说?它说,你给它一个数组,当它预期的字符串?然后你去php.net/preg_replace它说'preg_replace()返回一个数组,如果主题参数是一个数组,否则一个字符串'。仔细阅读,它提到**数组**。 –