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

 

Link to comment
Share on other sites

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>";
?>

 

?

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.