Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > Parse error: syntax error, unexpected T_OBJECT_OPERATOR



 

Parse error: syntax error, unexpected T_OBJECT_OPERATOR

 



Topic : 055349



โพสกระทู้ ( 106 )
บทความ ( 0 )



สถานะออฟไลน์




สวัสดีครับ วันนี้ผมปัญหาครับ คือผมเขียนบน Localhost แล้ว Run มัน Run ได้ปกติแต่พออัฟขึ้น SV. จริง มันฟ้อง

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\AppServ\www\repair\rpexcel.php on line 45

ไม่เข้าใจเหมือนกันครับ แก้ไงบอกหน่อยครับCode (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head>  
<body> 
<?php 
 
//$conn = mysql_connect("localhost", "root", "123");  
//$dbname = "Repair2"; 
//mysql_select_db($dbname) or die("ERROR");
//mysql_query("USE num_new"); 
//mysql_query("SET NAMES tis620", $conn);
include 'connect.php';

$sql="SELECT
`rp_datajan`.`id`,
`rp_datajan`.`pname`,
`rp_datajan`.`fname`,
`rp_datajan`.`lname`,
`rp_departsub`.`name`,
`rp_datajan`.`phone`,
`rp_datajan`.`id_typebroke`,
`rp_datajan`.`remake`,
`rp_datajan`.`id_status`,
`rp_datajan`.`datejan`,
`rp_datajan`.`nameuserrepair`,
`rp_datajan`.`result`
FROM
`rp_datajan`
Inner Join `rp_departsub` ON `rp_datajan`.`id_departsub` = `rp_departsub`.`id`";

 
$result = mysql_query($sql);   
if($result){             
//*** Get Document Path ***//  
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp   
//*** Excel Document Root ***//    
$strFileName = "MyExcel/MyExcel.xls";   
//*** Connect to Excel.Application ***//    
$xlApp = new COM("Excel.Application");    
$xlBook = $xlApp->Workbooks->Add();     
//*** Create Sheet 1 ***//    
$xlBook->Worksheets(1)->Name = "My Job";                               
$xlBook->Worksheets(1)->Select;    
//*** Width & Height (A1:A1) ***//     
$xlApp->ActiveSheet->Range("A1:A1")->ColumnWidth = 5.0;     
$xlApp->ActiveSheet->Range("B1:B1")->ColumnWidth = 7.0;     
$xlApp->ActiveSheet->Range("C1:C1")->ColumnWidth = 15.0;    
$xlApp->ActiveSheet->Range("D1:D1")->ColumnWidth = 15.0; 
$xlApp->ActiveSheet->Range("E1:E1")->ColumnWidth = 30.0;   
$xlApp->ActiveSheet->Range("F1:F1")->ColumnWidth = 10.0;  
$xlApp->ActiveSheet->Range("G1:G1")->ColumnWidth = 10.0;
$xlApp->ActiveSheet->Range("H1:H1")->ColumnWidth = 50.0;
$xlApp->ActiveSheet->Range("I1:I1")->ColumnWidth = 10.0;
$xlApp->ActiveSheet->Range("J1:J1")->ColumnWidth = 10.0;
$xlApp->ActiveSheet->Range("K1:K1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("L1:L1")->ColumnWidth = 50.0;

//*** Report Title ***//    
$xlApp->ActiveSheet->Range("A1:F1")->BORDERS->Weight = 1;   
$xlApp->ActiveSheet->Range("A1:F1")->MergeCells = True;    
$xlApp->ActiveSheet->Range("A1:F1")->Font->Bold = True;     
$xlApp->ActiveSheet->Range("A1:F1")->Font->Size = 20;   
$xlApp->ActiveSheet->Range("A1:F1")->HorizontalAlignment = -4108;                  
$xlApp->ActiveSheet->Cells(1,1)->Value = "JOB";    
//*** Header ***//                   
$xlApp->ActiveSheet->Cells(3,1)->Value = "ID";  
$xlApp->ActiveSheet->Cells(3,1)->Font->Bold = True;   
$xlApp->ActiveSheet->Cells(3,1)->VerticalAlignment = -4108;    
$xlApp->ActiveSheet->Cells(3,1)->HorizontalAlignment = -4108;    
$xlApp->ActiveSheet->Cells(3,1)->BORDERS->Weight = 1;  
  
$xlApp->ActiveSheet->Cells(3,2)->Value = "Sex"; 
$xlApp->ActiveSheet->Cells(3,2)->Font->Bold = True; 
$xlApp->ActiveSheet->Cells(3,2)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,2)->HorizontalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,2)->BORDERS->Weight = 1;   
 
$xlApp->ActiveSheet->Cells(3,3)->Value = "Name";    
$xlApp->ActiveSheet->Cells(3,3)->Font->Bold = True;    
$xlApp->ActiveSheet->Cells(3,3)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,3)->HorizontalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,3)->BORDERS->Weight = 1; 
           
$xlApp->ActiveSheet->Cells(3,4)->Value = "LastName";    
$xlApp->ActiveSheet->Cells(3,4)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,4)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,4)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,4)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,5)->Value = "Depart Sub";    
$xlApp->ActiveSheet->Cells(3,5)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,5)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,5)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,5)->BORDERS->Weight = 1; 
  
$xlApp->ActiveSheet->Cells(3,6)->Value = "Phone";    
$xlApp->ActiveSheet->Cells(3,6)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,6)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,6)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,6)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,7)->Value = "Item";    
$xlApp->ActiveSheet->Cells(3,7)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,7)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,7)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,7)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,8)->Value = "Trouble";    
$xlApp->ActiveSheet->Cells(3,8)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,8)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,8)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,8)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,9)->Value = "Status";    
$xlApp->ActiveSheet->Cells(3,9)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,9)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,9)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,9)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,10)->Value = "Date";    
$xlApp->ActiveSheet->Cells(3,10)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,10)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,10)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,10)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells(3,11)->Value = "Name Support";    
$xlApp->ActiveSheet->Cells(3,11)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,11)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,11)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,11)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,12)->Value = "solve a problem";    
$xlApp->ActiveSheet->Cells(3,12)->Font->Bold = True;     
$xlApp->ActiveSheet->Cells(3,12)->VerticalAlignment = -4108;     
$xlApp->ActiveSheet->Cells(3,12)->HorizontalAlignment = -4108;      
$xlApp->ActiveSheet->Cells(3,12)->BORDERS->Weight = 1;
//***********// 
  
$intRows = 4;    
while($objResult = mysql_fetch_array($result))    
{ 
              
//*** Detail ***//         
$xlApp->ActiveSheet->Cells($intRows,1)->Value = $objResult["id"];        
$xlApp->ActiveSheet->Cells($intRows,1)->BORDERS->Weight = 1;         
$xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;              
        
$xlApp->ActiveSheet->Cells($intRows,2)->Value = $objResult["pname"];         
$xlApp->ActiveSheet->Cells($intRows,2)->BORDERS->Weight = 1; 
$xlApp->ActiveSheet->Cells($intRows,2)->HorizontalAlignment = -4108;        
        
$xlApp->ActiveSheet->Cells($intRows,3)->Value = $objResult["fname"];         
$xlApp->ActiveSheet->Cells($intRows,3)->BORDERS->Weight = 1;   
$xlApp->ActiveSheet->Cells($intRows,3)->HorizontalAlignment = -4108;                
        
$xlApp->ActiveSheet->Cells($intRows,4)->Value = $objResult["lname"];        
$xlApp->ActiveSheet->Cells($intRows,4)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,4)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells($intRows,5)->Value = $objResult["name"];        
$xlApp->ActiveSheet->Cells($intRows,5)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,5)->BORDERS->Weight = 1;  

$xlApp->ActiveSheet->Cells($intRows,6)->Value = $objResult["phone"];        
$xlApp->ActiveSheet->Cells($intRows,6)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,6)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells($intRows,7)->Value = $objResult["id_typebroke"];        
$xlApp->ActiveSheet->Cells($intRows,7)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,7)->BORDERS->Weight = 1;            

$xlApp->ActiveSheet->Cells($intRows,8)->Value = $objResult["remake"];        
$xlApp->ActiveSheet->Cells($intRows,8)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,8)->BORDERS->Weight = 1;   
 
$xlApp->ActiveSheet->Cells($intRows,9)->Value = $objResult["id_status"];        
$xlApp->ActiveSheet->Cells($intRows,9)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,9)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells($intRows,10)->Value = $objResult["datejan"];        
$xlApp->ActiveSheet->Cells($intRows,10)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,10)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells($intRows,11)->Value = $objResult["nameuserrepair"];        
$xlApp->ActiveSheet->Cells($intRows,11)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,11)->BORDERS->Weight = 1; 

$xlApp->ActiveSheet->Cells($intRows,12)->Value = $objResult["result"];        
$xlApp->ActiveSheet->Cells($intRows,12)->HorizontalAlignment = -4108;         
$xlApp->ActiveSheet->Cells($intRows,12)->BORDERS->Weight = 1; 

       
$intRows++;        
}                
                                        
@unlink($strFileName); //*** Delete old files ***//  
        
$xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path ***//        
//$xlBook->SaveAs(realpath($strFileName)); //*** Save to Path ***//  
         
//*** Close & Quit ***//         
$xlApp->Application->Quit();        
$xlApp = null;        
$xlBook = null;        
$xlSheet1 = null; 
  
} 
   
mysql_close();    
echo "<script>alert('Successful to change to Excel');window.location='MyExcel/MyExcel.xls';</script>";
		exit();  
?> 
 
</body> 
</html>


ขอบคุณครับ



Tag : PHP, CakePHP, Excel (Excel.Application)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-01-31 16:52:22 By : yutthanagorn View : 2103 Reply : 9
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ดูที่ Line 45 น่ะครับ พวกเครื่องหมาย น่าจะ เปิด ปิด ไม่ครบครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 08:57:25 By : webmaster
 


 

No. 2



โพสกระทู้ ( 106 )
บทความ ( 0 )



สถานะออฟไลน์


คือว่าผมเอา code นี้ run local มันได้ครับ แต่พออัฟขึ้น Server แล้วมันฟ้องตลอดเลย

ผมคิดว่าไม่น่าจะเป็นที่ตัวเครื่องหมาย ขอบคุณครับที่มาตอบให้ผม
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 10:39:36 By : yutthanagorn
 

 

No. 3



โพสกระทู้ ( 355 )
บทความ ( 0 )



สถานะออฟไลน์


Code (PHP)
$xlApp = new COM("Excel.Application");


ผมว่าอาจจะเป็นเพราะโฮสใช้ Linux แน่ๆครับ มันไม่มี Excel แต่บนเครื่องเราเป็นวินโดว์และลง Excel เอาไว้ มันเลยรันได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 11:25:56 By : zankumuro
 


 

No. 4



โพสกระทู้ ( 106 )
บทความ ( 0 )



สถานะออฟไลน์


ถ้าเป็นอย่างนั้นจริง เป็นไปได้ไหมครับว่าเครื่อง Server นั้นไม่ได้ลง office ไว้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 13:11:37 By : yutthanagorn
 


 

No. 5



โพสกระทู้ ( 355 )
บทความ ( 0 )



สถานะออฟไลน์


ครับ ส่วนใหญ่เซิฟเวอร์เขาไม่ลงไว้หรอกครับ แต่ทว่า Linux มันไม่มี Excel ด้วยนะซิครับ มีแต่ spreadsheet ถ้าจะใช้ต้องเลือกเซิฟเวอร์ที่เป็น Windows นะครับ

https://www.thaicreate.com/php/php-com-excel.html


ประวัติการแก้ไข
2011-02-01 13:16:46
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 13:15:41 By : zankumuro
 


 

No. 6



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


server linux ต้องเขียนใหม่และครับ หันไปใช้ PHPExcel แทนรันได้ทุก platform
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 14:02:44 By : PlaKriM
 


 

No. 7



โพสกระทู้ ( 106 )
บทความ ( 0 )



สถานะออฟไลน์


สรุปว่าปัญหาที่เกิดขึ้นกับผมที่มัน Run บน Server ไม่ผ่านเป็นที่ Excel เหรอครับ หรือง่ายๆเลยคือถ้าจะ run code นี้จะต้องมี excel ในเครื่อง เครื่องนั้น


ประวัติการแก้ไข
2011-02-01 14:16:36
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-01 14:14:55 By : yutthanagorn
 


 

No. 8



โพสกระทู้ ( 106 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุรสำหรับทุกๆ คนที่ช่วยครับ แต่มันแก้ไม่ได้อ่ะ T_T
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-02 10:02:26 By : yutthanagorn
 


 

No. 9

Guest


เปลี่ยนจาก $xlBook->Worksheets(1)->Name = "My Job";

เป็น $xlBook->Worksheets[1]->Name = "My Job";

ให้ใช้ [ ] แทนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-06-17 09:20:48 By : JacKIE
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Parse error: syntax error, unexpected T_OBJECT_OPERATOR
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่