Hi guys I'm rich and I'm new to this forum and I hope I can help you guys as well as helping me!

I have been to staffs uni and got a 2:2 in applied it so I know almost all the in's and out's about IT and PHP, I have taken a year out as my mum has been very ill but now its time to start looking for graduate jobs employers want to see my coding skills so that is why I'm recreating the website I did for my dissertation.

I'm using heart internet for my domain name and this is where I'm accessing the SQL database. I'm aslo using joomla as my CMS.

I'm creating a space where users can regsiter and log in and retive results from a quiz that I'm making or hoping to make from PHP code and link to my database.

I have been working with some code that I used while I was at uni along with some code that I found in a PHP book as well.

While at uni I connected using the MS Access connection and not with SQL!

Here is the connection string

<?php #  mysql_connect.php

// This file contains the database access information. 
// This file also establishes a connection to MySQL and selects the database.

// Set the database access information as constants.
DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');

// Make the connnection.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );

// Select the database.
@mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
?>

I'm just a little stuck, I have the username and password, and I understand that I have to tell the 'DB name' is the name of my website?

But what is the local host? I'm using filezilla as my FTP to upload the PHP files

and help would be brilliant

Rich

Sometimes localhost works as name (if database in on the same server where website files are too). Sometimes those are different addresses so you would type there something like n12server.dbsomething.com. It is best way to check it in control panel where mysql section is. If you have working Joomla site, you definitely have database so check it easy in CP.

hey tpojka thanks for the replay I will have a look at this tomorrow. Its just having the courage to get it done I know what I want to do its just doing it

hi people I have just looked in my back end of the heart internet account and its saying in my manage mysql database the following

*** To connect to this database in a script running on your webserver you should use "localhost" as the hostname.**

DEFINE ('DB_USER', 'username'); this i have got 
DEFINE ('DB_PASSWORD', 'password'); this i have got
DEFINE ('DB_HOST', 'localhost'); using filezilla as my FTP... but got all the log in info for this 
DEFINE ('DB_NAME', 'sitename');and is this the name of my website?

Hi

Better use ur IP address of your website or Database

DEFINE ('DB_NAME', 'ip address'); Eg. IP address must be like 192.168.0.1

hey rpv_sen thanks for the replay and sorry for such a very late reply I have been snowed under with other things... I need to get the website back on track now!

Ok I will have a look at this now also

DEFINE ('DB_NAME', 'sitename');and is this the name of my website?

this will be the name of my website wont it?

REMOVE MYSQL_* FUNCTIONS! THEY ARE DEPRECATED

REMOVE MYSQL_* FUNCTIONS! THEY ARE DEPRECATED
Samuel Lewis (a.k.a. matrixdevuk) is right. The better option is PDO or mySQLi

Regarding your problem. The problem is that your database hostname is probably something else. You need to check your web hosting control panel under the phpmyadmin section for the hostname. And the username / password is usually different from your FTP login credentials as well. Also, I suggest that you change both the mysql_connect and mysql_select_db statements to either PDO (better because more driver support and has prepared statements feature) or mySQLi as they are far better. But if you'd like to stick then I have a better way to display the error which you get. In both statements remove the
or die("MESSAGE");
function and instead use
or die(mysql_error());

It will display the error which occured (most probably wrong hostname)

hey timetraveller1992 thanks for the replay I will have a look at this now. When I was at uni I used the old MS Access connection string and not MYSQL so its a learning curve for me.

I will have a look and let you know

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.