Jump to content

jonsamwell

Members
  • Posts

    31
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jonsamwell's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I have some code that takes a while to process so i don't want to wait while the script executes to continue with code on the caller code. is there a way to start a script and continue on without waiting for the call stack to return to the caller once the called code has completed? i.e. mulit thread but without an end return?? sorry if this is confussion see below code for visual explanation //some code //call long process $longscript = new longscript(); $longscript->process; //this may take minutes echo 'something'; /* how can i call the above code and imediately go to this statement without waiting for the * longprocess to complete? */ So its threading but not as i know you can't do that in php yet. Any ideas? Jon
  2. it's not the way the class is called i think as Mchl said "mysql extension doesn't have OO interface." never mind Regards Jon
  3. Hi, usually i use mysqli OO to connect to a database, i have a standard class. however, the server i need to put code on doesn't support mysqli so i changed my class using mysql instead of mysqli but it doesn't work?? i keep getting the error: "Class 'mysql' not found" Can you not use mysql in a OO way? see below code class db { private $username = 'username'; private $password = 'password'; private $server = 'server'; private $database_name = 'db_name'; private $mysql = null; //mysql connection object /** * Constructs a database connection object * @return none */ function __construct() {//Default Constructor $this->db_connect(); } /** * opens a connection with the database * @return none */ function db_connect() { $this->mysql = mysql_connect($this->server, $this->username, $this->password, $this->database_name); } /** * close the connect to the database * @return none */ function db_close() { $this->$mysql->close(); } /** * <p>executes given sql statement and returns an object</p> * @param string $sql * @return mysql_result */ function getQueryResults($sql) {//Method to return a mysql result object return $this->mysql->mysql_query($sql); } //blah blah blah }
  4. Thanks for you help, this is still not working, but works to every other email i have tried bar my web host internal mail servers?? Does anyone think this is less of a problem with the code and some internal error my host has?? Jon
  5. The below code works fine to windows mail server but is being rejected by linux servers because of the mail format (so tech support says) The error returned is that the remote server (mail.zippymail.co.uk) drops the connection because the server does not accept the mail in the format i am sending it in. I don't really have a clue what this means or how to change the format of the email. Tech support have just fobbed me off really. Please help Thanks Jon function newCompanyMail($clientName, $username, $password, $recipient, $companyKey, $moduleCost) {//sends a email to the company admin user containing company details $senderemail = 'blah@mydomain.co.uk'; $sendername = 'Company Name\r\n'; $mailheader = "From: $senderemail\r\n"; $mailheader .= "Reply-To: No-Reply\r\n"; $moduleCost = number_format($moduleCost, 2); //email variables $subject = 'blah blah :: blah blah:: blah blah - blah blah\r\n'; //Message $message = "blah blah.\r\n\r\n"; $message .= "blah blah "; $message .= "blah blah.\r\n\r\n"; $message .= "You can login to your account at http://www.mydomain.co.uk/blah/\r\n\r\n"; $message .= "blah blah.\r\n\r\n"; $message .= "Your Compnay Account Details:\r\n\r\n"; $message .= " Company Name: $clientName\r\n"; $message .= " Admin Username: $username\r\n"; $message .= " Admin Password: $password\r\n"; $message .= " Company Key: $companyKey\r\n"; $message .= " Module Cost: £$moduleCost\r\n\r\n"; $message .= "NOTE: blah blah.\r\n\r\n"; $message .= "For technical support please email xyz@mydomain.com.\r\n\r\n"; $message .= "Best regards,\r\n\r\n\r\n"; $message .= "Company Name\r\n"; ini_set('sendmail_from', $senderemail); mail($recipient, $subject, $message, $mailheader) or die ("Failure"); }
  6. Funny enough i'm having a similar problem but my script works fine to external emails just not to network internal emails, The tech support have tracked the error down to the php script producing email containing bare line feed i.e. '\n' as new line characters. The RFC standards say that all '\n' chars should be preceeded by a '\r' o that you always have a carriage feed they a line return so try replacing all your '\n' with '\r\n' . might help worth a try. Regards, Jon
  7. hi all, The below script works fine sending emails however when i send emails internal to my hosts network domain they are not getting recieved; the tech support at my webhost has narrowed it down to bareline feed being produced which is causing the error i.e. '\n' instead of '\r\n' which is now fixed. I am pulling my hair out over this one as it works fine to emails outside the webhosts network but not internal ones i.e. different server with there network. Has anyone had this problem before/ know how to fix it??? Help would be BRILLIANT!!! function newCompanyMail($clientName, $username, $password, $recipient, $companyKey, $moduleCost) {//sends a email to the company admin user containing company details $senderemail = 'blah@mydomain.co.uk'; $sendername = 'Company Name\r\n'; $mailheader = "From: $senderemail\r\n"; $mailheader .= "Reply-To: No-Reply\r\n"; $moduleCost = number_format($moduleCost, 2); //email variables $subject = 'blah blah :: blah blah:: blah blah - blah blah\r\n'; //Message $message = "blah blah.\r\n\r\n"; $message .= "blah blah "; $message .= "blah blah.\r\n\r\n"; $message .= "You can login to your account at http://www.mydomain.co.uk/blah/\r\n\r\n"; $message .= "blah blah.\r\n\r\n"; $message .= "Your Compnay Account Details:\r\n\r\n"; $message .= " Company Name: $clientName\r\n"; $message .= " Admin Username: $username\r\n"; $message .= " Admin Password: $password\r\n"; $message .= " Company Key: $companyKey\r\n"; $message .= " Module Cost: £$moduleCost\r\n\r\n"; $message .= "NOTE: blah blah.\r\n\r\n"; $message .= "For technical support please email xyz@mydomain.com.\r\n\r\n"; $message .= "Best regards,\r\n\r\n\r\n"; $message .= "Company Name\r\n"; ini_set('sendmail_from', $senderemail); mail($recipient, $subject, $message, $mailheader) or die ("Failure"); }
  8. what do you mean? i don't understand what your project is?
  9. Hi all, This isn't so much a php question but a general coding how to. Basicallly i'm trying to generate a 20 character key where each char corresponds to a value. however, i want the total value to = 500. I've got this code so far but it just gets stuck in an infinite loop. Any ideas how i can make it work?? <?php class KeyGen { //Length of key private $keyLength; //Actual Key private $Activation_Code = ""; //Final Value key must equal private $Activation_Code_Sum = 500; //Key Elements private $AlphaNumerics = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "W", "X", "Y", "Z", 1, 2, 3, 4, 5, 6, 7, 8, 9); //Corrosponding Key Element Values private $AlphaNumerics_Values = array( 22, 96, 13, 1, 3, 31, 19, 5, 2, 18, 12, 65, 26, 99, 15, 11, 4, 25, 17, 73, 5, 88, 50, 9, 8, 7, 65, 37, 22, 40); public function __construct($keyLen) {//Set Length of Key NOTE would always be 20 $this-> keyLength = $keyLen; } public function generateKey() {//Generate Key - Key value must equal $Activation_Code_Sum //current value of the key $currentValue = 0; //Generate random starting char and add to key //Get random starting character $j = rand(0, count($this->AlphaNumerics)); //Add char to code $this->Activation_Code .= $this->AlphaNumerics($j); //Increase current value $currentValue += $this->AlphaNumerics_Values($j); //Loop round so key has specified number of chars for ($i = 0; $i < $this->keyLength -1; $i++) { //Get random num $j = rand(0, count($this->AlphaNumerics)); //Determine next value $nextValue = $this->AlphaNumerics_Values($j); /*Check nextValue is not greater than current difference * between actual key value and final key value*/ while ($nextValue > ( $this->Activation_Code_Sum - $currentValue ) ) {//If so generate new random number and get ne value //TODO: Should make this seperate function and recurse //Get random num $j = rand(0, count($this->AlphaNumerics)); $nextValue = $this->AlphaNumerics_Values($j); } $this->Activation_Code .= $this->AlphaNumerics($j); //Increase current value $currentValue += $this->AlphaNumerics_Values($j); } return $this-> Activation_Code; } } ?> Any tips would be great!!! Thanks Jon
  10. Logic errors are alway the hardest to find. We've all been in exactly the same position at one time or another!!
  11. Hi, I think i am doing this right but keep getting a weird return value. I'm changing a date format from d/m/y to y/m/d using the DATE() function, see below code. However the date i put in is not the date i get back out?? $start_date = '23/01/2009'; //input $start_date = date("Y-d-m", strtotime($start_date) ); //output = 2010-01-11 Can anyone see what i am doing wrong? Thanks Jon
  12. Does it run at the same time as the parent process or just time slices with the parent or stops the parent process altogether? Thanks
  13. SELECT CUSTOMER_ID, COUNT(CART_ID) FROM `fcp_orders_master_log` WHERE `PROCESSED`='Y' GROUP BY CUSTOMER_ID ORDER BY COUNT(CART_ID) [DESC], CUSTOMER_ID [DESC]; This will count the number of processed orders with the most orders at the top then further sorted by customer id descending Regards
  14. Hi Is it possible to multi thread in php? Basically i have a huge amount of data that would be suite to splitting up into 3/4 threads to increase the speed, the information wouldn't have to be protected (thread safe) so not too difficult. Can php do this? Regards, Jon
×
×
  • 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.