变量值$rowData
和$altertext
希望在数据库tabe中添加2个单独的cloumn。所以,我写了这个,
<?php
include_once('simple_html_dom.php');
$link = mysqli_connect("localhost", "root", "", "coupons");
$html = file_get_html('http://www.couponrani.com/');
foreach(($html->find('img') as $imgelement),($html->find('button') as $btnelement)) {
$altertext = $imgelement->{'alt'};
$rowData = $btnelement->{'data-coupon'};
if(preg_match('/\bcoupons\b/i', $altertext, $matches) !== false){
$imp = implode('',$matches);
if(($imp !== '')&&($rowData != '')){
$query = mysqli_query($link,"INSERT INTO couponrani(couponname,couponcode) VALUES ('$altertext','$rowData')",MYSQLI_STORE_RESULT );
}
}
}
?>
但是,当我这样做时,它告诉我,
(!)解析错误:语法错误,意外&#39; as&#39; (T_AS)in 第6行的C:\ wamp \ www \ exp.php
那么,我怎样才能纠正我的代码...... 我做错了什么......?