Jump to content

pctechtv

New Members
  • Posts

    7
  • Joined

  • Last visited

pctechtv's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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!
  2. 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
  3. 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!
  4. 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.
  5. 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?
  6. Thanks that page taught me how to check if the headers are getting sent. Mine look to be OK, I am just not getting my trace in the console.
  7. 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 <?php ob_start(); // 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 require_once('database.php'); require_once('../../FirePHPCore/fb.php'); 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); } } ?>
×
×
  • 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.