jeudi 29 janvier 2015

wordpress database error


I write code to extract peice from website with curl. this should be refresh page to get price.


I want store data in the wordpress database with foreach.


when I refreshing page


but give this error.



Call to a member function insert() on a non-object in C:\wamp\www\wordpress\wp-content\plugins\price\fras-coin.php on line 73



database



foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$data[] = array(
$trip ['Name' ]= trim($row->item(0)->nodeValue),
$trip['LivePrice'] = trim($row->item(2)->nodeValue),
$trip ['Changing']= trim($row->item(4)->nodeValue),
$trip ['Lowest']= trim($row->item(6)->nodeValue),
$trip['Topest']= trim($row->item(8)->nodeValue),
$trip['Time']= trim($row->item(10)->nodeValue),

);
}
}
global $wpdb;
foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$wpdb->insert( $wpdb->farsc,
array(
'title' => " . trim($row->item(0)->nodeValue) . ",
'liveprice' => " . trim($row->item(2)->nodeValue) . ",
'changing' => " . trim($row->item(4)->nodeValue) . ",
'lowest' => " . trim($row->item(6)->nodeValue) . ",
'topest' => " . trim($row->item(8)->nodeValue) . ",
'time' => " . trim($row->item(10)->nodeValue) . " ),
array(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
) );
///$sql = "INSERT INTO `fars_coin`(title,liveprice,changing,lowest,topest,time) VALUES ('" . trim($row->item(0)->nodeValue) . "','" . trim($row->item(2)->nodeValue) . "','" . trim($row->item(4)->nodeValue) . "','" . trim($row->item(6)->nodeValue) . "','" . trim($row->item(8)->nodeValue) . "','" . trim($row->item(10)->nodeValue) . "')";
///
///mysql_query($sql);

}


}





Aucun commentaire:

Enregistrer un commentaire