Halls...?

Keep it clean but fun.
Post Reply
User avatar
Joey
Posts: 82
Joined: Mon Jan 11, 2010 3:47 am

Halls...?

Post by Joey »

Lets say... I want to upload the browser game to my Real Host and not WAMP, how would I go about it?
What would I have to change on my 'connect_to_database.php'?
FLASH - Epic

Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Halls...?

Post by Jackolantern »

You have to have your webhost administrator create a MySQL login for you. They should be able to provide you with a new user and password, and you need to update your MySQL connection code to reflect this new user.
The indelible lord of tl;dr
User avatar
Joey
Posts: 82
Joined: Mon Jan 11, 2010 3:47 am

Re: Halls...?

Post by Joey »

Yeah, my cPanel lets me choose a Username and Pass for my database, how do I enter those, so it connects?
FLASH - Epic

Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Halls...?

Post by Jackolantern »

I'm not sure what code exactly you are needing to update, but it should be outlined in Halls' videos. I am also not sure what the login he was using for the tutorials, but you just need to make sure it matches what you set up in the panel. If you post the code, I should be able to point it out.
The indelible lord of tl;dr
User avatar
Joey
Posts: 82
Joined: Mon Jan 11, 2010 3:47 am

Re: Halls...?

Post by Joey »

Not doing the code yet, just watching the tuts...

He uses WAMP and User is localhost :/

How would I go about connecting to my host itself?
FLASH - Epic

Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Halls...?

Post by Jackolantern »

The user shouldn't be "localhost". That is the host, which means the computer where the database resides. Your web admin will have to give you that name. Then the username will be what you set up in the panel. I have not watched that video yet, but Halls may just use "root" as the username, or he may create a specific user just for the tutorials. Just substitute your username that you create in the panel for that name, and the password you create for the password entered.

EDIT: If you are still watching the videos, and not coding yet, you probably should not be testing on your webhost. Just work on your files and test it locally, and when it is done, upload it all in its existing folders to the webhost. At that time you can just use a simple "Find and Replace" text editor feature to swap out your local username and password to the webhost username and password.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Halls...?

Post by hallsofvallhalla »

i am working on a video for this,

All you have to change is the host, username and password. At least for most hosts.
Loopy

Re: Halls...?

Post by Loopy »

Your server name will still generally be 'localhost'. It doesn't have to be, but it probably is. Cpanel lets you set up your own mysql users. So just go into cpanel and set up a new database. It will prompt you for the database name, and probably append your website username to the name of the database. So for instance, if your domain name is shizgaming.com, and you set up a database called 'shizdata', then your database name will probably look be 'shizgami_shizdata'.

Then you need to set up a user and assign him to the database. So create a new user by defining a username and a password. Again, your username will probably have the website username appended to it. So if your username is 'dbadmin', then your total username will probably be 'shizgami_dbadmin'

Password is just whatever you set it to.

Make sure after you set up the user, that you actually assign him to the database. It's done by just clicking a button in cpanel called 'Add User' or something like that.

So in your connection script, you'd have something that looks like this (I use a function, from a admin page, and then just include the file, and reference the function):

Code: Select all

function connectToMain(){
$userName = "shizgami_dbadmin";  //dbuser
$serverName = "localhost";
$password = "mypassword1234";
$dbConn=mysql_connect($serverName, $userName,$password);
if (!$dbConn){
  exit ('<p>Unable to connect to database</p>');
}
$select=mysql_select_db("shizgami_shizdata"); //db name
if(!$select){
print mysql_error() . "<br>\n";
}
return $dbConn;
}
Post Reply

Return to “Off-Topic”