Answer the question
In order to leave comments, you need to log in
Parser php oracle not writing to db?
Gives an error message:
Warning: oci_execute() expects parameter 1 to be resource, string given in
require_once "simple_html_dom.php";
error_reporting(E_ALL);
ini_set('display_errors', '1');
$conn = oci_connect('ddd', 'ddd', '127.0.0.1/orcl', 'AL32UTF8');
$brands = array();
$html = str_get_html(file_get_contents('https://kolesa.kz/cars/'));
$insert = oci_parse($conn, 'INSERT INTO kolesa_brands (id, name) VALUES');
$select = $html->find('select[id=auto-car-mm-0]', 0);
foreach($select->find('option') as $opt)
{
if($opt->value == '') continue;
$insert .= '('.$opt->value.', \''.$opt->plaintext.'\'),';
$brands[$opt->value] = $opt->plaintext;
}
oci_execute(rtrim($insert, ','));
Answer the question
In order to leave comments, you need to log in
Try like this:
require_once "simple_html_dom.php";
error_reporting(E_ALL);
ini_set('display_errors', '1');
$conn = oci_connect('ddd', 'ddd', '127.0.0.1/orcl', 'AL32UTF8');
$brands = array();
$html = str_get_html(file_get_contents('https://kolesa.kz/cars/'));
$i = 'INSERT INTO kolesa_brands (id, name) VALUES';
$select = $html->find('select[id=auto-car-mm-0]', 0);
foreach($select->find('option') as $opt)
{
if($opt->value == '') continue;
$i .= ' ('.$opt->value.', \''.$opt->plaintext.'\'),';
$brands[$opt->value] = $opt->plaintext;
}
$insert = oci_parse($conn, rtrim($i, ',').';');
oci_execute($insert);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question