Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   SQL/PHP Help (http://www.programmingforums.org/showthread.php?t=7144)

bigguy Nov 22nd, 2005 2:18 PM

SQL/PHP Help
 
I need to know what this does?

case "login":
$connection = mysql_connect($host, $user, $password) or die ("Could not connect.");
$db = mysql_select_db($database, $connection) or die ("Could not select database.");

I need to know what

&host
&user
&password
&database
&connection

does. Does it mean like connect to Database name host and then asign values in the user and password tables

in the PHP i have a

username
password
email
first name
last name

so i need to knwo what goes to what and thne when u loginin i have a

login
password field

Ooble Nov 22nd, 2005 2:40 PM

First of all, those are dollar signs ($), not ampersands (&). They're very different. This is very basic PHP - I suggest you pick up a book on the language or take a look at the excellent documentation on www.php.net.

DaWei Nov 22nd, 2005 2:59 PM

If you bring up that link Ooble provided, and put things like this:

mysql_connect
mysql_select_db

in the search box and click "go", you should feel that Christmas has come early.

Lich Nov 22nd, 2005 3:02 PM

aside from the fact that there's errors in your code and you should have it in PHP tags for this board, i'll try to explain your problem.

mysql_connect(); is a php function, it connects to mysql. It takes 3 args, host, user, and password.

$host is the host where the database is. This is usually localhost
$user is your database username and
$password is your database password

Now that you've connected to mysql, you need to select the database using
mysql_select_db();

This takes the connection you made before ($connection) and the name of the database you're using, stored in the $database variable.

Usually, all these variables are set in something like a config file that you make that all your site can access.

The stuff like the login form doesn't do anything with this page, those variables are stored in $_POST[] you need to do something with them and check to see if it matches the name and password in the database.

bigguy Nov 22nd, 2005 10:31 PM

Ok, localhost? what would that be I host with Yahoo, and it sasy PhpMyAdmin2.4.3.1 is running on myadmin.teamaando.com as bigguy@localhost.

Is this what i need or sumthign else, i have no idea how ot use phpmyadmin .

Lich Nov 23rd, 2005 12:14 AM

Quote:

Originally Posted by bigguy
Ok, localhost? what would that be I host with Yahoo, and it sasy PhpMyAdmin2.4.3.1 is running on myadmin.teamaando.com as bigguy@localhost.

Is this what i need or sumthign else, i have no idea how ot use phpmyadmin .

no. Do not confuse phpmyadmin with MySQL, they are not the same thing. MySQL is the database. PHPmyAdmin is a program, written in PHP, to allow mySQL database administration.

It says right there: bigguy@localhost. username@host. Localhost is your host, bigguy is your username, and you should know your password.

I highly reccomend picking up something like SQL in a nutshell or PHP and mySQL web development and start reading or you'll be fumbling through this quite a bit. Read first, ask questions later


All times are GMT -5. The time now is 8:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC