I am testing a local login database page on my pc under LAMP. And even though i can connect to mysql from terminal, I cannot do so from a php script. I've looked all over online but every where i go its just the following code in one variation or another
<!DOCTYPE HTML5>
<html>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css">
<head>
</head>
<body>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
/* connect to the db */
$connection = mysql_connect('localhost', 'username', 'password') or die ("Connect error");
mysql_select_db('myDatabase',$connection);
/* show tables */
$res = mysql_query("SHOW DATABASES", $connection) or die ("No Show Database");
while ($row = mysql_fetch_row($res))
{
echo $row[0], '<br/>';
}
?>
</body>
</html>
There is another page that takes username and password and then pass it to this page via POST method, But this page instantly shows me Connect error. I event tried it with an if else instead of the or die but still can't connect.