matant Posted May 11, 2015 Share Posted May 11, 2015 hello, i am new in php and i would like to develop a login screen in android. my server side is developed in php and for some reason i get every request the follwoing error: "no such file or directory". i have 1 index file and 3 files insdie the "include" directory. this is my files code: index.php <?php /** * Created by PhpStorm. * User: matant * Date: 4/29/2015 * Time: 4:57 PM */ $data = $_SERVER['HTTP_JSON']; $data = json_decode($data); $temp = $data->tag; if($temp == 'login') { $tag = $data->tag; $temp = 'insdieif'; require_once 'include/DB_Functions.php'; $db = new DB_Functions(); $response = array("tag" => $tag, "error"=>FALSE); //login if($tag == 'login') { $email = $data->email; $password = $data->password; $user = $db->getUserDet($email,$password); if($user != false){ $response["error"] = FALSE; $response["user"]["username"] = $user["usern"]; $response["user"]["email"] = $user["email"]; echo json_encode($response); }else { $response["error"] = true; $response["error_msg"] = "Incorrect Email or Password!"; echo json_encode($response); } }else { $response["error"] = true; $response["error_msg"] = "This is not Login request!"; echo json_encode($response); } } else { $response["tag"] = $temp; $response["error"] = true; $response["error_msg"] = "tag parameter is missing"; echo json_encode($response); } DB_Functions.php <?php /** * Created by PhpStorm. * User: matant * Date: 4/29/2015 * Time: 3:57 PM */ class DB_Functions { private $db; function _contrust() { require_once 'DB_Connect.php'; $this->db = DB_Connect(); $this->db->connect(); echo $this->db; } function _destruct() { // $this->close(); } public function getUserDet($email, $pass) { $res = mysql_query("SELECT * FROM users WHERE email = '$email'") or die (mysql_error()); $num_of_rows = mysql_num_rows($res); if ($num_of_rows > 0) { $res = mysql_fetch_array($res); $restemp = $res['password']; if ($pass == $restemp) return $res; else return false; } } } ?> DB_Connect.php: <?php /** * Created by PhpStorm. * User: matant * Date: 4/29/2015 * Time: 3:47 PM */ class DB_Connect{ function _construct(){ } function _destruct(){ } public function connect(){ require_once 'Config.php'; $con = mysql_connect("DB_Host","DB_User","DB_password"); if(!$con) { die('could not connect:'.mysql_error()); } else { mysql_select_db(DB_database, $con); } return $con; } public function close() { mysql_close(); } } ?> Config.php: <?php /** * Created by PhpStorm. * User: matant * Date: 4/29/2015 * Time: 3:35 PM */ define("DB_Host","sqlserver"); define("DB_User","user"); define("DB_password","pass"); define("DB_database","b12_16183751_gpsport"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/296213-json-response-is-no-such-file-or-directory/ Share on other sites More sharing options...
Ch0cu3r Posted May 11, 2015 Share Posted May 11, 2015 From the code your posted the "no such file or directory" message is not from your PHP code. It is most likely the default 404 file not found error message from your server. Are you sure all files are named and placed in the correct directory on your server? Quote Link to comment https://forums.phpfreaks.com/topic/296213-json-response-is-no-such-file-or-directory/#findComment-1511419 Share on other sites More sharing options...
Barand Posted May 11, 2015 Share Posted May 11, 2015 function _contrust() ??? Quote Link to comment https://forums.phpfreaks.com/topic/296213-json-response-is-no-such-file-or-directory/#findComment-1511425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.