Jump to content

clankill3r

Members
  • Posts

    106
  • Joined

  • Last visited

Everything posted by clankill3r

  1. yeah ok with echo it goes correct but i still wonder why it goes like that? althought this fixes it (bad fix i suppose?) $title = "".$article['title'][0];
  2. i have a array calles $articles, this is a part of it: Array ( [1335905082] => Array ( [channel] => [title] => SimpleXMLElement Object ( [0] => NEW PRODUCT – Blue 7-segment clock display – 0.56 digit height ) [link] => SimpleXMLElement Object ( [0] => http://www.adafruit.com/blog/2012/05/01/new-product-blue-7-segment-clock-display-0-56-digit-height/ ) [comments] => SimpleXMLElement Object ( [0] => http://www.adafruit.com/blog/2012/05/01/new-product-blue-7-segment-clock-display-0-56-digit-height/#comments ) [pubDate] => SimpleXMLElement Object ( [0] => Tue, 01 May 2012 20:44:42 +0000 ) [timestamp] => 1335905082 [description] => NEW PRODUCT – Blue 7-segment clock display – 0.56 digit height. Design a clock, timer or counter into your next project using our pretty 4-digit seven-segment display. These bright crisp displays are good for adding numeric output. Besides the four 7-segments, there are decimal points on each digit and an extra wire for colon-dots in [...] [isPermaLink] => SimpleXMLElement Object ( [0] => false ) [creator] => adafruit when i use: foreach($articles as $article) { $title = $article['title'][0]; echo '<pre>'; print_r($title); echo '</pre>'; } i get stuff like: But i expected: what do i do wrong?
  3. I try to get the content from http://www.adafruit.com/blog/feed/ some stuff is like this: no idea if that matters. Atm i have this: $xml = getFileContents("http://www.adafruit.com/blog/feed/"); $xmlTree = new SimpleXMLElement($xml); //foreach() //print_r2($xmlTree); for($i = count($xmlTree->channel->item)-1; $i >= 0; $i--) { $item = $xmlTree->channel->item[$i]; print_r2($item); //print_r2($item->category); //$category = $item->category; //print_r2($category); } it prints stuff like: category and description are empty, how can i get that content? print_r2 is just this: function print_r2($val){ echo "<pre>"; print_r($val); echo "</pre>"; }
  4. I have a table with words, what is a correct query to trim all words? this is wrong: $query = "UPDATE negative_words TRIM word"; it's structured like id - word - rating and negative_words is the tabel name.
  5. thank god it was that simple. thanks
  6. I have a database with articles, i also have a database with ratings. The ratings.articleId is for articles.id, in example if ratings.articleId = 50 then it belongs to the one where articles.id = 50; $t is a number $query = "SELECT articles.id, articles.headline ratings.rating FROM articles "; $query .= "LEFT JOIN ratings ON (ratings.articleId=articles.id) "; $query .= "WHERE articles.id>'$t'"; this is the error atm:
  7. i mean print_r thanks, it works like a champ now!
  8. atm i have this in a function: $returnInfo = array(); $returnInfo["totalWords"] = $totalWords; $returnInfo["uniqueWords"] = count($uniqueWords); $returnInfo["positiveWords"] = $positiveWords; $returnInfo["negativeWords"] = $negativeWords; $returnInfo["rating"] = $mappedrating; return $returnInfo; If i recursive print it it says Array instand of my expected values. p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line.
  9. thanks, the insert works now. One more thing, i have a function to check if something is inserted: function timeStampExists($pubDate) { //$query = "SELECT * FROM articles WHERE timestamp='$timestamp'"; $query = "SELECT * FROM articles WHERE timestamp='STR_TO_DATE('$pubDate', '%a, %d %b %Y %T')'"; $res = mysql_query($query); if (mysql_num_rows($res) > 0) { return true; } else { return false; } } I only get this error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in / on this line: if (mysql_num_rows($res) > 0) {
  10. How do i get a MySQL timestamp out of 'Thu, 01 Dec 2011 20:22:52 +0100' ?
  11. $query = "INSERT INTO articles VALUES ('', '$headline', '$description', '$broadtext', '$timestamp', '$categoryID')"; where $timestamp = 1322767372 for example.
  12. $pubDate: Thu, 01 Dec 2011 20:22:52 +0100 $timestamp = strtotime($pubDate); gives: 1322767372 so that seems to be ok. Also i get no query errors for inserting, only all values it inserts are 0000-00-00 00:00:00 I tried different setting in my database, this was the last: # Kolom Type Collatie Attributen Null Standaardwaarde Extra 5 timestamp timestamp on update CURRENT_TIMESTAMP Nee CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  13. It used to set it by 11 if i didn't fill in anything. Anyway, i did set it for the id now, same thing as above... a red error box without a error
  14. sometimes a image explains more then 1000 words: i don't get it.
  15. found it, i have to do it like this: if (isset($item->enclosure)){ if (isset($item->enclosure->attributes()->url)){ $imageUrl = (string)($item->enclosure->attributes()->url); } }
  16. I asume that in my case it would be if (isset($item->enclosure->attributes()->url)) { but this produces still the warning
  17. thanks mate! How can i check if the atribute exists? In some cases it's not there and then i get:
  18. yes no errors the, but neither a url.
  19. I want to get the url in the [@attributes] Atm i get the title like this foreach ($xmlTree->channel->item as $item) { echo '<p>'.$item->title.'</p>'; } i tried this $imageUrl = $item->enclosure->@attributes->url; print_r2($imageUrl); but then i get this error: this is the XML:
  20. thanks but that's not what i meant, i should have been more clear. I want to show multiple images in columns: [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] And therefore a image like this [ ] should be a rectangle so that's why i want to center them since often there is the more important content of a image.
  21. How can i get a image in a rectangle without scretching the image? I just want to center the image and have it set as background but i don't know what element to use for that.
  22. First i will show the code that activates the error: if($current_host != null) { print_r2("1"); print_r2($current_host); print_r2($current_foundResult); print_r2("2"); $current_host::addFoundResult($current_foundResult); } this is the output: the error comes from this line: $this->foundResults[] = $foundResult; class Host { public $hostname; public $foundResults; public function __construct($hostname) { $this->hostname = $hostname; $this->foundResults = array(); } public function addFoundResult($foundResult) { $this->foundResults[] = $foundResult; } } what i don't get about it is that both the Host Object and the FoundResult Object exist...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.