Здравствуйте, помогите с одним вопросом. Сделали API для сайта и возникла проблема, когда запускаешь скрипт и с базы берет более 1000 значений, становится белый экран, так же с русскими символами проблема, вместо них просто знаки вопроса В логи смотрели, ошибки в PHP выводили, все нормально, никаких ошибок нету. Попробовали в БД изменить кодировку не помогло. В чем может быть проблема? Так же запустил на домашнем ПК с помощью OpenServer, показывает более 1000 значений, но остается проблема с русскими символами.
логи чистые. Код: Спойлер: index.php Код (Text): <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); include_once("settings.php"); include_once("db_" . $dbtype . ".php"); if (!isset($_GET['mode'])) { $_GET['mode'] = "main"; } if ($_GET['mode'] == "main") { header("Content-type: text/html; charset=utf-8"); echo "<html><head><title>ollhd.com Api information</title></head><body>"; echo "<h1>site.com Api information</h1>"; echo "<big><big>Videolist:</big></big><br /><b><a href=http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?mode=list&token= target=_blank>http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?mode=list&token=[your_api_token]</a> , mode=GET , answer: application/json; charset=utf-8<br />"; echo "<i><span style=color:red;>!IMPORTANT!</span> POST param: <b>token</b> - Your api token</i><br />"; echo "<br />"; echo "© 2017 API site.com v1.0"; echo "</body></html>"; } if ($_GET['mode'] == "list" and isset($_GET['token'])) { if ($_GET['token'] !== $api_key) { header("Content-type: text/html; charset=utf-8"); die("Invalid token"); } header("Content-type: application/json; charset=utf-8"); $videosdb = BiQuery1("*", "vs_news", array(array("news_id", 0, ">")), "news_id", "DESC", "{$news_limit}"); $m = null; while($r = mysqli_fetch_object($videosdb)) { $tsize = explode("x", $r->file_dimensions); $tagsdb = BiQuery1("*", "vs_tags_news", array(array("news_id", $r->news_id))); $texttags = ""; while($r2 = mysqli_fetch_object($tagsdb)) { if (strlen($texttags) > 0) { $texttags .= ", "; } $tagdb = BiQuery1("*", "vs_tags", array(array("tag_id", $r2->tag_id))); $r3 = mysqli_fetch_object($tagdb); $texttags .= $r3->tag; } $categoriesdb = BiQuery1("*", "vs_categories_news", array(array("news_id", $r->news_id))); $textcategories = ""; while ($r2 = mysqli_fetch_object($categoriesdb)) { if (strlen($textcategories) > 0) { $textcategories .= ", "; } $categoriesdb2 = BiQuery1("*", "vs_categories", array(array("category_id", $r2->category_id))); $r3 = mysqli_fetch_object($categoriesdb2); $textcategories .= $r3->dir; } $contentdb = BiQuery1("*", "vs_content_sources", array(array("content_source_id", $r->content_source_id))); $textcontent = ""; while ($r2 = mysqli_fetch_object($contentdb)) { if (strlen($textcontent) > 0) { $textcontent .= ", "; } $contentdb2 = BiQuery1("*", "vs_content_sources", array(array("content_source_id", $r2->content_source_id))); $r3 = mysqli_fetch_object($contentdb2); $textcontent .= $r2->title; } $m[] = array( "id" => $r->news_id, "title" => $r->title, "content" => $textcontent, "category" => $textcategories, "tag" => $texttags, "duration" => $r->duration, ); } echo json_encode($m); } ?> Спойлер: settings.php Код (Text): <?php $dbtype = "mysql"; $db_connect_host = "localhost"; $db_connect_name = "user"; $db_connect_pass = "pass"; $db_name = "name"; $api_key = "dawdawfsfefawa"; $video_limit = 80; $startvidesiteourl = "http://www.site.com/"; ?> --- Добавлено --- Спойлер: mysql-1часть.php Код (Text): <?php function BiQuery($query) { global $showjserror; global $query_count; global $query_time; global $langt; $query_count++; global $dblink; $result = mysqli_query($dblink, $query); return $result; } function BiDBResCount($link, $what = 1) { $result = 0; if ($link) { if ($what == 1) { $result = mysqli_num_rows($link); } else { $result = mysqli_num_fields($link); } } return $result; } function BiDBResult($link, $row, $field) { $result = ""; if ($link) { $result = mysqli_result($link, $row, $field); } return $result; } function BiQueryWhere($where) { $query = ""; if ($where !== "") { $query = $query . " WHERE "; if (isset($where[0][0])) { for ($i = 0; $i < sizeof($where); $i++) { if (!isset($where[$i][1])) { $query = $query . " " . $where[$i][0] . " "; } else { $query = $query . " `" . addslashes($where[$i][0]) . "`"; if (isset($where[$i][2])) { $query = $query . $where[$i][2]; } else { $query = $query . "="; } $query = $query . "'" . addslashes($where[$i][1]) . "' "; if ($i < sizeof($where) - 1) { if (isset($where[$i + 1][1])) { $query = $query . " AND "; } } } } } else { $query = $query . $where . " "; } } return $query; } function BiQuery1($sel, $table, $where = "", $order = "", $order1 = "", $limit = "") { $query = "SELECT " . $sel . " FROM `" . $table . "` " . BiQueryWhere($where); if ($order !== "") { $query = $query . " ORDER by " . $order . " " . $order1 . " "; } if ($limit !== "") { $query = $query . " LIMIT " . $limit . " "; } $query = $query . " ;"; return BiQuery($query); } function BiQueryTableAdd($table, $rows) { $rows2 = ""; $key = ""; for ($i = 0; $i < sizeof($rows); $i++) { $temp = " `" . $rows[$i][0] . "` "; if ($rows[$i][1] == "int") { $temp = $temp . " int(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "varchar") { $temp = $temp . " varchar(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "text") { $temp = $temp . " text "; } if ($rows[$i][1] == "mediumtext") { $temp = $temp . " mediumtext "; } if ($rows[$i][3] !== "!-") { $temp = $temp . " NOT NULL default '" . addslashes($rows[$i][3]) . "' "; } if (isset($rows[$i][4])) { $temp = $temp . " NOT NULL auto_increment "; $key = $rows[$i][0]; } $rows2 = $rows2 . "" . $temp . ""; if ($i < sizeof($rows) - 1) { $rows2 = $rows2 . " , "; } } if ($key !== "") { $rows2 = $rows2 . " , KEY `" . $key . "` (`" . $key . "`) "; } $query = "CREATE TABLE `" . $table . "` ( " . $rows2 . " ) ENGINE=MyISAM;"; return BiQuery($query); } --- Добавлено --- Спойлер: mysql-2часть.php Код (Text): function BiQueryTableFields($table, $rows) { global $dblink; global $db_name; $fields = mysqli_list_fields($db_name, $table, $dblink); for ($i = 0; $i < mysqli_num_fields($fields); $i++) { $tmas[mysqli_field_name($fields, $i)] = mysqli_field_type($fields, $i); } for ($i = 0; $i < sizeof($rows); $i++) { if (!isset($tmas[$rows[$i][0]])) { $temp = " `" . $rows[$i][0] . "` "; if ($rows[$i][1] == "int") { $temp = $temp . " int(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "varchar") { $temp = $temp . " varchar(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "text") { $temp = $temp . " text "; } if ($rows[$i][1] == "mediumtext") { $temp = $temp . " mediumtext "; } if ($rows[$i][3] !== "!-") { $temp = $temp . " NOT NULL default '" . addslashes($rows[$i][3]) . "' "; } if (isset($rows[$i][4])) { $temp = $temp . " NOT NULL auto_increment PRIMARY KEY FIRST "; } BiQuery("ALTER TABLE `" . $table . "` ADD " . $temp . " ;"); } else { $temp = ""; if ($rows[$i][1] == "int") { $temp = $temp . "int"; } if ($rows[$i][1] == "varchar") { $temp = $temp . "varchar"; } if ($rows[$i][1] == "text") { $temp = $temp . "text"; } if ($rows[$i][1] == "mediumtext") { $temp = $temp . "mediumtext"; } if ($tmas[$rows[$i][0]] !== $temp) { $temp = " `" . $rows[$i][0] . "` `" . $rows[$i][0] . "` "; if ($rows[$i][1] == "int") { $temp = $temp . " int(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "varchar") { $temp = $temp . " varchar(" . $rows[$i][2] . ") "; } if ($rows[$i][1] == "text") { $temp = $temp . " text "; } if ($rows[$i][1] == "mediumtext") { $temp = $temp . " mediumtext "; } if ($rows[$i][3] !== "!-") { $temp = $temp . " NOT NULL default '" . addslashes($rows[$i][3]) . "' "; } if (isset($rows[$i][4])) { $temp = $temp . " NOT NULL auto_increment PRIMARY KEY FIRST "; } BiQuery("ALTER TABLE `" . $table . "` CHANGE " . $temp . " ;"); } } } }
Значит нет ошибок. Потому что всё так или иначе пишется в логи Логи php? php-fpm? nginx? apache? syslog? p.s. а у вас скорее всего лимит оперативки превышен.