Two wrong messages (mySql)


I wrote a wrong localhost:

$mysql_host = 'locfalhost';

This is all code:

$conn_error = 'Could not connect.';
$mysql_host = 'locfalhost';
$mysql_user = 'root';
$mysql_pass = '';
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die($conn_error);

And I receive two messages. Why Two?

Thank you.

You misspelled localhost (it doesn’t have an ‘f’ in it)

What framework are you using?
Perhaps it has duplicate codes in there.

Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn’t tie you down so much to a particular database server software.

Once you have migrated you should use Prepared Statements to prevent SQL Injection attacks. Have a read of this article from the PHP manual, it shows how to use prepared statements with PDO and also explains the principle.

Thank you very much :slight_smile: