好的,我最近購買了一個名爲WPArcade的wordpress插件,但是,我一直有一些問題。特別是我無法讓自己的遊戲像他們想象的那樣餵食。當我嘗試從比如說Kongregate那裏提供遊戲時,它說找到0個遊戲,但也給我這個錯誤:警告foreach的無效參數()
警告:爲C:\ Program Files(x86)\ Ampps \ www \ wp \ wp-content \ plugins \ wparcade-plugin \ feeds \ kongregate \ kongregate.php on line 113
我正在測試本地服務器上的站點,這就是它在C驅動器中的原因。
Kongregates飼料:http://www.kongregate.com/games_for_your_site.xml
這與每個出版社中發生的插件,除了一個不把我的警告。
線113至155:Kongregate的
$xml = simplexml_load_string($get_kongregate_feed);
foreach($xml->game as $game) {
$id = intval($game->id);
$name = mysql_real_escape_string($game->title);
$check_id = $wpdb->get_var("SELECT id FROM ".$wpdb->prefix."wparcade_kongregate_games WHERE id = '$id'");
$count = mysql_result(mysql_query("SELECT COUNT(*) as newgames FROM ".$wpdb->prefix."wparcade_kongregate_games WHERE id = '$check_id'"),0);
if($count !== '1') {
$name = mysql_real_escape_string($game->title);
$slug = mysql_real_escape_string($game->title);
$slug = wparcade_stringforslug($slug);
$category = mysql_real_escape_string($game->category);
$category = wparcade_strstr_before($category, " & ");
if(!$category) $category = mysql_real_escape_string($game->category);
$categories = mysql_real_escape_string($game->category);
$categories = str_replace(' & ', ', ', $categories);
if(!$categories) $categories = mysql_real_escape_string($game->category);
$description = mysql_real_escape_string($game->description);
$instructions = mysql_real_escape_string($game->instructions);
$thumbnail_url = mysql_real_escape_string($game->thumbnail);
$swf_url = mysql_real_escape_string($game->flash_file);
$width = $game->width;
$height = $game->height;
$tags = strtolower($categories);
$author = mysql_real_escape_string($game->developer_name);
$wparcade_kongregate_feed_game_status = $options['kongregate_feed_game_status'];
$status = $wparcade_kongregate_feed_game_status;
$feedsinglecat_id = $options['kongregate_feed_single_cat'];
$feedcategory = get_cat_name($feedsinglecat_id);
if($feedsinglecat_id !== 'none') {
$categories = $feedcategory;
$category = $feedcategory;
}
$sql = "INSERT INTO ".$wpdb->prefix."wparcade_kongregate_games (id, name, slug, description, thumbnail_url, swf_url, width, height, author, categories, category, tags, instructions, status) VALUES ('$id', '$name', '$slug', '$description', '$thumbnail_url', '$swf_url', '$width', '$height', '$author', '$categories', '$category', '$tags', '$instructions', '$status')";
$list .= '<li class="wparcade_new_games""><strong>'.$name.'</strong></li>';
$wpdb->query($sql);
$inserted++;
} else {
$list .= '<li class="wparcade_old_games"><strong>'.$name.'</strong></li>';
}
}
以防萬一,這是唯一的飼料所使用的代碼:
$xml = simplexml_load_string($get_scirra_feed);
foreach($xml->game as $game) {
$id = intval($game->gameid);
$name = mysql_real_escape_string($game->name);
$count = mysql_result(mysql_query("SELECT COUNT(*) as newgames FROM ".$wpdb->prefix."wparcade_scirra_games WHERE id = '$id'"),0);
$category = mysql_real_escape_string($game->category);
$slug = mysql_real_escape_string($game->name);
$slug = wparcade_stringforslug($slug);
$check_for = $wpdb->get_var("SELECT name FROM ".$wpdb->prefix."wparcade_scirra_games WHERE slug = '$slug'");
if($count !== '1' && $category !== 'Example' && !$check_for) {
$name = mysql_real_escape_string($game->name);
$slug = mysql_real_escape_string($game->name);
$slug = wparcade_stringforslug($slug);
$category = mysql_real_escape_string($game->category);
$category = str_replace('Shooter', 'Shooting', $category);
$category = str_replace('Defence', 'Defense', $category);
$category = str_replace('Puzzle', 'Puzzles', $category);
$category = str_replace('Rotary', 'Arcade, Rotary', $category);
$categories = $category;
$description = strip_tags(mysql_real_escape_string($game->description));
$instructions = strip_tags(mysql_real_escape_string($game->instructions));
$thumbnail_url = $game->images->small;
$thumbnail_large_url = $game->images->medium;
$screen1_url = $game->images->big;
$embed_url = mysql_real_escape_string($game->embedurl);
$embed_url = str_replace('http://', '//', $embed_url);
$embed_url = str_replace('//', 'http://', $embed_url);
$width = $game->width;
$height = $game->height;
$tags = strtolower($categories);
$author = mysql_real_escape_string($game->author->username);
$wparcade_scirra_feed_game_status = $options['scirra_feed_game_status'];
$status = $wparcade_scirra_feed_game_status;
$feedsinglecat_id = $options['scirra_feed_single_cat'];
$feedcategory = get_cat_name($feedsinglecat_id);
if($feedsinglecat_id !== 'none') {
$categories = $feedcategory;
$category = $feedcategory;
}
$sql = "INSERT INTO ".$wpdb->prefix."wparcade_scirra_games (id, name, slug, description, thumbnail_url, thumbnail_large_url, screen1_url, embed_url, width, height, author, categories, category, tags, instructions, status) VALUES ('$id', '$name', '$slug', '$description','$thumbnail_url', '$thumbnail_large_url', '$screen1_url', '$embed_url', '$width', '$height', '$author', '$categories', '$category', '$tags', '$instructions', '$status')";
$list .= '<li class="wparcade_new_games""><strong>'.$name.'</strong></li>';
$wpdb->query($sql);
$inserted++;
} else {
$list .= '<li class="wparcade_old_games"><strong>'.$name.'</strong></li>';
}
}
感謝您提前任何幫助。
P.S.我問了插件的支持網站,但已經差不多一個星期沒有答案。
不知道如何查看,但。插入到程序中不會改變任何東西,當我運行飼料。現在我只在下一行發生錯誤,沒有打印信息。 – saltin3s 2015-04-04 22:54:38
只需通過打印出行來保持向後工作,直到找到導致問題的行。如果其餘部分沒有響應,請嘗試打印$ get_kongregate_feed,以確保您傳遞正確的數據。您需要更好地瞭解實際值。如果你拉這個,繼續併發布你想加載的網址 – DaOgre 2015-04-04 23:01:24
我想你誤解了我的問題。我不知道如何實際打印行以找到它們的值,因爲當我更改代碼時,它不會顯示打印的文本,當我運行該插件的特定部分時。 – saltin3s 2015-04-04 23:40:22