-2

Hi i am using a admin panel and it work fine but when i go to the user website if have this error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\admin........... on line 188 and the second error is on line 128 here is the php code

    <?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>

how to avoid this error ? or how to correct it i delete the lines but that manipulate the output and destroy part of it how to fix this error

Aref Makke
  • 49
  • 10
  • 2
    There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future. –  Jan 29 '14 at 12:24

1 Answers1

0

What's missing in your code is the connection to the database...

As per specified in the documentation, you must have an already opened connection to use mysql_query without specifying a link identifier. Please refer to the documentation for mysql_connect on how to do so.

codeblur
  • 438
  • 1
  • 3
  • 8
  • Also note that your html is [not valid xhtml](http://www.htmldog.com/guides/html/) and that as user689 said the mysql_* function are deprecated as PHP 5.5 - however if you're stuck to an old PHP version with an existing codebase, you should keep using them. – codeblur Jan 29 '14 at 12:33
  • as it's mention on the example the first line `` which contain the connection to database so the problem is not the connection – Aref Makke Aug 06 '18 at 12:02