Click to See Complete Forum and Search --> : MySQL and php


spiresgate
06-30-2007, 10:54 AM
I am trying to learn the use of php with mySQL.

I have succesfully established a database (1 table, 6 fields) on the local server using XAMPP MySQL.

Where do I upload my php scripts that utilise the database? I know the obvious answer is to the local server, but I can't see how to do this. There is nothing indicating such a 'directory' on my Windows Explorer tree.:(

blulagoon
06-30-2007, 02:15 PM
If you are running Windows, you should have an htdocs folder somewhere, ( I don't use XAMPP myself) which is the default document root. Document root is set in the httpd.conf file, which you should find in a conf directory, so you can change it, but for now if you can't find the htdocs folder you can open the httpd.conf file in notepad and search it for document root.

You'll also need to look at the mysql_connect php function to see how to connect to the database using php.

HTH - Blu

spiresgate
07-01-2007, 08:13 AM
Thanks blulagoon.

htdocs was in the xampp directory.

TJ111
07-02-2007, 11:24 AM
PHP scripts can be located anywhere that the php.ini file points to.

Also they can be located on any webpage as long as you have a database connection set up.

$dbDatabase='your_db_name';
$dbUser='your_username';
$dbPass='password';
$dbHost='localhost'; //Default host

$db = mysql_connect("$dbHost","$dbUser", "$dbPass") or die ("Couldn't connect to Database.");

mysql_select_db($dbDatabase, $db) or die ("Couldn't find the database.");