|
 |
|
ช่วยด้วยครับหา Error ไม่เจอครับ มันขึ้นว่าParse error: syntax error, unexpected $end in C: |
|
 |
|
|
 |
 |
|
มันขึ้น Error อย่างนี้ครับ Parse error: syntax error, unexpected $end in C:\xampp\htdocs\ns\admin\add_product_ss.php on line 40
ช่วยหน่อยนะครับ หาแล้วหาไม่เจออ่ะ ว่า มันเป็นที่อะไร ครับ
Code (PHP)
<?
$dblink = mysql_connect("localhost","root","");//on pc
mysql_query("USE ns-ostrichfarm_zxq_1;");
$pdname = htmlspecialchars($_POST['pdname'],ENT_QUOTES);
$descr = htmlspecialchars($_POST['descr'],ENT_QUOTES);
$price = $_POST['price'];
$file_data = "";
if($_FILES['img']['error']==0){
$file = $_FILES['img']['tmp_name'];
$file_handle = fopon($file,"r");
$file_data = fread($file_handle,filesize($file));
$file_data = addslashes($file_data);
fclose($file_handle);
}
$sql = <<<SQL
INSERT INTO product VALUES
('','$pdname','$price','$descr','file_data');
SQL;
mysql_query($sql);
$msg="";
$reset_form = "";
if(mysql_affected_rows($dblink)==0){
$msg = "เกิดข้อผิดพลาดในการบันทึกข้อมูล";
}else{
$msg = "ข้อมูลได้รับการบันทึกแล้ว";
$reset_form = "top.document.forms['frm'].reset();";
} mysql_close($dblink);
?>
<script>
top.document.getElementById('indicator').innerHTML = "";
alert('<? echo $msg ?>');
<? echo $reset_form ; ?>
</script>
Tag : PHP, MySQL, JavaScript

|
ประวัติการแก้ไข 2011-06-24 16:59:09
|
 |
 |
 |
 |
Date :
2011-06-24 16:56:16 |
By :
adam_2549 |
View :
3414 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณลืมใส่ } ในส่วนของ if ครับ น่าจะใส่ line ที่ 33
|
 |
 |
 |
 |
Date :
2011-06-24 17:08:38 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองแล้วครับ มันก็ยังขึ้นเหมือนเดิม อ่ะครับ
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\ns\admin\add_product_ss.php on line 40
|
 |
 |
 |
 |
Date :
2011-06-24 17:32:36 |
By :
adam_2549 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้เป็นแบบนี้ครับ
Code (PHP)
<?
$dblink = mysql_connect("localhost","root","");//on pc
mysql_query("USE ns-ostrichfarm_zxq_1;");
$pdname = htmlspecialchars($_POST['pdname'],ENT_QUOTES);
$descr = htmlspecialchars($_POST['descr'],ENT_QUOTES);
$price = $_POST['price'];
$file_data = "";
if($_FILES['img']['error']==0){
$file = $_FILES['img']['tmp_name'];
$file_handle = fopon($file,"r");
$file_data = fread($file_handle,filesize($file));
$file_data = addslashes($file_data);
fclose($file_handle);
} //if
$sql = "INSERT INTO product VALUES('','$pdname','$price','$descr','file_data')";
mysql_query($sql);
$msg="";
$reset_form = "";
if(mysql_affected_rows($dblink)==0){
$msg = "เกิดข้อผิดพลาดในการบันทึกข้อมูล";
}else{
$msg = "ข้อมูลได้รับการบันทึกแล้ว";
$reset_form = "top.document.forms['frm'].reset();";
}
mysql_close($dblink);
?>
<script>
top.document.getElementById('indicator').innerHTML = "";
alert('<? echo $msg; ?>');
<? echo $reset_form; ?>
</script>
|
 |
 |
 |
 |
Date :
2011-06-24 18:24:39 |
By :
iamatomix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วครับ ขอบคุณ mr.win กับ DJ.Atomix มากๆเลยครับ เครียดมาตั้งหลายวันเลย อิอิอิ
|
 |
 |
 |
 |
Date :
2011-06-25 11:58:11 |
By :
adam_2549 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|