[SOLVED] Connecting to a db

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
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

[SOLVED] Connecting to a db

Post by dull1554 »

i wrote a registration script that writes given information to my database, but my problem is i cant connect to the database, heres my db connection code.

db.php

Code: Select all

<? 

$dbhost = 'www.freesql.org';
$dbusername = 'dull1554';
$dbpasswd = 'andrew';
$database_name = 'complexscripting';



$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server.");
	
$db = mysql_select_db("$database_name", $connection) or die ("Couldn't select database.");
?>
___________________________________

the odd thing is that when i run it on my local server it executes and connects to the server exactly how i want it to, but as soon as i upload it to my web server and try to execute it, it cont connect to the server

Warning: mysql_connect(): Can't connect to MySQL server on 'www.freesql.org' (10060) in d:\web\dull1554\db.php on line 10
Couldn't connect to server.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

i hope that isn't your actual username/password #1.

#2, make sure that's the correct address... because when I was with phpwebhosting.com, they gave me a specific address to connect to ( actuall it was an IP, not a domain ). if that's the address, then remove the www's ...
lachhekumar
Forum Newbie
Posts: 2
Joined: Tue Dec 02, 2003 10:17 am

Post by lachhekumar »

Hi

Test it by using the localhost at the host address

[ kumar ]
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

you have to give me some credit, i'm not stupid enough to put my username and password up, and can i specifiy the port # when i connect
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i just go trid of the www
it works now
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

sweet

edit :

no offense was intended man. just people have been doing that a lot lately, and was just making sure for your own security ;)
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

thanks a mill
Post Reply