mysql connect question
Posted: Mon Nov 22, 2010 8:24 am
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

Uploaded with ImageShack.us
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

Uploaded with ImageShack.us