PDA

View Full Version : How To ACCESS MySQL DATABASE FROM PHP CODE FOR SQUIRRELMAIL SERVER


Ghose Sumon
21st May 2007, 18:11
Hi Everyone,

My Organization is currently using Squirrelmail server. Now We are having some requirement of adding some additional info to the existing MySql database but in separate table.Now we r trying to customise some part of the code but facing the database connectivity problem. we r not able to access the database from the PHP code using Mysql_connect() function as the current system hides the database n connects using some different configuration.so please anyone help us to solve this issue..if possible provide the code also for the same.

Thanking You,
Sumon Ghose

sjau
21st May 2007, 22:41
Please do not use CAPITALS in the topic header. This is considered as shouting and it's not polite.

A very simple code snippet of accessing a mysql-db through php is this:


<?php

$username = ""; // Username for database here
$password = ""; // Password for database here
$db_host = "localhost"; // DB Server
$db_name = ""; //name of your database here

// Connect to DB
mysql_connect("$db_host","$username","$password")
or die("Unable to connect to SQL server!");
mysql_select_db("$db_name")
or die("Unable to select database!");

?>