我面臨着發送變量數據到MySQL的問題,我的變量之一是通過,但其他不是。MySQL所有的變量不通過數據
<?php
session_start();
if(!isset($_SESSION["PAT_ID"])){
ob_start();
header("location: login.php");
ob_end_flush();
}
$patient_id ="";
$complainID = "";
$patient_id = $_SESSION["PAT_ID"];
if(isset($_GET["ComplainID"])){
$complainID = $_GET["ComplainID"];
}
include "config/connect_to_mysql.php";
?>
<?php
//Diesease photo\
echo "Hello Patient Your Complain ID: " . $complainID;
$imageerr = "";
$typeerr = "";
$sizeerr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if((isset($_FILES['galleryField_1']) && $_FILES['galleryField_1']['error'] == 0)
|| (isset($_FILES['galleryField_2']))
|| (isset($_FILES['galleryField_3']))
|| (isset($_FILES['galleryField_4']))
){
$allowedExts = array("JPEG", "jpeg", "jpg", "JPG");
$temp = explode(".", $_FILES["galleryField_1"]["name"]);
$extension = end($temp);
if ((
($_FILES["galleryField_1"]["type"] == "image/JPEG")
|| ($_FILES["galleryField_1"]["type"] == "image/jpeg")
|| ($_FILES["galleryField_1"]["type"] == "image/jpg")
|| ($_FILES["galleryField_1"]["type"] == "image/JPG"))
&& in_array($extension, $allowedExts)){
if($_FILES['galleryField_1']['size'] > 1048576) { //1 MB (size is also in bytes)
$sizeerr = "Photo must be within 1 MB";
} else{
// Add this image into the database now
$sql = mysql_query("INSERT INTO `shasthojito`.`sdispic` (`sdis_pic_id`, `pat_id`, `comp_id`) VALUES (NULL, '$patient_id', '$complainID')")
or die (mysql_error());
$gallery_id = mysql_insert_id();
// Place image in the folder
$newgallery = "$gallery_id.jpg";
move_uploaded_file($_FILES['galleryField_1']['tmp_name'], "dpic/$newgallery");
}
}else{
$typeerr = "You have to put JPEG Image file";
}
}else{
$imageerr = "No Image Selected";
}
這裏變量$ patientID工作正常,並在將數據傳遞到它,但$ complainID不工作的SQL查詢,但其顯示的回波值...
我猜你正在做的職位,但試圖讓'$ complainID'如GET – 2014-12-06 15:03:57
繼續之前:讀這 - 爲什麼我不應該在PHP中使用mysql_ *函數? http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php並獲得基本知識,如REQUEST,GET和POST – 2014-12-06 15:04:30
@AbhikChakraborty,我同意你的意見.. @ mhtamum請檢查.. becauze您的代碼似乎很好。 – 2014-12-06 15:08:18