Jump to content

travo1992

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Posts posted by travo1992

  1. Database indexes - practises such as primary keys on ids, indexing columns that will be referenced, full text searching, etc. (Take that statement loosely, I know that doing tha as I said it may result in slower data access)

     

    As for code, really just use your head and remember that there are always the right and wrong tools for the job.

    Eg.

    If there is a function built into PHP, 9 times out of 10 it will be quicker than your PHP function which does the same job.

     

    If you wish to profile your scripts and see where you are losing time, have a look at Xdebug

  2. You should be doing better than fine with 1000 users. I know of a few sites with 20,000-30,000 users which are still running sub 0.5 seconds on shared hosting, you just need to make sure your code is not sloppy, your database indexes are correct, etc.

     

    EDIT: Did you mean total users or users at once? Apache defaults to a maximum of 256 connections at once, so you dont really need to worry about much if this is what you meant...

  3. I agree with thorpe that is probably the browser being sluggish rather than PHP. As far as I know, PHP doesnt slow down as it approaches the memory limit, only creates errors once it surpasses it.

     

    Does the browser need to maintain every line outputted?

     

    If not, perhaps you could echo out some js every few thousand lines to clear the window?

  4. The OP mentioned something about the variable being available in multiple files?

    Create a file which declares the variable, and simply use

    include 'file.php';

    to declare that variable in all files which require it.

  5. But if your server ever goes down, everyones copies of the class stop working. If for eg. a business is using your class and your server goes down and they lose profit because of you, you could be liable for damages.

     

    It costs a bit for the software, but I generally use Ioncube. Its fairly common now, so getting it running on hosts usually isnt a problem.

  6. @ rwwd

    I understand your point, however this is more relevant with larger, or even medium sized chunks of text.

    For smaller chunks of code, such as this, it is usually quicker (just) to just echo the code, rather than having php switch in and out

    I just tested to make sure I wasnt going to make a fool of myself, over 100000 reps of echoing 3 variables rather than html with inline php, echoing the lot is approx 40ms quicker.

    Inline PHP actually peaked higher cpu usage, showing that you need to take the context into account before you apply optimisations.

     

    Saying that, for this it probably doesnt really matter too much anyway :P

     

    @redhairgal that'll do it to you hehe, glad you worked it out.

  7. @rwwd that makes it harder to read the structures though. Execution time is cheap, man hours are expensive. Not to mention this is one of those microoptimisations which is almost negligible.

     

    @redhairgal just wondering why do you have <select ... /> on the first line? It should just be <select ... >

    Not sure if that will help...

  8. Sure. Im thinking something like

    <?php
    
    $aid = $_GET['aid'];
    // repeat for other menus
    
    switch($aid){
    case 1:
    	$menu_a = 'blah';// 1st menu text
    break;
    //etc
    }
    
    // repeat for other menus
    ?>
    

     

    And then display them by simply echoing the relevant variable ($menu_a, $menu_b, etc)

     

    Hope that helps

  9. For the sql error, Im thinking it could be 1 of these:

    1: there should be a space between your table and your rows

    2: like is a reserveed keywork, you should use quotes

     

    Try

    INSERT INTO lgu (`like`, `ip_address`) VALUES ('$LIKE','$IP')

     

    For the form, you dont use the same vaiable name, and you have specified post in the form. Try

    $LIKE = $_POST['like'];

  10. Im assuming you mean

    Array
    (
        [name_1] => John Doe, [name_2] => John Doe 2, [full_address_1] => 1234 test street, [full_address_2] => 1234 test street 2
    )
    

     

    At the moment you are replacing the array every time you go through the while loop.

    Try

     

    $i=0;
    $buildArray = array();
    while ($postage =db_fetch_array($postage_query)){
          $i++;
          $custname =$postage['delivery_name'] . '&';
          $custaddress = $postage['delivery_street_address'];
          $buildArray["name_" . $i] = $custname;
          $buildArray["full_address_" . $i] = $custaddress;
    }
    

×
×
  • 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.