Directory path issues?

Hi Everybody,

I have wampserver set up on my desktop.

Any databases that I might create are stored in:
C:\wamp\bin\mysql\mysql5.5.24\data\DataBase Folder\DataBase.name
Currently, the only contents of the DataBase Folder are a few files with a [frm] extension and a single db.obt file

On the other hand, any PHP projects I will play with are stored in:
C:\wamp\www\ProjectName

The following is where I bang my head into a wall…

mysqli_connect(host, username, password, database, port, socket)

host: I sorta get this one, as long as I am using wampserver but when I run a project from an actual live web hosting company what value is used here?

username and password: Totally don’t understand this. If a username and password are written right into the web code… doesn’t that just defeat the purpose?

database: If I am trying to find a specific field in one table contained in a database… what do I do?

There are several questions… but could someone direct me to a tutorial that will not assume that I can read between the lines??? I can do the “Hello World” level things with PHP, but even really low level registration scripts seem to assume that I understand these things and really… I swim like a rock.

many thanks,
Paul

After installing wamp you can access phpmyadmin at http://localhost/phpmyadmin. Phpmyadmin is an open source php tool for managing your sql databases.

In phpmyadmin you should set up a new user for each project, with a unique password. When registering a new user you can choose to create a database with the same name, and grant that user full access to the database.

Now you should have at least two databases
information_schema
yourdatabase

Then you should use the following settings
host: localhost
username: the username of the database user you created
password: the password of the database user you created
database: the name of the database, in this example it would be the same as the username

Your host will supply this information, it is either localhost or the ip/hostname to whichever db-server you get assignes to.

After successfully connecting you should look into mysqli or pdo parameterized queries.
http://php.net/manual/en/mysqli.prepare.php

I have a PDO tutorial in my signature, I find it much (much) easier to work with databases using a wrapper class.

Thank you, JimL

I’m still hung up about telling the connect script “where” to be looking for the data files. Ordinarily, I would expect to be saying something like “…/data/databaseName/tableName” or “C:\wamp…” etc.

How do I do that?

Paul

You don’t need to. Just connect to a database server with a valid login, and choose a database (which the user has access to). The database server handles the rest.

Sponsor our Newsletter | Privacy Policy | Terms of Service