免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2157 | 回复: 1
打印 上一主题 下一主题

继续PHP出错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-04 06:25 |只看该作者 |倒序浏览
本帖最后由 wxlg1117 于 2010-07-04 07:07 编辑
  1. <?php


  2. require "include/bittorrent.php";

  3. dbconn();
  4. loggedinorreturn();

  5. if (get_user_class() < UC_ADMINISTRATOR)
  6.         newerr($tracker_lang['error'], $tracker_lang['access_denied']);

  7. $action = $_GET["action"];

  8. //   Delete News Item    //////////////////////////////////////////////////////

  9. if ($action == 'delete')
  10. {
  11.         $newsid = (int)$_GET["newsid"];
  12.   if (!is_valid_id($newsid))
  13.           newerr($tracker_lang['error'],"Invalid news item ID - Code 1.");

  14.   $returnto = htmlentities($_GET["returnto"]);

  15.   $sure = $_GET["sure"];
  16.   if (!$sure)
  17.     newerr("Delete News","Are you sure you want to delete this news? Click \n" .
  18.             "<a href=?action=delete&newsid=$newsid&returnto=$returnto&sure=1>here</a> If you are sure.");

  19.   sql_query("DELETE FROM news WHERE id=$newsid") or sqlerr(__FILE__, __LINE__);

  20.         if ($returnto != "")
  21.                 header("Location: $returnto");
  22.         else
  23.                 $warning = "News <b>successfully</b> deleted";
  24. }

  25. //   Add News Item    /////////////////////////////////////////////////////////

  26. if ($action == 'add')
  27. {

  28.         $subject = $_POST["subject"];
  29.         if (!$subject)
  30.                 newerr($tracker_lang['error'],"Topic news may not be empty!");

  31.         $body = $_POST["body"];
  32.         if (!$body)
  33.                 newerr($tracker_lang['error'],"Body news may not be empty!");

  34.         $added = $_POST["added"];
  35.         if (!$added)
  36.                 $added = TIMENOW;

  37.   sql_query("INSERT INTO news (userid, added, body, subject) VALUES (".
  38.           $CURUSER['id'] . ", $added, " . sqlesc($body) . ", " . sqlesc($subject) . ")") or sqlerr(__FILE__, __LINE__);
  39.         if (mysql_affected_rows() == 1)
  40.                 $warning = "News <b>successfully added </b>";
  41.         else
  42.                 newerr($tracker_lang['error'],"What just happened?.");
  43. }

  44. //   Edit News Item    ////////////////////////////////////////////////////////

  45. if ($action == 'edit')
  46. {

  47.         $newsid = (int)$_GET["newsid"];

  48.   if (!is_valid_id($newsid))
  49.           newerr($tracker_lang['error'],"Invalid news item ID - Code 2.");

  50.   $res = sql_query("SELECT * FROM news WHERE id=$newsid") or sqlerr(__FILE__, __LINE__);

  51.         if (mysql_num_rows($res) != 1)
  52.           newerr($tracker_lang['error'], "No news item with ID.");

  53.         $arr = mysql_fetch_array($res);

  54.   if ($_SERVER['REQUEST_METHOD'] == 'POST')
  55.   {
  56.           $body = $_POST['body'];
  57.           $subject = $_POST['subject'];


  58.         $subject = $_POST["subject"];
  59.         if ($subject == "")
  60.                 newerr($tracker_lang['error'],"Topic news may not be empty");

  61.     if ($body == "")
  62.             newerr($tracker_lang['error'], "Body news may not be empty!");

  63.     $body = sqlesc($body);

  64.     $subject = sqlesc($subject);

  65.     $editedat = sqlesc(TIMENOW);

  66.     sql_query("UPDATE news SET body=$body, subject=$subject WHERE id=$newsid") or sqlerr(__FILE__, __LINE__);

  67.     $returnto = htmlentities($_POST['returnto']);

  68.                 if ($returnto != "")
  69.                         header("Location: $returnto");
  70.                 else
  71.                         $warning = "News <b>successfully</b> edited";
  72.   }
  73.   else
  74.   {
  75.                  $returnto = htmlentities($_GET['returnto']);
  76.           stdhead("Editing News");
  77.           print("<form method=post name=news action=?action=edit&newsid=$newsid>\n");
  78.           print("<table border=1 cellspacing=0 cellpadding=5>\n");
  79.           print("<tr><td class=colhead>Editing news<input type=hidden name=returnto value=$returnto></td></tr>\n");
  80.           print("<tr><td>Subject: <input type=text name=subject maxlength=70 size=50 value=\"" . htmlspecialchars($arr["subject"]) . "\"/></td></tr>");
  81.           print("<tr><td style='padding: 0px'>");
  82.           textbbcode("news","body",htmlspecialchars($arr["body"]));
  83.           //<textarea name=body cols=145 rows=5 style='border: 0px'>" . htmlspecialchars($arr["body"]) .
  84.           print("</textarea></td></tr>\n");
  85.           print("<tr><td align=center><input type=submit value='Edit News'></td></tr>\n");
  86.           print("</table>\n");
  87.           print("</form>\n");
  88.           stdfoot();
  89.           die;
  90.   }
  91. }

  92. //   Other Actions and followup    ////////////////////////////////////////////

  93. stdhead("News");
  94. if ($warning)
  95.         print("<p><font size=-3>($warning)</font></p>");
  96. print("<form method=post name=news action=?action=add>\n");
  97. print("<table border=1 cellspacing=0 cellpadding=5>\n");
  98. print("<tr><td class=colhead>Submit News</td></tr>\n");
  99. print("<tr><td>Subject: <input type=text name=subject maxlength=40 size=50 value=\"" . htmlspecialchars($arr["subject"]) . "\"/></td></tr>");
  100. print("<tr><td style='padding: 0px'>");
  101. textbbcode("news","body","");
  102. //<textarea name=body cols=145 rows=5 style='border: 0px'>
  103. print("</textarea></td></tr>\n");
  104. print("<tr><td align=center><input type=submit value='Add News' class=btn></td></tr>\n");
  105. print("</table></form><br /><br />\n");

  106. $res = sql_query("SELECT * FROM news ORDER BY added DESC") or sqlerr(__FILE__, __LINE__);

  107. if (mysql_num_rows($res) > 0)
  108. {


  109.         begin_main_frame();
  110.         begin_frame();

  111.         while ($arr = mysql_fetch_array($res))
  112.         {
  113.                 $newsid = $arr["id"];
  114.                 $body = $arr["body"];
  115.                 $subject = $arr["subject"];
  116.           $userid = $arr["userid"];
  117.           $added = get_date_time($arr["added"]) . " GMT (" . (get_elapsed_time($arr["added"])) . " Ago)";

  118.     $res2 = sql_query("SELECT username, donor FROM users WHERE id = $userid") or sqlerr(__FILE__, __LINE__);
  119.     $arr2 = mysql_fetch_array($res2);

  120.     $postername = $arr2["username"];

  121.     if ($postername == "")
  122.             $by = "Unknown [$userid]";
  123.     else
  124.             $by = "<a href=userdetails.php?id=$userid><b>$postername</b></a>" .
  125.                     ($arr2["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "");

  126.           print("<p class=sub><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
  127.     print("Posted ".$added."&nbsp;-&nbsp;$by");
  128.     print(" - [<a href=?action=edit&newsid=$newsid><b>Edit</b></a>]");
  129.     print(" - [<a href=?action=delete&newsid=$newsid><b>Delete</b></a>]");
  130.     print("</td></tr></table></p>\n");

  131.           begin_table(true);
  132.       print("<tr valign=top><td><b>".$subject."</b></td></tr>\n");
  133.           print("<tr valign=top><td class=comment>".format_comment($body)."</td></tr>\n");
  134.           end_table();
  135.         }
  136.         end_frame();
  137.         end_main_frame();
  138. }
  139. else
  140.   newerr("Sorry", "No News!",false,true);
  141. die;
  142. ?>
复制代码
其中的这一段:
  1.   $sure = $_GET["sure"];
  2.   if (!$sure)
  3.     newerr("Delete News","Are you sure you want to delete this news? Click \n .
  4.             "<a href=?action=delete&newsid=$newsid&returnto=$returnto&sure=1>here</a> If you are sure.");
复制代码
放服务器页面成这样了:


符号问题?

论坛徽章:
0
2 [报告]
发表于 2010-07-04 17:45 |只看该作者
newerr() 对于html是怎么处理的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP