please help noob i dont know how to connect mysql to php
Posted: 09. May 2010 02:38
i have download xampp and i dont know how to connect mysql to php. i dont know were to save the file that i have create.
so i have been reading some tutorial about conecting my mysql to php and iam not sure were to put these file.
So, my question is is the code right and were do i save this files.
i have create 3 files.
1st file named connection.php
second file name is index.php
i dont know were to save this file
3rd file data.php
i dont know were to save this file
so i have been reading some tutorial about conecting my mysql to php and iam not sure were to put these file.
So, my question is is the code right and were do i save this files.
i have create 3 files.
1st file named connection.php
- Code: Select all
<?php
$dbhost = 'localhost';
$db = 'info';
$dbuser = 'root';
$dbpass = 'trun'; // password not real so people cant hack it
}
?>
second file name is index.php
i dont know were to save this file
- Code: Select all
<?php
include ('connection.php');
$connect = mysql_connect($dbhost, $db_user, $db_pass);
if(!connect){
die ( "could not coect tothe database: <br />". mysql_error());
}
?>
3rd file data.php
i dont know were to save this file
- Code: Select all
$db_select=mysql_select_db($info);
if(!$db_select)
{
die ("could not select the database: <br />". mysql_error());
}