Jump to content

No luck with FirePHP


Recommended Posts

Hi, I am trying to use the FirePHP addon for Firefox to debug my PHP pages. I currently following training and feel the need to be able to have some introspection into what is going on. My knowledge of PHP is basic and I have just started really learning Object Oriented PHP. I don't find it easy to follow the trail of execution in a set of PHP files. So I wanted to use FirePHP to help. I am wondering what I am doing wrong and is anybody can help. I cannot seem to understand how to insert the code into the current pages to trace function execution. My code FirePHP code is around line 35 in the function find_by_sql. Could the fact that I am trying to use this on a static function be the problem. Thanks

// this is from the Lynda.com title PHP Beyond the Basics
// If it's going to need the database, then it's
// probably smart to require it before we start


class User {

	public $id;
	public $username;
	public $password;
	public $first_name;
	public $last_name;
	public static function find_all() {
		global $database;
		//$result_set = $database->query("SELECT * FROM users");
		//return $result_set;
		return self::find_by_sql("SELECT * FROM users");
	public static function find_by_id($id=0) {
		global $database;
		$result_array = self::find_by_sql("SELECT * FROM users WHERE id={$id} LIMIT 1");
		return  !empty($result_array)? array_shift($result_array) : false;
	public static function find_by_sql($sql="") {
		global $database;
		$firephp = FirePHP::getInstance(TRUE);
		$result_set = $database->query($sql);
		$object_array = array();
		while ($row = $database->fetch_array($result_set)) {
			$object_array[] = self::instantiate($row);

		$firephp->fb('Hello World!', FirePHP::TRACE);
		return $object_array;

	public static function authenticate($username="", $password="") {
		global $database;

		$username = $database->escape_value($username);
		$password = $database->escape_value($password);
		$sql = "SELECT * FROM users ";
		$sql .= "WHERE username = '{$username}' ";
		$sql .= "AND password = '{$password}' ";
		$sql .= "LIMIT 1";
		$result_array = self::find_by_sql($sql);
		return !empty($result_array) ? array_shift($result_array) : false;
	public function full_name() {
		if(isset($this->first_name) && isset($this->last_name)) {
			return $this->first_name . " " . $this->last_name;
		} else {
			return "";
	private static function instantiate($record) {
		// Could check that $record exists and is an array
		// Simple, long-form approach:
		$object = new self;
		//$object->id 		= $record['id'];
		//$object->username 	= $record['username'];
		//$object->password 	= $record['password'];
		//$object->first_name = $record['first_name'];
		//$object->last_name 	= $record['last_name'];
		//return $object;
		// More dynamic, short-form approach
		foreach($record as $attribute=>$value){
			if($object->has_attribute($attribute)) {
				$object->$attribute = $value;
		return $object;
	private  function has_attribute($attribute) {
		// get_object_vars returns an associative array with all attributes
		// (incl. private ones!) as the keys and their current values as the value
		$object_vars = get_object_vars($this);
		// We don't care about the value, we just want to know if the key exits
		// Will return ture or false
		return array_key_exists($attribute, $object_vars);


Link to comment
Share on other sites

I accidently broke the code trying things and it worked, that is until that point. Any idea what this means. I am not asking why the code broke I understand that, I am curious why it works when the function does not finish. Could this lead me to what I am ultimately doing wrong?broke_works.png

Link to comment
Share on other sites

You have a typo in there for your method call -- you're missing the greater than.


$firephp-trace() needs to be $firephp->trace()

Thanks, I totally understand that, it is the whole point of what I said. I know why the code broke but why does FirePHP work now is what I am trying to figure out? If I fix it will not give me anything in the console. Thanks again.

Link to comment
Share on other sites

I was having a hard time getting xdebug to work with local development. I have a setup with PHP MySQL and Apache installed separately, Can xdebug work with this? Do you know of any sites that Instruct for the configuration? I could only find info on getting it working with XAMMP Thanks a lot!

Link to comment
Share on other sites

I am using Windows with PHP MySQL and Apache installed on by one. I note the difference between use XAMMP or WAMP Server, because I see info how to use xdebug on those but don't find any info how to install if you have each one installed separately. Thanks

Link to comment
Share on other sites


It doesn't really make any difference. The process is the same, files and things might just be in different locations.

I got it! What you said made me look at it again. Now I have xdebug working and can follow tutorials like yours. I am going to keep trying with FirePHP because it is nice to have another option. Thank you so much!

Edited by pctechtv
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.