Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Yes - <script type="text/javascript"> function add_field(){ var max = 4; // total number of file fields var cont = document.getElementById('addhere'); // refer to the div var numfields = cont.getElementsByTagName("input").length; // get number of input fields in the div if(numfields < max){ // create a div element var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('fieldtpl').innerHTML; // append to div, so that template data becomes part of document document.getElementById('addhere').appendChild(div1); } } </script> <form method="post" action="formaction.php" enctype="multipart/form-data" > <div id="addhere"> <input type="file" name="upload[]" value="" size="50" onchange="add_field();" > </div> <input type="submit"> </form> <!-- Template. This whole data will be added directly to working div above --> <div id="fieldtpl" style="display:none"> <input type="file" name="upload[]" value="" size="50" onchange="add_field();" > </div>
  2. This HTML DOM parser is very easy to use for this type of task - http://sourceforge.net/projects/simplehtmldom/
  3. Your title implies that the code you posted is contained within a user-written function? Is that so and if so, please post the whole function definition and an example of how you are calling it.
  4. Yes, try it and observe if it does what you expect. That's how most learning takes place.
  5. error_reporting and display_errors are two php.ini settings.
  6. You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that problems like Pikachu2000 pointed out would be, well, pointed out to you. There would have been an error at the mysql_fetch_array() statement due to the fact that you are not passing it a result resource from a mysql_query() statement.
  7. There's a sticky post for this commonly occurring problem - http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Based on the line number (1) where the output is occurring, you likely have a file saved as a UTF-8 file with the BOM characters. You would need to save the file without the BOM or save it as an ANSI file.
  8. You need to get and read through a php book or a comprehensive php tutorial. You are asking how to do the basics that the php language can do and exptect a comprehensive answer in a couple of hundred of words that would be written in a reply in a forum post. Attempting to learn a programming language that way will leave you with huge gaps. See this link for examples of writing php functions - http://w3schools.com/php/php_functions.asp
  9. I've got to ask, what problem did you have when you tried it? Because you do exactly what you described - main file - <?php include 'functions.php'; ... $var = 'abc'; echo my_function1($var); // call a function that is defined in functions.php and echo the result it returned ?> functions.php <?php function my_function1($var){ // do some processing on the parameter $var return $result; // return the result } ?>
  10. The specific forum sections where that notation is posted are what it applies to. That specific forum section is not a place to ask for programming help.
  11. Do you have a specific example of what you are trying to accomplish? Php include files are typically used to include php code and content (settings, function definitions, class definitions, templates...) that are then used by the main php code on a page.
  12. A bit of advice when validating user supplied values. Don't lump together multiple tests and output a combined error message. You will never know which condition in the validation failed. Knowing which validation condition failed is the first step in finding the problem. Also, it is usually a good idea to display the value that was being used in the test as part of the error message so that the visitor can see what they supplied that your code used to determine if something was invalid. An empty $_FILES["rom"] will be due to one specific problem/setting. $_FILES['rom']['error'] not equal to zero has about 8 different possible reasons, some of which are under your control on the server/settings and some that are due to the visitor. $ext == "zip" is a separate problem (what if the visitor thinks .gz is a valid zip file extension.) $_FILES["rom"]["type"] == "application/zip" is a separate problem (what if the browser being used sends a different but valid value?) $_FILES["rom"]["size"] < 2500000 is yet a separate problem and you would want to tell the visitor that the only problem was that the file was larger than allowed.
  13. What exact problem, error, or specific question did you have about doing this? Just posting code without a statement of what problem, error, or other symptom it exhibits is pointless because without complete access to your development system or server we cannot execute your code and necessarily get the same result that you did. We must rely solely on the information that you supply in your posts. This forum is for help with problems, errors, or questions with php code that you have written, keeping in mind that in the few hundred words that will be in a typical reply that no one can possibly convey enough information to help you write a complete application.
  14. Could you also bother to provide some background information - 1) Has this code ever worked correctly? 2) What is the pagination class? Either provide a link to the author's web site so that someone could download it or post the source code for it. Also, have you modified the source code for it in any way? 3) Is the output (the <img> and <a href ...>) surrounding the double output correct (a single copy of it) or is doubled as well? 4) Have you checked directly in your database what your data is, so that you know that you don't have double data that would produce the double output? 5) Is this code being included into another file so that the possibility exists that it is being included twice or it is in some outer main loop and so produces the same output twice? Frankly, you haven't provided much actual information to use to help you with your problem
  15. Your code is using two different mysqli connection instance names, which ProjectFear pointed out back on August 01 and asked you which was correct. To which you replied: "It's $connect." Is there some reason you didn't change $connection to $connect in your code?
  16. If you use a html array, you don't need to keep track of how many fields there are - http://www.php.net/manual/en/faq.html.php#faq.html.arrays
  17. There's no time based selection in either query...
  18. Are you testing the value (TRUE/FALSE) that $stmt->execute(); returns so that you know if the query is being executed or is producing an error? You can also use $stmt->error to find out what error is occurring. Beyond that it would take seeing your code to be able to help you.
  19. There's are reason that the md5 is a 128bit (16 byte/32 hex character) checksum, to provide uniqueness. Using a smaller number of digits (your proposed hex triplet) would be down-right insecure because of the significantly fewer combinations that would need to be tested to find a source value that matches the same hex triplet. This is simply a bad idea.
  20. LOL, even the first 'working' link has 19 Errors, 9 warning(s) using the w3.org validator.
  21. You are also setting the name="..." of the hidden field to the randomly generated key. I suspect that you wanted to set the value="..." to the randomly generated key and wanted to set the name="..." to something that you would then use in your form processing code. Edit: Once you correct the mechanics of what you are doing, you will discover that your query must define the auto-increment column as a key. Use mysqli_error($dbc) to find out what errors your query generates.
  22. Where are you setting the variable $key at in your form processing code? Also, it would not be secure to pass such a piece of information through a hidden form field AND dynamically creating a bunch of randomly named tables creates a data management nightmare because you will spend more time keeping track of the tables and their names than you will spend actually querying the information in those tables. You should use 1 (one) table to hold all the same type information and have a column that distinguishes who/what each piece of information in that single table belongs to.
  23. When you have a list of possible values, it is better to put them into an array and use in_array to test if your value is anyone of the permitted values.
  24. If this was a real application, you would set it up as a credit/debit account. You would enter each transaction that affects the current account balance (which happens to be an expire date) as a separate row. This would give you a record of when the account was started, any payments, and any other adjustments to the balance, along with who caused those transactions.
  25. I edited my post above with a working query.
×
×
  • 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.