PHP网页无法与MYSql数据库连接

时间:2018-06-30 01:43:13

标签: php e-commerce wampserver

我正在开发在线商店。我想在加载网页时显示产品列表。但是问题是当我运行应用程序时,它显示以下错误...

)不推荐使用:mysql_connect():不推荐使用mysql扩展,以后将被删除:在第7行的C:\ wamp64 \ www \ onlineordering \ db \ connection.php中使用mysqli或PDO < / strong>

这是我的connection.php文件。

   <?php
session_start();
ob_start();
include ("define.php");

//connectivity
mysql_connect("localhost","root","") or die("<h2>Server Error:Unable to connect backend</h2>");
mysql_select_db("ecom") or die("<h2>Database not found</h2>");

//current location 
$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
//echo base64_decode($current_url);

$randomnumber = date ("dmYHis");
include ("functions/datafetching.php");


?>

这是类别文件的html。

<div class="sidebar_box"><span class="bottom"></span>
                <h3>Categories</h3>   
                <div class="content"> 
                    <ul class="sidebar_list">
                    <?php
                    $sqlCat= "select * from category where recordstatus='' order by sequence_order Asc";
                    $exeCat = mysql_query($sqlCat) or die ("Error in:sqlCat");
                    $counCat= mysql_num_rows($exeCat);
                    if($counCat>0)
                    { 

                       $classCat=1;
                       while($resCat= mysql_fetch_array($exeCat))
                       {
                         $categoryname= $resCat["categoryname"];
                         $auto_number= $resCat["auto_number"];

                        ?>
                        <form method="post" style="margin:0px;padding:0px;" action="productcategory.php" id="frmdetailcat<?php echo $classCat;?>">
                          <input type="hidden" name="category" value="<?php echo $categoryname?>">
                          <input type="hidden" name="categoryid" value="<?php echo $auto_number?>">
                        </form>

                        <?php

                          if($classCat==1)
                          {
                          ?>
                          <li class="first"><a  style="cursor:pointer;" onclick="subform('frmdetailcat<?php echo $classCat;?>')" ><?php echo $categoryname;?></a></li>
                    <?php
                          }else
                          if($classCat==$counCat)
                          {
                          ?>
                          <li class="last"><a  style="cursor:pointer;" onclick="subform('frmdetailcat<?php echo $classCat;?>')" >
                          <?php echo $categoryname;?></a></li>
                    <?php     
                          }else
                          {
                          ?>
                    <li><a  style="cursor:pointer;" onclick="subform('frmdetailcat<?php echo $classCat;?>')" >
                          <?php echo $categoryname;?></a></li>
                    <?php
                          }
                          $classCat++;
                       }
                      }else

                      {
                      ?>
                       <li class="first"><a href="#">No Category is avaliable</a></li>

                      <?php
                      }
                    ?>

                    </ul>
                </div>
            </div>

这是我运行应用程序时的屏幕截图。

enter image description here

0 个答案:

没有答案