Jump to content

Solaris

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Solaris's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Does PHP (or Apache, if PHP is running as an Apache module) have execute permission on /var/www/test.sh ?
  2. Doesn't work for me: <?php ignore_user_abort(true); set_time_limit(0); ob_start(); $i = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : 1; $redirect_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?i=' . ($i + 1); echo $redirect_url; /* do your stuff here */ sleep(1); if ($i < 100) { $i++; header("Location: " . $redirect_url); /* redirect here */ } ob_flush(); ?> Tried on localhost with Firefox 3.6.12.
  3. I don't see how your code is working. I see two issues: 1. According to the MySQL Manual, this code: IF(country_code = '".$country_code."', '', '') means that if country_code is equal to $country_code, then use '' (an empty string), otherwise use '' (again, an empty string). You might as well just use '' instead of the whole IF(...) construct. 2. In HTML, label IDs (or any other IDs for that matter) must be unique. While most mainstream browsers can tolerate invalid HTML to a certain extent, PHP does not. That said, can you fix these two issues and post the complete <form> ... </form> code? Also have a look at How do I create arrays in a HTML <form>?
  4. I'm sorry, did you even read my last reply? I'm neither asking for a complete script nor for general programming advice. In other words, I'm not asking for someone to do a wheel for me, but rather which existing wheel is the best (there are plenty available already, and I certainly don't want to reinvent one). Oh, and please don't look at my post count.
  5. Just how much code is considered to be a paid job? What I'm asking about is whether anyone knows which is the most robust code to restart a script, nothing more. I'm not asking for someone to write a complete script for me. The restart code can even be readily-available from a well-known open source script, provided it's short (a few lines?) and generic enough to use in other scripts, like the one I'm writing. Again, I've seen a few ways to restart a script, I just don't know which is the most robust. I apologize if I'm asking in the wrong place.
  6. I am asking for help and I thank you for trying. Is the question too hard, perhaps? Is there a board here about advanced topics?
  7. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM newsletter WHERE email = 'ross@mail.com'' at line 1 ManiacDan was talking about replacing INSERT with INSERT IGNORE in the query that actually inserts the e-mail addresses, not about replacing SELECT with INSERT IGNORE in the validation query. But if you want to know whether the e-mail address was duplicated or not (INSERT IGNORE just does the job silently), try the code I posted. If you're not sure about anything, just ask.
  8. Perhaps I haven't been clear... I'm not asking for ideas or code that I can test, but rather for code that has already been tested and found to work correctly at all times.
  9. Insert this code: else { $check = mysql_query("SELECT FROM newsletter WHERE email = '$email'") or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 > 0) $error_msg = 'email exists'; } before this line: if ($error_msg == ''){ EDIT: linuxjournal.com doesn't load for me, but I found some RFC-compliant e-mail validation code here: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html -- this is a huge regex, don't use it. The following is less strict but should do the job for 99.99% of e-mail addresses out there: [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b
  10. Thanks, but the script does output to the browser before restarting. I have seen a few code examples that show how to do it, I just don't know what code works reliably in all environments. In other words, I need proven code, not just something that works in X or Y server setup but is not tested on others.
  11. You can also use the MySQL functions TRIM() (or RTRIM() for trailing spaces only) directly: UPDATE `table` SET `field` = RTRIM(`field`);
  12. How does it not work? Also, if somehow the same e-mail address has been registered more than once, $check2 will not be equal to 1. If the e-mail address has not been registered, $check2 will be == 0. See the logic here?
  13. It's exactly the "call self" part that I'm asking about. I have no problem writing the rest of the code.
  14. Every 20-25 seconds, because I just cannot depend on the actual effect of set_time_limit(), apache_reset_timeout() and the like.
  15. I have searched this forum and the web, but I haven't been able to find a good answer. I'm interested in the best way (especially some working code snippet, hopefully!) to make a script stop when a limit (either number of rows or time limit or whatever) is reached, call itself and pass some variables to itself via sessions/cookies or $_REQUEST, and then resume where it left off the last time. Does anybody know a way to do this that works reliably in most (all?) environments? Any code that uses header(), output buffering, AJAX, or anything else, that is proven to work? What I want to do is make a generic script that accepts a (very large) local flat file as a data source, processes the contents and outputs the results either to another local flat file or to another application using the latter's routines. The result isn't necessarily going to be imported into MySQL (so no, LOAD DATA INFILE isn't applicable here). An example I can think of is processing a CSV file (say, about 100,000 records), converting it on-the-fly and importing the results into WordPress by calling WP's functions to do the actual import. Again, this is just an example. I can write all input, processing and output functions, it's just the best way to restart and resume the script that I'm asking about. BigDump is another script that does this, but it seems to use AJAX to restart itself. I wouldn't mind using AJAX/jQuery/whatever; in that case, I'd just need some working drop-in code, since my JavaScript/AJAX knowledge isn't very good, to say the least. Nevertheless, I'd rather prefer pure PHP, just in case the user has JavaScript disabled. Sorry for the long post and thanks in advance!
×
×
  • 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.