【发布时间】:2025-11-25 20:15:01
【问题描述】:
我正在尝试将网站从一家托管公司转移到另一家托管公司。在客户端拥有托管和域之前,我一直在使用 000webhost。现在客户有了自己的域和主机,使用 FatCow.com,我不能为我的生活调试我的 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();
}
?>
//类战俘
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.";
}
}
}
【问题讨论】:
-
下面的分号是什么 print $web;在做什么?
-
没什么。那是一根粗大的手指。生病删除它没有影响。