This has me stumped. I am trying to set encoding for my Sqlserver connection and all that I have tried has failed. I only get
Error: A Database connection using "Sqlserver" was missing or unable
to connect. The database server returned this error:
SQLSTATE[IMSSP]: An invalid encoding was specified for
SQLSRV_ATTR_ENCODING.
The original error I was trying to solve through encoding is:
Error: SQLSTATE[IMSSP]: An error occurred translating the query string
to UTF-16: No mapping for the Unicode character exists in the target
multi-byte code page.
The SQL version is 2008 R2
Cakephp Version: 2.4.2
PHP Version: 5.3.27
After a lot of trial and error this works:
public $default = array(
'datasource' => 'Database/Sqlserver',
'persistent' => false,
'host' => 'localhost',
'login' => 'sa',
'password' => 'password',
'database' => 'SchedulingDatabase',
'encoding' => PDO::SQLSRV_ENCODING_UTF8
);
Tried this out with Cakephp 3.0 seems to work nicely.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => false,
'host' => 'localhost',
'port' => '1433', //using this port
'username' => 'sa',
'password' => 'password',
'database' => 'cake_bookmarks',
'encoding' => PDO::SQLSRV_ENCODING_UTF8,
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
]
SQL 2008 doesn't support UTF-16 only SQL 2012
http://msdn.microsoft.com/en-us/library/ms143726(v=sql.110).aspx
UTF-8 isn't supported at all by MS SQL.
Related
How can I connect my Laravel to my SQL SERVER 2014?
TRIED METHODS
first
I tried to use sqlsvr in my .env and change my config > database.php to 'default' => env('DB_CONNECTION', 'sqlsvr').
"my..." replace my actual credentials.
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => 'myServerName',
'port' => '1433',
'database' => 'myDatabaseName',
'username' => 'myUserName',
'password' => 'myPassword',
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
But it throws an error of:
Database [sqlsrv] not configured
second
I tried some method using odbc connection find some package on GitHub but no luck, some have errors and some not supported by Laravel 5+
OTHER INFO
I'm using Larave 6.0.1 and SQL Server 2014.
Any help will do.
I am using Emoji character in my project for facebook post. Some emoji character are saved good but some characters are saved like (??) into mysql database. My database table Default collation is utf8mb4_unicode_ci .
Is there any way to save all emoji into database.
I am working in Cakephp3.
My database structure is :
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => '******',
'password' => '******',
'database' => '******',
'encoding' => 'utf8mb4',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
'url' => env('DATABASE_URL', null),
],
I had a similar problem to this when dealing with unusual characters such as this. The issue wasnt with the database, it was with how i was connecting to the database. Since you have provided no code, I can't give any specific advice, but check your DB connection string and make sure its using the mb4 version of utf8. Otherwise the response will not contain the characters.
If you are using PDO, then your db string will look like this.
$db = 'mysql:host=example.com;dbname=testdb;port=1234;charset=utf8mb4';
I have a Laravel 4 website on my localhost and i was using Oracle database.
I tested it perfectly for weeks, no problem occured.
Suddenly when it started giving the error: ORA-01017: invalid username/password; logon denied
In my app/config/database.php i have,
'oracle' => array(
'driver' => 'pdo-via-oci8',
'host' => 'localhost',
'port' => '1521',
'database' => 'orcl', //xe Service ID
'username' => 'system', //schema
'password' => '123',
'charset' => '',
'prefix' => '',
),
My SQL PLUS and Sql Developer is running fine with the same username-password.
Please help .
Try ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;
Hi i am trying to connect Postgresql with Apache 24.apache 24 for localhost runs on my webpage,but when i try to connect to the database it gives me this error.
Datasource class Postgres could not be found.
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Postgres',
'persistent' => false,
'host' => 'localhost:81',
'login' => 'postgres',
'password' => '786323',
'database' => 'Blog',
'schema' => 'public',
'prefix' => '',
'encoding' => 'utf8',
);
what m i doing wrong???
Check that your php has the pgsql pdo driver extension and that it is loaded.
The question was not clear.
But you can refer this website:
http://www.connectionstrings.com/postgresql
I think
'datasource' => 'Database/Postgres',
should be
'data source' => 'Database/Postgres',
I'm trying to setup my fuelphp on ubuntu12, nginx in a development environment.
Everything was working for me except when I try to do php oil refine migrate.
I was faced with the following error message:
Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94
My development/db.php:
return array(
'default' => array(
'connection' => array(
'dsn' => 'mysql:host=localhost;dbname=fuel_intro',
'username' => 'root',
'password' => '',
),
),
);
I searched the Internet and fuelphp docs, and still no luck.
Any help will be appreciated.
It seems you're doing database configuration incorrectly. It shouldn't be 'host:localhost', it should be like 'hostname'=>'localhost'. And please use mysql or PDO instead of mysql... (because mysql_* functions are deprecated.
It should be something like:
'default' => array(
'type' => 'mysqli',
'connection' => array(
'hostname' => 'localhost',
'port' => '3306',
'database' => 'fuel_db',
'username' => 'your_username',
'password' => 'y0uR_p#ssW0rd',
'persistent' => false,
'compress' => false,
),
'identifier' => '`',
'table_prefix' => '',
'charset' => 'utf8',
'enable_cache' => true,
'profiling' => false,
),
Take a look at:
http://fuelphp.com/docs/classes/database/introduction.html for further information.