Dragan Marjanovic Dragan Marjanovic - 14 days ago 7
MySQL Question

Connecting to a mysql Database via PHP?

Ok, Ive been playing around with PHP and databases. Note, Im doing all my work on a webserver hosted by bluehost.
So I went into the cpanel and set up a database called gagalugc_stocks.
I also setup a username (test) and a password (password) and added them to be able to control the databse. Below is my script in an attempt to connect to it, not it is also on the server.

<?php
$connect = mysql_connect('localhost','test','password');
if(!$connect){die('Could not reach database!');}
mysql_select_db("gagalugc_stocks", $connect)
?>


-Thanks

NOTE: The problem is that it can never reach the database.

Answer

Didn't check for port when adding database make sure to specify host and port

(localhost:2083)
Comments