|
|
|
PHP ช่วยหน่อยครับมีปัญหาการ ADD ข้อมูลลงฐานข้อมูลครับ |
|
|
|
|
|
|
|
นื่คือตัวที่ใช้แอดนะครับ
Code (PHP)
<?php require_once('../Connections/db.php');
mysql_query("SET NAMES UTF8"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO student_information (Student_identification_code, Semester, School_year, Student_time_sector, Prefixes_name, Student_name, Student_lastname, Course, Branch, Student_address, Student_Phone, Name_Dean, Picture_students, Date, Day_received) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,NOW(), date_add(curdate(),interval +7 day))",
GetSQLValueString($_POST['Student_identification_code'], "text"),
GetSQLValueString($_POST['Semester'], "text"),
GetSQLValueString($_POST['School_year'], "text"),
GetSQLValueString($_POST['Student_time_sector'], "text"),
GetSQLValueString($_POST['Prefixes_name'], "text"),
GetSQLValueString($_POST['Student_name'], "text"),
GetSQLValueString($_POST['Student_lastname'], "text"),
GetSQLValueString($_POST['Course'], "text"),
GetSQLValueString($_POST['Branch'], "text"),
GetSQLValueString($_POST['Student_address'], "text"),
GetSQLValueString($_POST['Student_Phone'], "text"),
GetSQLValueString($_POST['Name_Dean'], "text"),
GetSQLValueString($_POST['Picture_students'], "text"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($insertSQL, $db) or die(mysql_error());
$insertGoTo = "Internship1-02.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_db, $db);
$query_Recordset1 = "SELECT * FROM student_information";
$Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
|
|
|
|
|
Date :
2013-10-21 15:24:38 |
By :
นักศึกษาปี 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นี่คือ Code ไฟล์เก็บภาพในแฟ้มต่างหากใช่ไหมครับ>>>แล้วผมจะเอา Code อันนี้ไปไว้ส่วนไหนใน Code ข้างบนNo1 อะครับ
Code (PHP)
<?
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(FilesName) VALUES ('".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
|
|
|
|
|
Date :
2013-10-22 14:05:54 |
By :
นักศึกษาปี 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สมัครสมาชิกก่อนเถอะครับ
|
|
|
|
|
Date :
2013-10-22 15:08:54 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|