Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Is there actually a guide out there that lists all differences?
  2. Your code is still to general and you should narrow it down for example a record would resemble an object like: class Blog_Post { private $id = 0; private $authorId = 0; private $title = ''; private $content = ''; private $timestamp = 0; public function getId() { return $this->id; } public function setId($id) { $id = intval($id); if ($id > 0) { $this->id = $id; } } public function getAuthorId() { return $this->authorId; } public function setAuthorId($authorId) { $authorId = intval($authorId); if ($authorId > 0) { $this->authorId = $authorId; } } public function getTitle() { return $this->title; } public function setTitle($title) { $this->title = strval($title); } public function getContent() { return $this->content; } public function setContent($content) { $this->content = strval($content); } public function getTimestamp($format = '%c') { return strftime($format, $this->timestamp); } public function setTimestamp($timestamp) { if (is_integer($timestamp)) { $this->timestamp = $timestamp; } else if (is_string($timestamp)) { $this->timestamp = strtotime($timestamp); } } } Afterwards: $post = Blog::findPage('slug-title'); //update fields if (Blog::save($post)) { //success } Internal it would seek which fields have been modified and update only the modified fields instead of all fields using exception's you would do what you now do as user_error() and error_log()
  3. Plus PDO is not an abstraction layer rather a data-access layer which means it doesn't alter you SQL So is not true.
  4. No. It uses its own function library. Well this is all new to me till now I never have had this problem. I do find it interesting as this means that I would be able to leave the mysql and mysqli extension disabled and just include the pdo extension and still be able to connect to any (supported) database. I now understand what Mchl meant as I can check for mysql or mysqli but the problem rises when it comes to PDO as it may be enabled but provides no means to verify a mysql server is present besides instantiating PDO with the MySQL driver and check for an error but then again is it because the user mistyped the password or the lack of the mysql presence.
  5. Ok yeah but you can solve that as: define('MYSQL_ENABLED', function_exists('mysql_connect')); define('MYSQLi_ENABLED', function_exists('mysqli_connect')); Doesn't PDO use the mysql or mysqli extension?
  6. Well I figured that if the user selected for example mysql then a logical step would be to try to connect using his provided input. However if the extension isn't loaded/installed then those functions aren't available unless I'm wrong at this and they are even if the extension is loaded or not but then what is their default implementation? I don't fully understand what you mean by: "no reliable way of checking if/what database system is available"
  7. Short: you can't. Ask their timezone when they signup or let them select their country or their language.
  8. If you continue on that you could keep domain short for example: user@hisdomain.z.com
  9. They probably forgot the meaning of critique when they posted it..
  10. If you ever face something like: $name = stripslashes($_POST['Name']); $email = stripslashes($_POST['Email']); $phone = stripslashes($_POST['Phone']); $address = stripslashes($_POST['Address']); $city = stripslashes($_POST['City']); $number = stripslashes($_POST['Number']); $pettypes = stripslashes($_POST['PetTypes']); $petnames = stripslashes($_POST['PetNames']); $departuredate = stripslashes($_POST['DepartureDate']); $returndate = stripslashes($_POST['ReturnDate']); $specialinstructions = stripslashes($_POST['SpecialInstructions']); You can transform that to: function clean($value) { return addslashes(htmlentities(stripslashes($value))); } $_POST = array_map('clean', $_POST); extract($_POST); //.. "Name: ".$Name."\n" ."Email: ".$Email."\n" ."Phone: ".$Phone."\n" ."Address: ".$Address."\n" ."City: ".$City."\n" ."Number of Pets: ".$Number."\n" ."Pet Types: ".$PetTypes."\n" ."Pet Names: ".$PetNames."\n" ."Departure Date: ".$DepartureDate."\n" ."Return Date: ".$returndate."\n" ."Special Instructions: ".$SpecialInstructions."\n" //..
  11. Ofcourse not!! Daniel is way to smart for any average lawyer..
  12. Hi please post all relevant code as sessions should work because their internals weren't programmed to exclude certain types of programmers.
  13. That is generally called the learning process If you knew all you probably wouldn't be here instead making billion dollar applications ultra-optimized to execute in pico-seconds Hell you would probably take a vacation on Pluto or some other Galaxy far, far away
  14. Should I care? Does he know or even care about what I do?
  15. Sure and when I pass "?id=1 OR 1=1" as my id I would get all his table records. Try schilly's code though I would advice to use trigger_error() in the future instead of die() You can write: $con = mysql_connect("localhost","root"); if (!$con) Like: if (!($con = mysql_connect("localhost","root")) { Depends on what you like alo try to avoid dubble quotes (") if you don't need the extra processing power (eg "hello $world") and use single quotes (') instead 'hello $world' outputs hello $world and does not parse any contained variables. Hope this helps, cheers!
  16. If you aspire to be a designer, sure. If on the other hand you want to become a front-end engineer or back-end engineer why bother?
  17. Why would you emulate a db if you can just use a db?
  18. You can try this: define('MYSQL_ENABLED', function_exists('mysql_connect') ? true : false); define('SQLITE_ENABLED', function_exists('sqlite_open') ? true : false); //.. Then when the user selects a database you can verify that it is available.
  19. Not really, because a person who is using OOP approach in php should know better and use require_once(''); What Mchl said is TRUE that Guru thingie actually means something and if you were to use OOP then you wouldn't even bother using __autoload but you would be smart and be using spl_autoload_register Then why would you use __autoload in the first place? I generally declare a spl_autoload_register class and then leave the require_once out in class files
  20. You know all Palm WebOS apps are created in JS? That's why he said games
  21. To create something like http://devana.eu/devana/imgs/map.jpg You would use: create table world_map ( id integer not null auto_increment, tile_image varchar(255), x_coord integer, y_coord integer, primary key (id)); $user_xcoord = $_GET['xcoord']; $user_ycoord = $_GET['ycoord']; // add proper validation so user can not go out-of-bound $user_xcoord_min = $user_xcoord - 2; $user_xcoord_max = $user_xcoord + 2; $user_ycoord_min = $user_ycoord - 2; $user_ycoord_max = $user_ycoord + 2; $query = "SELECT * FROM world_map WHERE (x_coord BETWEEN $user_xcoord_min AND $user_xcoord_max) AND (y_coord BETWEEN $user_ycoord_min AND $user_ycoord_max)"; $result = mysql_query($query); //..
  22. Apparently the search on this forum to as neil.johnson already found one http://www.phpfreaks.com/forums/index.php/topic,285003.msg1351768.html#msg1351768
  23. It is indeed not good but why not do: $validator = FormElementValidator::findValidator($formElement); if ($validator && $validator->isVaild($formElement)) { Which can be used for each validator
  24. You probably already know this, but that's not valid syntax. I hope it will be someday Like Java " some string here ".trim()
×
×
  • 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.