Figuring out PHP, MySQL

Started by
7 comments, last by Drakkcon 19 years, 11 months ago
Wow, I'm completely and utterly confused! I know that PHP is a server-side scripting language, I know the syntax, I'm fine with PHP. Then I try to create forums. I know that mysql is usually used for this kind of thing, so I give it a look. Now I have both PHP and mysql working fine, but how do I use it? I put the php code:




   
I KNOW that this server exists, but what's wrong with my function call? Is the url supposed to be defined elsewhere? Are the username and password supposed to be surrounded by quotes? The documentation (always) makes no sense EDIT: Also, where does CGI enter the picture. The php binary somehow involves CGI, but isn't CGI just a scripting language? The true general first seeks victory, then seeks battle - Sun Tzu [edited by - Drakkcon on May 9, 2004 8:39:24 AM]
Advertisement
I found the documentation for PHP and mySQL to be almost faultless. Nevertheless, the correct command is(i think)..


mysql_connect("myserver","bob","mypassword");

note: some servers don't allow (for security reasons), access from external machines. So you should use "localhost". Even if the server you're putting the PHP on is the server the mySQL db is on, the IP resolved will not be 127.0.0.1, so it might complain.

Whilst I was learning mySQL and PHP I wrote a (rather shoddy) text based web game, you can get it in the Delphi section(rather intuitive I know), on my site.

"You are in a room. You can see a cow."
">look at cow"
"It is a cow."
.:Cubicle2:.


[edited by - Zanthos on May 9, 2004 8:45:03 AM]
Oh AYYYYE get it now! So localhost refers to the server ''cause it''s server side! I thought localhost referred to MY computer! Thanks for making a nü0b happy
Ah, to clarify Drakkcon, localhost is a computers loop-back address. It's the URL a computer can go to to connect to itself.

So in the case of PHP and MySql, if the webserver running the PHP scripts and the MySQL server are on the same computer, then you can use localhost.

Likewise, if you run a web server on your computer, fire up a browser and go to the URL 'localhost' (or 127.0.0.1), you will connect to your own webserver.

[edited by - botman2 on May 9, 2004 8:59:28 AM]
quote:
Oh AYYYYE get it now! So localhost refers to the server ''cause it''s server side! I thought localhost referred to MY computer! Thanks for making a nü0b happy

"localhost" is your computer. You always want to refer to "localhost" internally to avoid any issues with remote access to the server.

The problem is probably that you just don''t have SMTP configured on your computer...hence sending mail won''t work.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Nope, just POP3 for me.(you can tell I have no clue what I''m talking about) Would I have to setup SMTP in order to use any mailing functions with PHP?

The true general first seeks victory, then seeks battle
- Sun Tzu
quote:Nope, just POP3 for me.(you can tell I have no clue what I''m talking about)


POP3 is not used for sending mail. SMTP is.

quote:
Would I have to setup SMTP in order to use any mailing functions with PHP?


The machine that''s specified in the call needs to be, whether it''s the local host or a remote server.

I think you might be jumping ahead of yourself in the learning process. Try starting a little lower-level.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Fine, but I got the e-mail working. Now overly-ambitious me is trying to program a forum, because practical me can see only one use for php.... Any resources?
Ah, I found some. Nm.

This topic is closed to new replies.

Advertisement