Jump to content

vinny42

Members
  • Posts

    411
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by vinny42

  1. "I have the Varchar set to 1024, thats it. I can save about 50 letters worth of text" Which version of MySQL are you using, and that happens when you say "it doens't save"?
  2. Deamons don't terminate, that's the point of a deamon. But still, how would waiting help? You are not sending bulk emails, your hoster will have no problem handling them, so just go for it. If you still have doubts, contact your hoster and explain what you want to do. They will tell you what they thinks is best.
  3. What do you mean by "avoid looping"? The queue is the single reason why it really doesn't matter how fast or slowly you queue the messages. It doesn't have to check if the server is down, because it must connect in order to queue the mail. If the server is not responding the mail cannot be queued and that must result in an errormessage.
  4. A custom session handler could work, but given that this function itself has nothing to do with the session itself I'd go for a crontab. But, that's assuming that logging out is an event at which you want something critical can happen, especially given the fact that you cannot know when a user logs out (because they don't). I think the OP should probably explain a bit more about what he's doing.
  5. vinny42

    SQL error

    Out of curiosity and for possible future visitors of this topic; what was the alternative you ended up using?
  6. I highly doubt that, but then again mail() is a crappy function. It's usually better to use something like phpmailer or swiftmailer, they use sockets to connect so if a server is down there will be an error.
  7. I'd rather do a new table, because this information is purely for presentation on the website and it's not part of the video's data. Other than that; yes a database would work, sure.
  8. Who told you that? :-) mail() contacts the local delivery service and returns true or false when it has completed, so PHP cannot continue until mail() has completed. You cannot send the next message before the last one has completely finished, so your sleep command cannot be executed before mail() has finished. There is no point in waiting for a finished proces to finish. Worst case, if you send thousands and thousands of emails, the local delivery will throttle you to give itself time to pass the messages on to the internet, which makes mail() return false to indicate that the mail has not been sent. In that case, and pretty much only in that case, do you have to wait for the mailserver to catch up. But when sending two emails there is no need whatsoever to wait for any amount of time.
  9. He's right, PHP cannot interact with the browser. If you think it can, then you are not building what you think you are building. What you've done here is redefined what you are trying to do from "display a message when a countdown reaches zero" to "display a message when a page is reloaded after X time has passed". This will not stop people from taking as long as they want to complete a task.
  10. The suggestion was utf8_decode), not utf8_encode(). If you just want to repeat the content from the remote server, then yes, add a header and you see the data again. Of course the next step is using the data and that's more complicated in utf8 in PHP. I don't, I missed the part that said this was JSON, and just quickly copied from the manual that I also told the OP to read.
  11. Given that you can re-use the selection all day, I'd run a query and save the result somewhere. The query can be as simple as: SELECT * FROM table ORDER BY RANDOM() LIMIT 3; and the three results you get, you can save as a normal PHP array using serialize(). Then your script can load them again using file_get_contents() and unserialize(); like this: $filename = 'saved_randoms.txt'; // Create a new set of values$arrRandoms = array(10,45,88);$strRandoms = serialize($arrRandoms);file_put_contents($filename, $strRandoms); echo 'new randoms:</br>';var_dump($arrRandoms);echo '</br>'; // Load the set of arrays.$strLoadedRandoms = file_get_contents($filename);$arrLoadedrandoms = unserialize($strLoadedRandoms); echo 'loaded randoms:</br>';var_dump($arrRandoms);echo '<br/>'.$filename. ' was last modified: ' . date ("F d Y H:i:s.", filemtime($filename)).'<br/>'; You can do this once a day using a cronjob, or you can use filemtime() at every pageview to see if the last-modified date is older than one day, and save a new list of arrays.
  12. Uniqueness cannot be guaranteed that way, it can only be done by a unique constraint in the database. But in this case there is nothing that has to be unique, it's even possible that the new data must overwrite existing data.
  13. What do you mean by anti-bot software? Stopping bots from signing up is usually done using captcha and requiring the user to reply to a confirmation email. Type "phpbb captcha" in google and you'll see literally tons of hints, tips and forumposts about this.
  14. Hold on, are you saying that you have several MS-Access applications running that all insert data into the same database? So two MS-Access applications generate the same audit_id for completely different data? That would mean that there are no duplicate *records*, only duplicate audit_id's. You can't just ignore the duplicate audit_id's, because you would loose the rest of the data and the table would contain some records from the first division, som from the second, etc, depending on who created each audit_id first. The table would be completely useless. You could simply change the audit_id depending on the division; division 1 would start at audit_id = 1000000, division2 at 2000000, etc. The size of the numbers would depend on how many records you expect to get before people decide that MS-Access it not the right choice :-) A cleaner but more involved solution would be to combine the audit_id with a division_id, then the combination could be forced unique, and each division can use audit_id=1 as long as their division_id is different. I guess we need more info about what exactly you are doing :-)
  15. You don't have to sleep between sending two emails.... that's just silly. If you are sending hundreds of emails then yes, leave some time for the server to catch up, but two emails...
  16. Then I suggest you talk to your hoster, perhaps they can think of a safe alternative to do this. The issue is not with executing system(), it's with how PHP could be tricked to execute anything a hacker wants. So if the hoster get's control over what the system() command actually contains, it's safe for them. If not, then all you can do is find a PHP alternative for the system command, HP can do encryption but we (and possibly you?) don't know what kind it's doing right now. If there are no alternatives in PHP and the host doesn't want to help, then all you can do is move host...
  17. vinny42

    SQL error

    What you want to do is find rooms where the checkin and checkout dates don't overlap. Normally in SQL you'd just do: WHERE NOT (checkin,checkout) OVERLAPS ($newchecking, $newcheckout) but MySQL doesn't support OVERLAPS so you'll have to write up the conditions that define when there is an overlap. I suggest that you gogle for this, you're probably not the first to want this.
  18. More important is why not: because the characters used in the example do not exist in latin1. Back to the question: Because you are looking at an UTF8 string while the browser thinks it's Latin1. If you add a header like Content-Type: text/html; charset=UTF-8 you should see things correctly. Read the PHP manual about header().
  19. Just make *very* sure that you fill all variables with new data, you don't want to send thw wrong emails to the wrong people. And for that reason it might be a good idea to put the two email routines in separate functions, so there is no possibility of cross contamination. (it's no big deal for your private website, but accidently sending a log of a serious exception to a randmon visitor who was trying to subscribe to a mailinglist is something else...)
  20. vinny42

    SQL error

    Because you can only join tables on the basis that some field has the same value, not on having a different value. What you *can* do is LEFT JOIN on records that *do* have the same value. If there are no records that match, LEFT JOIN will use NULL values for the missing data, and you can check for NULL in either SQL or your application.
  21. That depends on why you would get duplicates and what you want to do when you get duplicates. The only way you can detect a duplicate is to create a rule in the database that enforces uniqueness, so the nest question is: what makes a record unique? Iif you create a UNIQUE index on a combination of all columns that must have unique values then the database will refuse to insert those values twice in separate records. The "DUPLICATE KEY" error that will generate can be intercepted with INSERT IGNORE, but be aware that IGNORE means "skip records that gave an error, *any* error" and you wil never get a message telling you which records were skipped. That may be what you want, it may not be what you want, you'll have to tell. :-)
  22. And even then the file could contain javascript which the browser could pickup. For images you can use PHP's image functions and there are problably a few validations for other filetypes out there, but once you allow data from uncontrolled sources into your system you are op to all kinds of weird attacks.
×
×
  • 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.