Jump to content

Agony

Members
  • Posts

    34
  • Joined

  • Last visited

Posts posted by Agony

  1.     private $file;    private $time;    public function __construct($filename,$cachefolder,$cachetime){        $this->file = $cachefolder.$filename;        $this->time = $cachetime;    }

    thats all - values are passed to the class through the constructor.

    $gallery_cache = new cache($gallerycachename,$cachefolder,$cachetime);

    $cashetime is from the database a and its stored in seconds. in Varchar field.The value is accessed:

    $cachetime = intval ($config['data']['assoc']['cachetime']);
  2. failure is here:

        public function check_cache(){        if(file_exists($this->file)){            if((time() - $this->time) < filemtime($this->file)){                return include($this->file);            }        }        else{          return false;        }    } 

    It works fine most of the time - but around once a day, the whole statement fails and ends up as null.

     

    Which means it wont include the cached file and wont start the code to cache new one.

    it seems to fail at timecheck - even tho manually echoing each side i compare - it should be ether true or false but it seems to do fail - so its nether true or false and there for even the else part wont run.Will it automatically round the timestamps somehow at one point so they are equal?

  3. what part of it didnt work? using the array or declaring it?

     

     

    <?php
    $time_day = array(
    0=> array ("daytime" => "custom", "time" => 6),
    1=> array ("daytime" => "Morning", "time" => 12),
    2=> array ("daytime" => "Afternoon", "time" => 2)
    );
    echo "<select>";
    for ($i=0;$i < sizeof($time_day);$i++){
    echo "<option value = '".$time_day[$i]["time"]."'/>".$time_day[$i]["daytime"]."</option>";
    }
    echo "</select>";
    ?>

    works fine when i run it.You need to specify for what are you using the array for - textarea, drop list, etc.

  4. So... again - on a wamp setup for test/local inserting the text works.

     

    The same text however on production server fails and returns the error.

     

    The collation for the column and table is set as utf8mb4_unicode_ci

    So is the server connection under general settings.

     

    Everything looks identical to the wamp server setup yet it doesn't seem to recognize the 4byte utf8.

     

     

     

    mysql is Server version: 5.6.19

    windows 2008 R2

     

    to make sure i even run (edited):

    ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;# For each table:ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;# For each column:ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    and:

    character_set_client utf8mb4 character_set_connection utf8mb4 character_set_database utf8mb4 character_set_filesystem binary character_set_results utf8mb4 character_set_server utf8 character_set_system utf8 collation_connection utf8mb4_unicode_ci collation_database utf8mb4_unicode_ci collation_server utf8_general_ci

     

    the charachter_set_server for some reason is still utf8 - even to in the my.ini its set to utf8mb4

    [client]no-beepdefault-character-set = utf8mb4port=3306[mysql]default-character-set = utf8mb4[mysqld]port=3306datadir="C:/ProgramData/MySQL/MySQL Server 5.6/data"character-set-server = utf8mb4collation-server = utf8mb4_unicode_cidefault-storage-engine=INNODBsql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"log-output=FILEgeneral-log=0general_log_file="FALCON578.log"slow-query-log=1slow_query_log_file="FALCON578-slow.log"long_query_time=10log-error="FALCON578.err"max_connections=151query_cache_size=0table_open_cache=2000tmp_table_size=181Mthread_cache_size=10myisam_max_sort_file_size=100Gmyisam_sort_buffer_size=352Mkey_buffer_size=8Mread_buffer_size=64Kread_rnd_buffer_size=256Ksort_buffer_size=256Kinnodb_additional_mem_pool_size=25Minnodb_flush_log_at_trx_commit=1innodb_log_buffer_size=13Minnodb_buffer_pool_size=2Ginnodb_log_file_size=48Minnodb_thread_concurrency=17innodb_autoextend_increment=64innodb_buffer_pool_instances=8innodb_concurrency_tickets=5000innodb_old_blocks_time=1000innodb_open_files=300innodb_stats_on_metadata=0innodb_file_per_table=1innodb_checksum_algorithm=0back_log=80flush_time=0join_buffer_size=256Kmax_allowed_packet=4Mmax_connect_errors=100open_files_limit=4161query_cache_type=0sort_buffer_size=256Ktable_definition_cache=1400binlog_row_event_max_size=8Ksync_master_info=10000sync_relay_log=10000sync_relay_log_info=10000

    its in programdata and the mysql folder itself. i restarted mysql after edits.

  5. North & Islands

     

    might be breaking it. a single & would be considered as an operatoras in "if var is equal to north and islands is true".

    var_dump($db_oregion=="North & Islands");

    It should ether return true or false.

     

     

    So use single quotes(the specials will not be processed) or escape it like: &

  6. Thats where prepared statement comes handy.

     

    This way any " or ' or special keywords wotn break ur query. They are inserted purely as a value.

    A piece of code from my project for example:

        public function set_post($author,$title,$content,$id){        $db =  $this->connect();        $sql = "UPDATE posts SET author = ?, title = ?, content = ? WHERE id = ?";        $rows = null;        if ($db === false) {               $rows['error'] = "DB connection error";                        }        else{$result = $db->prepare($sql);                        if ($result === false) {                $rows['error'] = "Query syntax error";            }            else {                $result->bind_param('ssi',$author,$title,$content,$id);                $result->execute();                return true;                $result->close();            }        }         return $rows;     }

    Also, you can use var_dump();

    If you dont want to use prepared statements. At least separate the query itself to a new variable.

    like

    $sql = "INSERT INTO messages (to, from, subject, message)VALUES ('$to', '$from', '$subject', '$message')";//Then u can use the $result = mysqli_connect($con,$sql);//Alsovar_dump($sql); //to test if the whole query looks allright
    • Like 1
  7. I assume u have a listbox with select options made with that array ( with a loop)?

    static public $time_day = array(1=>"Morning", 2=>"Afternoon", 0=>"custom");

    Would give you an array like

     

    where 1 is the key and the word is the value. But if you need to show a day based of the int but you need the int value as well.Use multidimensional array.

    static public $time_day = array(                                0=> array ("daytime" => "custom", "time" => 6),                                1=> array ("daytime" => "Morning", "time" => 12),                                2=> array ("daytime" => "Afternoon", "time" => 2)                          );

    Then you can populate the list with name as the

    $time_day[0]["daytime"],$time_day[1]["daytime"],$time_day[2]["daytime"]

    and value as

    ​ $time_day[0]["time"],$time_day[1]["time"],$time_day[2]["time"]

    And then use the value with javascript as a value for the 2nd textbox or what ever it is.

  8. Test server ( where it works)

    Accept-Ranges:bytesCache-Control:max-age=604800Connection:Keep-AliveContent-Encoding:gzipContent-Type:application/javascriptDate:Thu, 05 Jun 2014 02:42:11 GMTETag:"41474-4fa5780af25bf-gzip"Expires:Thu, 12 Jun 2014 02:42:11 GMTKeep-Alive:timeout=5, max=99Last-Modified:Tue, 27 May 2014 01:20:34 GMTServer:Apache/2.4.9 (Win32) PHP/5.5.12Transfer-Encoding:chunkedVary:Accept-Encoding

    iis:

    Accept-Ranges:bytesDate:Thu, 05 Jun 2014 02:40:34 GMTETag:"7bf915dc4979cf1:0"Last-Modified:Tue, 27 May 2014 01:20:34 GMTServer:Microsoft-IIS/7.5X-Powered-By:ASP.NET

    iid response doesn't seem to include content-type.

  9. Running the same site with the same files on a local test ( wamp 2.5 based) - it all runs fine. no jscript errors and everything works.

    Even jquery doesn't work.

     

     

    I have set the permissions and browser does seem to download the .js files.

    I could even access them and run a compare ( to the one browser sees from my test and vs iis7 on win2008r2) - identical.

     

    what i get in console is:

    Uncaught SyntaxError: Unexpected token ILLEGAL 

    for line 1. its referring to ink-all.min.js from ink.sapo.pt framework.

     

    event tried adding the "; charset=Windows-1252" to the .js mime type - assuming it might be in ansi.. but nothing.

     

    ​is there something special u have to set/change on iis?

  10. nop, no error messages. that's why i don't understand why its not working.It should just reset the form to original values ( hide the image, show the button) - but button stays hidden and image wont vanish.using console.log or alert in the code sections that lead to it - works fine. But the function itself doesn't seem to get called.

  11. <IfModule mod_expires.c>ExpiresActive OnExpiresByType image/jpg "access 1 week"ExpiresByType image/jpeg "access 1 week"ExpiresByType image/gif "access 1 week"ExpiresByType image/png "access 1 week"ExpiresByType text/css "access 1 week"ExpiresByType text/html "access 1 week"ExpiresByType application/pdf "access 1 week"ExpiresByType text/x-javascript "access 1 week"  ExpiresByType text/javascript "access 1 week"  ExpiresByType application/javascript "access 1 week" ExpiresByType application/x-javascript "access 1 week"ExpiresByType text/plain "access 1 week"ExpiresByType application/json "access 1 week"ExpiresByType application/x-shockwave-flash "access 1 week"ExpiresByType image/x-icon "access 1 week"ExpiresByType application/x-font-woff "access 1 week"ExpiresDefault "access 1 week"</IfModule>

    in apache that works nicely - clean and simple.But all iv found this far in iis is an option that caches EVERYTHING - or some web.config option u can edit for every file manually. This is no good for dynamic site.Can you specify mime /filetypes like that with expire time?

  12. jquery.form.js library. The alert i added there shows up, so it does succeed and work there.

        if (options.resetForm) {       alert('eeffeS');       callbacks.push(function() { $form.resetForm(); });    }

    this alerts as well:

        options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg        var context = options.context || this ;    // jQuery 1.4+ supports scope context        for (var i=0, max=callbacks.length; i < max; i++) {            callbacks[i].apply(context, [data, status, xhr || $form, $form]);        }        alert('eeffeS');    };
    /** * Resets the form data.  Causes all form elements to be reset to their original value. */$.fn.resetForm = function() {    return this.each(function() {        // guard against an input with the name of 'reset'        // note that IE reports the reset function as an 'object'        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {            this.reset();        }    });};

    it all works - but the resetForm: true that is sent as a parameter and runs the function above on success fails to reset the form.

    once code runs it does this:

    $('#submit-btn').hide();$('#loading-img').show();

    but the function above doesn't seem to reset it to default values.

  13. $gallery_cache = new cache('gallery_content.php',$cachetime);if($gallery_cache->check_cache() !== false){}else{    $gallery_cache->start_cache();//stuff    $gallery_cache->end_cache();}

    Thats the code for the part. As you can see the first if itself is empty {}.

    check_cache returns: return include($this->file) on or false.

     

    So im checking it for false to run another function or do nothing ( since if its not false it returns the include already).

     

  14. edit converted those to minified versions and added few extra mime types - it seems to be caching them now.

     

     

    however i cant seem to get the

    nk-all.min.map

    to cache - chrome dev tools report it as text/plain and i even added a line to htaccess for it.

  15. in the .htaccess iv got the js lines set up as:

    ExpiresByType text/x-javascript "access 1 month"  ExpiresByType text/javascript "access 1 month"  ExpiresByType application/javascript "access 1 month" ExpiresByType application/x-javascript "access 1 month"

    to cover all the possible diff mimes.

    <script type="text/javascript" src="http://cdn.ink.sapo.pt/3.0.2/js/holder.js"></script><script type="text/javascript" src="http://cdn.ink.sapo.pt/3.0.2/js/ink-all.min.js"></script><script type="text/javascript" src="http://cdn.ink.sapo.pt/3.0.2/js/autoload.js"></script>That's how its defined, yet they don't seem to cache.

     

    Leverage browser caching for the following cacheable resources:http://cdn.ink.sapo.pt/3.0.2/js/autoload.js (6 hours)http://cdn.ink.sapo.pt/3.0.2/js/holder.js (6 hours)http://cdn.ink.sapo.pt/3.0.2/js/ink-all.min.js (6 hours)

    Any ideas what might be breaking it?

    • Like 1
  16. So im trying to set up error handling for the:

    $result = $db->prepare($this->query);

    However - if i break the input query, all i get is NULL - no error from prepare.

    if i var_dump ($result) - its NULL, If i var_dump() the returned $db->prepare($this->query) - its also all NULL - no errors or anything.

    object(mysqli)[2]  public 'affected_rows' => null  public 'client_info' => null  public 'client_version' => null  public 'connect_errno' => null  public 'connect_error' => null  public 'errno' => null  public 'error' => null  public 'error_list' => null  public 'field_count' => null  public 'host_info' => null  public 'info' => null  public 'insert_id' => null  public 'server_info' => null  public 'server_version' => null  public 'stat' => null  public 'sqlstate' => null  public 'protocol_version' => null  public 'thread_id' => null  public 'warning_count' => null

    Query is:

    "UPDATE SELECT * FROM posts" 

    so that's clearly wrong and should fail.

    How am i supposed to catch any query caused errors from it?

  17. The expect to start programming when u go to work as a developer is understandable - but what often is left out is the difficulty of the work itself.

    For example if you would hire an entry/junior level developer - Would it include just the basics ( loops, if/else, arrays, basic database use, variables, operators and such) or would it also reach the realm of custom built classes, functions, sessions, cashing, file handling databases, ajax, js and such?

  18. Looking at the job ads gets quite confusing.

    You often see things like:

    Experience with PHP, mysql, jquery

     

    But experience is a quite wide term - even if they add years.

    1 year of experience for one might be 1 week worth of learning or other.

     

    So it makes me wonder - what is actually expected when you go to work as PHP developer.

     

    Iv held back - being unsure if id be able to currently handle te workload or not ( sure trying wont hurt usually - but it does if u need to move/rent an apartment just to work - in which case u may be stuck with a contract and no money).

    The job ads are more then often full of " technical" details written by someone in charge of recruiting - but knows nothing of the php itself.

    Here is an example:

     

     

    Requirements
    • Goog knowledge and skills in PHP, MySQL
    • Understanding in web services (i.e. XML, SOAP, JSON)
    • Documentation skills
    • Education in IT and working experience as a software developer
    • Ready to take the initiative and ask questions, good interpersonal skills
    • Good analytical and conceptual skills
    • Sense of punctuality, correctness and responsibility

    But based of that - no clue what the "goog" knowledge expects me to actually do.Anyone whos actually part of recruiting people - or applied to jobs with diff requirements could elaborate.

    What do they usually/commonly expect you to be able to do within the first days/weeks/months?Net is full of " oh u just need to be able to write simple code to being able to build full featured forums from scratch"

×
×
  • Create New...