所以我把这个android应用程序连接到数据库,我在php中得到了这个错误
警告:require_once(/db_connect.php)[function.require-once]:无法打开流:第47行的C:\ AppServ \ www \ android_connect \ viewAllWeb.php中没有此类文件或目录
致命错误:require_once()[function.require]:无法打开所需的' /db_connect.php'第47行的C:\ AppServ \ www \ android_connect \ viewAllWeb.php中的(include_path ='。; C:\ php5 \ pear')
特定的php应该从我的数据库调用数据并将其显示为表
问题是,我在我的计算机中尝试过它(比如它的comp1)在我的localhost中(使用wamp,没有PEAR,注册全局关闭)并且它正常工作,即使在我的应用程序中也没有任何错误
但是当我把它放在另一台计算机(比如comp2)中我想把它作为服务器(appserv,PEAR,注册全局)时显示错误
知道这是关于什么的吗?我尝试在comp2中打开和关闭注册全局,就像google中的一些建议一样,无济于事。它与comp1没有梨或什么有关吗?因为我在comp1中进行了编码
comp1中的路径是C / wamp / www / android_connect comp2中的路径是C / AppServ / www / android_connect
由于
<?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> </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> </td>
</tr>
</table>
<p> </p>
</body>
</html>
答案 0 :(得分:2)
尝试使用require_once("db_connect.php")
或require_once("./db_connect.php");