Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. This is something I have had a play with but can never get quite right. Lets say I have a php script that may take 30 seconds to a few minutes to process, maybe it processes a large number of database records and writes them to a text file or multiple files or alternatively reads in a file and creates a database, tables and imports thousands of records. Normally I would opt to write a command line tool that can just sit there and run, then display a message when it is complete. However in this instance I require the script to run through the browser so what I dont want is for the user to sit there for 5 minutes whilst the process is running viewing a blank screen. Basically I need to display maybe an animated gif or a peice of text notifying the user that the process is running. Maybe the text will change when it gets to certain parts of the process. I know the ob functions are designed for this but its where to fit them in that gets me. So lets say we have an example script (process.php) // display a message to the screen that the process is running print "Please be patient whilst process is running"; // start running the process // ========================= // open file fopen(); // read data from database mysql_query() // loop through records while() { // write to file fwrite(); // display a message to the screen that the record is written - clear all other screen messages print "Written record X to file. Please be patient. X number of records remaining"; } // close file fclose(); // display complete message print "All results written to file. File can now be downloaded from ......"; exit(); Where do the output methods fit in to something like this?
  2. What you are best doing is using temporary tables. 1. Create a temporary table that can store the users email address and a count of how many times it exists. CREATE TEMPORARY TABLE userAddresses SELECT COUNT(id) AS totalAddresses, email FROM users GROUP BY email 2. You can then select from the temp table all the users who have an email address that exists more than once. SELECT email FROM userAddresses WHERE totalAddresses > 1 3. This gives you the offending email addresses that you can then delete from your main table
  3. You have 2 input fields both named 'quote' aswell as the form name!
  4. If you are including the file where the function resides then you should have no problem calling it. i.e. functions.php =========== function helloWorld() { return "Hello World"; } index.php =========== include('functions.php'); print helloWorld();
  5. Using ftp_mkdir . If you are basically making a program that will read directories and files from a source location and transfer them recursively you will need a function (recursive) that can read your source directory then create it at the destination, read files within and transfer them, then move onto the next directory, etc until all folders and files are replicated. Just do some Googling on FTP tutorials for php. Preferably transferring files and folders.
  6. You cannot have a url formatted like: index.php?spela=ligaid=12&serie=2 You could however use: /index/ligaid=12/serie=2 Requires rewrite and use of urldecode()
  7. using ftp_fput
  8. SELECT p.ID, p.TITLE, l.TYPE FROM products p LEFT JOIN linked_products l ON (p.ID = l.PRODUCT_ID AND l.TYPE !='3') ORDER BY p.TITLE ASC
  9. Firstly you need a unique IP address for your website. If you are on a shared hosting account you should be able to request this. If not you need to add a new IP to your dedicated server. You then need to generate a certificate signing request to obtain an SSL cert (CSR) Again shared hosting accounts usually have control panels that can do this. If on a dedicated server use OPEN SSL. http://www.geotrusteurope.com/support/csr/csr_apache.htm Use the CSR to obtain your SSL key from wherever you decide to purchase it. Once you have your key you then need to upload it to your server and update the httpd.conf file for your website. http://www.flatmtn.com/article/setting-ssl-certificates-apache You should then be able to ammend the http:// links in your website to https:// for whatever pages you want secure. i.e. https://yourdomain.com/checkout.php
  10. Use a unique key string within the url to download the file. Store this key in a db along with a timestamp. i.e. http://yourdomain.com/download.php?key=123456789 On the download page - get the timestamp from the db using the key and you can then check whether or not the download has expired. Present the user with a message if the download has expired or kill completely if an invalid key is used.
  11. Wouldnt you be better using a shopping cart model with user accounts to track purchases and downloads? Give a user a 5 day download period or something. If you password protect a directory as soon as somebody gets the username/password it could end up being posted all over the Internet!
  12. If the root directory name does not exist in the $_GET['folderName'] variable then redirect the user to the root directory using a conditional statement.
  13. Private methods can only be called from the internals of the class. Protected methods can only be called from the internals of the class or any derived classes (sub-classes). Public methods can be called from anywhere. Without specifying anything a method or function is deemed public. Do some Googling on the topic for examples.
  14. fopen() should work if you have the correct permissions set on the directory and specify the correct mode parameter. If using linux you could issue a system command with exec() (if your host allows this) exec("touch myfile.txt")
  15. If you wanted each selection to be stored in a single field you may use something like the following: $benefit = implode(",", $_POST['benefit']); This would produce (dependent on the user selection) car,pension,shares
  16. Using Javascript validation for form input is a really bad idea in my opinion. Here are my reasons: 1. Can be easily switched of within the web browser so no user data gets validated leaving a gaping security hole, especially if the input is used with database queries (see SQL injection) 2. If your form sends out email after processing input a bot can easily be written (bots do not parse javascript) to create outbound spam from your server.
  17. Simple answer - check the server outbound mail logs. The php mail() function will not return any error, only a boolean true/false. That is assuming you are using the mail() function. If you are it is a bad idea for large volumes of email. Quote from php.net manual:
  18. You can run from a tag that includes a src element i.e. an image: <img src="filetorun.php"
  19. Just place the student ID value in the radio value param: echo '<tr><td>'.$row['StudentID'].'</td><td>'. $row['SurName'].'</td><td>'.$row['FirstName']. '</td><td> <input name="'.$row['StudentID'].'" type="radio" value="-3" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="-2" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="-1" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="0" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="1" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="1" /> </td><td> <input name="'.$row['StudentID'].'" type="radio" value="3" /></td></tr>';
  20. Isn't Mario Nintendo or am I just getting too old for this stuff!
  21. Use a seed with the mysql RAND() function. If you want them to change daily: $query = "SELECT stocks_used FROM table ORDER BY RAND(".date('d',time()).")";
  22. Just check the page source like suggested. Its obviously a stray whitespace or something being outputted. Ive had this error tons of times.
  23. The fact that one is more than twice the price of the other answers this question.
  24. Bit vague. Better writing this yourself.
  25. This is obviously the connection used in your application previously. You need to update the mysql connection settings with your new database username and password.
×
×
  • 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.