| Code: |
| <?
$db_host = "localhost"; $db_user = "[color=red]username[/color]"; $db_password = "[color=red]password[/color]"; $db_name = "[color=red]database name[/color]"; mysql_connect($db_host,$db_user,$db_password) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error()); ?> |
The bits in red, you change to your appropriate details. Sometimes your host isnt localhost, but most of the time it is.
| Code: |
|
$db_host = "localhost"; $db_user = "[color=red]username[/color]"; $db_password = "[color=red]password[/color]"; $db_name = "[color=red]database name[/color]"; |
Just sets the variables for the code to connect to.
| Code: |
| mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error()); |
This just connects to the database and is ready for you to echo data!
Also, remember that when filling in your database name and user name, your cpanel user always comes in front. Example:
jack_databaseuser
jack_databasename
