我正在处理我为我的网站设置的分类广告,我发现自己再次“陷入困境”。
我是PHP的新手,但我正在为分类广告和我将在下面提供的脚本开发一个更好的鼠标陷阱,我已经完全从头开始编写它的工作原理。 (将数据上传到数据库)但是当我添加if块时,以:if($ _ POST ['Image 1']!=“”){整个事情崩溃了。 (我得到一个没有错误信息的白色屏幕)。
以下是此页面的完整代码;
<?php
ob_start();
session_start();
require_once('z-mysql_ini.php');
require ('z-connect.php');
$mysql = new mysql();
if($_POST['Description'] != "") {
$TypeID = $_POST['TypeID'];
$FatherID = $_POST['fatherID'];
$Model = $_POST['Model'];
$Price = $_POST['Price'];
$Description = $_POST['Description'];
$Year = $_POST['Year'];
$VIN = $_POST['VIN'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone'];
$InformOfUpdates = $_POST['Inform'];
}
$node = new sqlNode();
$node->table = sprintf("`tt_%s`", abs(intval($_POST['TypeID'])));
$node->push("int", "CategoryID", $FatherID);
$node->push("int", "MemberID", $_SESSION['memberID']);
$node->push("text", "Model", strtoupper($Model));
$node->push("int", "Price ($)", $Price);
$node->push("text", "Description", $Description);
$node->push("int", "Year", $Year);
$node->push("text", "VIN", $VIN);
$node->push("defined","PostDate","NOW()");
$node->push("text","Featured","yes");
$node->push("defined","ExpireDate","DATE_ADD(NOW(),INTERVAL 30 DAY)");
$node->push("text", "Address", $Address);
$node->push("text", "City", $City);
$node->push("text", "State/Province", $State);
$node->push("text", "ZIP/Postal", $ZIP);
$node->push("text", "Country", $Country);
//$node->push("text", "Email", $Email);
//$node->push("text", "Phone", $Phone);
$node->push("int", "Inform", $InformOfUpdates);
if(($result = $mysql->insert($node)) === false) {
echo mysql_error();
echo 'Unable to Insert Data';
} else {
$ListingID = mysql_insert_id();
}
if($_POST['Image 1'] != "") {
echo 'File Selected and Data set in DB';
} else{
echo 'No File Selcted but Data Inserted';
//header("Location:memberindex.php");
}
}
?>
如果有人能够告诉我我做错了什么导致页面崩溃,我会非常感激,因为我可以继续重新实现分类广告附带的图片上传代码,但我可以甚至没有超过页面死亡(而不是上传到数据库。)
底线是,如果我完全从页面中取出以下代码,脚本会将上面的所有可变数据上传到数据库中,但如果我添加这段代码,整个事情就会崩溃。
if($_POST['Image 1'] != "") {
echo 'File Selected and Data set in DB';
} else{
echo 'No File Selcted but Data Inserted';
//header("Location:memberindex.php");
}