Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. AFAIK you have to begin and end the regexp with matching chars, in this case I use forward slashes. I believe the characters you use are arbitrary, for example I think this is just as valid (though I've never tried it): $regexp = '@^[A-Za-z0-9.!?,"]+$@'; I believe whichever char you use needs to be escaped within the regexp though. For example, if I want to match two forward slashes, I can do this: /\/\// or I can do this: @//@ Notice how in the second example I didn't have to escape the forward slashes with a backslash. I'm going from memory here so I could be mistaken. Someone else might be able to give a better or more concrete answer.
  2. [A-Za-z0-9.!?,"] ^ That only matches a single character. Append a + to match one or more characters. [A-Za-z0-9.!?,"]+ ^ Matches one or more. Prefix a caret and append a dollar sign to specify the beginning and end of the string. ^[A-Za-z0-9.!?,"]+$ ^ Should be closer to what you want. I normally use preg_match() and I'm not sure if it behaves any differently than ereg. With preg_match() it'd be closer to: $regexp = '/^[A-Za-z0-9.!?,"]+$/'; if(!preg_match($regexp, $stringToTest)){ echo 'error'; }
  3. What do you mean "what do I put here?" You put the rest of your CREATE TABLE statement.
  4. Rather than trying to think of all the characters that are invalid (i.e. a blacklist), it is usually easier to check for only the characters that are valid (i.e. a whitelist).
  5. A stupid example, but... SELECT `users`.`id` FROM `users` INNER JOIN `users` ON `users`.`id`=`users`.`id` Given the SELECT above, which `users` table do we mean in the following parts? SELECT `users`.`id` ON `users`.`id`=`users`.`id` The answer is we don't know. Since we are joining the table to itself there is an ambiguity. To solve this we alias the table. SELECT a.`id` FROM `users` a INNER JOIN `users` b ON a.`id`=b.`id` Going back to Barand's query above: INNER JOIN (SELECT id, max(date1) as latest FROM the_table GROUP BY id) He is using a nested query to create what behaves as a temporary table. But how can you refer to the records returned from the nested SELECT? You can't until you alias the nested result, which he did with as b. To avoid confusion, it is not the alias that creates the temporary table. The nested query creates the temporary table.
  6. This is entirely arbitrary and there is no right answer. The best thing you can do is download some existing frameworks and see how they organize things. After that you need to try and come up with something on your own and after a few hundred iterations you'll eventually develop an organization that works for you.
  7. The following are equivalent, see if you can spot the pattern: SELECT `users`.`id`, `users`.`password` FROM `users` SELECT u.`id`, u.`password` FROM `users` u (No, it does not create a temporary table.)
  8. If you want to develop PC or console games you'll need to know C and C++ very well. It also helps to specialize in something like graphics, sound, networking, permanent storage, etc. Also, from my understanding, be ready to work long hours because the game industry is particularly brutal. I initially wanted to be a game developer but it was hard to get in the door so I landed in web development. I'm happy where I am because the environment is relaxed and the hours are regular and dependable. In 2 years I've never once had to call home and say, "I'm going to be a little late, there is a problem that has to be fixed by tomorrow." I don't think you could say that in game development. Oh, one more quick thought, a great way these days to get yourself noticed is with a mod to a current game.
  9. DNS updates can take as long as 72 hours to propagate around the internet.
  10. It's Javascript. It places the cursor in a field on the page.
  11. I'm with haku. You can develop everything to work without Javascript first and then add it in later. Then you get the best of both worlds. To take it a step further, Javascript should not be embedded in your markup either. This gets you a slap on the wrist in my book: <a href="#" onclick="alert('hi');">click</a>
  12. Change your query to get rid of the duplicates for you. SELECT id, MAX(date_1) AS `date_1`, date_2 FROM `the_table` WHERE ... GROUP BY id
  13. You'll need to use a combination of PHP and Javascript to accomplish what you want. But yes it is entirely possible. (It's entirely possible with just PHP and some simple CSS but the UI won't be as slick.)
  14. I know a guy that works for a game company located near San Francisco, though I'm not sure which one. I worked as a contract programmer for a small game company around 2000 or 2001. What are you looking to find out?
  15. It's probably something like: if( !empty($msg) ){ } Some of the PHP functions will consider certain values empty even when we don't want them to, such as '0'. I'm going from memory here so I could be mistaken.
  16. Not quite and I'm not so tired right now so I can give you a bit more of an explanation. ValidateForm() will go through and check all of your validation conditions. Each time it finds one that fails you add an item to the $errors array. Therefore, $errors is an array with keys: fname_invalid, lname_invalid, email_invalid, etc. Each one of these indexes is the error message you wish to display. This allows you in ShowForm() to do something simple like: echo '<p>We found the following errors:</p>' . '<ul><li>' . implode('</li><li>', $errors) // this line expands the $errors array . '</li></ul>'; Now if you want to eliminate the global variable, you can just have ValidateForm() return a local variable $errors and pass this into your ShowForm() equivalent as a single argument.
  17. I don't have the patience to sort through all that code. Somewhere in there you have a check that basically says: "If the incoming message is not empty, then do this" Can you find and paste that code?
  18. Follow the link in my signature to Part I for PHP forms; it will give you a pretty good outline for building PHP forms. I do use a global variable in the example to make it slightly more simple; I'm working on Part II where the global is eliminated and a few other things are cleaned up. Globals are bad for a number of reasons, the most significant of which is they create unmaintainable code in large programs. What will happen is you will have a large number of global variables and be unable to tell from where they are being set and / or changed. You will create a global named $errors in one script and use it again in another, not meaning to overwrite the existing one. Program bugs like this can be very difficult to debug. The best solution to access data in a function is to pass it in as a parameter (or argument). This means your functions can only use data given to them and can't inadvertently modify data in another part of the program. The only global variables in PHP you can use safely are $_POST, $_GET, $_COOKIE (or $_COOKIES), $_SESSION, $_SERVER, and any other non-deprecated auto-globals I forgot to mention.
  19. Save the image on the hard drive. Store it's path and meta information in the database. When you need to edit it open the image on the hard drive and use the GD library.
  20. You must be performing a check to determine if the message is worth posting. What check are you using?
  21. You need to read up on variable scope. http://us3.php.net/variables.scope Once you understand what is happening, I'll warn you about using the keyword global. Don't use it. Global variables are bad. Pass the variable into your function instead.
  22. Barand's solution will work for what you want to do. SELECT GROUP_CONCAT(date SEPARATOR ', ') as date_list FROM example_table GROUP BY id
  23. It was removed when the forums were upgraded, not sure when it's coming back.
  24. It can be really hard to debug server side scripts invoked via XHR. The best thing to do is create a test script that calls the code invoked via XHR to make sure it is working correctly. Then use it for your actual XHR requests.
  25. It sounds like you are about to make a gigantic unmaintainable mess of your code. Chances are some reorganization will help you a lot more. Why don't you paste some sample code and describe what you'd like to do.
×
×
  • 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.