为什么我的服务器会出现这些问题? [英] Why is my server giving these problems?

查看:89
本文介绍了为什么我的服务器会出现这些问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在wamp服务器设置端创建了一个文件夹android_connect,并在那里上传了我的php文件。你可以在下面的错误中看到文件路径..文件是:



db_config.php

 <?php  
define(' DB_USER' root);
define(' DB_PASSWORD' vikrant);
define(' DB_DATABASE' sys);
define(' DB_SERVER' 本地实例wampmysqld64);
?>







db_connect.php

 <?php  
DB_CONNECT {
function _construct(){
$ this-> connect();
}
函数_destruct(){
$ this-> close();
}
函数connect(){
require_once_DIR _。' / dbconfig.php' ;
$ con = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD) die(mysql_error());
$ db = mysql_select_db(DB_DATABASE) die(mysql_error()) die(mysql_error) ());
return $ con ;
}
函数close(){
mysql_close();
}
}
?>









get_all_products.php

 < ;?php  
$ response = array();
require_once_DIR _。' / db_connect.php';
$ db = new DB_CONNECT();
$ result = mysql_querry( SELECT * FROM users die(mysql_error());
if(mysql_num_rows($ result)> 0){
$ response [ products ] =阵列();
while($ row = mysql_fetch_array($ result)){
$ product = array();
$ product [ pid] = $ row [ pid];
$ product [ name] = $ row [ name];
$ product [ price] = $ row [ price];
$ product [ description] = $ row [ description];
$ product [ created_at] = $ row [ created_at];
$ product [ updated_at] = $ row [ updated_at];
array_push($ response [ products],$ product);
}
$ response [ success] = 1;
echo json_encode($ response);
} else {
$ response [ success] = 0;
$ response [ message] = 找不到产品。;
echo json_encode($ response);
}
?>





哪个给出了两个错误:

注意:使用未定义的常量require_once_DIR_  - 在C:\ wamp64 \\\android_connect \get_all_products.php中假定为'require_once_DIR_' 3 
致命错误:第4行的C:\ wamp64 \ www \\ _android_connect \ get_all_products.php中找不到DB_CONNECT类



< br $>




delete_products.php

 <?php  
respose = array();
是(isset($ _ POST [' pid'])){
$ pid = $ _ POST [' pid'];

require_once_DIR _。' / db_connect.php';
$ db = new DB_CONNECT();
$ result = mysql_querry( DELETE FROM products WHERE pid = $ pid);

if (mysql_affected_rows()> 0){
$ response [ success] = 1 ;
$ response [ message] = 产品已成功删除;
echo json_encode($ response);
} else {
$ response [ 成功] = 0 ;
$ response [ message] = 未找到产品;
echo json_encode($ response);
}
} else {
$ response [ success ] = 0 ;
$ response [ message] = 缺少必填字段;
echo json_encode($ response);
}
?>





哪个给出错误:

解析错误:语法错误,第2行的C:\ wamp64 \ www \\\ _android_connect \ delete_product.php意外'='













这些是我尝试上传的众多文件中的一部分。请提前帮助并谢谢。



我的尝试:



尝试再次重写代码并重新上传文件。

解决方案

this-> connect();
}
函数_destruct(){


this-> close();
}
函数connect(){
require_once_DIR _。' / dbconfig.php' ;


con = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD) die(mysql_error());

I have created a folder inside the wamp server setup end as "android_connect" and have uploaded my php files there. you can see the file path if you want in the errors below.. the files are :

db_config.php

<?php
define('DB_USER',"root");
define('DB_PASSWORD',"vikrant");
define('DB_DATABASE',"sys");
define('DB_SERVER',"Local instance wampmysqld64");
?>




db_connect.php

<?php
class DB_CONNECT{
	function _construct(){
		$this->connect();
	}
	function _destruct(){
		$this->close();
	}
	function connect(){
		require_once_DIR_.'/dbconfig.php';
		$con=mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
		$db=mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
		return $con;
	}
	function close(){
		mysql_close();
	}
}
?>





get_all_products.php

<?php
$response=array();
require_once_DIR_.'/db_connect.php';
$db=new DB_CONNECT();
$result=mysql_querry("SELECT * FROM users") or die(mysql_error());
if(mysql_num_rows($result)>0){
	$response["products"]=array();
	while($row=mysql_fetch_array($result)){
		$product=array();
		$product["pid"]=$row["pid"];
		$product["name"]=$row["name"];
		$product["price"]=$row["price"];
		$product["description"]=$row["description"];
		$product["created_at"]=$row["created_at"];
		$product["updated_at"]=$row["updated_at"];
		array_push($response["products"],$product);
	}
	$response["success"]=1;
	echo json_encode($response);
}else{
	$response["success"]=0;
	$response["message"]="No Product Found.";
	echo json_encode($response);
}
?>



which is giving two errors:

 Notice: Use of undefined constant require_once_DIR_ - assumed 'require_once_DIR_' in C:\wamp64\www\android_connect\get_all_products.php on line 3
Fatal error: Class 'DB_CONNECT' not found in C:\wamp64\www\android_connect\get_all_products.php on line 4





delete_products.php

<?php
respose = array();
is(isset($_POST['pid'])){
	$pid=$_POST['pid'];
	
	require_once_DIR_.'/db_connect.php';
	$db=new DB_CONNECT();
	$result=mysql_querry("DELETE FROM products WHERE pid=$pid");

	if (mysql_affected_rows() > 0) {
        $response["success"] = 1;
        $response["message"] = "Product successfully deleted";
        echo json_encode($response);
    	} else {
        $response["success"] = 0;
        $response["message"] = "No product found";
        echo json_encode($response);
    	}
}else{
	$response["success"] = 0;
    	$response["message"] = "Required field(s) is missing";
	echo json_encode($response);
}
?>



which is giving error:

Parse error: syntax error, unexpected '=' in C:\wamp64\www\android_connect\delete_product.php on line 2







These are some of many files i have tried uploading. Please help and thank you in advance.

What I have tried:

Tried rewriting the code again and reuploading files.

解决方案

this->connect(); } function _destruct(){


this->close(); } function connect(){ require_once_DIR_.'/dbconfig.php';


con=mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());


这篇关于为什么我的服务器会出现这些问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆