打开需要' / db_connect失败。php”(include_path = '。C:\ php5 \梨”)

时间:2021-12-30 07:13:47

so I made this android application connecting to database, and I got this error in php

我让这个android应用程序连接到数据库,我在php中得到了这个错误。

Warning: require_once(/db_connect.php) [function.require-once]: failed to open stream: No such file or directory in C:\AppServ\www\android_connect\viewAllWeb.php on line 47

警告:require_once(/ db_connect.php)[功能。没有打开流:没有这样的文件或目录在C:\AppServ\www\android_connect\viewAllWeb。php在47行

Fatal error: require_once() [function.require]: Failed opening required '/db_connect.php' (include_path='.;C:\php5\pear') in C:\AppServ\www\android_connect\viewAllWeb.php on line 47

致命错误:require_once()函数。要求:打开/db_connect失败。php”(include_path = '。C:\ php5 \梨”)在C:为其提供AppServ \ www拥有\ \ android_connect \ viewAllWeb。php在47行

that particular php is supposed to call data from my database and display it as a table

这个特定的php应该从我的数据库中调用数据,并将其显示为一个表。

the thing is, I tried it in my computer (say it's comp1)in my localhost (with wamp, no PEAR, register global off) and it works, no error whatsoever even in my application

事情是这样的,我在我的计算机中尝试了它(说它是comp1)在我的本地主机(有wamp,没有PEAR, register global off),而且它是有效的,即使在我的应用程序中也没有任何错误。

but when i put it in another computer (lets say comp2)which I want to put as a server (appserv, PEAR, register global on) it shows that error

但是当我把它放到另一台计算机(比如说comp2)时,我想把它作为一个服务器(appserv, PEAR, register global on)来显示这个错误。

any idea what this is about then? I tried turning register global on and off in comp2 like some suggestion in google, to no avail. Does it have something to do with comp1 not having pear or something? Because i did my coding in comp1

知道这是怎么回事吗?我试着在comp2中像一些谷歌的建议一样,将register global打开和关闭,但都无济于事。它和comp1有什么关系吗?因为我在comp1中做了编码。

the path in comp1 is C/wamp/www/android_connect the path in comp2 is C/AppServ/www/android_connect

comp1中的路径是C/wamp/www/android_connect,其中的路径是C/AppServ/www/android_connect。

Thanks

谢谢

        <?php
    require "db_connect.php";
    //require "get_all_products.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Daftar Barang</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Calibri, Verdana, Arial;
}
body {
    background-color: #000;
}
-->
</style></head>
<body>
<p>&nbsp;</p>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
  <tr>
    <td><div align="center">
      <h1><strong>Daftar Barang</strong></h1>
    </div></td>
  </tr>
  <tr>
    <td><table width="98%" border="1" align="center" cellpadding="2" cellspacing="2">


        <table border='1'>
            <tr>
            <th>Serial Number</th>
            <th>Label</th>
            <th>Jenis</th>
            <th>Merk</th>
            <th>User</th>
            <th>Departemen</th>
            <th>Kondisi</th>
            </tr>
        <?php
            $response = array();


// include db connect class
require_once '/db_connect.php';

// connecting to db
$db = new DB_CONNECT();

// get all products from products table
$result = mysql_query("SELECT * FROM products ORDER BY label") or die(mysql_error());

// check for empty result
if (mysql_num_rows($result) > 0) {
    // looping through all results
    // products node
    $response["products"] = array();

    while ($row = mysql_fetch_array($result)) {

        $product = array();
        $product["SN"] = $row["SN"];
        $product["label"] = $row["label"];
        $product["jenis"] = $row["jenis"];
        $product["merk"] = $row["merk"];
        $product["user"] = $row["user"];
        $product["dept"] = $row["dept"];
        $product["cond"] = $row["cond"];

        while($row = mysql_fetch_array($result))
            {
            echo "<tr>";
            echo "<td>" . $row["SN"] . "</td>";
            echo "<td>" . $row["label"] . "</td>";
            echo "<td>" . $row["jenis"] . "</td>";
            echo "<td>" . $row["merk"] . "</td>";
            echo "<td>" . $row["user"] . "</td>";
            echo "<td>" . $row["dept"] . "</td>";
            echo "<td>" . $row["cond"] . "</td>";
            echo "</tr>";
            }
            echo "</table>";


    }
    // success
    $response["success"] = 1;

    // echoing JSON response
    //echo json_encode($response);

} else {
    // no products found
    $response["success"] = 0;
    $response["message"] = "No products found";

    // echo no users JSON
    echo json_encode($response);
}





        ?>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

1 个解决方案

#1


2  

Try using either require_once("db_connect.php") or require_once("./db_connect.php");

尝试使用require_once("db_connect.php")或require_once("./db_connect.php");

#1


2  

Try using either require_once("db_connect.php") or require_once("./db_connect.php");

尝试使用require_once("db_connect.php")或require_once("./db_connect.php");