mysql - PHP mysql_connect with array -
i'm creating website php. have information of mysql in file , use $cnf=file("cnf.txt");
information. use $ligacao=mysql_connect($cnf[0],$cnf[1],$cnf[2]);
. when enter in website gives me warning in mysql_connect. if make echo of positions of array haves correct values.
can 1 tell me wrong?
the original code:
$cnf=file("cnf.txt"); $erro=0; $ligacao=mysql_connect($cnf[0],$cnf[1],$cnf[2]);
avoid using mysql_*
functions deprecated.
the issue each value in $cnf
array has trailing newline \n
character on file.
at least, try:
$cnf = file("cnf.txt"); $erro = 0; $ligacao = mysql_connect(rtrim($cnf[0]),rtrim($cnf[1]),rtrim($cnf[2]));
Comments
Post a Comment