php - Simple Exec Insert -


the issue think i've done wrong, don't know what. i've tried try/catch, every other part of code functions (i've echoed everything), nothing inserted "text". i'm 99% sure isn't privileges, general question ok use exec when you're shooting around data in server , other urls? hope replies.

<?php include('simplehtmldom_1_5/simple_html_dom.php');   $html = new simple_html_dom();   $html->load_file('http://www.youtube.com/live/all/videos?sort=dd&tag_id=&view=41'); $count = 0; $pdo = new pdo('mysql:host=localhost;dbname=scraper', 'user', 'aa'); $string = $pdo->query('select text urls'); while ($row = $string->fetch()) {   $links[] = $row['text']; } foreach($html->find('[class=content-item-title yt-ui-ellipsis yt-ui-ellipsis-2]') $element) { $array[$count]=$element->href; foreach ($links $link) { if (strpos($array[$count], $link) == false) { $pdo->exec('insert urls set text=$array[$count]'); } } $count += 1; } ?> 

instead of this

$pdo->exec('insert urls set text=$array[$count]'); 

use this

$pdo->prepare('insert urls set text=?')->execute(array($array[$count])); 

take time , read prepare in pdo. variable parsing.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -