2009-04-23 7 views
1
Fatal error: Call to undefined function mysql_connect() in 
/opt/lampp/htdocs/cake/cake/libs/model/datasources/dbo/dbo_mysql.php on line 370 

//shell 
<?php 

class ReportShell extends Shell 
{ 
    var $uses = array('Customer'); 
    function main() 
    { 
      $customers = $this->Customer->find('all'); 
      var_dump($customers); 
      $this->out('lol my first CakePHP shell is baked'); 
    } 
} 

?> 

//model 
<?php 

class Customer extends AppModel 
{ 
    var $name = "Customer"; 
    var $useTable = "customer"; 
    var $hasMany = array 
    ('CustomerPrice', 
    'Order' => array('foreignKey' => 'customer_id')); 

    // Validation settings 
    var $validate = array(
      'customer_id' => array(
        'rule' => 'numeric', 
        'message' => 'A customer ID should be numeric !' 
      ), 
      'customer_number' => array(
        'rule' => 'numeric', 
        'message' => 'A customer number should be numeric !' 
      ), 
      'customer_name' => array(
        'rule' => 'notEmpty', 
        'message' => 'A customer number should be numeric !' 
      ) 
    ); 


    /** 
    * Function to retrieve Customer data 
    * 
    * @param string $response_type - CakePHP find() type 
    * @param array $response_setting - CakePHP find() parameter array (set$ 
    * @param int $customer_id - Find customer by customer ID 
    * @param int $customer_number - Find customer by customer number 
    * @param string $customer_name - Find customer by customer name 
    * @param int $customer_billing_month - Find customer by customer billi$ 
    * @param int $customer_start_date - Find customer by start date 
    * @param int $customer_end_date - Find customer by end date 
    * @param string $customer_email - Find customer by customer e-mail 
    */ 
    function FjmCustomerGetCustomer($response_type, $response_setting = arr$ 

      /* Conditions: Find Customer by customer data */ 
      if($customer_id) 
      {  $response = $this->Customer->findByCustomerId($response$ 
      if($customer_number) 
      {  $response = $this->Customer->findByCustomerNumber($resp$ 
      if($customer_name) 
      {  $response = $this->Customer->findByCustomerName($respon$ 
      if($customer_billing_month) 
      {  $response = $this->Customer->findByCustomerBillingMonth$ 
      if($customer_start_date) 
      {  $response = $this->Customer->findByCustomerStartDate($r$ 
      if($customer_end_date) 
      {  $response = $this->Customer->findByCustomerEndDate($res$ 
      if($customer_email) 
      {  $response = $this->Customer->findByCustomerEmail($respo$ 

      if(!$customer_id || !$customer_number || !$customer_name || !$c$ 
      {  $response = $this->Customer->find('all', $response_sett$ 

      return $response; 
    } 

    /* FjmCustomerGetCustomerByProduct 
    * FjmCustomerGetCustomerByOrder 
    * FjmCustomerGetCustomerByBill 
    * FjmCustomerGetCustomerByHandle 
    */ 
} 

?> 

//database config php 
    var $default = array(
      'driver' => 'mysql', 
      'persistent' => false, 
      'host' => 'localhost', 
      'login' => 'root', 
      'password' => 'pwd', 
      'database' => 'fjm_pps', 
      'prefix' => 'fjm_', 
    ); 

Répondre

1

La réponse est que le extention pour mysql en php cli n'a pas été activé ou installé

5

« Erreur fatale: Appel à mysql_connect undefined function() » signifie que vous n'avez pas les bibliothèques MySQL incluses dans votre installation de PHP.

Vérifiez votre php.ini et assurez-vous que l'extension mysql est activée. Le "extension = mysql.so" (ou "extension = php_mysql.dll") doit être décommenté.

Aidez-nous à obtenir de l'aide pour intégrer les bibliothèques MySQL dans votre installation PHP.

4

Notez également que sur certaines installations (debian vient à l'esprit), sinon tous, cli-php et apache-php ont séparé php.ini: s. Donc, avoir mysql activé dans l'un ne contribue pas nécessairement à l'autre. Utilisez phpinfo() pour savoir d'où il cherche php.ini.

+0

oui probablement la plupart des distributions linux ont un php.ini différend –

Questions connexes