Jump to content

aschk

Staff Alumni
  • Posts

    1,245
  • Joined

  • Last visited

    Never

Posts posted by aschk

  1. I'm guessing that this will be running as the Apache user unless you have the PHP equivalent of suexec (suPHP anyone?) so all your files/permissions will be written or done as that user. Thus you cannot chown (to my knowledge) as Apache, because if you could, you would be able to chown apache:apache / bringing the whole server to a standstill.

  2. file size is easy enough to do in PHP, however I think in order to process dimensions you'll need to utilise GD which SHOULD now be part of the standard PHP build. Also, the dimensions are specified in pixels not mm for GD ;)

  3. I should ask why you're not doing the summation in the database query?

     

    SELECT (SUM(fin_record_debit)-SUM(fin_record_credit)) as fin_record_bal1 
    FROM fin_records 
    WHERE (fin_record_date<='$data') 
        AND (id_production_unit='$pu') 
        AND (id_bank_account='$ba')
    GROUP BY id_production_unit, fin_record_date, id_bank_account;
    

  4. Seems to me like you have a non-normalised database layout. You have duplicate data there that should not be.

    Secondly do NOT do a query inside a query while still using mysql_... functions. They overwrite each other...

    $sql1 = "select * from ...";
    $res1 = mysql_query($sql1,$conn);
    while($row1 = mysql_fetch_assoc($res1){
      
       $sql2 = "select * from ...";
       $res2 = mysql_query($sql1,$conn);
       while($row2 = mysql_fetch_assoc($res2){
            /// BLAM!!!!
            /// WE JUST OVERWROTE OUR OUTER LOOP...
       }
    }
    

     

    So you're probably wondering what you should do about this. Use arrays...

     

    $sql1 = "select * from ...";
    $res1 = mysql_query($sql1,$conn);
    $data1 = array();
    while($row1 = mysql_fetch_assoc($res1){
       $data1[] = $row1;
    }
    
    $sql2 = "select * from ...";
    $res2 = mysql_query($sql2,$conn);
    while($row2 = mysql_fetch_assoc($res2){
       // Use data1 array or do something else.  
    }
    

     

    If you don't understand why the first loop is being messed then you best read up on mysql_fetch... ;)

  5. In answer to your single question : yes

    I hope you're not talking about iframes.

    You might also want to consider some nifty javascript instead. Google jquery, you might not even need another page ;)

    Basically you need to have a unique identifier for each image in question and have the text related to it (probably want a database for this storage). So when you click on your particular image it calls a page like : myimage.php?id=1235 , which is then interpreted by PHP, does the lookup on the database, loads up the information and present it with the html. Simple...

  6. If you are doing a GET request

    ?order=1&id_mod=2&order=2&id_mod=4&order=3&id_mod=5
    then you need to make them arrays, e.g.

    ?order[]=1&id_mod[]=2&order[]=2&id_mod[]=4&order[]=3&id_mod[]=5

    Then you can utilise them in PHP properly.

     

    To see what you're passing over :

    print_r($_GET['order];
    print_r($_GET['id_mod'];
    

  7. Can you give us some sample arrays for $test and $main_table and the starting value for $x.

    You probably find once you've intepreted the arrays the value you are looking for is in fact not set. Hence the loop termination.

     

    If $x is 0;

    What is $test[0] ?

    If $test[0] = "myvalue";

    Then what does $main_table["myvalue"] equal?

     

     

  8. Session timeout is determined by the settings in your php.ini file. However I believe there is a way to change the session timeout on a per domain basis (for virtual hosts).

     

    In PHP you can try

    ini_set("session.gc_maxlifetime", 60*60);

    The above sets the timeout to 1 hour.

  9. Don't use cookies, there is no guarantee that the user has not modified them, let alone allowed them to be utilised.

    I imagine they're just as efficient as each other. As for disk access; it would be at both ends. SESSION on the server and cookies on the local machine, however the overhead from writing a SESSION would be negligble to be honest unless you're planning on writing MBs worth of information. Alternatively you could utilised a database to store the information instead of a session, but relate it to session_id and to the lookup. Either way it's disk access, although there is a good chance that your database system will have cached the query in memory for use in subsequent requests.

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