Parse error: parse error, unexpected T_ELSE in โปรเจคจบคร๊าบ
Parse error: parse error, unexpected T_ELSE in C:\AppServ\www\com_buss\function.php on line 42
Code (PHP)
<? function dateShow($datetime){
$monthname = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$monthnum = array("01","02","03","04","05","06","07","08","09","10","11","12");
$tmpSplit = split(" ",$datetime);
$datadate = $tmpSplit[0];
$datatime = $tmpSpilt[1];
$splitDate = split("-",$datadate);
$output = $splitDate[2]."".str_replace($monthnum,$monthname,$splitDate[1])." ".$splitDate[0]." ".$datatime;
return $output;
}
function showIP($ipaddress){
if($ipaddress<>"::1"){
$tmpSplit = split("\.",$ipaddress);
$output = $tmpSplit[0].".".$tmpSplit[1].".".$tmpSpilt[2].".xxx";
} else {
$output = "127.0.0.xxx";
}
return $output;
}
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
}else{
$output = " ";
}
return $output;
}
function showEmo($detail) {
for($i=1;$i<=15;$i++) {
$detail = str_replace("[$1]","<img src=\"emo/$i.gif\" />",$detail);
}
}
?>
Tag : PHP
ประวัติการแก้ไข 2010-11-16 02:07:25
Date :
2010-11-16 01:43:33
By :
kooy2828
View :
1105
Reply :
23
else ซ้ำกันเพียบเลยครับ เช็คดีๆ
Date :
2010-11-16 01:54:51
By :
PlaKriM
คือว่าผม ทำตามหนังสือครับ ในนั้นมันมีเท่านี้ครับ ผมก็ งงๆ
ช่วยชี้แนะหน่อยนะครับ
Date :
2010-11-16 01:59:24
By :
kooy2828
} germ ma 1 tou krub
Date :
2010-11-16 03:51:24
By :
mystudent
จริงๆ ไม่เกินหรอก มันดูยาก เลยมองผิด มันขาด }
Code (PHP)
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
}else{
$output = " ";
}
return $output;
}
Date :
2010-11-16 07:04:33
By :
PlaKriM
ไม่ได้ครับ เหมือนเดิมเลย แค่ขยับบรรทัดที่เออเร้อไป
Date :
2010-11-16 12:37:39
By :
kooy2828
ใครก็ได้ช่วยชี้แนะโค๊ตนี้หน่อยนะครับ
ขอความกรุณาด้วย
Date :
2010-11-16 21:35:13
By :
kooy2828
บรรทัดไหนละครับ คุณเอาโค๊ดมาหมดแล้วหรอ บางทีอาจจะมี if อะไรอยู่บนๆ มันต้องไล่ปิดให้ครบให้ถูกต้องครับ
Date :
2010-11-16 22:02:38
By :
PlaKriM
บรรทัดที่ 42 ครับ พอใส่ตามที่แนะนำ มันก็เป็น43
}else{
Date :
2010-11-16 22:21:41
By :
kooy2828
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
}else{
$output = " ";
}
return $output;
}
มี elseif ไหมครับ นี่มัน else แล้ว else อีก จะ else ไปไหนเนี้ย
Date :
2010-11-16 22:31:49
By :
PlaKriM
ผมทำตามหนังสือครับ มันติดหน้านี้หน้าเดียวเลยครับ
ยังไงช่วยชี้แนะหน่อยนะครับ ตัดหรือเพิ่ม เปลี่ยนรูปแบบก็ได้ครับ ขอให้ใช้ได้พอครับ
Date :
2010-11-16 22:33:32
By :
kooy2828
เอานี่ออกละกัน คงไม่เพี่ยนหรอกมั้งงงงงงงงงงงง
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
Date :
2010-11-16 22:38:46
By :
PlaKriM
เอาออกแล้วก็ยัง Parse error: parse error, unexpected T_ELSE in C:\AppServ\www\com_buss\function.php on line 46
Code (PHP)
<? function dateShow($datetime)
{
$monthname = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$monthnum = array("01","02","03","04","05","06","07","08","09","10","11","12");
$tmpSplit = split(" ",$datetime);
$datadate = $tmpSplit[0];
$datatime = $tmpSpilt[1];
$splitDate = split("-",$datadate);
$output = $splitDate[2]."".str_replace($monthnum,$monthname,$splitDate[1])." ".$splitDate[0]." ".$datatime;
return $output;
}
function showIP($ipaddress){
if($ipaddress<>"::1"){
$tmpSplit = split("\.",$ipaddress);
$output = $tmpSplit[0].".".$tmpSplit[1].".".$tmpSpilt[2].".xxx";
} else {
$output = "127.0.0.xxx";
}
return $output;
}
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
} else {
$output = " ";
}
return $output;
}
function showEmo($detail) {
for($i=1;$i<=15;$i++) {
$detail = str_replace("[$1]","<img src=\"emo/$i.gif\" />",$detail);
}
}
?>
Date :
2010-11-16 23:40:05
By :
kooy2828
กรรม น่าจะสังเกตุหน่อยว่าผมบอกผิด
เอาออกแค่นี้ครับ
}else{
$w = $imagesize[0];
$h = $imagesize[1];
Date :
2010-11-16 23:47:32
By :
PlaKriM
Parse error: parse error, unexpected $end in C:\AppServ\www\com_buss\function.php on line 57
Code (PHP)
<? function dateShow($datetime)
{
$monthname = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$monthnum = array("01","02","03","04","05","06","07","08","09","10","11","12");
$tmpSplit = split(" ",$datetime);
$datadate = $tmpSplit[0];
$datatime = $tmpSpilt[1];
$splitDate = split("-",$datadate);
$output = $splitDate[2]."".str_replace($monthnum,$monthname,$splitDate[1])." ".$splitDate[0]." ".$datatime;
return $output;
}
function showIP($ipaddress){
if($ipaddress<>"::1"){
$tmpSplit = split("\.",$ipaddress);
$output = $tmpSplit[0].".".$tmpSplit[1].".".$tmpSpilt[2].".xxx";
} else {
$output = "127.0.0.xxx";
}
return $output;
}
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/$imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
} else {
$output = " ";
}
return $output;
}
function showEmo($detail) {
for($i=1;$i<=15;$i++) {
$detail = str_replace("[$1]","<img src=\"emo/$i.gif\" />",$detail);
}
}
?>
จากเออเร้อคือ สัญลักณ์ตอนจบใช่มั้ยครับ ผม งง กับบรรทัดครับ มันปิด ?> แบบมะใช่หรอครับ
Date :
2010-11-16 23:57:52
By :
kooy2828
OK
ไปเช็ค syntax มาให้ละ
Code (PHP)
function dateShow($datetime){
$monthname = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$monthnum = array("01","02","03","04","05","06","07","08","09","10","11","12");
$tmpSplit = split(" ",$datetime);
$datadate = $tmpSplit[0];
$datatime = $tmpSpilt[1];
$splitDate = split("-",$datadate);
$output = $splitDate[2]."".str_replace($monthnum,$monthname,$splitDate[1])." ".$splitDate[0]." ".$datatime;
return $output;
}
function showIP($ipaddress){
if($ipaddress<>"::1"){
$tmpSplit = split("\.",$ipaddress);
$output = $tmpSplit[0].".".$tmpSplit[1].".".$tmpSpilt[2].".xxx";
} else {
$output = "127.0.0.xxx";
}
return $output;
}
function showAttachfile($imagename){
if($imagename<>""){
$imagesize = getimagesize("attach/imagename.jpg");
if($imagesize[0]>$imagesize[1]){
if ($imagesize[0] > 150) {
$w = 150;
$h = ($imagesize[1]*150)/$imagesize[0];
}else{
$w = $imagesize[0];
$h = $imagesize[1];
}
}else{
if($imagesize[0] > 150) {
$h = 150;
$w = ($imagesize[0]*150)/$imagesize[1];
}else{
$w = $imagesize[0];
$w = ($imagesize[0]*150)/$imagesize[1];
}
}
$output = "<img src=\"attach/$imagename.jpg\" width=\"$w\" height=\"$h\" />";
}else{
$output = " ";
}
return $output;
}
function showEmo($detail) {
for($i=1;$i<=15;$i++) {
$detail = str_replace("[$1]","<img src=\"emo/$i.gif\" />",$detail);
}
}
Date :
2010-11-17 00:07:38
By :
PlaKriM
ขอบพระคุณมากครับ
Date :
2010-11-17 00:12:48
By :
kooy2828
พอดีเจอนี้เข้า ช่วยอธิบายนิดครับ
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 'desclimit ,10' at line 1
Date :
2010-11-17 00:15:29
By :
kooy2828
desclimit เคาะวรรคด้วยครับ desc limit
Date :
2010-11-17 00:25:14
By :
PlaKriM
ลองแล้วครับ เหมือนเดิม ฝากช่วยดูอีกนิดนะครับ
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 '10' at line 1
Code (PHP)
<? session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Webbord</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
<script language="javascript">
function addEmo(num){
document.frmTopic.detail.value = document.frmTopic.detail.value +'['+ num +']';
}
function checkNull(){
if(document.frmTopic.subject.value=="" || document.frmTopic.subject.value==null){
alert('โปรดกรอกชื่อเรื่องด้วยครับ');
document.frmTopic.subject.focus();
return false;
}
if(document.frmTopic.detail.value=="" || document.frmTopic.detail.value==null){
alert('โปรดกรอกรายละเอียดด้วยครับ');
document.frmTopic.detail.focus();
return false;
}
if(document.frmTopic.name.value=="" || document.frmTopic.name.value==null){
alert('คุณลืมชื่อนะครับ');
document.frmTopic.name.focus();
return false;
}
document.frmTopic.submit();
}
</script>
</head>
<body>
<center><br />
<? include("connect.php");
include("function.php") ?>
<form id="frmManage" name="frmManage" method="post" action="managewebbord.php">
<table width="1000" class="square" cellpadding="4" cellspacing="1">
<tr>
<td width="50" class="square" align="center"> </td>
<td width="641" class="square" align="center">Subject</td>
<td width="201" class="square" align="center">Date</td>
<td width="76" class="square" align="center">View</td>
<td width="66" class="square" align="center">Reply</td>
</tr>
<? $sql = "select * from webboard_post order by question_id desc ";
$query = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($query);
$page = isset($_GET['page'])?$_GET['page']:1;
$perpage = 10;
$totalpage = ceil($num/$perpage);
$startpoint = ($page-1)*$perpage;
$sql .= "limit $startpoin,$perpage";
$query = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($query);
if($num>0){
for($i=0;$i<$num;$i++){
$row = mysql_fetch_array($query); ?>
<tr>
<td width="50" class="square" align="center">
<? if(!isset($_SESSION['admin'])){ ?>
<img src="image/bullet.gif" width="6" height="12" />
<? }else{ ?>
<input type="checkbox" id="id[]" name="id[]" value="<?=$row['question_id']?>" class="verdana" />
<? } ?>
</td>
<td width="641" class="square" align="center">
<a href="viewtopic.php?id=<?=$row['question_id']?>"target="_blank"><?=$row['subject']?> </a></td>
<td width="201" class="square" align="center">
<?=dateShow($row['datadate'])?> </td>
<td width="76" class="square" align="center">
<?=$row['view']?> </td>
<td width="66" class="square" align="center">
<?=$row['reply']?> </td>
</tr>
<? }
} else { ?>
<tr> <td colspan="5" class="square" align="center"> DataBase is emply
</td> </tr>
<? } ?>
<? if($totalpage>0){ ?>
<tr><td colspan="5" class="square" align="center">
<? for($i=1;$i<=$totalpage;$i++){
echo"<a href=\"?page=$i\">$i</a>"; } ?>
</td></tr>
<? } ?>
<? if(isset($_SESSION['admin'])){?>
<tr><td colspan="5" class="square" align="right">
click here for delete <input type="submit" value="Delete" class="verdana" /> :
<a href="logout.php" class="verdana">Logout</a>
</td></tr>
<? } ?>
</table><br/>
</form>
<form id="frmtopic" name="frmTopic" enctype="multipart/form-data" method="post" action="inserttopic.php" onsubmit="checkNull();return false;">
<table width="1000" class="square" cellpadding="4" cellspacing="1">
<tr>
<td width="200" class="square" align="center">Subject</td>
<td width="800" class="square" align="left">
<input type="text" id="subject" name="subject" style="width:500px" class="verdana"/>
</td>
</tr>
<tr>
<td width="200" class="square" align="center">Detial</td>
<td width="800" class="square" align="left">
<textarea name="detail" rows="4" class="verdana" id="detail" style="width:500px"></textarea>
</td>
</tr>
<tr>
<td width="200" class="square" align="center">Emo</td>
<td width="800" class="square" align="left">
<? for($i=1;$i<=15;$i++) { ?>
<img src="emo/<?=$i?>.gif" onclick="addEmo(<?=$i?>)" />
<? } ?>
</td>
</tr>
<tr>
<td width="200" class="square" align="center">Attach file</td>
<td width="800" class="square" align="left">
<input type="file" id="attach" name="attach" class="verdana" />
</td>
</tr>
<td width="200" class="square" align="center">Name</td>
<td width="800" class="square" align="left">
<input type="text" id="name" name="name" style="width:444px" class="verdana" />
<input type="submit" value="Post" class="verdana" />
</td>
</tr>
</table>
</form>
<? mysql_close($conn); ?>
</center>
</body>
</html>
Date :
2010-11-17 00:35:33
By :
kooy2828
$startpoint = ($page-1)*$perpage;
$sql .= "limit $startpoin ,$perpage";
ดูเอง
Date :
2010-11-17 00:39:07
By :
PlaKriM
ขอขอบพระคุณอย่างสูงเลยครับ
เอาไว้จะมารบกวนใหม่
ขอให้เจริญยิ่งๆ ขึ้นไปนะครับ
Date :
2010-11-17 00:46:09
By :
kooy2828
รบกวนถาม insert topic Unknown column 'subject_detail' in 'field list' มันขึ้นที่ไฟล์ inserttopic.php
<? $subject = $_REQUEST['subject'];
$detail = $_REQUEST['detail'];
$attachfile = $_FILES['attach'];
$name = $_REQUEST['name'];
$datadate = date("Y-m-d H:i:s");
$ip_address = $_SERVER['REMOTE_ADDR'];
$newname = "";
if($attachfile['size']>0){
if($attachfile['type']=="image/jpeg" || $attachfile['type']=="image/pjpeg" || $attachfile['type']=="image/gif"){
$newname = time();
move_uploaded_file($attachfile['tmp_name'],"attach/$newname.jpg");
}else{
echo "<script>alert('Upload image file type JPG and GIF only!');history.back();</script>";
exit();
}
}
include("connect.php");
$sql = "insert into webboard_post(subject,datadate,subject_detail,attach_file,name,ip_address,view,reply)";
$sql .= "value('$subject','$datadate','$detail','$newname','$name','$ip_address',0,0)";
mysql_query($sql) or die (mysql_error());
mysql_close($conn);
echo "<script>alert('Insert your question complete.');window.location='index.php';</script>";
?>
Date :
2012-04-05 10:36:51
By :
realgame
มันไม่รู้จัก ฟิลด์ subject_detail นี้น่ะ
คือฟิลด์นี้มันไม่มีอยู่ในตารางที่คุณทำรายการน่ะ
Date :
2012-04-05 10:47:19
By :
บังเอิญผ่านมาเห็น
Load balance : Server 00