Error Save [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 '' at line 1]
งงมากเลยครับผมก็ว่า ทำตามหมดทุกอย่างแล้วนะครับ เพราะแก้แค่ ตัวแปรเฉยๆแต่ทำใมมันถึงขึ้นแบบนี้อะครับ
Error Save [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 '' at line 1]
เวลาที่กด Add อะครับ
<html>
<head>
<title>MyRoMance</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","mamacpe_mama01","9543688") or die("Error Connect to Database");
$objDB = mysql_select_db("mamacpe_01");
//*** Add Condition ***//
if($_POST["hdnCmd"] == "Add")
{
$strSQL = "INSERT INTO Carin ";
$strSQL .="(Id,Name,Number,City,Color) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddId"]."','".$_POST["txtAddName"]."' ";
$strSQL .=",'".$_POST["txtAddNumber"]."' ";
$strSQL .=",'".$_POST["txtAddCity"]."','".$_POST["txtAddColor"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE Carin SET ";
$strSQL .="Id = '".$_POST["txtEditId"]."' ";
$strSQL .=",Name = '".$_POST["txtEditName"]."' ";
$strSQL .=",Number= '".$_POST["txtEditNumber"]."' ";
$strSQL .=",City= '".$_POST["txtEditCity"]."' ";
$strSQL .=",Color = '".$_POST["txtEditColor"]."' ";
$strSQL .="WHERE Id = '".$_POST["hdnEditId"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Delete Condition ***//
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM Carin ";
$strSQL .="WHERE Id = '".$_GET["ID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
$strSQL = "SELECT * FROM Carin";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Id </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Number </div></th>
<th width="97"> <div align="center">City</div></th>
<th width="59"> <div align="center">Color</div></th>
<th width="30"> <div align="center">Edit </div></th>
<th width="30"> <div align="center">Delete </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["Id"] == $_GET["ID"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<td><div align="center">
<input type="text" name="txtEditId" size="5" value="<?=$objResult["Id"];?>">
<input type="hidden" name="hdnEditId" size="5" value="<?=$objResult["Id"];?>">
</div></td>
<td><input type="text" name="txtEditName" size="20" value="<?=$objResult["Name"];?>"></td>
<td><input type="text" name="txtEditNumber" size="20" value="<?=$objResult["Number"];?>"></td>
<td><div align="center"><input type="text" name="txtEditCity" size="2" value="<?=$objResult["City"];?>"></div></td>
<td align="right"><input type="text" name="txtEditColor" size="5" value="<?=$objResult["Color"];?>"></td>
<td align="right"><input type="text" name="txtEditUsed" size="5" value="<?=$objResult["Used"];?>"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</div></td>
</tr>
<?
}
else
{
?>
<tr>
<td><div align="center"><?=$objResult["Id"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Number"];?></td>
<td><div align="center"><?=$objResult["City"];?></div></td>
<td align="right"><?=$objResult["Color"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["Id"];?>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["Id"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<tr>
<td><div align="center"><input type="text" name="txtAddId" size="5"></div></td>
<td><input type="text" name="txtAddName" size="20"></td>
<td><input type="text" name="txtAddNumber" size="20"></td>
<td><div align="center"><input type="text" name="txtAddCity" size="2"></div></td>
<td align="right"><input type="text" name="txtAddColor" size="5"></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table>
</form>
<?
mysql_close($objConnect);
?>
</body>
</html> Tag : PHP, MySQL
Date :
2011-09-01 04:03:21
By :
mama
View :
7886
Reply :
4
Code (PHP)
$strSQL = "INSERT INTO Carin ";
$strSQL .="(Id,Name,Number,City,Color) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddId"]."','".$_POST["txtAddName"]."' ";
$strSQL .=",'".$_POST["txtAddNumber"]."' ";
$strSQL .=",'".$_POST["txtAddCity"]."','".$_POST["txtAddColor"]."' ";
$objQuery = mysql_query($strSQL);
วงเว็บปิดน่าจะหายครับ
Date :
2011-09-01 06:14:42
By :
webmaster
ขอบคุณมากครับ ตอนนี้ ที่ถามไปแก้ได้เรียบร้อยแล้วครับ แต่ตอนนี้ติดปัญหาอื่นอยู่ ยังใงเดี้ยวผมจะลอง หาดูก่อนนะครับว่าเป็นเพราะอะไร ยังใง ถ้าติด เดี้ยวจอ ขอมาถามอีกทีนะครับ
ขอบคุณมากๆครับ ฮือๆๆๆๆ
Date :
2011-09-01 12:47:21
By :
ขอบคุณคร้าบ
<?
include("connect.php");
$objDB = mysql_select_db("$db_name");
echo mysql_error();
if($_GET["Action"] == "Save")
{
//*** Insert Reply ***//
$strSQL = "INSERT INTO comment ";
$strSQL .="(mem_id,title_id,com_story,com_pic,com_date) ";
$strSQL .="VALUES('') ";
$strSQL .="('".$_POST["mem_id"]."','".$_GET["title_id"]."','".$_POST["txtcom_story"]."','".$_POST["com_pic"]."','".date("Y-m-d H:i:s")."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//*** Update Reply ***//
//$strSQL = "UPDATE webboard ";
//$strSQL .="SET Reply = Reply + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
//$objQuery = mysql_query($strSQL);
}
?>
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<body>
<?
//*** Select Question ***//
$strSQL = "SELECT * FROM titleboard WHERE title_id = '".$_GET["title_id"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
//*** Update View ***//
//$strSQL = "UPDATE webboard ";
//$strSQL .="SET View = View + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
//$objQuery = mysql_query($strSQL);
?>
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2"><center><h1><?=$objResult["title_id"];?></h1></center></td>
</tr>
<tr>
<td height="53" colspan="2"><?=nl2br($objResult["title_story"]);?></td>
</tr>
<tr>
<td width="397">Name : <?=$objResult["mem_id"];?> Create Date : <?=$objResult["title_id"];?></td>
</tr>
</table>
<br>
<br>
<?
$intRows = 0;
$strSQL2 = "SELECT * FROM comment WHERE title_id = '".$_GET["title_id"]."' ";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
$intRows++;
?> No : <?=$intRows;?>
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td height="53" colspan="2"><?=nl2br($objResult2["title_story"]);?></td>
</tr>
<tr>
<td width="397">รหัสผู้ตอบกระทู้ :
<?=$objResult2["mem_id"];?> </td>
<td width="253">วันที่ตอบกระทู้ :
<?=$objResult2["title_date"];?></td>
</tr>
</table><br>
<?
ช่วยดูหน่อยค่ะ คือมันerror
Error Save [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 '('trutyift','','','','2012-07-01 20:41:44')' at line 1]
}
?>
<br>
<a href="Webboard.php">Back to Webboard</a> <br>
<br>
<form action="ViewWebboard.php?QuestionID=<?=$_GET["title_id"];?>&Action=Save" method="post" name="frmMain" id="frmMain">
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td width="78">คำตอบกระทู้</td>
<td><textarea name="txttitle_story" cols="50" rows="5" id="txttitle_story"></textarea></td>
</tr>
<tr>
<td width="78">รหัสผู้ตั้งกระทู้</td>
<td width="647"><input name="mem_id" type="text" id="mem_id" value="" size="50"></td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="Submit">
</form>
</body>
</html>
<?
mysql_close();
?>
Date :
2012-07-01 19:48:35
By :
Beeoi
Error Save [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 '('trutyift','','','','2012-07-01 20:41:44')' at line 1]
<?
include("connect.php");
$objDB = mysql_select_db("$db_name");
echo mysql_error();
if($_GET["Action"] == "Save")
{
//*** Insert Reply ***//
$strSQL = "INSERT INTO comment ";
$strSQL .="(mem_id,title_id,com_story,com_pic,com_date) ";
$strSQL .="VALUES('') ";
$strSQL .="('".$_POST["mem_id"]."','".$_GET["title_id"]."','".$_POST["txtcom_story"]."','".$_POST["com_pic"]."','".date("Y-m-d H:i:s")."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//*** Update Reply ***//
//$strSQL = "UPDATE webboard ";
//$strSQL .="SET Reply = Reply + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
//$objQuery = mysql_query($strSQL);
}
?>
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<body>
<?
//*** Select Question ***//
$strSQL = "SELECT * FROM titleboard WHERE title_id = '".$_GET["title_id"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
//*** Update View ***//
//$strSQL = "UPDATE webboard ";
//$strSQL .="SET View = View + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
//$objQuery = mysql_query($strSQL);
?>
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2"><center><h1><?=$objResult["title_id"];?></h1></center></td>
</tr>
<tr>
<td height="53" colspan="2"><?=nl2br($objResult["title_story"]);?></td>
</tr>
<tr>
<td width="397">Name : <?=$objResult["mem_id"];?> Create Date : <?=$objResult["title_id"];?></td>
</tr>
</table>
<br>
<br>
<?
$intRows = 0;
$strSQL2 = "SELECT * FROM comment WHERE title_id = '".$_GET["title_id"]."' ";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
$intRows++;
?> No : <?=$intRows;?>
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td height="53" colspan="2"><?=nl2br($objResult2["title_story"]);?></td>
</tr>
<tr>
<td width="397">รหัสผู้ตอบกระทู้ :
<?=$objResult2["mem_id"];?> </td>
<td width="253">วันที่ตอบกระทู้ :
<?=$objResult2["title_date"];?></td>
</tr>
</table><br>
<?
}
?>
<br>
<a href="Webboard.php">Back to Webboard</a> <br>
<br>
<form action="ViewWebboard.php?QuestionID=<?=$_GET["title_id"];?>&Action=Save" method="post" name="frmMain" id="frmMain">
<table width="738" border="1" cellpadding="1" cellspacing="1">
<tr>
<td width="78">คำตอบกระทู้</td>
<td><textarea name="txttitle_story" cols="50" rows="5" id="txttitle_story"></textarea></td>
</tr>
<tr>
<td width="78">รหัสผู้ตั้งกระทู้</td>
<td width="647"><input name="mem_id" type="text" id="mem_id" value="" size="50"></td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="Submit">
</form>
</body>
</html>
<?
mysql_close();
?>
Date :
2012-07-01 19:50:59
By :
Beeoi
Load balance : Server 02