Jump to content

Having a Problem connecting to data base


louthmedia

Recommended Posts

i have just sent the last 4 hours trying to connect to the msql database here is the to sets of code i i'm using

 

<?php

$db_host = "host";

$db_usernamen = "username";

$db_pass = "password"

$db_name = "database name";

 

mysql_connect("$db_host","$db_username","$db_pass") or die ("couldnot connect to mysql");

mysql_select_db("db_name") or die ("no database");

?>

 

this code i'm using to connect to the database

 

<?php

require "connect_to_mysql.php";

 

echo "<h1>success in database connection! happy coding</h1>";

?>

and i have used this one as a quick test.

 

i have up loaded the the two codes to the sever however when i opened the web site to test it all i get is a blank screen. i have looked at a number of codes like this one and i can't see anything wrong with the code. i have uploaded the codes three times just in case the files had been corrupt while uploading have every this has not work

 

if anyone can help i would be very greatful

 

What happens when you use:

 

<?php
$db_host = "host";
$db_usernamen = "username";
$db_pass = "password"
$db_name = "database name";

mysql_connect($db_host, $db_username, $db_pass) or die ("couldnot connect to mysql");
mysql_select_db("db_name") or die ("no database");
?>

 

and

 

<?php
require("connect_to_mysql.php");

echo "<h1>success in database connection! happy coding</h1>";
?>

 

?

i would like to thank you all for your help with my problem. i have know found the problem

 

the first was the as Pikachu had pointed out i was missing the end tag on line;

$db-pass = "password"

the next problem was the i had addied typing mistake on line 3

and the final one was i and missed the '$' off on line 9

 

i know have connection to the database.

 

which means i can move on with building the CMS software

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.