Jump to content

BrandonK

Members
  • Posts

    27
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

BrandonK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. IE has a default body margin. Use: <body STYLE="overflow-y:scroll;margin:0;">
  2. Perhaps you can take a look at this library: http://code.google.com/p/modem-emulator/ I've used it in the past and it was okay. A little flaky, but not bad for testing.
  3. using a for loop with count is inefficient. At the beginning of each loop, the script has to recount the array, so if your query ever returns a large amount of data (say 100 rows or so), you might notice some lag. I prefer using foreach loop: foreach($result as $row) { echo $row['username']; echo $row['password']; } Same results and it should be faster.
  4. Key differences I see are (these are the spam entries): To: 321321 321321 <projectest@ymail.com> Reply-to: REPLY <angelitoestebancito@gmail.com> Also, your content length is different, so there the messages aren't 100% the same.
  5. They shouldn't be. You'd have to post your code, but numerics should stay: <?php $str = 'Shrek2 vs Shrek 2'; $str = str_replace('&', 'and', $str); $str = preg_replace(array('/[^\w\s-_\\/]+/', '/[^\w]+/'), array('', '-'), $str); echo $str;
  6. I threw Cheech-Chong in there to show that it preserves existing hyphens. You initial example still works with Cheech & Chong. I tend to make urls lowercase because servers can be case sensitive. I do think that search engines are smart enough to not mistake Cheech with cheech, but its always better to error on the side of caution. strtolower() is easy to add.
  7. I discovered a bug with the regex that I posted. Since I am planning on using this function to replace my current method for creating slugs, I ran it through some of my odd product names... If your product name has a hyphen, it is stripped by the \p{P} so: "Cheech-Chong Up In Smoke" becomes "CheechChong-Up-In-Smoke" After a lot of trial and error, I came up with this: <?php $str = 'Cheech & Chong\'s Nice Dreams'; $str = str_replace('&', 'and', $str); $str = preg_replace(array('/[^\w\s-_\\/]+/', '/[^\w]+/'), array('', '-'), $str); echo $str; It loses some of its simplicity that we had earlier, but it allows the above string to come out as "Cheech-Chong-Up-In-Smoke" as well as handling backslashes like I needed it to. If someone else has an idea to clean it up, I'd be happy to run it through my tests. P.S. For those that are interested, here's what I found out about the \p variations: not matched by \p{P}: `~$^+=<> {Pc}: _ {Pd}: - {Pe}: )]} {Pf}: ????? - no clue, probably has to do with the placement of the punctuation {Pi}: ????? - no clue, probably has to do with the placement of the punctuation {Po}: !@#%&*:"?\;',./ {Ps}: ({[ Not much more info here: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
  8. Very nice idea tgavin. That's a lot more efficient than what I was using before. I added one more step to the replacement for slightly better results (strips punctuation): <?php $str = 'Cheech & Chong\'s Nice Dreams'; $str = str_replace('&', 'and', $str); $str = preg_replace(array('/[\p{P}]+/', '/[^\w]+/'), array('', '-'), $str); echo $str; This way you don't get Cheech-and-Chong-s-Nice-Dreams, but instead Cheech-and-Chongs-Nice-Dreams. YMMV. \p{P} matches all punctuation (PHP 4.4.0+ and 5.1.0+)
  9. Check out Zend_Db_Profiler from the Zend Framework. Its really cool and might give you a good idea or two
  10. I plan on using the Zend_Framework in my next big project, and I am starting to play around with it. I am currently debating Zend_Db vs the standard PDO and I think that the ZF version is a lot nicer. I plan to extend the class just a little and wrap it in my own namespace. I have created the connection like this: <?php try { $db_config = array( 'host' => $hostname, 'username' => $username, 'password' => $password, 'dbname' => $dbname, 'profiler' => true, 'adapterNamespace' => 'My_Db_Adapter' ); //in the future I may use load from Zend_Config or something $db = Zend_Db::factory('Pdo_Mysql', $db_config); } catch (Exception $e) { throw $e; } This works fine, and I think its fairly straight forward. One problem I have is related to the exceptions, but that's a different post I guess. Then I want to come down and make some queries: <?php $sql = " SELECT name , alpha FROM countries WHERE id < :max_id AND alpha LIKE :alpha"; $stmt = $db->prepare($sql); $stmt->bindValue(':max_id', 5, PDO::PARAM_INT); $stmt->bindValue(':alpha', 'A%'); $stmt->execute(); But this is where I get mixed up as to what I should be doing. Zend_Db::execute() will return false when the query has an error (right?), but it will also throw an exception. Exceptions override a return, so I have to put a try {} catch() {} around every query I make?? Without implementing a Table Data Gateway or other data access pattern, is there a "better" way to use this class?
  11. 1) Wordwrap() does not truncate the string, it merely makes it wrap after X characters. If you want to truncate the description, use substr() 2) You will get a product description for each product since you are looping through all of your products 3) Removing old/unused code, irrelevant code and intending your code can make understanding your code a lot easier for those trying to help you.
  12. I always hate people who ignore the OP's question and offer a different solution, but I have to be "that guy". Instead of adding of this complexity with changing global variables for the sake of case-insensitivity, why not just use the appropriate error handler to do this for you? On your 404 page, you can try and see if the the lowercase version of the page exists. If it does, use a 301 redirect to send the user to that page. This has an added SEO benefit, and it separates the logic. If I'm missing the reasoning for this plugin, just ignore me.
  13. what if the person is using /me in more than one spot -- perhaps explaining how to use /me: [/me things that you do an emote you simply say "/me emote"]
  14. The way I usually handle forms, is to have them submit to themselves. Include all of the processing and validation of your form above the form only if the form has been submitted. If there are any errors, show the form again and list the errors. If there were no errors, hide the form, send the e-mail and display a confirmation message.
  15. Why can't your artist class create its own instance of the db? Use a singleton pattern if you are afraid of multiple connections, but why should one class have to share with another? What if your artist_control class changes completely to a different database type? My thought would be to create layers, and don't make them dependent on each other.
×
×
  • 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.