Uploding the files of website to the Internet

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mustafamisir
Forum Newbie
Posts: 23
Joined: Wed Jun 22, 2005 1:00 pm
Contact:

Uploding the files of website to the Internet

Post by mustafamisir »

Hi all,

I want to my website on the Internet.

Code: Select all

$db = mysql_connect("127.0.0.1", "root");

	if ( ! $db ) die ("...");

	mysql_select_db("mysql" , $db)
	or die ("...". mysql_error() );

	$result = mysql_query("SELECT * FROM tel_detail",$db);
But the code includes like "127.0.0.1", "mysql" etc. They are valid in my computer but not valid on the Internet. So, what will I do for these terms and which files I must upload for database?

d11wtq | Please use

Code: Select all

tags to post PHP code[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Assuming your host that you will put the script on has it's own mysql server, you shouldn't need to change the IP. 127.0.0.1 is the IP address of localhost so their server will *most likely* be on that same IP address.

You'll need to change your username and password to whatever the web host gave you so that you can access the database though.

What files should you upload? I don't understand :? All of them if it's a gonna be run on the web host.
mustafamisir
Forum Newbie
Posts: 23
Joined: Wed Jun 22, 2005 1:00 pm
Contact:

Post by mustafamisir »

I mean that for files;
There are some files which comes from database. Like for my website, there is a database called "mysql" which includes the table called "tel_details" which covers all the information. I only put "tel_detay.MYI" or another files, I dont know this.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

mustafamisir wrote:I mean that for files;
There are some files which comes from database. Like for my website, there is a database called "mysql" which includes the table called "tel_details" which covers all the information. I only put "tel_detay.MYI" or another files, I dont know this.
Huh? If I'm understanding you correctly (MYI is a MyISAM database file) you're trying to move the database files themselves to the server?

If I have that correct, you need to read up on database backups. The correct method is to take a "dump" of your database and then restore it to the database on your host.

You can take a dump using the mysqldump command from the command line.

Code: Select all

mysqldump databasename -u username -p > dumpfilename.sql
That dumps all the SQL code for the database into dumpfilename.sql

You then need to upload that to the other server and login to mysql and issue the command.

Code: Select all

mysql> \. /path/to/dumpfilename.sql
That will spit all the data back out to your other database.

d11

EDIT | You can do this via phpMyAdmin too ;)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

It's not completely on-topic, but one thing that I do for sites that makes life easier when you come to upload them is define all the database and URL settings as constants, and use them throughout the site rather than hardcoding stuff. Then I can dump everything in a constants file, and choose which to use there:

Code: Select all

switch($_SERVER['SERVER_NAME']) {

case "localhost":
//Local development machine
define("DATABASE_HOST","localhost");
define("DATABASE_USER","localuser");
define("DATABASE_PASSWORD","localpass");
define("PRIMARY_DATABASE_NAME","database");
define("SECURE","");
break;

case "www.testurl.com":
//Test server
define("DATABASE_HOST","localhost");
define("DATABASE_USER","testuser");
define("DATABASE_PASSWORD","testpass");
define("PRIMARY_DATABASE_NAME","database");
define("SECURE","");
break;

case "www.liveurl.com":
//Live server
define("DATABASE_HOST","localhost");
define("DATABASE_USER","liveuser");
define("DATABASE_PASSWORD","livepass");
define("PRIMARY_DATABASE_NAME","database");
define("SECURE","https://www.domain.com/");
break;

}
This means you don't have to concern yourself with changing passwords and stuff when you upload. So long as the URL is right it'll just work. (Note: It does give hackers more info if they break in though)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I awlays make a db_settings.conf.php file but I hadn't thought of using that method onion2k. Using SERVER_NAME sounds like a good idea to save time, thanks for that bit of inspiration :D
Post Reply