Was wondering if I wanted to connect to a database and in PHP I would normally use localhost, what would I use for C++? I don't have MySQL++, I have some MySQL++ look-a-like and it didn't come with a tutorial.
Was wondering if I wanted to connect to a database and in PHP I would normally use localhost, what would I use for C++? I don't have MySQL++, I have some MySQL++ look-a-like and it didn't come with a tutorial.
localhost is defined via the OS, not by your program. You can use localhost when it asks for an ip address or host name. You could also use 127.0.0.1
I'm trying to connect to my database on the internet for my site using a program and it says it can't connect to the database. I'm positive I have the database correct, but not sure about localhost because I thought localhost meant the address to the mysql databases. I guess I'm confused.
No, localhost is defined by your OS. For instance, you can open up a command window and type in "ping localhost". localhost is just defined as your own machine.
Right, this might be confusing because in the case of PHP, which is executed on the machine that runs the webserver, localhost refers to that machine and not ... say, the machine running the webbrowser through which you look at your php site.Originally Posted by bithub
PHP is executed on the webserver, so localhost in a PHP program refers to that server.
So you're saying that localhost is defined by the server and not your machine when using PHP? And if so, how would I get to the server with C++?Originally Posted by Nyda
No, Nyda is saying that localhost refers to the machine that the code is being run on. With PHP, the code is run on the server, so localhost refers to the server.So you're saying that localhost is defined by the server and not your machine when using PHP?
This depends. Is the C++ code going to be run on the server, or the client machine?And if so, how would I get to the server with C++?
If your c++ program is going to be run on the server, then localhost will refer to the server.
If your program is going to be run on the client, then you need the domain name or ip address of the server to access it.
That makes sense now. Thanks for the info and both of your help is much appreciated, but I have one last question. I'm using the IP Address instead of localhost and now I can't select a database. I'm using the same settings as I would for PHP. Do I need to change the database, or username, or password in my program? Do I need to allow outside access on the server (And if so, how would I do that)? Sorry if I'm asking for too much.Originally Posted by bithub
Probably, because you are not connecting that DB server from it's own hostmachine.Originally Posted by stickman
I don't know. This is better be asked in a MySQL board or newsgroup. It might also well be your webhost won't permit outside access.Originally Posted by stickman
umm i didnt read the rest of the post, so ill just
throw my two cent in real quick.
localhost = 127.0.0.1 = the computer that your on
no matter where your at if its a windows computer, to access
itself you can use localhost or 127.0.01 , this is internal
ip address you could think of it like that. its a loopback
address, hope that clears it up more.
well technically localhost is whatever the HOSTS file says it is. This file is in c:\windows\system32\drivers\etc on XP machines (not sure where it is on other windows versions).localhost = 127.0.0.1 = the computer that your on
no matter where your at if its a windows computer
lol need to be specific do we, that wasnt anyways
it was just my point cause if i remember it doesnt
apply whatsoever to unix/linux systems
It does. The file is usually called /etc/hosts and could look like ...Originally Posted by JarJarBinks
Code:nyda, nyda/ $ cat /etc/hosts 127.0.0.1 traveltux localhost localhost.localdomain # IPV6 versions of localhost and co fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts # follows:AD removal [...]
Last edited by Nyda; 09-13-2004 at 11:14 AM.
Not present by default anywhere in 98SE other than the sample files (.SAM), you may however create one directly in the windows folder.Originally Posted by bithub
How do I add access from my IP Address to the server so I can connect to the databases? I totally understand the loaclhost thing, but I tried adding my IP Address as an access host and that didn't work. Shall I ask this on a mysql/cpanel forum? Anyway, thanks for all of your help. It's been much appreciated.