Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. This is NOT done automatically, it is a configurable option, just like most everything else to do with http servers.
  2. Are you getting any errors or anything? With the information you've provided, we can't really offer much advice.
  3. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=337165.0
  4. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=337174.0
  5. file_get_contents(0 doesn't make a request for the file via http, therefore the php is never parsed. A better options is to wrap the include construct. Something like.... function loadTemplate($template) { ob_start(); include $template; return ob_get_contents(); } This loads the template (parsing the php) into a buffer then returns the buffers contents.
  6. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=337182.0
  7. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=337187.0
  8. $this->db stores the database object that you pass in via the __construct(). In my example, I was using a fictional database class, you would need to modify the code somewhat to make it work with yours. It's named the same, but obviously your class has a slightly different interface. See above.
  9. Your pretty close. Instead of making specific CreateUser class though, I would more than likely create something a little more generic. class User { private $db; private $id; private $username; private $password; public function __construct(MySql $db, $id = 0) { $this->db = $db; $this->id = $id; if ($this->id != 0) { $results = $this->db->query(" SELECT username, password FROM users WHERE id = '{$this->id}' "); if ($results) { $this->username = $results->username; $this->password = $results->password; } } } public function setUsername($name) { $this->username = $name; return $this; } public function setPassword($pass) { $this->password = $pass; return $this; } public function getUserName() { return $this->username; } public function getPassword() { return $this->password; } public function save() { if ($this->id = 0) { $id = $this->db->query(" INSERT INTO users (username, password ) VALUES ( '{$this->username}', '{$this->password}' "); $this->id = $id; } else { $this->db->query(" UPDATE users SET username = '{$this->username}', password = '{$this->password}' WHERE id = '{$this->id}' "); } return $this->id; } } You can then use this to create and retrieve users. $user = new User(new Mysql); $user->setUsername('thorpe'); $user->setPassword('dontbecrazy'); $id = $user->save(); echo "New user {$user->getUsername()} created with an id of $id"; And to get user 101. $user = new User(new Mysql, 101); echo $user->getUsername(); Of course there is allot of things missing in this example, but this is a basic model. You would want to ensure that your database class itself takes care of sanitizing data, and you would very much want to have it implement some interface or Abstract class.
  10. Surely you would want to put your actual query code within the CreateUser class?
  11. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=336975.0
  12. And it only took like 3 days? You should take a look at the manual in relation to control structures. A simple 'if' statement would have fixed this in 5 minutes. http://php.net/manual/en/control-structures.if.php
  13. There are no tables on the page you link to.
  14. function error($errorID=null) { echo !empty($errorID) ? $errorID : 'somedefault'; }
  15. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=336948.0
  16. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=336965.0
  17. This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=336916.0
  18. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=336252.0
  19. This page just loaded with 18 queries so I would think 19 is fine. At my work. We develop a custom Intranet distribution, some of the application run upward of 400 queries per page and handle. Of course, the environment is a little more controlled, but we don't yet have any problems.
  20. *All* data needs to be escaped properly before going in a database query. It's not a security measure.
  21. Your running your markup through htmlspecialchars(), this will cause the markup to be output instead of being processed by the browser. I also notice your note escaping your data prior to insert, see mysql_real_escape_string.
  22. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=336814.0
×
×
  • 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.