안녕하세요. 내 블로그에 블로그 게시물의 제목을 만들고 해당 게시물이있는 새 페이지를 클릭 할 수있게하려고합니다. 나는 오류가 있지만 내가 그것을 할 때 : 여기알림 : 정의되지 않은 색인 : post_id
Notice: Undefined index: post_id in C:\wamp\www\blog_test\index.php on line 264 Call Stack #TimeMemoryFunctionLocation 10.0009322712{main}()..\index.php:0 ">Fanboy-ism
라인 (264)입니다 :
<h3><a href="post.php?post_id=<?php echo $row_getDisplay['post_id']; ?>"><?php echo $row_getDisplay['title']; ?></a></h3>
사람이 나를 혼란, 그것을 해결하는 방법을 어떤 생각을 가지고있다. & & 감사
편집하십시오 : 다음
서버 비헤이비어의 코드가 될 때 :
$maxRows_getArchives = 10;
$pageNum_getArchives = 0;
if (isset($_GET['pageNum_getArchives'])) {
$pageNum_getArchives = $_GET['pageNum_getArchives'];
}
$startRow_getArchives = $pageNum_getArchives * $maxRows_getArchives;
mysql_select_db($database_blog, $blog);
$query_getArchives = "SELECT DISTINCT DATE_FORMAT(news.updated, '%M %Y') AS archive, DATE_FORMAT(news.updated, '%Y-%m') AS link FROM news ORDER BY news.updated DESC";
$query_limit_getArchives = sprintf("%s LIMIT %d, %d", $query_getArchives, $startRow_getArchives, $maxRows_getArchives);
$getArchives = mysql_query($query_limit_getArchives, $blog) or die(mysql_error());
$row_getArchives = mysql_fetch_assoc($getArchives);
if (isset($_GET['totalRows_getArchives'])) {
$totalRows_getArchives = $_GET['totalRows_getArchives'];
} else {
$all_getArchives = mysql_query($query_getArchives);
$totalRows_getArchives = mysql_num_rows($all_getArchives);
}
$totalPages_getArchives = ceil($totalRows_getArchives/$maxRows_getArchives)-1;
mysql_select_db($database_blog, $blog);
$query_getRecent = "SELECT news.post_id, news.title FROM news ORDER BY news.post_id DESC LIMIT 10";
$getRecent = mysql_query($query_getRecent, $blog) or die(mysql_error());
$row_getRecent = mysql_fetch_assoc($getRecent);
$totalRows_getRecent = mysql_num_rows($getRecent);
$maxRows_getDisplay = 1;
$pageNum_getDisplay = 0;
if (isset($_GET['pageNum_getDisplay'])) {
$pageNum_getDisplay = $_GET['pageNum_getDisplay'];
}
$startRow_getDisplay = $pageNum_getDisplay * $maxRows_getDisplay;
mysql_select_db($database_blog, $blog);
$query_getDisplay = "SELECT news.post_id, news.title, news.pre, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC";
$query_limit_getDisplay = sprintf("%s LIMIT %d, %d", $query_getDisplay, $startRow_getDisplay, $maxRows_getDisplay);
$getDisplay = mysql_query($query_limit_getDisplay, $blog) or die(mysql_error());
$row_getDisplay = mysql_fetch_assoc($getDisplay);
if (isset($_GET['totalRows_getDisplay'])) {
$totalRows_getDisplay = $_GET['totalRows_getDisplay'];
} else {
$all_getDisplay = mysql_query($query_getDisplay);
$totalRows_getDisplay = mysql_num_rows($all_getDisplay);
}
$totalPages_getDisplay = ceil($totalRows_getDisplay/$maxRows_getDisplay)-1;
mysql_select_db($database_blog, $blog);
$query_getPosts = "SELECT post_id, title, updated FROM news ORDER BY updated DESC";
$getPosts = mysql_query($query_getPosts, $blog) or die(mysql_error());
$row_getPosts = mysql_fetch_assoc($getPosts);
$totalRows_getPosts = mysql_num_rows($getPosts);
$queryString_getDisplay = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_getDisplay") == false &&
stristr($param, "totalRows_getDisplay") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_getDisplay = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_getDisplay = sprintf("&totalRows_getDisplay=%d%s", $totalRows_getDisplay, $queryString_getDisplay);
$queryString_getArchives = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_getArchives") == false &&
stristr($param, "totalRows_getArchives") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_getArchives = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_getArchives = sprintf("&totalRows_getArchives=%d%s", $totalRows_getArchives, $queryString_getArchives);
$var1_getDisplay2 = "-1";
if (isset($_GET['archive'])) {
$var1_getDisplay2 = $_GET['archive'];
$query_getDisplay = sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y'), news. AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC", GetSQLValueString($var1_getDisplay2, "text"));
} elseif (isset($_GET['post_id'])) {
$var2_getDisplay3 = $_GET['post_id'];
$query_getDisplay = sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s", GetSQLValueString($var2_getDisplay3, "int"));
} else {
$query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT ".$pageNum_getDisplay.", 5";
}
$getDisplay = mysql_query($query_getDisplay, $blog) or die(mysql_error());
$row_getDisplay = mysql_fetch_assoc($getDisplay);
$totalRows_getDisplay = mysql_num_rows($getDisplay);
?>
음 :
여기당신이 당신의 코드로이 어떻게 구현 될 수있다? (정확하게 오류가 나타납니다 :) :) – povilasp
'var_dump ($ row_getDisplay);가 실행될 때 xdebug가 반환하는 것은 무엇입니까? 주제 해제 – Jelmer
: mysql_xxx() 함수가 이제는 사용되지 않습니다. 그것들을 사용하지 말고 새로운 mysqli 또는 PDO 확장으로 전환하는 것이 좋습니다. – SDC