ช่วยด้วยคะ #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 '$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address' at line 1
Code
Error
SQL query:
$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic) VALUES ('".$_POST[ "txtdomainname"]. "','".$_POST[ "txttitle"]. "','".$_POST[ "txtdescrip"]. "', '".$_POST[ "txttags"]. "','".$_POST[ "txtlanguages"]. "','".$_POST[ "txtaddress"]. "','".$_POST[ "txtcontact"]. "','".$_FILES[ "filUpload"][ "name"]. "')";
MySQL said: Documentation
#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 '$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address' at line 1
Code (PHP)
if($_POST["add_submit"]){
if(copy($_FILES["filUpload"]["tmp_name"],"./logo images/".$_FILES["filUpload"]["name"]))
{
//*** Insert Record ***//
$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic) VALUES ('".$_POST["txtdomainname"]."','".$_POST["txttitle"]."','".$_POST["txtdescrip"]."','".$_POST["txttags"]."','".$_POST["txtlanguages"]."','".$_POST["txtaddress"]."','".$_POST["txtcontact"]."','".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
}
Tag : PHP
Date :
2011-07-13 11:02:22
By :
Poster
View :
2675
Reply :
7
INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic ) ผิดแถวนี้ นะ ลองเช็คดูตรงกับฐานข้อมูลไม มีช่องว่างหรือเปล่า
Date :
2011-07-13 11:08:03
By :
ckcr
ขอบคุนมากคะ เช็คตามที่แนะนำแล้วนะคะ แต่ก้อหาไม่เจอยุดี
Date :
2011-07-13 11:31:00
By :
Poster
คำสั่งผิดต้องไล่ดู You have an error in your SQL syntax;
เป็นผมจะเอาตัวแปรมาเก็บก่อนดีกว่าได้ไม่งง และค่อยส่ง
$txtdomainname = $_POST["txtdomainname"];
ลองสร้างตารางมาและรับคำสั่งแค่ทีละฟิว และค่อยเพิ่มฟิวก็จะเจอจุดผิดอะนะ
Date :
2011-07-13 11:42:47
By :
bank1324
Code (PHP)
<?
if($_POST["add_submit"]){
if(copy($_FILES["filUpload"]["tmp_name"],"./logo images/".$_FILES["filUpload"]["name"]))
{
$txtdomainname = $_POST["txtdomainname"];
$txttitle = $_POST["txttitle"];
$txtdescrip = $_POST["txtdescrip"];
$txttags = $_POST["txttags"];
$txtlanguages = $_POST["txtlanguages"];
$txtaddress = $_POST["txtaddress"];
$txtcontact = $_POST["txtcontact"];
$filUpload = $_FILES["filUpload"]["name"];
//*** Insert Record ***//
$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic) VALUES ('$txtdomainname','$txttitle','$txtdescrip','$txttags','$txtlanguages','$txtaddress','$txtcontact','$filUpload')";
$objQuery = mysql_query($strSQL);
}
}
?>
Date :
2011-07-13 11:46:15
By :
avsqlz
echo $strSQL ดู สิ
แล้วกอฟ ไปลองใน phpmyadmin ดู
Code (PHP)
if($_POST["add_submit"]){
if(copy($_FILES["filUpload"]["tmp_name"],"./logo images/".$_FILES["filUpload"]["name"]))
{
//*** Insert Record ***//
$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic) VALUES ('".$_POST["txtdomainname"]."','".$_POST["txttitle"]."','".$_POST["txtdescrip"]."','".$_POST["txttags"]."','".$_POST["txtlanguages"]."','".$_POST["txtaddress"]."','".$_POST["txtcontact"]."','".$_FILES["filUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
echo $strSQL; <<<<<<ลองดู
}
}
Date :
2011-07-13 11:46:23
By :
ckcr
ลองตามที่ทุกท่านแนะนำแล้วนะคะ มันก้อไม่ลงฐานยุดีคะ
datawebform.php
<?
include("./config/config.php");
if($_POST["add_submit"]){
if(copy($_FILES["filUpload"]["tmp_name"],"./logo images/".$_FILES["filUpload"]["name"]))
{
$txtdomainname = $_POST["txtdomainname"];
$txttitle = $_POST["txttitle"];
$txtdescrip = $_POST["txtdescrip"];
$txttags = $_POST["txttags"];
$txtlanguages = $_POST["txtlanguages"];
$txtaddress = $_POST["txtaddress"];
$txtcontact = $_POST["txtcontact"];
$filUpload = $_FILES["filUpload"]["name"];
//*** Insert Record ***//
$strSQL = "INSERT INTO webdata (domainname,title,descrip,tags,languages,address,contact,logo_pic) VALUES ('$txtdomainname','$txttitle','$txtdescrip','$txttags','$txtlanguages','$txtaddress','$txtcontact','$filUpload')";
$objQuery = mysql_query($strSQL);
echo $strSQL;
}
}
?>
<html>
<head>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<div id="stylized" class="adddataform">
<form id="form" name="add" method="post" action="?Action=insert" enctype="multipart/form-data">
<h1>Add Website Data</h1>
<p>We know the web</p>
<label>Domain name<span class="small">Add Domain name</span></label>
<input name="txtdomainname" id="txtdomainname" />
<label>Title<span class="small">Add Title</span></label>
<input name="txttitle" id="txttitle" />
<label>Description<span class="small">Add Description</span></label>
<input name="txtdescrip" id="txtdescrip" />
<label>Key<span class="small">Add Key</span></label>
<input name="txttags" id="txttags" />
<label>Languages<span class="small">Add Languages</span></label>
<input name="txtlanguages" id="txtlanguages" />
<label>Address<span class="small">Add Address</span></label>
<input name="txtaddress" id="txtaddress" />
<label>Contact<span class="small">Add Contact</span></label>
<input name="txtcontact" id="txtcontact" />
<label>Logo<span class="small">Add Logo</span></label>
<input name="filUpload" type="file">
<button type="submit" name="add_submit">Save</button>
<div class="spacer"></div>
</form>
</div>
</body>
</html>
--
-- Database: `aboutus`
--
-- --------------------------------------------------------
--
-- Table structure for table `webdata`
--
CREATE TABLE `webdata` (
`domainname` varchar(100) COLLATE utf8_bin NOT NULL,
`title` varchar(500) COLLATE utf8_bin NOT NULL,
`descrip` varchar(2000) COLLATE utf8_bin NOT NULL,
`tags` varchar(500) COLLATE utf8_bin NOT NULL,
`languages` varchar(20) COLLATE utf8_bin NOT NULL,
`address` varchar(600) COLLATE utf8_bin NOT NULL,
`contact` varchar(500) COLLATE utf8_bin NOT NULL,
`logo_pic` varchar(600) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`domainname`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `webdata`
--
Date :
2011-07-13 12:01:25
By :
Poster
ได้ละคะ ขอบคุนทุกๆคนคะ
Date :
2011-07-13 13:55:18
By :
Poster
Load balance : Server 01