Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. I'm glad you went with the second suggestion. I also agree that it's a better solution. Also, you are right that (while extremely slim) a query could go between your other two queries and muck things up. If you were to go that route, which I wouldn't recommend anyway, then you'd probably want to use a transaction to ensure the integrity of the data. Anyway, glad you got what you wanted.
  2. The following allows you to get the auto-increment value of a DB table: http://stackoverflow.com/questions/15821532/get-current-auto-increment-value-for-any-table You could use that query as a subquery in your INSERT to set the publicname field. With that said though, even though you're only executing one query by doing that, because the query has a subquery, you're still essentially executing two. Unless you need to index and heavily search on the publicname field, I think a better idea is to dynamically generate the publicname value on SELECT, and never bother with it on INSERT. You could either use MySQL's CONCAT function to create it on the DB side, or you could easily create the value on the PHP side. It's up to you.
  3. I think it depends on how you're trying to hack a password. If you're going through a normal web interface, then you would never enter a hash directly. You would enter a regular password, and that would then be turn into a hash and compared to a hash in the DB on the back-end. If, somehow, you got access to a whole DB of hashed passwords, then yes, you could potentially do what you suggested, which is akin to a dictionary attack, which is a popular technique for trying to crack passwords. Anyway, I think (and I could be wrong) that a lot of password hashing algorithms these days take the time into account when hashing the password, and somewhere within the hash itself is a key hidden to retrieve that time so that at any later time, you can check that the hash you're creating for confirmation purposes matches the original hash when it should. Honestly, I don't know though. The whole password hashing industry is an incredibly complex one with a deep history that's probably worth reading about.
  4. Hello, and welcome to the forums. I like your user name. I can't think of any use cases where you would want to insert unchecked checkboxes into the DB, so if you don't mind me asking, why do you want to do that? Thanks.
  5. If the PHP code was all printing out directly, then either: You were not running the script through localhost, or More likely, you were running the PHP script as an HTML file. There is no other explanation. Either way, if it works now and you know what you did wrong, don't sweat it.
  6. Your question is a bit unclear, but assuming my understanding is correct, what you want to do is not possible, regardless of the programming language you use. Probably the closest you can get is to force the browser to download the file, and then let the user open that file directly using either the default suggested program or a program of their choosing. I think it's important to realize that the web as a whole intentionally does not give websites access to a user's local file system and the programs installed there, as that could lead to huge security concerns.
  7. My guess would be that your form element doesn't have the method="post" attribute, and as a result, the form is being submitted via the GET method, thus causing the $_POST superglobal to not be populated, thus leading to those errors you stated. Try adding the following code right above where you are attempting to set those four PHP variables to either confirm or deny my suspicions: echo '<pre>'; print_r($_GET); print_r($_POST); echo '</pre>'; You can also easily confirm if the GET method is being used by seeing if all the form data is placed in the URL bar as URL parameters upon form submission.
  8. You are running your files through localhost, and not just opening them in the browser, correct?
  9. Make a new PHP file called test.php and then add the following to the file and try to run it: <?php php_info(); If that works, then the installation is fine. It seems to me that you're trying to run an HTML file as a PHP file, but I could be wrong. Please let us know what you find. Thanks.
  10. Whitespace doesn't matter for some things. For strings, whitespace always matters.
  11. Very likely, those errors are a result of your query being invalid. Try running the query directly on your DB to debug it.
  12. Any decent JS/DOM reference should have all of that info. The following site, while a bit old, is decent: http://www.javascriptkit.com/ Also, just to clarify, the search method works on the value property because the value property is a string. That's the key. The search method can only be called on strings, and DOM objects are not strings (because they're objects... duh!).
  13. Basically, document.getElementById is a DOM object, not a string. The best way to verify this is to put the following lines of code after your three var declarations in calculate: console.log(sentence); console.log(keyword); You'll see that the console will show you DOM elements, not the strings entered for those inputs. Now, if you either loop through the DOM object properties (or more simply, check an online resource), you'll see that all DOM objects that represent input elements have a property called value. Thus, by typing DOM-object.value, you can access the value actually entered for that DOM element. That make sense?
  14. Elizabeth, welcome to the forums. You're more than welcome to post here, but please do not advertise like that. Thanks.
  15. On line 9 of stringTest.js, change sentence.search(keyword) to sentence.value.search(keyword.value), and then on line 10, change keyword to keyword.value.
  16. I overlooked the obvious error before. sentence is a DOM element, not a string. Run search on sentence.value, not sentence.
  17. Likely the search method is not a valid method because sentence is not a valid string (I'm guessing). Could you please provide your HTML markup as well? Thanks.
  18. Here's a good explanation: http://stackoverflow.com/questions/2704314/multiple-file-upload-in-php
  19. To download just the PDF, use the readfile function on just the PDF file, not the HTML file. There's no way I know of just displaying the cover of the PDF beyond taking a screenshot of the PDF and displaying that, but really, I think it's pretty much a moot point, since all browsers these days can natively display PDF files in their entirety. Edit: You could create a second copy of the PDF that is just the cover page and link to that as well.
  20. You can store binaries (i.e., the actual PDF in the DB), but it's generally not preferable. You're better to store just the path to the PDF in the DB. With that path, you can very easily link to any PDF, which is all you need for viewing and downloading the PDF. That answer your question?
  21. Basically, you never want to assume anything in programming. In this case, you're ensuring that comments is not null (i.e., it's a valid DOM element) and that it has the value property (i.e., it's a valid form input element). If you assume both of those things without checking, then your code would through an error on the comments.value.indexOf part of the if statement whenever comments was not set to a DOM input element. That make sense?
  22. Very likely your query is invalid, thus causing that error down the line. I would execute your query directly on the DB and make sure it's okay. Also try echoing the query string out to the screen to make sure it's what you're expecting.
  23. Very likely /home/content/68/10520168/ is your server root, meaning that if you use an FTP client to log in to your server, you will be in the /home/content/68/10520168/ directory, and there will be a directory called html in that directory. That html directory is your web root, meaning that anything outside that directory is not accessible via the web. That make sense?
  24. To answer your other question, I have heard of companies that make software packages for easily putting together e-commerce sites and shopping carts, though sadly, I cannot point you in a particular direction. Perhaps Larry or someone else on here can offer more guidance.
×
×
  • Create New...