警告:mysql_fetch_assoc():提供的参数不是C:\ xampp \中的有效MySQL结果资源

时间:2014-01-29 12:10:36

标签: php mysql

您好我正在使用管理面板,它工作正常,但当我去用户网站时,如果有这个错误 警告:mysql_fetch_assoc():提供的参数在第188行的C:\ xampp \ htdocs \ admin ...........中不是有效的MySQL结果资源,第二个错误在第128行 这是php代码

    <?php include("config.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Admin panel</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">


<STYLE type=text/css>
BODY {
            BACKGROUND-REPEAT: repeat; BACKGROUND-COLOR: #CCFFFF}
</STYLE>
<LINK href="index_files/induc.css" type=text/css rel=stylesheet>
<STYLE type=text/css>
.style1 {
            COLOR: #cc0000
}
#notice {
            Z-INDEX: 1; LEFT: 375px; WIDTH: 422px; POSITION: absolute; TOP: 201px; HEIGHT: 99px; BACKGROUND-COLOR: #ffffff
}
a:link {
            color: #FFFFFF;
            text-decoration: none;
}
a:visited {
            text-decoration: none;
            color: #FFFFFF;
}
a:hover {
            text-decoration: underline;
            color: #000000;
}
a:active {
            text-decoration: none;
            color: #FFFFFF;
}
.style2 {color: #FFFFFF}
.style3 {FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; LETTER-SPACING: 0.02em; font-weight: bold;}
.style4 {FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; LETTER-SPACING: 0.02em; font-weight: bold; color: #FFFFFF; }
.style5 {
            color: #0000FF;
            font-weight: bold;
}
.style6 {
            font-size: 16px;
            font-weight: bold;
}
.style7 {           color: #FFFFFF;
            font-family: Verdana;
            font-size: 11px;
            font-weight: normal;
            text-decoration: none;
}
</STYLE>


</HEAD>
<BODY leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE cellSpacing=0 cellPadding=0 width=812 align=center bgColor=#ffffff
border=0>
  <TBODY>
  <TR>
    <TD width=21><IMG height=21 src="index_files/topcorner1.gif" width=21></TD>
    <TD background=index_files/up.gif>&nbsp;</TD>
    <TD width=21><IMG height=21 src="index_files/topcorner2.gif"
  width=21></TD></TR>
  <TR>
    <TD background=index_files/lside.gif>&nbsp;</TD>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 width=770 align=center bgColor=#ff6600
      border=0>
        <TBODY>
        <TR>
          <TD bgcolor="#3D7FEF">            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
              <TR>
                <TD width=205 bgColor=#9c9a9c><img height=132 alt=""
                  src="index_files/topbanne.jpg" width=205></TD>
                <TD vAlign=top width=565>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                      <TR>
                        <TD bgColor=#3D7FEF><IMG height=100 alt=""
                        src="index_files/toprighte1.jpg" width=565></TD>
                      </TR>
                      <TR>
                        <TD background=index_files/backg_top.gif height=32>
                          <TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
                            <TBODY>
                              <TR>
                                <TD width="70%">
                                  <MARQUEE class="redbod style1"
                              scrollDelay=150>
                                  Welcome to Main page
                                </MARQUEE></TD>
                                <TD class=forbody2 width="30%">
                                  <DIV align=center>
                                    <SCRIPT language=javascript
                              src="index_files/date.js"></SCRIPT>
                                </DIV></TD>
                              </TR>
                            </TBODY>
                        </TABLE></TD>
                      </TR>
                    </TBODY>
                </TABLE></TD>
              </TR>
            </TBODY>
          </TABLE></TD>
        </TR>
        <TR>
          <TD vAlign=top>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD vAlign=top width=205 bgColor=#3D7FEF>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD height=187 colspan="3" vAlign=top bgColor=#3D7FEF><TABLE cellSpacing=0 cellPadding=0 width=180
                        align=center border=0>
                        <TBODY>
                                                                        <?php
                                                                        $str="select * from content";
                                                                        //echo $str;
                                                                        $row=mysql_query($str);
                                                                        while($res=mysql_fetch_assoc($row))
                                                                        {
                                                                        ?>
                          <TR>
                            <TD class=button><DIV align=left>
                                                                                    <A class=link href="index.php?qs=cont_show&pageid=<?php echo $res["id"];?>"><?php echo $res["page_title"];?></A></DIV></TD>
                          </TR>
                                                                          <?php } ?>

                        </TBODY>
                      </TABLE></TD>
                    </TR>
                    <TR>
                      <TD colspan="3">&nbsp;</TD>
                    </TR>
                    <TR>
                      <TD width="22%">&nbsp;</TD>
                      <TD width="58%"><div align="center" class="redbod style2">Last updated </div></TD>
                      <TD width="20%">&nbsp;</TD>
                    </TR>
                    <TR>
                      <TD>&nbsp;</TD>
                      <TD><div align="center"><span class="style2">[<?php echo date("d-m-y"); ?></span><span class="style2">]</span></div></TD>
                      <TD>&nbsp;</TD>
                    </TR>
                    </TBODY></TABLE></TD>
                <TD vAlign=top bgcolor="#FFFFFF">
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TR>
                      <TD>
                                                              <table width="100%" height="759" border="0" cellpadding=" 0" cellspacing=" 0">
                <tr>
                  <td height="674" valign="top" bgcolor="#FFFFFF" style="padding-left:10px; padding-right:10px">
                                                  <table width="100%" border="0" cellspacing=" 0" cellpadding=" 0">
                                                   <?php
                                                                                    if($_REQUEST["qs"]=="cont_show")
                                                                                    {
                                                                                    $_SESSION["ses"]="1";
                                                                                                $cont="select * from content  where id='".$_GET["pageid"]."'";
                                                                                                //echo $cont;
                                                                                                //exit;
                                                                                                $cont_row=mysql_query($cont);
                                                                                                $cont_res=mysql_fetch_assoc($cont_row);

                                                                                    ?>
                      <tr>
                        <td valign="top">
                                                                        <?php
                                                                        echo "<font color='#3D7FEF'>"."<b>"."Site Map >".$cont_res["page_title"]."</b>"."<font>"."<br>"."<br>";
                                                                        echo $cont_res["details"];
                                                                        ?>                          </td>
                        </tr>
                                                                         <?php } ?>
                                                                          <?php
                                                                           if($_SESSION["ses"]=="")
                                                                                    {
                                                                                    $cont="select * from content  where id='1'";
                                                                                                //echo $cont;
                                                                                                //exit;
                                                                                                $cont_row=mysql_query($cont);
                                                                                                $cont_res=mysql_fetch_assoc($cont_row);

                                                                                    ?>
                                                                                    <TR>
                                                                                    <td>
                                                                                    <?php
                                                                                    echo "<font color='#4A2E0F'>"."<b>"."Site Map >".$cont_res["page_title"]."</b>"."<font>"."<br>"."<br>";
                                                                                    echo $cont_res["details"];
                                                                                    ?></td>
                                                                                      </TR>
                                                                                      <?php
                                                                                      }

                                                                                      ?>
                    </table>                      </td>
                </tr>
              </table>                        </TD></TR></TBODY></TABLE></TD>
              </TR></TBODY></TABLE></TD></TR>
        <TR bgColor=#ffffff>
          <TD bgColor=#3D7FEF height=25>&nbsp;</TD>
        </TR>
        <TR bgColor=#ffffff>
          <TD bgColor=#3D7FEF height=25>
            <DIV class=smallbluebold align=center></DIV></TD></TR>
        <TR bgColor=#ffffff>
          <TD bgColor=#3D7FEF>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
                <TR>
                  <TD vAlign=bottom align=left width=10><IMG height=10
                  src="index_files/cornerwhite_lower_left.gif" width=10></TD>
                  <TD bgcolor="#3D7FEF">
                    <DIV class=forbody2 align=center>
                      <DIV align=center></DIV>
                  </DIV></TD>
                  <TD vAlign=bottom align=right width=10><IMG height=10
                  src="index_files/cornerwhite_lower_right.gif"
              width=10></TD>
                </TR>
              </TBODY>
            </TABLE></TD>
        </TR></TBODY></TABLE></TD>
    <TD background=index_files/rside.gif>&nbsp;</TD></TR>
  <TR>
    <TD><IMG height=20 src="index_files/downcorner1.gif" width=21></TD>
    <TD background=index_files/down.gif>&nbsp;</TD>
<TD><IMG height=20 src="index_files/downcorner2.gif"
  width=21></TD></TR></TBODY></TABLE>
</BODY></HTML>

如何避免此错误?或者如何纠正它我删除行但操纵输出并销毁其中的一部分如何修复此错误

1 个答案:

答案 0 :(得分:0)

代码中缺少的是与数据库的连接......

根据documentation中的指定,您必须已经打开连接才能使用mysql_query而不指定链接标识符。有关如何操作,请参阅documentation for mysql_connect