Learn PHP Part 1 Taster
By cloudweb
Learn PHP Part 1 Taster
In these series of tutorials I will show you how to learn php my way. I am self taught in the language and I will show you the useful tips and hints that I have learnt on the way.
In order to complete these tutorials I would advise you have some knowledge of programming.
Connecting to a MySQL Database
It’s always handy to write a little script which you can include into your projects to connect to a database:
<?php
// Connect to a mysql database
// Host Name
$hostname_dbase = "localhost";
// Database Name
$database_dbase = "mydatabase";
// Database Username
$username_dbase = "root";
// Database Password
$password_dbase ="password";
>
// Connect...
$dbase = mysql_connect($hostname_dbase,$username_dbase,$password_dbase) or die(mysql_error()); // show error if fails
mysql_select_db($database_dbase, $dbase);
?>
When you create you php project files you can include this into each page where you wish to connect to the database and perform queries:
<?php
require_once(“settings.php”);
?>
If you would like to see more of these tutorials, or have any specific requests then please let me know and I will get to work!
Comments
No comments yet.