 |
|
พอดีจะทำกรอกข้อมูลใน android แล้วไปบันทึกใน mysql แต่พอดีเจอ Err
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$_POST["stxtStu"] = "ce355"' at line 1
ขอคำแนะนำทีครับ
อันนี้เป็น json ครับ
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","root","root");
$objDB = mysql_select_db(".........");
$strUsername = $_POST["stxtStu"];
$strPassword = $_POST["stxtName"];
$strStr = $_POST["stxtroom"];
$strStu_id = $_POST["stxt_s"];
$strName = $_POST["stxt_Term"];
$strlastname = $_POST["stxt_Year"];
$strEmail = $_POST["stxt_C"];
/*** Check Email Exists ***/
$strSQL = "SELECT * FROM subject WHERE Sub_ID = '".$strUsername."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
$arr['StatusID'] = "0";
$arr['Error'] = "รหัสวิชานี้ได้มีการเพิ่มไปแล้ว !! ";
echo json_encode($arr);
exit();
}
/*** Insert ***/
$strSQL = "INSERT INTO subject (Sub_ID,Sub_name,Class,Teacher,Color,Term,Year)
VALUES (
'".$strUsername."',
'".$strPassword."',
'".$strStr."',
'".$strStu_id."',
'".$strEmail."',
'".$strName."',
'".$strlastname."',
)
";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
$arr['StatusID'] = "0";
$arr['Error'] = " !!";
}
else
{
$arr['StatusID'] = "1";
$arr['Error'] = "";
}
/**
$arr['StatusID'] // (0=Failed , 1=Complete)
$arr['Error'] // Error Message
*/
mysql_close($objConnect);
echo json_encode($arr);
?>

Tag : Mobile, MySQL, Android
|
|
 |
 |
 |
 |
Date :
2016-05-02 00:12:18 |
By :
oreo1109 |
View :
1089 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |