So, I've tried connecting to a database I made... but I can't get the servername right. Apparently, after a little search of the forums, I am not allowed to connect to x10 or whatever to get to my database. I'm confused.
I've pretty much copy pasted some code I found somewhere to help me connect to the database... looks something like this:
So is it a hopeless cause and I can't use my database at all, or is it something to do with the code? I'm new to php and mysql and whatnot, so I really have no clue.Code:// hostname or ip of server $servername='localhost'; // username and password to log onto db server $dbusername='myusername'; $dbpassword='mypassword'; // name of database $dbname='my_database'; ////////////// Do not edit below///////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
Thanks.


LinkBack URL
About LinkBacks
Reply With Quote


