Jump to content

CheesierAngel

Members
  • Posts

    105
  • Joined

  • Last visited

    Never

About CheesierAngel

  • Birthday 07/18/1984

Contact Methods

  • Website URL
    http://www.scouts-stzeel.be

Profile Information

  • Gender
    Male
  • Location
    Belgium

CheesierAngel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Found some temporary solution, still all suggestions welcome !! [code] <?php /* ... */                 $lastAssigned = ""; foreach($newCustomers as $newCustomer) { print $newCustomer . '\n'; /* Gather Online Operators With The Fewest Assigned Customers */ $sql = <<<SQL SELECT u.id as `operatorId`, COUNT(a.customer_id) as `assignments` FROM users u LEFT JOIN assignments a ON a.user_id = u.id WHERE u.id <> 0 AND u.role_id = 3 AND u.active = 1 AND u.online = 1 $lastAssigned                                                //-> Extra check GROUP BY operatorId ORDER BY assignments ASC SQL; $results = $cCustomer->query($sql); /* Assign New Customer To Operator */ if(!empty($results)) { $operatorId = $results[0]['u']['operatorId']; if(isset($results[1])) {                                            //-> last operator may not be used (if there are more then 1) $lastAssigned = "AND u.id <> $operatorId"; } $sql = <<<SQL INSERT INTO assignments VALUES($newCustomer, $operatorId) SQL; $cCustomer->query($sql); $sql = <<<SQL UPDATE users SET tsAssigned = NOW() WHERE id = $operatorId SQL; $cCustomer->query($sql); } } /* ... */ [/code]
  2. Hi, i really don't know which forum to post this in but i got a mysql php problem. I would like to calculate the number of assigned customers to an operator and link the new customers to the operator who has the fewest customers assigned too. I already wrote some code but the problem is that before the insert is executed the new count calculation is already performed... So if there are 3 new customers, they will all three be assigned to one operator? I already tried to use LOW_PRIORITY and HIGH_PRIORITY inside my queries but the MySQL server doesn't support this yet. (can't upgrade because i don't have the access to do so) I rather do not wanna use a sleep function because if the server is busy there might be a chance the problem occurs again. Any suggestions ? [code] <?php /* ... */ foreach($newCustomers as $newCustomer) { print $newCustomer . '\n'; /* Gather Online Operators With The Fewest Assigned Customers */ $sql = <<<SQL SELECT u.id as `operatorId`, COUNT(a.customer_id) as `assignments` FROM users u LEFT JOIN assignments a ON a.user_id = u.id WHERE u.id <> 0 AND u.role_id = 3 AND u.active = 1 AND u.online = 1 GROUP BY operatorId ORDER BY assignments ASC SQL; $results = $cCustomer->query($sql); /* Assign New Customer To Operator */ if(!empty($results)) { $operatorId = $results[0]['u']['operatorId']; $sql = <<<SQL INSERT INTO assignments VALUES($newCustomer, $operatorId) SQL; $cCustomer->query($sql); $sql = <<<SQL UPDATE users SET tsAssigned = NOW() WHERE id = $operatorId SQL; $cCustomer->query($sql); } } /* ... */ ?> [/code] The query executions may look strange but this code is written inside the CMS cakePHP. (There are no syntax errors!) If you liked some explanation on some line, just ask ... Thanks a lot
  3. You could use some PEAR packages for that: - [url=http://pear.php.net/search.php?q=PDF&in=packages&x=0&y=0]http://pear.php.net/search.php?q=PDF&in=packages&x=0&y=0[/url]
  4. Please set your code between  [ code ] and [ /code ] tags. This makes its beter readable for us. (without the spaces!)
  5. That would be javascript that manipulates the statusbar message. ??? But don't know it is even possible in combination with the PHP header() function
  6. Try doing this: [code] <?php function check_city($name = null) {     if(!empty($name)) {       $checkname = mysql_query("SELECT * FROM users WHERE cityname = '$name'");       $namecheck = mysql_num_rows($checkname);       if ($namecheck > 0){ $reason = "-The name of the city you choose have been taken already<br>"; header("Location: index.php?page=register&reason=$reason");       }       // What if the name does not exists ?       return;     }   $reason = "-Your City must have a name, please fill in the City name field<br>";   header("Location: index.php?page=register&reason=$reason"); } ?> [/code]
  7. So the code is never executing the inside of the if(is_uploaded_file()) ? or are there stille errors generated ?
  8. You shouldn't write on the links.php page the <html> tags. The links.php should look like this (nothing more, nothing less): [code] <?php if($_POST['cmd'] == "link1") {   header("Location: http://www.coolgorilla.com/images/banner.png"); } ?> [/code] Modification: This because the user accessing this page will never see this page... PHP gave you the error because you wanted to write/transmit some header information to the user. [code] <html> <head>  <!-- And here is your header output to the user -->   .... </head> <body> <!-- Here is some information you are transmitting to the user -->   <?php     if(...) {       /*         * Sending again some header information after the headers where already send by the html header tag         * and after you already transfered some content to the user by the <body> tags.       */       header(...);  // Nothing may be outputted already to the user when using this function !!!     }   ?>   </body> </html> [/code]
  9. Do you have write access to the folder you're uploading your files ?
  10. The idee to seperate your error handling from all other classes is to create a class specially for this. Now you could make a class errors or something like that that will keep all your generated errors into a database (by using your database class) or error log file. And on every page of your application/site you could aks the errorClass the latest error to display if any new errors where added. something like: [code] <?php require_once('error.class.php'); require_once('database.class.php'); $cError = new Error(); $cDatabase = new Database(); $cDatabase = new Database('databaseName'); if($error = $cDatabase->getErrorMessage()) { $cError->add(ERROR_CRITICAL, $error); } ?> [/code] And you could add in your pages header or footer: [code] <?php if($cError->newError()) {   $echo "<font color='red'>" . $cError->lastError() . "</font>"; } ?> [/code] And indeed in your dbConfiguration.inc.php you put all your configurations. You should know that programming OO is to extract all specific functionalities into an object/class and only these specific functionalities. So if you create a database class you should only create the functionalities that concern databases into this class. And so on ...
  11. There is a ) to much after the $_FILES[][] and add it again at the end. It should be: [code] <?php if(!preg_match('/^((\w)(.[pdf|ppt]))$/', $_FILES[$userfile]['name'], $match = array())) { // ... } ?> [/code]
  12. Show me the code you are using now ... (put it between the code tags [ code ][ /code ], without the spaces)
  13. There is missing a " at the begining of the header() function. It should be: [code] <?php <?php if($_POST['cmd'] == "link1") {   header("Location: http://www.coolgorilla.com/images/banner.png"); } ?> [/code]
  14. create a script inbetween your link-button (or form) and your actual script. Linkspage: [code] <form action="links.php" method="post">   <input type="hidden" name="cmd" value="link1"> <input type="submit" value="GoToThisLink"> </form> [/code] Your script inbetween: <?php if($_POST['cmd'] == "link1") {   header(Location: http://www.blahblah.com"); } ?>
×
×
  • 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.