mam taki kod
<?PHP
$pdo = new PDO('mysql:host=localhost;dbname=wrzuta', 'admin', 'xxx');
$pdo -> query ('SET NAMES utf8');
$sql = "select * from filmy where key is null limit 1";
$statement = $pdo->query($sql);
$row = $statement->fetch(PDO::FETCH_ASSOC);
$adres=$row['web'];
#$adres ='http://daria24.wrzuta.pl/film/wdKctZmPkJ/';
$url = curl_init($adres);
curl_setopt($url, CURLOPT_USERAGENT, 'holmes/3.10.1 (OnetSzukaj/5.0; +http://szukaj.onet.pl)');
curl_setopt($url, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($url, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($url, CURLOPT_HEADER, 0);
$strona=curl_exec($url);
#curl_close($url);
$DOM = new DOMDocument();
@$DOM->LoadHTML(iconv("ISO-8859-2","UTF-8",$strona));
$tablica = array(); #deklaracja tablicy
foreach ($DOM->getElementsByTagName('input') as $input)
{
$id = $input->getAttribute('id');
if($id == 'new_cmnt_key')
{
$key = $input->getAttribute('value');
}
}
foreach ($DOM->getElementsByTagName('input') as $input)
{
$id = $input->getAttribute('id');
if($id == 'link_do_pliku')
{
$web = $input->getAttribute('value');
#$web = str_replace('"http://', 'www.', $webe->nodeValue);
}
}
#var_dump($web);
#exit;
foreach ($DOM->getElementsByTagName('input') as $input)
{
$id = $input->getAttribute('id');
if($id == 'miniatura_embed')
{
$object = $input->getAttribute('value');
}
}
foreach ($DOM->getElementsByTagName('title') as $title)
{
$tytul = str_replace('Wrzuta.pl - ', '', $title->nodeValue); }
foreach ($DOM->getElementsByTagName('meta') as $meta)
{
$tag = $meta->getAttribute('name');
if($tag == 'keywords')
{
$tagi = $meta->getAttribute('content');
}
}
$sql = "INSERT INTO filmy(`tytul`, `tag`, `url`, `web`, `created_at`) VALUES(:tytul, :tag, :url, :web, :created_at)";
$statement = $pdo->prepare($sql);
$statement->bindValue(':tytul', $tytul, PDO::PARAM_STR);
$statement->bindValue(':tag', $tagi, PDO::PARAM_STR);
$statement->bindValue(':url', $object, PDO::PARAM_STR);
$statement->bindValue(':web', $web, PDO::PARAM_STR);
# $statement->bindValue(':key', $key, PDO::PARAM_STR);
$statement->bindValue(':created_at', date( 'Y-m-d H:i:s', time()), PDO
::PARAM_STR); $statement->execute();
$sql = "update filmy set key = :key where id = :id";
$statement = $pdo->prepare($sql);
$statement->bindValue(':key', $key, PDO::PARAM_STR);
$statement->bindValue(':id', $row['id'], PDO::PARAM_INT);
$statement->execute();
?>
i do tego baze :
id INT unsigned notnull auto_increment
tytul text notnull
tag text notnull
url text notnull
web text notnull
key text null
created_at datatime notnull
do bazy mam wrzucone 3 rekordy w ktorych podane jest :
id tytul url web created_at
i idea kodu jest pobranie 1 filmiku z bazy ktory nie ma uzupelnionego key
pobranie jego adresu i z adresu pobranie jego key i wpisanie go do bazy.
ale nie dziala siedze nad tym caly dzien i lipa:/
dostaje blad
Fatal error: Call to a member function fetch() on a non-object in
C:\Program Files\WebServ\httpd\pobieranie4.php on line
7prosze pomozcie jak ktos wie gdzie jest blad??