• Advertisement

Archived

This topic is now archived and is closed to further replies.

Figuring out PHP, MySQL

This topic is 5032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

  • Advertisement