php - Connect to MySQL in MAMP -


i'm trying make html form connect mysql database on mamp.

however i'm not able open mysql connection. keep getting message "could not connect"

my thoughts -

  1. the host incorrect
  2. the username and/or password incorrect. found information in config.inc.php, believe correct, there's possibility ..

here's php script

<?php class database {     function insert() {         $dbhost = 'localhost:8888';         $conn = mysql_connect($dbhost, 'root', 'root');         if (! $conn) {             die('could not connect: ' . mysql_error());         }         else {             echo "connected";         }     }    } 

?>

possible solutions this thread:

a) launch mamp, go preferences , set sql port 3306.

b) use set of commands:

ps aux | grep mysql  lsof -i  killall -9 mysqld  

in terminal , restart mamp.

have nice day.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -