php - 无法跳转到第 8 行 .../tag.php 中 MySQL 结果索引 6 上的第 0 行

标签 php mysql caching

我正在使用用于观看视频的 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/

相关文章:

PHP 捕获最大执行时间错误

php - codeigniter 3 - 缺少 css 文件

php - 用户评论 : Implementation of Comments - What technologies to use?

MySQL在线测试工具

c# - 将 Response.RemoveOutputCacheItem 与 RedisOutputCacheProvider 结合使用

php - 从 MySQL 流式传输二进制文件以使用 PHP 下载

javascript - 将变量从 FancyBox 传递到父级时未捕获类型错误

mysql - NodeJS 检查记录是否存在

javascript - 如何确定从缓存中提供文件?

java - DataNucleus 和缓存协调