An uncaught Exception was encountered - ERROR CONNECT DATABASE - php

An uncaught Exception was encountered
Type: Error
Message: Call to undefined function mysql_connect()
Filename: C:\xampp\htdocs\Salab\system\database\drivers\mysql\mysql_driver.php
Line Number: 136
Backtrace:
File: C:\xampp\htdocs\Salab\application\third_party\MX\Loader.php
Line: 109 Function: DB
File: C:\xampp\htdocs\Salab\application\third_party\MX\Loader.php
Line: 65 Function: initialize
File: C:\xampp\htdocs\Salab\application\third_party\MX\Base.php Line:
55 Function: __construct
File: C:\xampp\htdocs\Salab\application\third_party\MX\Base.php Line:
60 Function: __construct
File: C:\xampp\htdocs\Salab\application\third_party\MX\Controller.php
Line: 4 Function: require
File: C:\xampp\htdocs\Salab\application\third_party\MX\Modules.php
Line: 123 Function: include_once
File:
C:\xampp\htdocs\Salab\application\modules\acesso\controllers\Acesso.php
Line: 3 Function: spl_autoload_call
File: C:\xampp\htdocs\Salab\index.php Line: 315 Function: require_once

Could you Send the method you using to connect to the database
you could try this
<?php
//Create Connection
$con=mysql_connect("localhost","root","");
//Create Database
$CreateDb="Create database db2";
mysql_query($CreateDb,$con);
//Select Database
mysql_Select_db("db2",$con);
?>

If you are using php7 you should move to mysqli as mysql was deprecated
If you are using an earlier version then it seems that the mysql extension is not installed or enabled (note that looking forward you'd better move to mysqli anyway)

Check in your php.ini file if you have the line and it's not commented:
extension=php_mysql.dll

Related

Call to undefined function mysqli_init() [duplicate]

This question already has answers here:
Codeigniter: fatal error call to undefined function mysqli_init()
(14 answers)
Closed 2 days ago.
An uncaught Exception was encountered
Type: Error
Message: Call to undefined function mysqli_init()
Filename: /home/sourcecars/public_html/carsonbarlcon.com/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 135
Backtrace:
File: /home/sourcecars/public_html/carsonbarlcon.com/application/hooks/EloquentHook.php
Line: 31
Function: database
File: /home/sourcecars/public_html/carsonbarlcon.com/application/hooks/EloquentHook.php
Line: 46
Function: loadDatabase
File: /home/sourcecars/public_html/carsonbarlcon.com/index.php
Line: 316
Function: require_once
Install mysqli php extension
please check php-mysqli is installed?
check php.ini and make sure the extension is loaded.
extension=php_mysqli.dll
if it's a php framework make sure in the framework config.php file what driver you are using.

A PHP Error was encountered with core/Model

Hi am trying Basic CRUD Operation with MySQL Database with example and am new in this platform am facing some problem please help
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Products::$db
Filename: core/Model.php
Line Number: 73
Backtrace:
File: C:\xampp\htdocs\CodeIgniter-3.1.9\application\models\ProductsModel.php
Line: 9
Function: __get
File: C:\xampp\htdocs\CodeIgniter-3.1.9\application\controllers\Products.php
Line: 17
Function: get_products
File: C:\xampp\htdocs\CodeIgniter-3.1.9\index.php
Line: 315
Function: require_once
An uncaught Exception was encountered
Type: Error
Message: Call to a member function get() on null
Filename: C:\xampp\htdocs\CodeIgniter-3.1.9\application\models\ProductsModel.php
Line Number: 9
Backtrace:
File: C:\xampp\htdocs\CodeIgniter-3.1.9\application\controllers\Products.php
Line: 17
Function: get_products
File: C:\xampp\htdocs\CodeIgniter-3.1.9\index.php
Line: 315
Function: require_once

Error after install SSL Codeigniter

For the first time I see this message error after I put https in my codeigniter website.
Message: Call to undefined function iconv()
Filename: /home/admedica/public_html/admedicall_v1/application/views/admin/billing/bill/centro/bill.php
Line Number: 45
Backtrace:
File: /home/admedica/public_html/admedicall_v1/application/controllers/Admin.php
Line: 3981
Function: view
File: /home/admedica/public_html/admedicall_v1/index.php
Line: 315
Function: require_once
Before without https it works.
How can i solve this problem ?

Issue with PHPSpreadsheet

I'm trying to build a script that will write data to an excel file before sending an email. I'm using PHPSpreadsheet for this, but the initial example is throwing an error. Can someone please let me know where I'm going wrong and how I can fix it.
A PHP Error was encountered
Severity: Warning
Message: ZipArchive::close(): Failure to create temporary file: Permission denied
Filename: Writer/Xlsx.php
Line Number: 374
Backtrace:
File: /Library/WebServer/Documents/Projects/app/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php
Line: 374
Function: close
File: /Library/WebServer/Documents/Projects/app/application/controllers/Login.php
Line: 52
Function: save
File: /Library/WebServer/Documents/Projects/app/index.php
Line: 323
Function: require_once
An uncaught Exception was encountered
Type: PhpOffice\PhpSpreadsheet\Writer\Exception
Message: Could not close zip file helloworld.xlsx.
Filename: /Library/WebServer/Documents/Projects/app/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php
Line Number: 375
Backtrace:
File: /Library/WebServer/Documents/Projects/app/application/controllers/Login.php
Line: 52
Function: save
File: /Library/WebServer/Documents/Projects/app/index.php
Line: 323
Function: require_once
P.S. I'm using Codeigniter and my dev machine is a macbook and server is Ubuntu16.04 on AWS.

codeigniter doctrine getRepository() working on local but not on server

I am user CodeIgniter 3 and Doctrine2. Now, when I tried to find record it works on my local server but its not woking on my web server; here is my find code
$user = $this->em->getRepository('entities\AdminAuth')->findBy(
array(
'username' => $data['username'], 'password' => $pwd
)
);
Its showed me following error on my web server,
An uncaught Exception was encountered
Type: Error
Message: Access to undeclared static property: Modules::$loader
Filename:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/Common/ClassLoader.php
Line Number: 228
Backtrace:
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Line: 904 Function: classExists
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Line: 189 Function: validateAssocations
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Line: 171 Function: validateRuntimeMetadata
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Line: 302 Function: doLoadMetadata
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Line: 205 Function: loadMetadata
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/ORM/EntityManager.php
Line: 268 Function: getMetadataFor
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/third_party/Doctrine/ORM/EntityManager.php
Line: 682 Function: getClassMetadata
File:
/home/tiffintom/public_html/mgt/Master_Panel/application/modules/admin/controllers/Authentication.php
Line: 21 Function: getRepository
File: /home/tiffintom/public_html/mgt/Master_Panel/index.php Line: 322
Function: require_once**
Please help me
It was happening for the version of the doctrine classLoader. I used old version classLoader from my previous project thats why it was showing error.

Categories