Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. What are you refreshing it with? You could do something like... setInterval(function(){ $('div#something').html('refreshed'); }, 120000);
  2. http://api.jquery.com/load/ You should understand what code does before you blindly copy & paste it.
  3. No, like this $(function() { $("form#form33").submit(function() { $("#dvloader").show(); $(".block1").load("editcalendar.php", function(){ $("#dvloader").hide(); }); return false; }); });
  4. You can use a .htaccess rule to redirect traffic that goes to /sounds. Or, you can use Options -Indexes to make it so if someone browses to /sounds, they won't be able to view the contents of the directory (alternatively you can just stick a blank index.html file in it). However there's not really any way to stop something like HTTrack. If you simply guess the file name you could download it. If you want it so they can only download a file once they buy it, you could hide the files in a directory that isn't accessible to the public (like outside the docroot) and then use PHP to serve the file as a download. See here for how to do that. In this way, users wouldn't be able to see where the files come from. Like I said though, you can't stop people from downloading the files freely if you allow streaming. For example that soundowl site, I can download all the MP3's in mere seconds with no problems.
  5. How are you trying to stream it?
  6. Assuming you are on Windows 7, try turning off UAC (User Account Control). You can also try running cmd as Administrator (Start > type "cmd" > press and hold ctrl+shift, press enter) and then deleting it that way.
  7. If you allow people to stream it, you allow people to save it. You can prevent them from directly accessing the files by using an .htaccess rule on the directory. deny from all Save that code as .htaccess and stick it in the "sounds" directory, and people will no longer be able to navigate to it. However they will still be able to save the files from the stream, but there's nothing you can do about that.
  8. Can you show me what this gives you: echo '<pre>' . print_r($_FILES, true) . '</pre>'; It needs to be run when the form is submitted.
  9. They are exactly as they seem. 0 is an integer. FALSE is a boolean. In PHP, 0 evaluates to FALSE. The ! operator checks to see if a statement is FALSE. Therefore, if something returns 0 (or FALSE), the ! operator will work. function returnsZero() { return 0; } function returnsFalse() { return false; } if (!returnsZero()) { // passed } if (!returnsFalse()) { // passed } if (returnsZero() == 0) { // passed } if (returnsZero() == false) { // passed } if (returnsZero() === 0) { // passed } if (returnsZero() === false) { // did NOT pass } if (returnsFalse() == 0) { // passed } if (returnsFalse() == false) { // passed } if (returnsFalse() === 0) { // did NOT pass } if (returnsFalse() === false) { // passed } Hope that clears it up. Also, as a side note, you can run an interactive PHP shell from the command line by using the commands php -a. Then, you can execute any PHP commands. Therefore you don't even need to create a file, you can test code right there.
  10. Because I have 300+ lines of broken code because everyone tells me to go left and then right and I didn't want to write something from scratch just to test this particular issue, so I was hoping someone would throw me a bone and just say "Yes it'll work" or "No, it doesn't work that way". You don't have to test it in your "300+ lines of broken code", simply create a new file and test it there. It takes far less time and effort than to post a thread and wait for a response. Well I wasn't going to assume that with a Regex. Why not? It is simply a function like any other. False is false, it doesn't matter where it came from.
  11. So what's the error?
  12. What you can do is change the name of your input so that it is an array. So change it to something like this: <input type=\"text\" name=\"item_new_stock_total[" . $row['item_id'] . "]\" style=\"width:20px\"> Now if you look at the $_POST data for "item_new_stock_total", it will be an array and the keys will be the ID of the item you want to update. So you can simply loop through the array and update the rows. $items = $_POST['item_new_stock_total']; foreach($items as $key => $val) { mysql_query("UPDATE stocks SET level = '$val' WHERE ID = '$key'"); }
  13. A better way is to target the form and use the .submit() event.
  14. The div would go in your HTML markup wherever you wanted the loading.gif to show. The rest of it is jQuery (so you will need to have loaded the jQuery library to use that) and goes in the <head> section of your HTML in <script> tags.
  15. I'm not sure I understand. Can you copy & paste the output?
  16. You can update multiple rows with no problem, you can use WHERE ... IN(...). For example, let's say you want to update rows 1, 2, and 3 to have a new stock level of 7. You could do... UPDATE stocks SET level = 7 WHERE ID IN (1,2,3) The problem is, if you want each updated row to have a different stock level, then you need multiple queries. If you wanted row 1 to have a level of 7, row 2 to have a level of 9, and row 3 to have a level of 13, you would have to do this: UPDATE stocks SET level = 7 WHERE ID = 1; UPDATE stocks SET level = 9 WHERE ID = 2; UPDATE stocks SET level = 13 WHERE ID = 3;
  17. That will output the image for the last row returned. So if you return more than one row you still only get one image. If you want to show multiple images you need to loop the result. while($row = mysql_fetch_assoc($result_img)) { echo '<img src="includes/images/' . $row['Van_Image'] . '" />'; }
  18. If you wanted to say, change the new stock level of rows 1 and 3 to "17" then you could do that in one query. If you wanted to change the new stock level of row 1 to "17" and the new stock level of row 3 to "9", you would need two queries.
  19. If you are using the same data for each row you can use WHERE ID IN(1,2,3) to update rows with the ID 1, 2, and 3. If you want different data for each update though, you will have to use multiple queries.
  20. No, it won't echo results. Replace "//Echo the formatted data" with echo '<pre>' . print_r($row, true) . '</pre>';
  21. Generally you create the database in cPanel with the "MySQL Databases" button, and then manage them with phpMyAdmin.
  22. If you spend too much time trying to optimize code before it is written, you are likely wasting time. If you feel your application is too slow afterwards, you can profile it and attempt to pin-point where the slowness is coming from and then you can try to optimize it. Learn how to normalize the database and make sure your queries are efficient (like using joins over sub-selects, not looping queries, not using multiple queries when you could have used a single query, etc).
  23. You would need to separate each set of values with a comma, and then you will insert multiple rows. Also, take the actual INSERT query out of the loop since you only want that to happen once. Your query should look like INSERT INTO orders (column1, column2, column2) VALUES (1,2,3), (4,5,6), (7,8,9)
  24. Wow, all of my problems are solved! I'll never have to post here again, because all I have to do is test my code! Debbie Why would you not test your code? That is the best way to learn programming IMO, trial and error. I probably have ~50 random PHP files floating around my local dev box where I have tested various things. Furthermore if your code is structured properly, even if it is very complex code, it is a lot easier to debug such things as this. For the record, any statement or function that returns true or false can be negated with the ! character. If you look on the PHP manual for preg_match(), you can see its return value: So if there is no match preg_replace() will return 0. Since 0 is evaluated as false in PHP, you can simply negate it with the !. If preg_match() fails due to an error, however, it will return boolean false. Depending on your circumstances you may want to handle both cases. So therefore you could do something like... if (preg_match() === 0) { // no matches } else if (preg_match() === false) { // the match failed due to an error } else { // matches! }
  25. Why not try it and see?
×
×
  • 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.