2013-06-21 66 views
0

嗨我仍然不知道爲什麼這些代碼不起作用,他們還沒有產生任何錯誤,雖然我已經測試small example,它的工作。包括和功能不工作

下面是這些代碼: securedlogin.php

<?php 
include_once '/../toggleFirePHP.php'; //ok 
// Start here................................................................... 
function connect($database) 
{ 
$firephp->group("In securedlogin.php, debugging begins"); 
$firephp->info("Info: Building parameters before login and use database"); 

/*** mysql hostname ***/ 
$hostname = 'localhost'; 

/*** mysql username ***/ 
$username = 'root'; 

/*** mysql password ***/ 
$password = ''; 

/*** mysql database ***/ 

$firephp->log("Log: hostname=".$hostname.", username=".$username.", password=".$password.", database=".$database); 

try { 
    $dbh = new PDO("mysql:host=$hostname;dbname=$database", $username, $password); 
    echo 'Connected to '.$database.' database'."<br/>"; 
    $firephp->warn("Warn: Login and connected to $database database is successful!"); 
    } 
catch(PDOException $e) 
    { 
    $shorterr = $e->getMessage(); 
    $alertmsg = $shorterr; 
    include 'alertmessage.php'; 
    echo $shorterr."<br/>"; 
    $firephp->error("Error: Login and connected to database is NOT successful! See below:"); 
    $firephp->error("Error: $shorterr"); 
    } 

$firephp->groupEnd(); 
} 
?> 

toggleFirePHP.php

<?php 
require_once($_SERVER['Document_ROOT'].'/firephp_include.php'); 
$firephp->setEnabled(TRUE); 
?> 

main.php

<?php 
include_once '/toggleFirePHP.php'; //ok 

// Start here................................................................... 
include_once 'secured/securedlogin.php'; 

$firephp->group("In main.php, debugging begins"); 
$database = 'testdata1970_05'; 
$firephp->log("Log: Include securedlogin.php once and use $database"); 
connect($database); 

$firephp->groupEnd(); 
?> 

那麼什麼地方出錯了這些代碼? 我們將非常感謝您的幫助。 克萊門特

+0

你試過在你的兩個phps的開頭添加這個? - 「全球$ firephp;」 – Akshay

+0

它是如何「不工作」?你得到什麼錯誤,或發生了什麼? –

+0

'include()'中的'require()'?你知道這有什麼區別嗎? –

回答

0

如果/首先,你從根FS包括文件

使用

include_once './../toggleFirePHP.php'; 

include_once 'toggleFirePHP.php'; //ok 
+0

現在我開始更好地理解相關鏈接的用法。 HTML和PHP中的相對鏈接不同。嘆息......我還注意到$ firephp腳本在PHP函數內不能正常工作。我正在使用FirePHP核心。 – user1739825

0

linklink

  • 正確的在securedlogin.php中是'/toggleFirePHP.php'。
  • 在toggleFirePhp.php中正確的是'firephp_include.php'。
  • 正確的main.php是 'toggleFirePHP.php' 和 '/secured/securedlogin.php'

根文件系統看起來如下: -

Root folder 
    toggleFirePHP.php 
    main.php 
    alertmessage.php 
    firephp_include.php 
    secured folder 
     securedlogin.php