Page 1 of 1

mysql connect question

Posted: Mon Nov 22, 2010 8:24 am
by pagnil8
hi every 1...

can you help me on my problem?

ok its all about php connect to mysql...

here is my scenario:

ok

* i have my own website which is uploaded to a web hosting with database...

*(lets call this website http://www.uploaded_website.com / sample external ip is 199.199.1.1 and sample internal ip is 192.168.1.1 and connected to port:80 "idk if it is port 80 or port 8080")

1. my first question... if im going to connect it to its database which is uploaded also on the host. am I still allowed to use localhost?

ex. code

$dbhost = 'localhost'; or $dbhost = '199.199.1.1:80'; or $dbhost = '192.168.1.1:80';
$dbuser = 'user';
$dbpass = '121212';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');



problem 2.

lets assume that i connected the database of my website on its webserver:

*then i got a php webpage which is on my PC/personal computer with wampserver (not uploaded on my hosting site).

*am i able to connect to the database on http://www.uploaded_website.com? (ofcorse i know its IP and database username and password.)

the question:

1. is it possible to connect? "pls say yes :_: ... my project depends on this"

2. what would be my connection code if ever?

i found a code here but idk if it is the answer on my question 1

db.php-mysql-tutorial.com is the sqlserver name [how could i know my sqlserver name?]

and the 3306 is the port for mysql "they say"

<?php
$dbhost = 'db.php-mysql-tutorial.com:3306';
$dbuser = 'root';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');


if ever you get confused to my problem... here is a image that shows all about what i say

Image

Uploaded with ImageShack.us

Re: mysql connect question

Posted: Mon Nov 22, 2010 8:27 am
by aravona
First things first.

I have some websites with a third party hosting. They have Ip's and ports. I use localhost. You should be able to, best to try a test php page.

As for point number 2. Your wamp should be able to connect to a live DB, I've connected mine in the past so that I can use live data but test layout and design locally.

Re: mysql connect question

Posted: Mon Nov 22, 2010 8:37 am
by pagnil8
aravona wrote:First things first.

I have some websites with a third party hosting. They have Ip's and ports. I use localhost. You should be able to, best to try a test php page.

As for point number 2. Your wamp should be able to connect to a live DB, I've connected mine in the past so that I can use live data but test layout and design locally.
wow thnx for your answer...

actually i cant do an experiment on this since i hvnt find a reliable web hosting here on my country.

though im glad that you can use localhost...


on the second point... WOW... so it is possible... well all i just nid is the connection string on this... ^^, do you still remember?

any ways... thank you... ^^, i am more relieve...