Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Learn to read code as well. Pick something that interests you and find existing applications for it. Download them and study them, and then make your own based on the ideas you find.
  2. You can use rawurlencode and rawurldecode to do everything for you.
  3. No, $GLOBALS is a big array which holds all the other superglobal arrays, plus anything else you want to be global. Go ahead and run this code: echo '<pre>' . print_r($GLOBALS, true) . '</pre>'; after submitting a form, using a cookie, using querystrings, etc.
  4. It depends how in-depth you want to get. If you want it to be really simple you can differentiate the live site from the development ("beta") site using two virtual hosts under Apache. You could use a subdomain (like beta.example.com) to access the development portion. You could then use version control to push updates to the live site. On the other end of spectrum it is common to have multiple servers for the whole process. Typically there is two separate servers: a development server, and the live production server. Sometimes a staging server is thrown in the middle as well. Note that you don't necessarily need three entire servers for this; you could run all of this off of one dedicated server or VPS. However, ideally, the production server should be a separate entity; that way you can fiddle with things on the server and never worry about bringing down the site. So to break the role of those three types of servers down, it is roughly like this: - Development server: all of the development occurs here, from start to finish and anything in between. - Staging server: this server should match the production server as closely as possible. Its purpose is to test the site out as if it were the production site. Most likely the development server will have a more development-friendly setup - more packages, more extensions, more bleeding-edge software versions, etc - so therefore what works on the development server might not actually work on the production server, and you don't want to push an update that breaks the production server because that just makes a big mess. - Production server: this is the server running the live website. You should avoid touching this server as much as you possibly can, because the last thing you want to do is break the live site. That means absolutely no untested changes or direct file modification. As with the first setup, it is good practice to use version control to push updates to the live production server. This way, even with all of the precautions if an update happens to break something you can quickly and easily revert it - plus there are other benefits like logs and such. Hope that helps.
  5. Yeah, that was one of the quirky things about doing it this way. mysqli_stmt::bind_param only accepts parameters passed by reference for whatever reason. Add this code right before // add the types to the beginning of the parameters array array_unshift($parameters, $types); $parameters_ref = array(); foreach(array_keys($parameters) as $key) { $parameters_ref[$key] = &$parameters[$key]; } Also you are setting the $parameters array incorrectly. Look carefully at the syntax of mine vs yours.
  6. Honestly, I'm not really sure the purpose of that function. I've never worked in an environment where register_globals was a problem, so I've never had to deal with it. What you mostly need to be aware of is initializing your variables before using them, so that it is not possible to inject them. Really though there is little reason to have to bother with register_globals nowadays. They have to be explicitly turned on, and I'm not sure why anyone would do that. In PHP 5.4.0 register_globals is removed altogether.
  7. No. The function doesn't unset $_POST, $_GET, etc - it unsets $GLOBALS variables which share keys with those superglobal arrays.
  8. $search.'si' needs to become $search, and you need to add si at the end of each pattern in the $search array, IE: after the "#" at the end.
  9. Make $parameters an array not a string: $parameters = array($userid, $one, $null, $lang, $one, $newLink);
  10. There is a much easier solution: turn off register_globals in the php.ini.
  11. Why didn't you use a compression utility like 7Zip or WinRAR to create a split archive? Seems like it would have been easier.
  12. Yeah, I use the PHP CLI a lot too. It's nice for quick things like that. I also have the HackBar Firefox addon which does all kinds of things, like: hashing, encoding/decoding, string manipulation, string generation, etc. I don't use it a ton but it's quite handy when I need a quick MD5 hash or encode/decode base 64 or something.
  13. You could use a GET action to put the form contents into the URL. Or, after processing the POST request you could redirect to the page with the email in the URL. Or, you could forget about the URL and simply process the POST request.
  14. What kind of random proprietary-esque apps have you guys made for yourself or friends/family? I've made two for my girlfriend: one is a simple little finance/budget manager and the other is a card organizer for her Pokemon card collection; which lists all of the cards she currently has (and quantity) and also a wishlist for cards she wants.
  15. $count = 1; while($count < 20) { if ($count == 1 || $count % 4 == 0) { echo $count . ', '; } $count++; } This outputs: 1, 4, 8, 12, 16 Is that right?
  16. I've made quick random scripts to do specific tasks such as calculate the UNIX timestamp of a specific date, convert dates to different formats, hash strings with different methods, etc. But I've never grouped them together into a single reusable entity. However, the idea sounds neat so that will give me something to do this afternoon.
  17. You are still creating the connection on each function call. And this isn't going to solve not using global's, because those variables don't exist in the function scope. What you need to do is this: 1. Create a file called "connect.php" 2. In the file, put this code: <?php $mysqli = @new mysqli('localhost', 'root', 'root', 'dbname'); if ($mysqli->connect_error) { die('Could not establish database connection'); } 3. From now on whenever you need a script to have database access, simply run include 'connect.php'; at the top of the script. The script will then have access to the $mysqli object and you can access the database. 4. For this to work with your function you will either need to make the $mysqli object global or pass it into the function (the recommended way). Something like: function runSomeQuery(mysqli $mysqli) { } 5. Now when you call the function simply pass the object in: <?php include 'connect.php'; // ... runSomeQuery($mysqli); You now have full access to the $mysqli object inside your function. Also, you don't need to (and shouldn't) explicitly close the database connection; PHP will do it for you automatically.
  18. I don't think I understand what you want. Is this it? echo $_POST['inspection'];
  19. Because that code creates a table.
  20. Do you know how to run SQL queries and retrieve data from the database? All you need to do is retrieve the specific user and stick the HomePage into the header().
  21. You can redirect with: header('location:http://example.com'); exit;
  22. A better solution may be to select the previous/next car by its ID and not an arbitrary page number. Your links might look like vehicles.php?vid=40495 for a Mustang and vehicles.php?vid=50694 for a Corvette. Use the ID from the database and make sure the column is a primary key and auto incrementing; that way the ID's will always be unique.
  23. You can use a ternary operator: <a href='edit-page.php?page={$page['pageid']}' " . ($page['status']==0 ? "class='inactive'" : "") . ">{$page['pagename']}</a>
  24. It doesn't work because you are trying to concatenate an array which turns it into a string. You need to remove the ".'si'" from preg_replace() and place it after each pattern.
  25. What do you mean by "big" and "small"? I really can't see how it would make a difference.
×
×
  • 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.