PHP database connection

I have site of wordpress, I nedd to write PHP code in my page or post

Page 1 of 1

3 Replies - 1145 Views - Last Post: 13 January 2010 - 08:05 AM Rate Topic: -----

#1 hasanhabib  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-January 10

PHP database connection

Posted 12 January 2010 - 07:12 PM

PHP database connection

I have site of wordpress.org, I need to write PHP code in my page or post

<?php echo "Hasan Habib"; ?>

This code can't show in view site. I need to write mysql databse connection.

My site : http://freelance-bangladesh.info/
Is This A Good Question/Topic? 0
  • +

Replies To: PHP database connection

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: PHP database connection

Posted 12 January 2010 - 07:18 PM

Here is a link to all of the mysql documentation provided by php.net. It is chuck full of detailed descriptions & examples of usage.

Without knowing what you are trying to do, (or even if database means mysql) it's going to be impossible to help you.
Was This Post Helpful? 0
  • +
  • -

#3 it_1  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 10-August 09

Re: PHP database connection

Posted 13 January 2010 - 01:07 AM

its for db connection of mysql:

define('DB_HOST','your hostname');
define('DB_USER','username of database');
define('DB_PASSWORD','password of database');
define('DB_DATABASE','your databasename');
$db = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die('could not connect to database:'.mysql_error());
mysql_select_db(DB_DATABASE);
Was This Post Helpful? 0
  • +
  • -

#4 nick1200  Icon User is offline

  • Php Coder
  • member icon

Reputation: -19
  • View blog
  • Posts: 922
  • Joined: 21-March 09

Re: PHP database connection

Posted 13 January 2010 - 08:05 AM

View Postit_1, on 13 Jan, 2010 - 12:07 AM, said:

its for db connection of mysql:

define('DB_HOST','your hostname');
define('DB_USER','username of database');
define('DB_PASSWORD','password of database');
define('DB_DATABASE','your databasename');
$db = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die('could not connect to database:'.mysql_error());
mysql_select_db(DB_DATABASE);


you dont say what you wanna do

your showing us a connect :blink:
so i take it you wanna connect to the database a mysql

e.g
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database name") or die(mysql_error());




Then you just do a my sql after it update select or what ever you want to do ( seen has your not telling us )
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1