Jump to content

peipst9lker

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

Posts posted by peipst9lker

  1. One last thing. In my form I have some <select> elements with many many options. In order to make the <select> fields to have the values before submission I have to put a small code snippet like this below in each option?

     

    Yes you have, but I'd rather create option-tags via loop.

    Another little tip for you, always put html-attributes in ""-quotes not single ones.

     

    // somwhere on top of the script
    $options = array(1 => 'Cheeseburger', 2 => 'Hamburger', 3 => 'BigMac');
    $selected = $_POST['selectname'];
    
    // inside your <select>
    foreach ($options as $val => $option)
    echo (isset($selected) && $val == $selected) ? '<option value="'.$val.'" selected="selected">'.$option.'</option>' : '<option value="'.$val.'" >'.$option.'</option>';
    

  2. Place this 3 lines on top of your processor.php

    You should see errors then. If not check your error.log of the webserver.

     

    (Linux default Apache2 error.log: $ watch tail /var/log/apache2/error.log)

     

    error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors', 1);
    ini_set('html_errors', 1);

  3. Usually an exported table is just 2 querys (CREATE IF NOT EXISTS and a huge INSERT INTO).

    Read those into a string then split them e.g $createTable and $tableData then execute them.

    Querys are sperated by a semicolon that should be enough to split the querys.

     

    Notice that a query often has more then 1 line!

  4. Just some very basic stuff I quickly wrote down.

    Imagine products are renting servers and stuff.

     

    Table customers (id, name, email, locked, registration_date)

    Table products (id, name, price, description, picture)

    Table active_products (id, customer, productid, duration_date)

    Table invoices (id, customer, productid, creation_date, due_date, paid)

     

    Your cronjob will INSERT a new row INTO invoices FOREACH active_products WHERE duration_date > today.

    In your application you SELECT invoices WHERE paid = 0 and customer = logged in user, and if there's any row -> tell the user.

     

    Edit: Just to clearify, when a customer buys a server for 1 month you INSERT a row into active products with duration = date+30days or so

  5. You'll need cronjob's or some other technique to create those monthly/weekly/whatever-ly invoices.

    That cronjob should start a PHP script which creates your invoices (DB entries) - loads a template of a PDF fills some information in (there are thousands of PDF-librarys out there) and sends it via mail.

     

    For what do you need a tutorial now?

  6. As already indirectly pointed out, you can use a domain name to connect, it just maps across to an IP address. You can also put "localhost:3306" as the host as its the correct way to define a port on the end of a host. Have you eer considered how MySQLi does it behind the scenes? Just like that.

     

    Thanks, I didn't know that, I just knew there is an extra parameter for it - so why not using it.

     

    mysql_connect('remotesite.com:3306', 'user', 'password') or die(mysql_error());

    It show "Connect failed: Unknown MySQL server host 'seovalley.com:3306' (1)" error.

     

    Looks like the server can't resolve the domain - do you get any other error when you try the IP instead?

  7. Do you mean some kind of div-overlay or a new small browser window?

    For the overlay check out jQuery.ajax()

    For the browser window this here might help

    function popup (url) {
    var pop = window.open(url, "popup title", "width=400,height=300,resizable=yes");
    pop.focus();
    return false;
    }

  8. You can do it in 2 different ways

     

    Way 1

    Whenever a formfield looses focus you do an AJAX-request to some kind of validation.php (GET/POST parameter for the type and value of the field)

    If u go that way I'd rather write ur own jQuery Extension for this (kinda easy)

     

    Way 2

    Use a client-side and a server-side validation. 1 Javascript which watches your fields and when the data is sent your PHP script checks everything again (incase someone just turns off JavaScript or modifies the request)

  9. If you're using jQuery.ajax() you can use  beforeSend, success and error options.

     

    $.ajax({
    url: "target.php",
    beforeSend: function () {
    	// show "Please wait"-popup
    },
    success: function (a) { /* ... */ },
    error: function () { /* ... */}
    })
    

  10. You should use the IP instead of domain (To get the IP of a domain simply ping it)

    Have you tried Mysqli instead of standart mysql class?

     

    Edit: The Port would be another parameter, dont put it behind the IP.

    Edit2: Here is a small example of Mysqli (replace the $db-vars with your's!)

    $connection = @new mysqli($db->host, $db->user, $db->pass, $db->name, $db->port, $db->socket);

  11. You need to provide an identifier in catch-blocks e.g

     

    try {
    $this->hooksFired++;
    call_user_func(array($this->$hook, $method));
    } catch (Exception $e) {
    // error handling code
    }
    

  12. Thanks for your reply xyph, benchmark results (using microtime() to get the exact time differences):

     

    5000x Parsing xml-file: 1.3933548927307
    5000x Unserializing cache-file: 0.56393098831177

     

    Parsing serialized data is a lot quicker then parsing XML data, so parsing it once and saving serialized data once  is totally worth it :)

    Of course u can only do it when the XML-file is always the same (which is, in my case).

     

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