Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Who did you learn to program like: ob_start(); echo 'blabla'; $var = ob_get_clean(); Seriously, this is horrible. Not to mention the serious overhead. While it's only: $var = 'blabla';
  2. Before shooting yourself, read up on Regex and PHP Regex functions. str_replace() is not one of 'em. $text = 'why won\'t you change my word. @@origionalWord@@'; echo preg_replace('/@@([a-z])+@@/i', 'replacementWord', $text); Edit: meh
  3. $artist = $_GET['artist']; $url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&' . 'artist=' . $artist . '&api_key=097a7ab0f5b56a894eb7a25e1c51b0da'; $headers = get_headers($url); if (400 >= (int) substr($headers[0], 9, 3)) { echo 'Artist: ', $artist, ' does not exist.'; exit(0); } $xml = simplexml_load_file($url); //
  4. To get the active page and the number of pages use the corresponding methods. include("DataBase.class.php"); include("Paginator.class.php"); $db = DataBase::getInstance(); $row = $db->executeGrab("SELECT * FROM ".PADU_NOTICE." WHERE DEPARTMENT_CODE='04'"); if($row){ $paginator = new Paginator($row, 20); $items = $paginator->getItemsForPage(1); echo $paginator->getActivePage(), ' of ', $paginator->getNumberOfPages(), ' pages.', "<br/>\n<br/>\n"; foreach ($items as $item) { echo $item["NOTICE_NO"], "<br/>\n"; } }
  5. No, I was actually referring to a many-to-many relationship as: - one genre has many movies and - one movie has many genres And yes I get paid by Marvel to SPAM that link everywhere and tell everyone how awesome that video, just for doing so I get 1K for every referral. I only just hit $1M
  6. This context you are referring to is an illusion. An e-mail is not a database, and never will be. Your application should always model after real-world objects. You don't add/update/delete records in an e-mail, do you? A correct implementation would be: class Mail { private $from = ''; private $to = array(); private $headers = array(); private $subject; private $message; public function setFrom($email, $name = null) { $this->from = $name ? "$name <$email>" : $email; $this->headers[] = 'Reply-To: ' . $this->from; $this->headers[] = 'Return-Path: ' . $this->from; return $this; } public function setSubject($subject) { $this->subject = $subject; return $this; } public function setMessage($message) { $this->message = str_replace("\n.", "\n..", $message); $this->message = wordwrap($this->message, 70); return $this; } public function addTo($email, $name = null) { $this->to[] = $name ? "$name <$email>" : $email; return $this; } public function send() { $to = implode(',', $this->to); $headers = implode("\r\n", $this->headers); return mail($to, $this->subject, $this->message, $headers); } } $users = $db->execute('SELECT concat(firstname, ' ', lastname) AS name, email_address FROM table')->fetchAll(); foreach ($users as $user) { $email->addTo($user['email_address'], $user['name']); } $email->send();
  7. Most of us would have written our own. The rest of you would use Magento
  8. Apparently you didn't follow the tutorial thoroughly: movie_id (primary, a.i) genre_id (foreign key) movie_title It's not uncommon for a movie to fit under multiple genre's like IMDB shows you. http://www.imdb.com/title/tt1228705/
  9. So every e-mail you send (with Gmail, Hotmail, Outlook, ..) is a database?
  10. You also mind telling what that is? I also want to point out you take a look at: Now take a look at: You notice something? Hint #1: Hint #2: You sure it was )??
  11. echo translate('$textSource', 'en', 'ar'); should be echo translate($textSource, 'en', 'ar');
  12. Your Email class violates the LSP (Liskov Substitution Principle) which states that every child should be substitutable for it's parent. class UserService { private $db = null; public function __construct(Database $db) { $this->db = $db; } public function findUserByName($name) { return $this->db->execute("SELECT * FROM table WHERE name = '$name'")->fetchAll(); } } Does the below make sense to you? $userService = new UserService(new Email()); Another example what happens when I would want to load e-mails from a service, like an external CRM? Extends implies an is-a relationship, does this makes sense to you?
  13. It would seem more natural to give each column the same amount of spacing. So you won't end up with something like: | text | text | text | Or did you never hear of text-align: right?
  14. Why do you give only the second and third a padding-left?
  15. You mean besides the horrible writing? It misses a }
  16. if ($resultado == true) is wrong it should be: if (1 === $resultado) { //login OK } else if (0 === $resultado) { //no records found } else { //ambiguous (2 or more records found) }
  17. What are you talking about? g++ is a C++ compiler. I see now, I had mistaken it for Go.
  18. WHERE week(date_post) = week(CURRENT_DATE) AND dayofweek(date_post) BETWEEN 2 AND 6
  19. Yes something like that, but like I said DON'T LOCK-OUT YOUR USER some valid users will require more then 3 times to log-in (like myself due to my name being "popular") require_once('recaptchalib.php'); $enableCaptcha = FALSE; if (array_key_exists(array('username', 'password'), $_POST)) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); if (!array_key_exists('logon_tries', $_SESSION)) { $_SESSION['logon_tries'] = 1; } else { $_SESSION['logon_tries']++; } if ($_SESSION['logon_tries'] === 3) { $enableCaptcha = TRUE;//only show reCaptcha don't yet validate } if ($_SESSION['logon_tries'] > 3) { $enableCaptcha = TRUE; if (!array_key_exists(array('recaptcha_challenge_field', 'recaptcha_response_field'), $_POST)) { //user is messing with the HTML, lock him out } $privatekey = "..."; $response = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$response->is_valid) { //reCaptcha invalid. } } } if ($enableCaptcha) { $publickey = "..."; // you got this from the signup page echo recaptcha_get_html($publickey); } This will show a reCaptcha once the user enters login information for the third time.
  20. I couldn't have said it better myself
  21. You need ActiveX but I see more and more people install something like NoScript (or AdBlocker?) like my Dad did (as did a few of his friends/colleagues) as they grow tired of all those annoying misleading ads/pop-ups/survey's which means JS is disabled for these users and you will have to come up with a solution that requires to look further then your nose.
×
×
  • 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.