0
I have the connection PDO
with mysql
down below:
$dsn = 'mysql:host=' . self::$hostname . '; dbname=' . self::$dbname;
$opcoes = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
self::$conexao = new PDO(
$dsn,
self::$username,
self::$password,
$opcoes
);
that works perfectly.
But if I put the contents of variable $dsn
next to string of connection as below error which seems to me to be of concatenation.
Will someone please help me find out where that mistake is?
$opcoes = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
self::$conexao = new PDO( "mysql:
host=" . self::$hostname . ";
dbname=" . self::$dbname,
self::$username,
self::$password,
$opcoes
);
As far as I know, it is not possible to have line breaks in the DSN.
– Gabriel Heming
solved the problem?
– Wees Smith
yes. I have already accepted the answer below. Thank you!
– Carlos Rocha