ช่วยดูให้หน่อยนะคะ เป็นcodeเพิ่มข้อมูล สอง ตาราง และรูปภาพ
Code (PHP)
<?
session_start() ;
if(move_uploaded_file($_FILES["P_image"]["tmp_name"],"myfile/".$_FILES["P_image"]["name"]))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("project");
$P_id = $_POST['P_id'];
$P_name = $_POST['P_name'];
$P_date = $_POST['P_date'];
$P_month = $_POST['P_month'];
$P_year = $_POST['P_year'];
$P_address = $_POST['P_address'];
$P_tumbon= $_POST['P_tumbon'];
$P_amper = $_POST['P_amper'];
$P_province = $_POST['P_province'];
$P_zipcode = $_POST['P_zipcode'];
$P_salary = $_POST['P_salary'];
$P_career = $_POST['P_career'];
$P_phone = $_POST['P_phone'];
$Login_user = $_POST['Username'];
$Pw_user = $_POST['password'];
$re_pass = $_POST['re_pass'];
$status_user=$_POST['status_user'];
$P_email = $_POST['P_email'];
$P_image=$_POST['P_image'];
$strSQL="INSERT INTO parent (P_id,P_name,P_date,P_month,P_year,P_address,P_tumbon,P_amper ,P_province,P_zipcode,P_salary,P_career,P_phone,P_email,P_image) VALUES('$P_id','$P_name','$P_date','$P_month','$P_year','$P_address' ,'$P_tumbon','$P_amper','$P_province','$P_zipcode','$P_salary','$P_career','$P_phone','$P_email','$P_image')";
$Id_user=$P_id;
$strSQL2="INSERT INTO user (Id_user,Login_user,Pw_user,re_pass,status_user) VALUES('$Id_user','$Username','$password','$re_pass','$status_user')";
$objQuery = mysql_query($strSQL); $objQuery = mysql_query($strSQL2);
}
?>
แร้วมัน ERRor ตรง
Code
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\test\par_add_new1.php:3) in C:\AppServ\www\test\par_add_new1.php on line 4
ผิดตรงไน๋ช่วยดูให้หน่อยนะคะ ขอบคูณค่ะTag : PHP
Date :
2012-07-22 13:53:50
By :
นักศึกษา
View :
1073
Reply :
3
ใส่ ob_start();
ไว้บน
session_start() ;
Date :
2012-07-22 14:35:16
By :
adaaugusta
พี่คะ หนูทำลองทำตามบทเรียนอ่ะ โค๊ดนี้ แต่พอเรา
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
if($_FILES["filUpload"]["name"] != "")
{
//*** Read file BINARY ***'
$fp = fopen($_FILES["filUpload"]["tmp_name"],"r");
$ReadBinary = fread($fp,filesize($_FILES["filUpload"]["tmp_name"]));
fclose($fp);
$FileData = addslashes($ReadBinary);
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("project");
$strSQL = "INSERT INTO files ";
$strSQL .="(Name,FilesName) VALUES ('".$_POST["txtName"]."','".$FileData."')";
$objQuery = mysql_query($strSQL);
echo "Copy/Upload Complete<br>";
mysql_close($objConnect);
}
?>
<a href="PageUploadToMySQL3.php">View files</a>
</body>
</html>
แต่ทำไปรูปมันขึ้นเป็นรูปกากะบาทสีแดงอ่ะ คะ
Date :
2012-07-27 21:22:16
By :
นักศึกษา
Load balance : Server 04