@NogDogFeb 15.2016 — #It is not clear to me what you are trying to do with regard to the free server, and what that has to do with connecting to it from local host (does that mean from your own personal computer?).
@RuchithauthorFeb 15.2016 — #i was sleepy, sorry. what i am saying is i got this free web server and i uploaded my db and the php files. when trying to run it its giving a lot of errors. specially with the connection string.
i have defined as localhost. now i need to change and i dont know what to change it to
@NogDogFeb 15.2016 — #You may have to find that out from the hosting company. Somewhere on their control panel for your site there, they should have info about the host name (and possibly port number) you should use to connect to the DB server.
@ginerjmFeb 20.2016 — #Has your problem been solved yet? I ask only because I'm thinking that you might be trying to get an answer from a recalcitrant hosting company.
Here is how my code does it ( I use pdo) [code=php] $pdo = new PDO($host,$uid,$pswd,$db_options); [/code]
where $host is the string: [code=php] $host="mysql:host=localhost;dbname=$sc_dbname;charset=utf8"; [/code] $uid and $pswd are what you have setup when you created the database that you are trying to connect to. $db_options are defaulted to the common settings: [code=php] $db_options = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); [/code]
This code is part of a std. db connect function that I use all the time where I pass in the desired dbname as an argument of the function header.