ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comความรู้ทั่วไปE-commerceรบกวน เซียน PHP ช่วยหน่อยครับ(ภาค2)
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: รบกวน เซียน PHP ช่วยหน่อยครับ(ภาค2)  (อ่าน 1893 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
Godfather
ก๊วนเสียว
*

พลังน้ำใจ: 1
ออฟไลน์ ออฟไลน์

กระทู้: 201



ดูรายละเอียด เว็บไซต์
« เมื่อ: 17 สิงหาคม 2007, 14:04:31 »

ผมมี Error ใน Controlshop รบกวนเซียน PHP ช่วยหน่อยครับ


Warning: error_log(/var/log/www/tep/page_parse_time.log) [function.error-log]: failed to open stream: No such file or directory in d:\ip1\madeatthailand.biz\www\controlshop\includes\classes\logger.php on line 49
Parse Time: 0.858s


และนี่คือโค๊ดที่ระบบแจ้งว่า Error บรรทัด 49 จะเป็นสีแดง

<?php
/*
  $Id: logger.php,v 1.3 2003/06/20 16:23:08 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class logger {
    var $timer_start, $timer_stop, $timer_total;

// class constructor
    function logger() {
      $this->timer_start();
    }

    function timer_start() {
      if (defined("PAGE_PARSE_START_TIME")) {
        $this->timer_start = PAGE_PARSE_START_TIME;
      } else {
        $this->timer_start = microtime();
      }
    }

    function timer_stop($display = 'false') {
      $this->timer_stop = microtime();

      $time_start = explode(' ', $this->timer_start);
      $time_end = explode(' ', $this->timer_stop);

      $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);

      $this->write(getenv('REQUEST_URI'), $this->timer_total . 's');

      if ($display == 'true') {
        return $this->timer_display();
      }
    }

    function timer_display() {
      return '<span class="smallText">Parse Time: ' . $this->timer_total . 's</span>';
    }

    function write($message, $type) {
      error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }
  }
?>



ขอบคุณล่วงหน้าสำหรับคำตอบ
บันทึกการเข้า

[Color = Red]ท่านที่ ว่างงานอยู่กำลังมองหางาน หรือ ท่านที่ต้องการรายได้เสริม เชิญทางนี้ครับ [Color]http://www.thaiseoboard.com/index.php/topic,65120.0.html
EThaiZone
เจ้าพ่อโลลิค่อน
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 321
ออฟไลน์ ออฟไลน์

กระทู้: 12,516



ดูรายละเอียด
« ตอบ #1 เมื่อ: 17 สิงหาคม 2007, 14:17:11 »

ฟังค์ชั่น error_log มันอยากจะเขียน log ไว้ที่ /var/log/www/tep/page_parse_time.log

แต่มันทำไม่ได้ครับ

งานนี้มี 2 ทางเลือก

1. หาฟังค์ชั่น error_log แล้วไปแก้โค้ดที่มัน
2. ตัดปัญหา // หน้า บรรทัดที่ 49 ไปเลยครับ

ข้อ 2 นี้ // ไปคงไม่เป็นไร เพราะไม่น่าเกี่ยวกะระบบอะไรมาก แค่เก็บ log
บันทึกการเข้า

Tee++;
โปรแกรมเมอร์ จอหงวน
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 79
ออฟไลน์ ออฟไลน์

กระทู้: 1,861



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 17 สิงหาคม 2007, 14:18:56 »

ผมมี Error ใน Controlshop รบกวนเซียน PHP ช่วยหน่อยครับ


Warning: error_log(/var/log/www/tep/page_parse_time.log) [function.error-log]: failed to open stream: No such file or directory in d:\ip1\madeatthailand.biz\www\controlshop\includes\classes\logger.php on line 49
Parse Time: 0.858s


และนี่คือโค๊ดที่ระบบแจ้งว่า Error บรรทัด 49 จะเป็นสีแดง

<?php
/*
  $Id: logger.php,v 1.3 2003/06/20 16:23:08 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class logger {
    var $timer_start, $timer_stop, $timer_total;

// class constructor
    function logger() {
      $this->timer_start();
    }

    function timer_start() {
      if (defined("PAGE_PARSE_START_TIME")) {
        $this->timer_start = PAGE_PARSE_START_TIME;
      } else {
        $this->timer_start = microtime();
      }
    }

    function timer_stop($display = 'false') {
      $this->timer_stop = microtime();

      $time_start = explode(' ', $this->timer_start);
      $time_end = explode(' ', $this->timer_stop);

      $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);

      $this->write(getenv('REQUEST_URI'), $this->timer_total . 's');

      if ($display == 'true') {
        return $this->timer_display();
      }
    }

    function timer_display() {
      return '<span class="smallText">Parse Time: ' . $this->timer_total . 's</span>';
    }

    function write($message, $type) {
      error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }
  }
?>



ขอบคุณล่วงหน้าสำหรับคำตอบ


คำสั่งการเขียน error log แบบที่ 3 จะเขียนไปใน abs path ที่กำหนด โดยที่ ตอนนี้มันวิ่งผ่าน ค่าที่ ตั้งใน constant
(STORE_PAGE_PARSE_TIME_LOG)

แต่ว่ามันหา path ไม่เจอเลยเขียนไปไม่ได้ path นี้
/var/log/www/tep/page_parse_time.log

แก้ไขโดยการไปสร้างไฟล์ ตาม path ออกมาหรือว่า comment error_log ทิ้งไปเลย
บันทึกการเข้า

EThaiZone
เจ้าพ่อโลลิค่อน
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 321
ออฟไลน์ ออฟไลน์

กระทู้: 12,516



ดูรายละเอียด
« ตอบ #3 เมื่อ: 17 สิงหาคม 2007, 14:33:24 »

กำ error_log เป็นฟังค์ชั่นปกติเหรอเนี่ย (ไม่ทันคิดจะค้น)

แนะนำให้แก้พาทหาที่ลง error ครับ

แล้วเปิดดู error ที่ได้

ผมว่า ถ้ามันไม่มีอะไรขัดข้อง ส่วนนี้มันก็ไม่น่าจะทำงานครับ
บันทึกการเข้า

Godfather
ก๊วนเสียว
*

พลังน้ำใจ: 1
ออฟไลน์ ออฟไลน์

กระทู้: 201



ดูรายละเอียด เว็บไซต์
« ตอบ #4 เมื่อ: 17 สิงหาคม 2007, 14:37:30 »

ผมต้องทำไงบ้างรบกวนช่วยบอกด้วยครับ ผมไม่มีความรู้เรื่อง PHP เลย
บันทึกการเข้า

[Color = Red]ท่านที่ ว่างงานอยู่กำลังมองหางาน หรือ ท่านที่ต้องการรายได้เสริม เชิญทางนี้ครับ [Color]http://www.thaiseoboard.com/index.php/topic,65120.0.html
EThaiZone
เจ้าพ่อโลลิค่อน
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 321
ออฟไลน์ ออฟไลน์

กระทู้: 12,516



ดูรายละเอียด
« ตอบ #5 เมื่อ: 17 สิงหาคม 2007, 14:59:17 »

แก้ตรง STORE_PAGE_PARSE_TIME_LOG

เป็นพาทที่ต้องการ เช่น

"d:\ip1\madeatthailand.biz\www\controlshop\page_parse_time.log"

เลยก็ได้

คือเอาไว้ไหนก็ได้ที่คิดว่าไฟล์มันจะเขียนได้

แล้วเราอาจลองโหลดมาดูก็ได้

แต่ถ้าตามจริงถ้าคุณไม่ถนัด
ผมว่า

ใส่ //
หน้าบรรทัด 49 ก็จบครับ

เป็นการปิดระบบการบันทึก log ไม่ให้ทำงานอะ
บันทึกการเข้า

หน้า: [1]   ขึ้นบน
พิมพ์