Jump to content

Mchl

Staff Alumni
  • Posts

    8,466
  • Joined

  • Last visited

Posts posted by Mchl

  1. There is no $u_name property in this object.

     

    Maybe you want something like this:

     

    class register{
    
    //Setting up Variables, you can add more, for example EMAIL.
    
    private $_username;
    private $_password;
    
    //Giving the variables values
    function __construct($u_name, $p_word)
    {
        $this->_username = $u_name;
        $this->_password = $p_word;
    }
    
      public function getUsername() {
        return $this->_username;
      }
    }
    
    //then
    
    echo $reg->getUsername();

     

  2. key_buffer_size = 64M

    Start by increasing that to 512MB-1024M, see what's the effect on your performance (might improve database, but impact negatively on other services)

     

    table_cache = 100M

    ???? do you have 100 million tables in your databse?

    http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_table_cache

     

    key_buffer = 16M

    what's that? documentation doesn't mention such variable

     

    sort_buffer_size

    See here for some tips:

    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_sort_buffer_size

     

    read_buffer_size

    Again, this is something you must consider yourself

    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_net_buffer_length

     

    myisam_sort_buffer_size

    This is only used when creating/altering or repairing tables (table indexes specifically). Shoudln't affect normal operation

     

    Also consider enabling query cache

    http://dev.mysql.com/doc/refman/5.1/en/query-cache-configuration.html

     

     

  3. Use date function to get current hour. Then you can use different banner when hout is between 6PM and 6AM (night) and different when it's between 6AM and 6PM

     

    <?php
    $h = date('H');
    if($h >= 6 && $h < 18) {
      echo 'display daytime banner';
    } else {
      echo 'display nighttime banner';
    }

  4. Would this do the same?

     

    Not really. More like this:

     

    class myMySQLiAccess extends mysqli {
    
      public function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null) {
        parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
      }
    }

     

    if you want to hardcode your access credentials (not really a good idea) it would look like this

     

    class myMySQLiAccess extends mysqli {
    
      public function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null) {
        parent::__construct('localhost', 'root', 'password', 'mydatabase');
      }
    }
    
    $con = new myMySQLiAccess();
    
    

     

    closing is done like this

    $con->close();

     

    but in most cases you can safely let PHP close the connection for you (it does it automatically when script ends, or when the scope of $con is destroyed)

  5. When you use OO interface of mysqli you do

    $connection = new mysqli(..);

     

    so with more connections you do

    $connection1 = new mysqli(...);
    $connection2 = new mysqli(...);
    

     

    where $connection1 and $connection2 are MySQLi objects, that 'know' which connection to use.

     

  6. Did I tell you to use $_POST['mypassword']? I guess not. The field in your form has name="password" so you need to use $_POST['password']

     

    <?php
    //connct to database...
    
    $password = md5($_POST['password']);
    $username = mysql_real_escape_string($_POST['username']);
    $email= mysql_real_escape_string($_POST['email']);
    
    mysql_query("INSERT INTO members (username, password, email) VALUES ('$username', '$password', '$email')");

  7. [edit]

    Gah... too sleepy

     

    $wagwoord = md5("password"); //this is what I added 

     

    should be

     

    $wagwoord = md5($_POST['password']); //this is what I added 

     

    also make sure a field in database is able to store at least 32 characters (that's how long MD5 hashes are)

  8. One thing PHP lacks is a formal specification of the language. There only is a Zend's implementation, which must be taken as a point of reference by anyone who would like to create their own interpreter. Since this implementation in turns hasn't got a roadmap, or a set of goals to achieve, it's always a moving target.

  9. Also PHP-MSSQL, PHP-Postgres, PHP-Oracle, PHP-SQLite... :P

    No... I can't really see it coming.

     

    Just try to decide, if the issue is more on scripting side, or on database side. As a rule of thumb, if your question concerns PHP code, you should ask it in PHP section (even if there's also MySQL involved)

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