Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Philip last won the day on May 7 2015

Philip had the most liked content!

About Philip

  • Birthday September 25

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

70,405 profile views

Philip's Achievements

Advanced Member

Advanced Member (4/5)

123.5m

Reputation

  1. And I could say I'm a veterinarian because I have a dog.
  2. It's almost as bad as the real thing. *Philip runs
  3. The following scenarios are what I consider code completion (all of which, I hate): Start typing "$foo" and it finishes it with "bar", resulting in "$foobar" Type a quote or start of like an html attribute and it puts in the closing quote e.g. type "<a href" and it finishes it to "<a href=''>"- this by far is the most annoying one IMO Type "<div>" and it includes a "</div>"
  4. I must be the only one that hates code completion.
  5. mysql* expects parameter 1 to be resource, boolean given This means your query failed, for some reason or another. Remove any error suppressing (@), make sure you have error displaying enabled, and output mysqli_error to see specific information about your error!
  6. Where oh where did my debugger go...

  7. I use MySQL workbench, mainly on windows. It's not the best that's for sure. I'm interested in seeing other options as well.
  8. PHP kept crashing on preg_match* on large strings, why? This is actually one I kept running into recently... There is a limit on the amount of recursions that PHP will do. You're likely running into this limit and should either up the limit or found a different way to go about your problem.
  9. When shouldn't I use regex? It may be cool and hip to be a "regex guru" (it is!). And regex may be powerful and sexy (it is!). But more often than not, you don't really need regex to solve your coding dilemma. In reality, regex is almost always either too powerful or not powerful enough for the job. It has an extremely small set of circumstances where it's the best tool for the job. So, before you try to use regex, ask yourself if you really need it. A good rule of thumb is to assume you don't need regex, and turn to it when you are certain that no other option exists. Too powerful There are many string and substring functions that will handle things much more efficiently than regex. For example: Want to know if the value has only numbers or letters or alphanumeric etc? Use one of the ctype functions Want to know if "foobar" is in "this is the foobar moment in time!" Use strpos or stripos Want to split up a string into an array by a known delimiter, e.g. a comma or pipe? Use explode Want to trim whitespace or other known chars from beginning and/or end? Use trim or ltrim or rtrim Want to replace or strip a known value from a string? Use str_replace Not powerful enough On the other end of that spectrum, regex sometimes isn't powerful enough for the job. The most common example of when regex falls short is that a lot of people turn to regex as a solution for trying to parse HTML/XML content. Sometimes regex may work out for you, depending on what you are trying to accomplish. But most of the time, regex is not what you should be using for HTML/XML manipulation. Regex has come a long way over the years, but at its core, regex is for parsing regular grammar, but html/xml is context-free grammar. If you are looking to parse html/xml content, you should use a DOM parser. There are several libraries that are by default included with php, such as DOM or SimpleXML, as well as a lot of great 3rd party libraries, such as Simple HTML DOM or phpQuery. Also, if you are using a php framework, there's a good chance it already has one or more of these (or its own) included and wrapped in your framework syntax.
  10. I need help with some regex, how should I post? Regex can be a tricky subject, especially when you need some help with it. Here is the bare minimum on what you should include with your post: Describe your problem Give lots of sample input data Give the matching expected data for the input data you gave (this is important!) If you already have some code (which you should!), show us the code and tell us what you think is going wrong with it We assume its a PHP regex related as this is PHP Freaks, but you still need to specify (if not obvious) if you are talking about POSIX (ereg) or PCRE (preg) flavor.
  11. Should I salt my user's passwords, and why? YES! Salting makes it much harder to crack if an attacker is using a rainbow table.
  12. What is the point of MD5 / SHA1 / SHA256 / etc.? You should always, always, be hashing your users passwords. Note the word hashing and not encrypting (difference: hashing is one way and cannot be reversed.) These functions will hash a string with varying levels of security. The more processing power it takes (SHA512 will take more than MD5), the more secure it is likely to be. It should be noted that MD5 really shouldn't be used for password hashing, and instead you should be using the crypt function with a more secure algorthym (like Blowfish).
  13. I'm getting a "headers already sent error". What does that mean? When you get this error, it means that you've already started to send content to the user and you're trying to send other header information that should be at the beginning of the request. Common situations include outputting content and trying to redirect the user later, or outputting content and then trying to set cookies. This works in javascript, because it is clientside. This doesn't work with php or other server-side languages, because cookies and redirects are sent in the header of a response, and the header goes at the beginning of the response, before content. It's like trying to dial a number to call your friend when you already called them and are in the middle of talking to them. The only thing that happens is your friend starts wondering why you're pressing random numbers. IOW the browser will not do anything with headers sent after content has already started being sent. So for example, if you try and set a cookie after outputting content, it's not going to get set. So php outputs a warning to inform you of this. So, how do you fix it? There are 2 ways; the first and preferred method, you can reorder your script so that you send the vital information (cookies, header redirects, etc.) before you send any content. The second would be to use output buffering. You can also read more about this in one of older, yet still relevant, resource topic.
  14. Call to undefined function "mysql_connect" This means your MySQL PHP library is not loaded. You should check to see if it is loaded by running phpinfo();. If it is not included, you need to check your php.ini configuration or contact your host for more information. It should be noted that mysql_ functions should be replaced with PDO library or the mysqli library.
  15. Can you do / write _________ for me? Sure, we could do it for you. But it is going to cost you, and better suited for the freelance forum. Instead, show us some code that you've tried or ask for guidance on what is the best way to go about something. Otherwise, don't expect anything except for snarky replies! Remember, we are volunteering our time to help you. Help us help you by at least attempting to solve the problem on your own!
×
×
  • 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.