我正在使用用于观看视频的 php 脚本。过去 2-3 天大约有 1000 人同时在线,现在我随机收到内部服务器错误。当我的网站访问者数量减少时,我有从来没有见过这个错误。
<?php
include('config.php');
if($site[cache]>=3)
include('cache.head.php');
$tsef=htmlspecialchars($_GET[sef]);
$query=mysql_query("SELECT tag FROM tags WHERE sef='$tsef' LIMIT 1");
@mysql_query("UPDATE tags SET views=views+1 WHERE sef='$tsef'");
**$tag=mysql_result($query,0);**
$tkeywords=explode(' ',$tag);
?>
我认为我需要一些缓存机制,因为我看到我的网络托管服务上的进程限制接近最大值。但我不知道如何实现。
最佳答案
此错误表明您的查询没有返回任何行;你无法凭空阅读专栏。没有与 URL 中的“sef”值匹配的标签。我认为这与您的服务器负载问题无关。
让我们稍微清理一下:
include('config.php');
if ($site[cache] >= 3)
include('cache.head.php');
$tsef = mysql_real_escape_string(htmlspecialchars($_GET['sef']));
$result = mysql_query("SELECT tag FROM tags WHERE sef='$tsef' LIMIT 1");
$tkeywords = array();
if ($result && mysql_num_rows($result) > 0) {
$tag = msyql_result($result, 0);
$tkeywords = explode(' ', $tag);
mysql_query("UPDATE tags SET views=views+1 WHERE sef='$tsef'");
}
关于php - 无法跳转到第 8 行 .../tag.php 中 MySQL 结果索引 6 上的第 0 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18088935/