Veritabanı bağlantı ancak kayıt ekleme değil?

0 Cevap php

Im birlikte tweetmeme API içerik çeker ve daha sonra biçimlendirme için bir veritabanına ekler basit bir script koyarak. Bu i şu anda ne var ama hiçbir kayıt ekler ve i bağlanır ve ekleme başarısız varsayabiliriz böylece veritabanı bağlantısı için hata döndürür.

   $dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'footy';
mysql_select_db($dbname) or die('Couldnt connect to database table');



  $tweetmeme = "http://api.tweetmeme.com/stories/popular.xml?category=sports-soccer&count=30" ; 

  $xml = @simplexml_load_file($tweetmeme) or die ("no file loaded") ; 

 echo count($xml->stories->story)."stories in the XML file<br /><br />";
echo $xml->getName() . "<br /><br />";
foreach($xml->stories->story as $story)
{
    $title=$story->title;
    $url=$story->url;
    $media_type=$story->media_type;
    $created=$story->created_at;
    //$current_time=$date();
    $url_count=$story->url_count;
    $comment_count=$story->comment_count;
    $excerpt=$story->excerpt;

    $sql = "INSERT INTO ft_tweets (title,url,media_type,created_at,mention_count,comment_count,excerpt) VALUES ($title,$url,$media_type,$created,$url_count,$comment_count,$excerpt)";
    $result = mysql_query($sql);

Çeşitli öğeleri bir vardump () yapıyor "nesne (SimpleXMLElement)" döndürür ve bu xml yapısı bir örnek gibi görünüyor ne link text

0 Cevap