Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-03-2009
Member
 
Join Date: Dec 2008
Posts: 69
Problem connecting to mysql db

hi,
I need more pages to access the db. Currently, in every page I have specified the variables needed for the connection, like this:
$ host = 'localhost';
$ db_user = 'root';
$ pass = 'root';
$ database = 'db_pro';

However, if for example you change the password to access the db should go to each page to change this value. I tried to create a file containing connection.php these variables and then calling this file in the pages where I need using the require, but it seems not work. How can I do?
Reply With Quote
  #2  
Old 21-03-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Problem connecting to mysql db

Quote:
I need more pages to access the db. Currently, in every page I have specified the variables needed for the connection, like this:
$ host = 'localhost';
$ db_user = 'root';
$ pass = 'root';
$ database = 'db_pro';

However, if for example you change the password to access the db should go to each page to change this value. I tried to create a file containing connection.php these variables and then calling this file in the pages where I need using the require, but it seems not work. How can I do?
In what sense does not seem to work? If it is called right initialization should be able to connect normally and solve the problem. What you did is right, it remains to understand why it does not work.

Error that you reported?
Reply With Quote
  #3  
Old 21-03-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Problem connecting to mysql db

hi,
mysql supports SSL. Did you check your server's logfiles? most implementations try a private key, then revert to password authentication. Starting the server in "verbose" mode also might enlighten you.
Reply With Quote
  #4  
Old 21-03-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Problem connecting to mysql db

creates a file called type connection.php
<? php
$ host = 'localhost';
$ db_user = 'root';
$ pass = 'root';
$ database = 'db_prova';
>

then all of your file instead of rewriting these lines, for example in the index.php file type:

<? php
include ( "connection.php");

BODY OF THE PAGE

>

Doing so in all your pages, in case you should change the login information (for example if you change your domain or put your code on other web servers) just changing the data in the file only connection.php.

You could use this method to simplify your pages and to simplify maintenance of the code (eg. A file with only the menus, one with only the header, one with only the footer). One need only recall it from your php page.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem connecting to mysql db"
Thread Thread Starter Forum Replies Last Post
Connecting C# with MySQL database Quattro Software Development 5 05-03-2010 10:13 PM
Connecting to remote MySQL Gavisht Software Development 4 10-12-2009 08:35 PM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
Problem connecting to mysql Damodar Software Development 3 25-02-2009 03:16 PM
Connecting VB.net with mysql Jateen Software Development 1 05-01-2009 09:37 PM


All times are GMT +5.5. The time now is 12:32 AM.