Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. What are the various "content loop" numbers? Sounds like you basically just want a four-column layout, except using Bootstrap tables instead of actual tables. (Speaking of, are you sure you should not be using an actual table?) column = 1 loop { if column = 1 then output column start output cell column = column % 4 + 1 if column = 1 then output column end } // normally you would close out incomplete rows here // no need with bootstrap if column != 1 then output column end $column = 1; foreach (/* whatever */) { if ($column == 1) { echo "<div class='row'>"; } echo "<div class='col-sm-3'>"; // whatever echo "</div>"; $column = ($column % 4) + 1; if ($column == 1) { echo "</div>"; } } if ($column != 1) { echo "</div>"; }But maybe I didn't understand your question. Maybe you want to use two loops at once?
  2. What are you talking about?
  3. How do you expect to get any rows before you've execute()d the query?
  4. prid and prflavour (and the other two) are protected, which means you can't change them in your code like you're trying to do. You need to use methods in the class. For example, 1. Use a getFlavour() method to get the flavor and check that it is "Mango" 2. Use updateQuantity() just like how you have there If your problem is finding out which object in the array is the Mango item then you need a loop like foreach ($_SESSION['cart'] as $prid => $item) { if ($item->getFlavour() == "Mango") { $item->updateQuantity(123); break; // don't need to check the rest of the cart } }What would be nicer than this is if you had a sort of ItemCollection that could do much of this work for you. One class representing an entire cart. Then that class could handle the searching part, and you could call it with code like $_SESSION['cart']->updateFlavourQuantity("Mango", 123);
  5. 1. Can't use header() if there has been any output. 2. The script cannot output anything except for what it does with readfile(). No HTML, no whitespace, nothing. <?php $exe = "Testing/Testprogram.exe"; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"Testprogram.exe\""); header("Content-Length: " . filesize($exe)); readfile($exe); exit;That's all you need.
  6. That's why you don't do it by yourself but hire people who know how to do this kind of stuff. I'd be surprised if you can find somebody online, just some random person you find online, who actually knows what's going on with the systems and isn't subject to an NDA. Another approach is not doing the booking yourself but using a third-party system, like Expedia. You're much more likely to get something working that way than by actually negotiating with hotels yourself. Going that route makes things a lot easier, and as long as you obey whatever restrictions and terms of service come with the system you could do whatever you wanted.
  7. Okay. Can you answer the rest of my questions too?
  8. So the problem is that when you submit the form in Firefox or Safari the $_POST is empty? Also... poop calculator? WTF? :/
  9. Make a PHP script output the file, rather than give the user a direct link to it. Then make sure the .exe isn't actually anywhere that can be accessed directly by the user, if they were to somehow find or guess where it was (this typically means outside of a "public_html" or "www" directory you have). Your PHP script can do whatever it wants in terms of authentication. When it's satisfied, it outputs the file's contents to the browser with a bit of supplemental information. $exe = "/path/to/file.exe"; header("Content-Type: application/octet-stream"); // binary file header("Content-Disposition: attachment; filename=\"installation-file.exe\""); // download as "installation-file.exe" header("Content-Length: " . filesize($exe)); // tells the browser and user how large the file download will be readfile($exe); // dump the file exit;What you cannot do is serve a download and HTML at once. Instead,1. Give the user a page where they would go to download the file. Do authentication here. 2. This page is where you give the instructions. 3. On that page, use a client-side redirect to send them to the PHP script that does the downloading. The browser will see it's a download and keep the previous page open. The client-side redirect looks like <script type="text/javascript"> window.setTimeout(function() { document.location.href = "/path/to/download/script.php"; }, 5000); // 5 seconds </script>If you don't like Javascript for some reason, <meta http-equiv="Refresh" content="5; url=/path/to/download/script.php">in the will also work.
  10. It looks like you have an $imagetest flag you intended to use later but didn't? $file_to_delete will only be set in certain circumstances but your code will try to getimagesize() it regardless.
  11. Passwords never go in cookies. Never ever. Not encrypted, not hashed, not any way whatsoever. Now what are you talking about, putting passwords in cookies? What is this for?
  12. CSV is the right first step. If you only need to show the information there, not do any sophisticated searching or make any modifications, and as long as there isn't "too much" data, then you can keep it as the CSV file and display it using PHP code. Otherwise your best bet is, yes, to import it into a database. That also raises the question of whether the spreadsheet changes and, if so, how often and how you want to deal with updating the database. If you do think the first option is appropriate, consider whether you'll ever possibly want to do more in the future. If there's a chance then you should do the database thing now.
  13. (obligatory disclaimer about getting business/legal/finance advice on the internet) To lower transaction fees, often these kinds of things are done in bulk. Meaning when you take money from the user, you don't immediately transfer it to the (let's just say) hotel. Instead you keep records and then periodically, like monthly, settle accounts. Bookings likely require use of some sort of API so that you can find out about available rooms and provide reservations.
  14. What's the code you're using? What happens when you run it? Exactly what does "can't send any email" mean? Do you get any errors? Is your code even checking for errors?
  15. Use pathinfo to get the extension. Remember that the extension may not be entirely lowercase. You can omit the directory portion of the filename by using basename. Also check that the filename is a file, which will make sure the file exists and block any attempt to delete directories like . or .. (which would fail anyways).
  16. Do the authentication before accepting the file upload, then confirm they're still authenticated when actually accepting the upload. Authentication at the time of an upload isn't a great idea because (a) the user has to wait for the upload before they'll get the authentication dialog, and thus (b) if they fail authentication, such as by mistyping their password, then they have to go through the upload process another time. For the new tab, the simplest thing would be to point the form to a new page (target=_blank) and have the output of the upload script be the "source of the file" or whatever.
  17. 1. What does the error log say about the 500 error? 2. If you use the [R] flag I mentioned, where does your browser get redirected to? If there is a loop then you might not see it and have to look at the server's response headers to find out.
  18. The name is "list[]". Am I missing something?
  19. You shouldn't assign to an on* event handler directly as it only allows you to use one handler per element per event (using that method). Use event registration instead. There are browser differences so it's easier to do with a Javascript framework, but if you want to do it manually then you use element.addEventListener or element.attachEvent. // a quick and simple helper function function registerEventListener(element, event, handler) { // IE9+ and other browsers if (element.addEventListener) { element.addEventListener(event, handler); } // IE<9 else if (element.attachEvent) { element.attachEvent("on" + event, function() { // in here, this != element handler.call(element, window.event); }); } } registerEventListener(document, "keydown", function(e) { // e is already normalized to the event object var key = e.keyCode || e.charCode; // ... });Note that key has the var keyword too. Without it you create/assign properties on the global (ie, window) object, and that creates clutter, and clutter is bad. For the second question, for printable characters, keydown will repeat as long as the key is held down. Which you've discovered. If you want to do something once then you want to do it the first time the keydown event happens, and then reset when the keyup happens. (function() { // separate scope for this variable var once = false; registerEventListener(document, "keydown", function(e) { if (once) return; once = true; // ... }); registerEventListener(document, "keyup", function() { // reset once = false; }); })();That may be a little finicky if you try multiple keys at once.
  20. Backslash. Or use different quotes for the string. 'Ryan O\'neill' "Ryan O'neill"
  21. Is it as simple (in your case) as saying "remove all the whitespace between a > and
  22. How many images will you need? Like a dozen or so, or many more? Will you ever want to change them (either the images or the times) and if so how often?
  23. Caching does not happen by default - only if something on your server told the browser to cache the content. Versioning isn't really that great of a solution, given that there are others which can cause caching to happen the way you want, and more suited for when you don't have control over the server sending the content (like a CDN). What are the response headers for a page on your site that gets cached? Your browser might have something built-in to see them, or you may need an extension. Caching headers include Last-Modified, ETag, Expires, Cache-Control, and Pragma.
  24. There's a newline at the end of the file. How you deal with that is up to you: remove the newline, trim() it off, use a different function than fread() which stops at newlines, use file_get_contents() and avoid the whole file opening thing though you'll still have the newline...
×
×
  • 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.