Shaked Klein Orbach echo 'Just smile';

12Sep/110

PHP & MySQL Error: “…MySQL 4.1+ using the old insecure authentication…”

Posted by Shaked

Hey,

I didn't write here for long time, though this post is very short, I will try to add some nice things in the near future. So like I always say - lets get to work: 

Error:

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file

Suggested Solution:

  1. Connect to your MySQL server: mysql -h HOST -u USER -p (for password)
     
  2. Update MySQL user password to new MySQL password: 
    mysql> UPDATE mysql.user SET Password = PASSWORD('password') WHERE User = 'username' limit 1;
    Query OK, 1 row affected (0.00 sec)

    Rows matched: 1 Changed: 1 Warnings: 0

  3. Check password length:
    mysql> SELECT LENGTH(Password) FROM mysql.user WHERE User = 'kitchenbug';

    +------------------+
    | LENGTH(Password) |

    +------------------+
    |                   41 |

    +------------------+
    1 row in set (0.00 sec)

     
  4. Flush MySQL privileges: 
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
That's worked for me, if you have the same error and my solution didn't help you may try Stackoverflow's suggestions.
-- Shak

Or Ovadia liked this post
Tagged as: , No Comments
4Jun/110

Zend Framework – Working with Modules

Posted by Shaked

Zend Framework has much more power then you really know, and today we will talk about Zend Framework working with modules.
Lets just start:

How we define modules and why we need them?
Modules are very important, fully power and useful tool. As I see it, its helps us to create mini-application inside our main application. While using our module, we have the ability to use its power on our main application and to replace it any time we want without hurting our code. Another important issue is the ability of flexibility which means that we can detach our module from one program and use it on another program.
While creating  modules you need to know few things which will help you to start fast. 
  • For creating new module with zf tool, use the following command:
     

    zf create module name, e.g: zf create module Users.

    Note: Before using this command, you will have to be on your project (ZF) directory, e.g:

    cd /var/www/html/skoproject/ | zf create module Users

  • Know your enemy ;) . Its important to know modules folder structure which you can see here. Note that you can use controllers/ folder as well.
    full folder structure will be:

forms/

models/

    DbTable/

    mappers/

plugins/

services/

views/

    helpers/

    filters/

controllers/

Bootstrap.php

 

  • After creating your module and your desired directory structure, you will have to update your main Bootstrap.php(/path/to/project/application/Bootstrap.php) to know your module(s):

//Don't forget to bootstrap the front controller as the resource may not been created yet...

protected function _initAppModules(){

      $this->bootstrap("frontController");

      $front = $this->getResource("frontController");

      /*adding modules dir to defult route, see:

http://framework.zend.com/manual/1.11/en/zend.controller.modular.html#zend.controller.modular.directories*/

      $front->addModuleDirectory(APPLICATION_PATH . '/modules');
}
  • When using modules, you probably should know that you have some "default" module that surprisingly  will called "Default"

  • While using your module, you will have to know files & classes syntax. All of your classes will be:
    ModuleName_DirectoryName_FileName, for example, when you are working with Users module, on Register form you will use:Users_Form_Register and you will find this class under: APPLICATION_PATH . '/modules/users/forms/Register.php'

  • When working with "Default" module, you won't have to name your classes with ModuleName , which means that you will work with:
    Form_Register under APPLICATION_PATH . '/modules/default/forms/Register.php'. I still advice to use your naming convention the same as the others.

  • Full naming convention may be found at Zend Framework documentation

  • You may use different configuration file for your module instead of your main application config file.
    Use it under APPLICATION_PATH . '/modules/ModuleName/config/application.ini , and don't forget to init your settings inside the module's Bootstrap.php

To sum-up, I`v read some helpful articles about Zend Framework and modules, and I think you should read them as well:

Matthew Weier O'Phinney - About Modules

Creating and Managing Zend Framework Modules

Zend Framework Store Front example project with modules

 

Hope I it helped.

 

    18May/110

    Installing & Creating Zend framework project with zf tool

    Posted by Shaked

    OK so I think I want to make it much clear from other guides that I found. So lets just get started:

    1. Open your command line (on windows use cmd, on linux use your terminal). Note: don't forget that you need web server. you can make it by your self or use WAMP (Windows), LAMP (Linux) or MAMP (Mac).
    2. There are few ways to install Zend Framework:
      • Download as a Linux distribution package:
        • sudo aptitude install zendframework 
        • sudo apt-get install zendframework 
        • sudo yum install zendframework [As far as I know, Remi's repository is up-to-date]
      • You may install Zend Framework by your self, which is good practice, though you don't have to.
        • First download Zend Framework
        • Unpack tar.gz zip
        • Add your Zend Framework library to OS's PATH. [Windows Linux]
        • My recommendation is to copy Zend Framework library to your PHP library
        • Add Zend Framework to include_path on php.ini [When adding your path note path's slash. On Windows use "" and on Linux use "/"]. Read more about ZF & include_path
        • If you have problems with ZF tool, please read this
    3. Lets create our project: zf create project /path/to/project/ [NAME-OF-PROFILE] [FILE-OF-PROFILE]. Our project will be skoproject: zf create project /var/www/html/skoproject/ skoproject
    4. Its very important to remember that you need to add "PROJECTNAME" to your path. if you forget and then you'll try to create another project you may see the following error msg:
       
       An Error Has Occurred
       A project already exists here
      zf create project error while project is already exists.

      If you want to fix this problem, you'll have to remove .zfproject.xml. You can find this file by using find /path/to/project -name '.zfproject.xml' and then delete it with  rm -rf /path/to/project/.zfproject.xml another optional solution may be found here

    5. Till now we have a working project, as you may see it on your webserver path, e.g: http://localhost/skoproject/
      Zend Framework - Welcome screen 

    Next, we will create our inside project, including Models, Controllers, Modules and everything that we need for understanding how Zend framework works.