Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. You shouldn't close your connections in-between queries either. PHP has garbage collection built in, you don't need to manage it yourself. Why would you want to close it if you're going to perform another query anyway? You're just going to slow things down.
  2. "theSide" is being parsed as a property, not a variable. In order to use a variable as a property name, you need to define it in the array style syntax: var theSide = 'marginLeft'; var options = {}; options[theSide] = 400; $('#animDiv').animate(options, 400); You can use that syntax for accessing any object's property -- for example: var html = element['innerHTML'];
  3. How did I not know about that website!? You probably never heard of the http://thetoolbox.cc ? No!! Got it book marked now though
  4. It's hard to give suggestions for improvement without knowing what's causing the delay. Option 1 sounds like the right approach, but I can't see why it would take five minutes to load. I'm guessing he's first selecting all the rows that are within radius, then performing an additional query for each returned row to find out which have a "record"? That would explain such insane load times, but it's a little concerning that the programmer you sound like you might be paying isn't capable of writing joins. Can you shed any more light on the implementation, or get your programmer to talk to us?
  5. You can use a regular expression: $html = preg_replace('/<table[^>]*>.*?<\/table>/s', '', $html); That will match any opening table tag with or without attributes, up until the first found closing table tag, and then replace it all with nothing. Also preg_replace() will replace all occurences unless you tell it not to, using the 4th parameter.
  6. Although you are updating a column: updated_on=NOW()
  7. Here's a rough example: $sql = " insert into tableName ( col1, col2 ) values ( ?, ? ) "; $statement = $dbo->prepare($sql); foreach ($datasets as $dataset) { $statement->execute(array( $dataset['col1'], $dataset['col2'] )); } As you can see, the $statement object is re-used/re-executed for each dataset.
  8. No, a prepared statement is essentially a string of SQL (a statement) with place holders for dynamic data. That's then sent to the database to be prepared, which is essentially the database working out how to process it. You can then bind data into the prepared statement and execute it. After you can bind different data into the statement and execute it again. Each time the statement is executed the database already has the execution plan cached, so it re-uses it, taking out a substantial amount of the processing required and speeding up the query. If you only execute it a few times you probably won't notice the difference, but for an "undetermined" number of inserts it's definitely the best approach. Each extension has it's own syntax but they're roughly similar.
  9. Use prepared statements. Databases cache the execution plan of prepared statements for the length of the connection (the request, in the web world), so re-executing the same statement in a loop with different values is perfectly efficient.
  10. Is there a specific reason you want to look for 5.1.1, functionality wise? Unless this is for some cool magic trick to tell the user what they already know (, or stats, though I don't know why you would be doing anything related to that client-side,) you'd be much better off using "feature detection" techniques, as opposed to parsing the user agent. What I mean by that is don't check what device they're on, check if a certain function/object/property/feature exists.
  11. How did I not know about that website!? @Stefany93 I would drop the date/time in the header, the use of comic sans (!important), and also the "created on" date. Everybody has a clock visible whatever operating system, so unless there's some legal requirement to have it then there's no point. Printing the date you created the website is fine for now, but in a year or two (assuming you kept your current design), it's going to make the website seem old. You want to give a modern, up to date impression. The text on the home page sounds more like a CV's "personal qualities" description. People won't be going to your website to primarily find out about your work ethic, it's about what you can do. Sure you want to promote yourself in that way, but not there. Reserve that space for a strong, easy to understand overview of your abilities. Also the text on your 'contact us' page sounds a little unfriendly. I would reword it to so that it's made clear you can speak Bulgarian, but don't mention anything about not responding to people. Just don't respond to them? If they're going to contact an English-written website in Japanese they should probably expect to not get a reply. Lastly I don't know why you would ever want to put your blog offline, with a message that just says..? "OFFLINE!!!"
  12. The user agent exposes the version as say "5_1_1". How exactly do you want to fit this into your current script? Only detect 5.1.1, or detect 5 then 5.1.1?
  13. "YYYY-MM-DD" is the correct format for T-SQL dates.
  14. Nobody is saying you're imaging it, but given the inability to reproduce the problem it's probably such an edge case that it's not worth worrying about. You say you encountered it before, so you should be able to reproduce it? You can't ask a bunch of devs to help you fix an issue you can't explain or give steps to reproduce.
  15. Judging by the home page, I find it difficult to navigate. Where is the main navigation? Categories? Can't really go any further because most of the links are returning 404s.
  16. Which did you download? The development version is 4 lines (including a comment) and minified to keep it light. The development version is about 9,400 lines long and full of comments. Want to post the first few lines? Either way though, jQuery is light-weight.
  17. And to attract the kind of users you're looking to protect against, you need a community. Those arguments don't really hold up. You don't need to moderate comments to prevent SPAM, and you would assume your professional readers aren't going to post comments you would consider inappropriate, or upload naked photos of themselves. Then I would stop worrying about trivial issues like this, until you actually have a reason to, and concentrate on your content. That's what makes a site!
  18. Personally, I really hate it when websites/services over-police their content. The PS3 is perhaps the perfect example of this; they star out any string that's remotely offensive to anyone in messages. It's ridiculous. It doesn't even match whole words, you can be writing a genuine message but because it finds "ass" in "bass", it'll star it out. Then you have to rewrite it, creatively replacing letters to get around the filter. My point being I'm a grown man, I'm allowed to throw the odd F-bomb amongst friends, and if I find something offensive I can handle it. I don't need a website to protect me. With the PS3 however I'm kind of tied to it; I'd have to re-invest in a new console to go with a competitor. A website is completely different though, I could easily go somewhere else if I'm having daft restrictions forced on me like a child. Obviously in contrast to that you have to protect your website's image. You don't want it riddled with filth, if filth-seekers aren't your target audience. If that is the case though, you can't punish those genuine users by making your service slow and unusable, on the off chance someone may upload something unsuitable. Just allow the community to report to you what they think is inappropriate.
  19. You can include this meta tag to stop Chrome offering to translate the web page: <meta name="google" value="notranslate"> The translation API however isn't free, only the drop-down widget is. I'm not sure about Google Voice, from a quick search it doesn't look like there's an API at all.
  20. Both can handle multi-dimensional arrays, but I don't see much reason to manually loop through the array, when you can use a native function to do it for you.
  21. The key was left out because it isn't needed. "&" means loop through by reference. Instead of putting a copy of each array item into the variable, the variable is just a reference. That means you can modify the original array by just changing $value. The following would produce the same result: foreach ($array as $key => $value) { $array[$key] = htmlentities($value); } foreach ($array as &$value) { $value = htmlentities($value); } Worth noting though that after the second method, $value would still exist as a reference. In this situation it's not a problem because nothing happens afterwards (except the array is returned to the parent caller), but if anything else did happen after within that function you should always unset the reference.
  22. Which bit of foreach($str as &$v) do you not understand exactly? I would suggest reading the manual for foreach loops.
  23. I much prefer Psycho's version. It's simple really; if an array is passed to entities() it will array_walk() through it, and pass back the escaped array. If any item in that array happens to also be an array, the same happens but a level deeper; the escaped array is passed back, which is then passed back as part of it's parent. That can happen infinite levels, essentially. Eek! There's a reason constants are used -- to prevent future change breaking things! Also for readability, for anyone else who doesn't happen to know that ENT_QUOTES == 3. Given the manual doesn't generally document constant values either, it can be a pain in the arse to work out these kind of things.
  24. Why not use an absolute file path to include it? Or you could use $_SERVER['DOCUMENT_ROOT'] to create a relative path?
  25. Their username is stored in $_SESSION['username']. I'm assuming you have session_start() in your script and have verified they're logged in before you're trying to display it?
×
×
  • 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.