これは接続用の私のコードです。エラーは次のとおりです。
10-16 21:33:29.300: E/JSON(359):
10-16 21:33:29.300: E/JSON(359):警告: mysql_connect() [function.mysql-connect]: 不明な MySQL サーバー ホスト ' https' (1) /home/shifteb/public_html/studentreg/_android_alexmed_api/include/DB_Connect.phpの24行
目 10-16 21:33:29.300: E/JSON(359):
10-16 21:33:29.300: E/JSON(359):警告: mysql_select_db() [function.mysql-select-db]: /home/shifteb/public_html/studentreg/_android_alexmed_api内のユーザー 'shifteb'@'localhost' (使用パスワード: NO) のアクセスが拒否されました/include/DB_Connect.php 26行
目 10-16 21:33:29.300: E/JSON(359):
10-16 21:33:29.300: E/JSON(359):警告: mysql_select_db() [function.mysql-select-db]: サーバーへのリンクを/home/shifteb/public_html/studentreg/_android_alexmed_api/include/DB_Connect.php行26
10-16 21:33で確立できませんでした: 29.300: E/JSON(359):
10-16 21:33:29.300: E/JSON(359):警告: mysql_query() [function.mysql-query]: ユーザー 'shifteb'@'localhost' のアクセスが拒否されました (パスワードの使用: NO) /home/shifteb/public_html/studentreg/_android_alexmed_api/include/DB_Functions.php行121
10-16 21:33:29.300: E/JSON(359):
10-16 21:33:29.300: E/JSON(359):警告: mysql_query() [function.mysql-query]: サーバーへのリンクを確立できませんでした/home/shifteb/public_html/studentreg/_android_alexmed_api/include/DB_Functions.php行121
10-16 21:33:29.300: E/JSON(359): ユーザー 'shifteb'@'localhost' のアクセスが拒否されました (パスワードを使用: NO) 10-16 21:33:29.320: E/JSON Parser(359): データ org.json.JSONException の解析エラー: 値
これは、オンラインに接続しようとすると???
アプリケーションは問題なく動作しlocalhost
ますが、オンライン サーバーの URL を変更して PHP スクリプトをアップロードすると、上記のエラーが表示されます。
これらはスクリプトです
関数スクリプト
<?php
/**
* @author ziad gamal baiomy gholmish
* @copyright 2012
*/
class DB_Functions {
private $db;
//put your code here
// constructor
function __construct() {
require_once 'DB_Connect.php';
// connecting to database
$this->db = new DB_Connect();
$this->db->connect();
}
// destructor
function __destruct() {
}
/**
*
*function to search student
*
*/
public function searchStudent($method ,$information){
if($method == 'e_mail'){
$query=mysql_query(" SELECT * FROM persons WHERE `email_personal` = '$information' ");
$no_of_rows = mysql_num_rows($query);
if($no_of_rows > 0){
$resultset=mysql_fetch_array($query);
return $resultset;
}else{
return false;
}
}else if($method == 'mobile'){
$query=mysql_query(" SELECT * FROM persons WHERE `mobile` = '$information' ");
$no_of_rows = mysql_num_rows($query);
if($no_of_rows > 0){
$resultset=mysql_fetch_array($query);
return $resultset;
}else{
return false;
}
}else if($method =='phone'){
$query=mysql_query("SELECT * FROM persons WHERE `phone` = '$information'");
$no_of_rows = mysql_num_rows($query);
if($no_of_rows > 0){
$resultset=mysql_fetch_array($query);
return $resultset;
}else{
return false;
}
}else if($method == 'id'){
$information= intval($information);
$query=mysql_query("SELECT * FROM persons WHERE `id` = $information");
$no_of_rows = mysql_num_rows($query);
if($no_of_rows > 0){
$resultset=mysql_fetch_array($query);
return $resultset;
}else{
return false;
}
}
}
/**
*
*function to staff login
*
*
*/
public function staffLogin($username , $password){
$hashed_password= sha1($password);
$result=mysql_query("SELECT * FROM admins WHERE `username` = '$username'") or die(mysql_error());
$no_of_rows = mysql_num_rows($result);
if($no_of_rows > 0){
$result = mysql_fetch_array($result);
if($hashed_password == $result['hashed_password']){
return $result;
}else{
//user not found
return false;
}
}
}
/**
*
*function to add staff member
*
*
*
*/
public function addStaffMember($username , $password , $national_id){
$result=mysql_query("SELECT `username` FROM admins WHERE `username` = '$username'");
$no_of_rows = mysql_num_rows($result);
if($no_of_rows == 0){
$query=mysql_query("INSERT INTO persons( `national_id` ) VALUES('$national_id')");
if($query){
$resultset=mysql_query("SELECT max(id) FROM persons");
$admin = mysql_fetch_array($resultset);
$admin_id = $admin['0'];
$admin_id= intval($admin_id);
$hashed_password= sha1($password);
$query=mysql_query("INSERT INTO admins (`id`, `username`, `hashed_password`) VALUES ($admin_id , '$username', '$hashed_password')");
if($query){
return true;
}else{
return false;
}
}
}
}
/**
*
*
* edit student information
*
*
*/
public function editStudentInfo($f_name ,$s_name ,$t_name ,$l_name ,$phone ,$mobile ,$e_mail ,$city ,$department ,$street ,$building,$flat ,$id){
$id=intval($id);
$query=mysql_query("UPDATE persons SET `english_fName`= '$f_name' , `english_sName`= '$s_name' , `english_tName`= '$t_name' , `english_lName`= '$l_name' , `phone`= '$phone' , `mobile`= '$mobile' , `city`= '$city' , `p_department`= '$department' , `street`='$street' , `building`='$building' , `flat`='$flat' , `email_personal`= '$e_mail' WHERE id= $id ") or die(mysql_error());
if($query){
return true;
}else{
return false;
}
}
/**
*
*function to change the student password
*
*
*/
public function changeStudentPass($old_pass , $new_pass , $id){
$hashed_old=sha1($old_pass);
$hashed_new=sha1($new_pass);
$id= intval($id);
$query =mysql_query("SELECT * FROM students WHERE id = $id AND `hashed_password` ='$hashed_old' LIMIT 1") or die(mysql_error());
$no_of_rows = mysql_num_rows($query);
if($no_of_rows == 1){
$query=mysql_query("UPDATE students SET `hashed_password` = '$hashed_new' WHERE id = $id ") or die(mysql_error());
if($query){
return true;
}else{
return true;
}
}
}
/**
*
*get the user by user name and password
*
*/
public function getUserByUserNameAndPassword($username, $password){
$hashed_password= sha1($password);
$result=mysql_query("SELECT * FROM students WHERE `username` = '$username'") or die(mysql_error());
$no_of_rows = mysql_num_rows($result);
if($no_of_rows > 0){
$result = mysql_fetch_array($result);
if($hashed_password == $result['hashed_password']){
return $result;
}else{
//user not found
return false;
}
}
}
/**
* registeration process
*
*
*/
public function registerUser($english_fName , $english_sName , $english_tName , $english_lName ,$phone ,$mobile ,$email_personal , $sex , $religion , $city ,$p_department, $street , $building ,$flat , $birth_date , $social , $nationality ,$seat_number ,$password){
$query=mysql_query("select * from persons p join students s on p.id =s.id and `seat_number` =$seat_number");
if($query){
$resultSet=mysql_fetch_array($query);
$file_number= $resultSet['file_number'];
$file_number= takeTodigit($file_number);
$username=$english_fName.".".$english_tName."12".$file_number;
$hashed_password=sha1($password);
$email_college=$username."@alexmed.edu.eg";
$id=$resultSet['id'];
$birth_date=strtotime($birth_date);
$birth_date=date('y-m-d',$birth_date);
$query=mysql_query("UPDATE persons set `english_fName`='$english_fName' , `english_sName`='$english_sName' , `english_tName`='$english_tName' ,`english_lName`='$english_lName',`phone`='$phone' , `mobile`='$mobile' , `email_personal`='$email_personal' , `sex`='$sex' , `religion`='$religion' ,`city`='$city' ,`p_department`='$p_department' ,`street`='$street' , `building`='$building' ,`flat`='$flat' ,`social`='$social' , `nationality`='$nationality' ,`email_college`='$email_college' ,`birth_date`='$birth_date' WHERE `id`=$id ");
$query=mysql_query("UPDATE students set `username`= '$username' ,`hashed_password`='$hashed_password' ,`active` = 1");
$query=mysql_query("SELECT * FROM students WHERE `id`=$id ");
if($query){
$resultSet=mysql_fetch_array($query);
return $resultSet;
}else{
return false;
}
}
}
/**
*add new student
*
*
*/
public function addNewStudent($fName ,$sName ,$tName,$lName,$national_id,$seat_number,$total_grades){
$issuance_of=getissuanceof($national_id);
$query = mysql_query("INSERT INTO persons(`arabic_fName` , `arabic_sName` ,`arabic_tName` ,`arabic_lName` , `national_id` ,`issuance_of`) VALUES ('$fName' ,'$sName','$tName' ,'$lName' ,'$national_id' ,'$issuance_of')");
if ($query) {
//Success!
//Generating student id:
$resultset = mysql_query("SELECT max(id) FROM persons");
$student = mysql_fetch_array($resultset);
$student_id = $student['0'];
//Inserting into the studens' table:
$date = date('Y-m-d');
$query = mysql_query("INSERT INTO students (`id` , `seat_number` ,`total_grades` , `file_number` , `join_date` ) VALUES ('$student_id', '$seat_number', '$total_grades' ,'$student_id' , '$date')");
if ($query){
//Generating student id:
$student_id= intval($student_id);
$resultset = mysql_query("SELECT `file_number` FROM students WHERE id =$student_id");
$student = mysql_fetch_array($resultset);
$file_number_2= $student['file_number'];
$student_number =(int) generate_snumber($file_number_2);
mysql_query("UPDATE students SET `student_number`=$student_number WHERE `file_number` =$file_number_2");
return true;
}else{
die(mysql_error());
}
}
}
public function search_Seat_Number($s_seat_number){
$query = mysql_query("SELECT * FROM students WHERE `seat_number` =$s_seat_number");
if($query){
if(mysql_num_rows($query) == 0){
return false;
}else{
return true;
}
}else{
return false;
}
}
}
function generate_snumber($file_number){
$file_number= strval($file_number);
if(strlen($file_number) == 1){
$file_number= "000".$file_number;
}
else if(strlen($file_number) == 2){
$file_number= "00".$file_number;
}
else if(strlen($file_number) == 3){
$file_number = "0".$file_number;
}
$student_number= "12".$file_number;
return $student_number;
}
function takeTodigit($file_number){
if(strlen($file_number) == 1){
$file_number = "0".$file_number;
}
if(strlen($file_number) == 2 )
{
$file_number =$file_number;
}
if(strlen($file_number) ==3){
$file_number = substr($file_number, -2);
}
if(strlen($file_number) == 4){
$file_number= substr($file_number, -2);
}
return $file_number;
}
function getissuanceof($national_id){
$issuance_of=$national_id[7].$national_id[8];
return $issuance_of;
}
?>
構成スクリプトは次のとおりです。
<?php
/**
* @author ziad gamal baiomy gholmish
* @copyright 2012
*/
/**
* Database config variables
*/
define("DB_HOST", "https://supremecenter10.se/pma/index.php?token=a8aa13f9715f82765b6d101b2b1a43ff");
define("DB_USER", "ultratech_mobdb");
define("DB_PASSWORD", "******"// the password );
define("DB_DATABASE", "******//the username here ");
?>
接続スクリプト:
<?php
/**
* @author ziad gamal baiomy gholmish
* @copyright 2012
*/
class DB_Connect {
// constructor
function __construct() {
}
// destructor
function __destruct() {
// $this->close();
}
// Connecting to database
public function connect() {
require_once 'config.php';
// connecting to mysql
$con = mysql_connect("https://supremecenter10.se/pma/index.php?token=a8aa13f9715f82765b6d101b2b1a43ff", "username" ,"password");
// selecting database
mysql_select_db("https://supremecenter10.se/pma/index.php?token=a8aa13f9715f82765b6d101b2b1a43ff");
// return database handler
return $con;
}
// Closing database connection
public function close() {
mysql_close();
}
}
?>