Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Database problems

General discussions related to php

Moderators: macek, egami, gesf

Database problems

Postby scorpage » Sat Aug 16, 2003 9:55 am

i am trying to repair a database i had made for me. when i upload it, it comes up with "Unable to connect to database." i have tried removing it see if i can get the basic site to load but i can't even get to remove it.

<? include 'functions.php';
databaselogin();
?>

this is at the top of the page but if i remove it there is no change. can somone suggest how i can make the database work please? or if i sent it to somone could they have a look?
scorpage
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Aug 14, 2003 2:41 am

Re: Database problems

Postby swirlee » Sat Aug 16, 2003 11:15 am

scorpage wrote:
Code: Select all
<? include 'functions.php';
databaselogin();
?>


We'd have to see the contents of functions.php, or at least the parts that relate to the databaselogin() function.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby scorpage » Sat Aug 16, 2003 11:43 am

<?php
function databaselogin() {
mysql_connect("localhost","*****","*****")
or die ("Unable to connect to database.");
mysql_select_db("hindbacca_co_uk")
or die ("Unable to select database.");
}
function messagescreen($message, $title, $url, $type) {
?>

taken from functions.php


i think its that but what do i change it to? hindbacca and everything within that is relating to my mates site.
scorpage
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Aug 14, 2003 2:41 am

Postby swirlee » Sat Aug 16, 2003 11:46 am

The code looks fine, so the problem is probably that either your database server is not running (or isn't running on localhost) or your username/password is wrong.

By the way, please don't post usernames/passwords to this board.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby scorpage » Sun Aug 17, 2003 12:35 am

i apoligize mate ...i didn't know that was the username/password ..... what username/pass does it have to be the website un/pass ...or do you have to make one?

also what is this line for? what should i replace "hindbacca_co_uk"

mysql_select_db("hindbacca_co_uk")


thanks for the help so far
scorpage
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Aug 14, 2003 2:41 am

Postby swirlee » Sun Aug 17, 2003 12:39 am

scorpage, I think you ought to learn PHP's MySQL functions for yourself. See the documentation, and I also recommend that you Google a few good tutorials. There's no sense in trying to fix something you don't understand.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby scorpage » Sun Aug 17, 2003 2:32 am

thanks for the link swirlee

although i am a bit more understanding of it ...i still don't understand what to put as username and password? it just says
username = name of the user that owns the server process and password = empty password.


is that the website server? and do u leave the password empty?

also with mysql_select_db it says the name of your database
how do you name it?
scorpage
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Aug 14, 2003 2:41 am

Postby Joan Garnet » Sun Aug 17, 2003 8:00 am

Code: Select all
mysql_connect("the_name_of_your_host","the_username_of_the_mysql_server","the_password_of_the_mysql_server") ;
mysql_select_db("the_name_of_the_database_where_your_tables_are");

I suggest you to try using your own code, so you will understand what you are doing.
There's no sense in doing something you just don't know, you'll end up asking questions in each step of your developement...
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

MySQL Connection

Postby ruturajv » Mon Aug 18, 2003 1:08 am

Hi scorpage,
Seems you are using the tripod.lycos.co.uk free php and mysql hosting ... ? Right ???

Now the username in this case is your login name for lycos, and there is no password

Code: Select all
$conn = mysql_connect('localhost', 'scorpage', '');


And if even this doesn't work, try to deacitvate the PHP / MySQL for your ID on lycos and then reactivate.. It helped in my case!!
:lol:
hope it works for you [/code]
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India


Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron