php - Unknown database 'database_name' in MySQL with WAMPServer -
i have database named als , still got error.
<?php $mysql_host='localhost'; $mysql_user='root'; $mysql_password=''; $mysql_db='als'; $con = @mysql_connect($mysql_host,$mysql_user,$mysql_password) or die(mysql_error()); @mysql_select_db($mysql_db) or die(mysql_error()); ?>
there go. mysql_
family has been deprecated time. please change mysqli_
library. machine may work because it's using older version of php in hasn't been deprecated or deprecated warnings have been globally supressed.
in wild
$mysql_host='localhost'; $mysql_user='root'; $mysql_password=''; $mysql_db='als'; $con= mysqli_connect($mysql_host,$mysql_user,$mysql_password, $mysql_db) or die("error " . mysqli_error($con));
there's no need arbitrarily select database anymore. can use $con
argument mysqli_
family of procedural functions.
last, not least, never debug @
symbol. suppresses error warnings function precedes.
Comments
Post a Comment