我正嘗試將網站從一個託管公司轉移到另一個託管公司。我一直在使用000webhost,直到客戶端託管一個域。現在,客戶端擁有他們的域名和託管,使用FatCow.com,我不能爲我的生活,調試我的PHP代碼。我沒有收到任何錯誤。我有一個成功的數據庫連接。如果你程序化地顯示數據,它可以工作,但是當我嘗試使用我的原始對象時,某些事情正在破裂,而只是返回「0:」。我有所有錯誤。PHP奇怪的錯誤「0:」。可能的對象語法問題?
在舊服務器所在部位的工作:
PHP版本5.2.11
的MySQL版本:5.0.81
在新服務器裏,我得到了 「0」:
PHP版本5.2.12
MySQL版本5 .0.32
我已經設置了一個測試頁面來測試數據庫連接變量的輸出。
下面是我的代碼:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
try
{
$link = mysql_connect('connectionstring', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
else{
$db = mysql_select_db('a8210422_lit');
}
if($db){
include_once('admin/classes/clsPOW.php');
include_once('admin/classes/clsProviders.php');
$pow = new POW();
$prov = new Providers();
$new = $pow->getNew();
$newAr = $new->val();
$get = $prov->getAll($newAr['providerId']);
$getAr = $get->val();
$img = $getAr['image'];
$name = $getAr['provider'];
$desc = $getAr['description'];
$zip = $getAr['zip'];
$web = $getAr['link'];
if($zip==0){
$zip = "Unavailable";
}
print_r($getAr);
}
else{
print 'fail!';
}
}
//catch exception
catch(Exception $e)
{
echo 'Message: ' .$e->getMessage();
}
?>
//類POW
require_once('clsSql.php');
require_once('clsResult.php');
include_once('/hermes/web07/b1323/moo.madisoncountyliterac/assets/includes/db.php');
class POW{
public function getNew(){
//instantiate the sql class
$SQL=new sql();
//Run a query - Result is automatically stored in the class
$sel = "SELECT providerId
FROM litProviders
WHERE image != ''
ORDER BY RAND()
LIMIT 1";
$q=$SQL->query($sel);
return $q;
}
}
//類供應商
require_once('clsSql.php');
require_once('clsResult.php');
include_once('/hermes/web07/b1323/moo.madisoncountyliterac/assets/includes/db.php');
class Providers{
public function getAll($where=""){
if($where == ""){
$getAllQuery = "SELECT * FROM litProviders";
}
else{
$getAllQuery = "SELECT * FROM litProviders WHERE providerId = '".$where."'";
}
//instantiate the sql class
$SQL=new sql();
//Run a query - Result is automatically stored in the class
$q=$SQL->query($getAllQuery);
return $q;
}
public function submit($id="", $provider, $description, $zip, $image, $link){
if($id != ""){
//update
$query = "UPDATE litProviders SET provider = '".$provider."', description = '".$description."', zip = '".$zip."', image = '".$image."', link = '".$link."'
WHERE providerId = '".$id."' ";
$message = "The provider has been updated.";
}
else{
//insert
$newid = md5(uniqid());
$query = "INSERT INTO litProviders
VALUES ('".$newid."','".$provider."','".$description."','".$zip."','".$image."', '".$link."')";
$message = "You have added a new provider.";
}
//instantiate the sql class
$SQL=new sql();
//Run a query - Result is automatically stored in the class
$q=$SQL->query($query);
return $message;
}
public function delete($id=""){
if($id !=""){
$delQuery = "DELETE FROM litProviders WHERE providerId = '".$id."'";
//instantiate the sql class
$SQL=new sql();
//Run a query - Result is automatically stored in the class
$q=$SQL->query($delQuery);
if($q){
return true;
}
else{
return false;
}
}
else{
return "No ID was provided for deletion.";
}
}
}
什麼是低於打印$網絡分號;在做什麼? – Jack 2010-04-29 18:21:35
沒什麼。這是一個胖手指。虐待它刪除它沒有影響。 – 2010-04-29 18:25:18