answersLogoWhite

0

Simple way to connect to mysql server using PHP..

$hostname = 'localhost';

$username = 'root';

$password = 'anypassword';

//Connecting to mysql server..

$connect = mysql_connect($hostname, $username, $password);

if(!$connect)

{

die('Connection Failed'. mysql_error());

}

//Selecting the database..

$select = mysql_select_db('any_database_name');

if(!$select)

{

die('Database not Selected'. mysql_error());

}

?>

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How you can take backup of database in mysql?

It is quite easy to back up a database using dbForge Studio for MySQL. To do this, open the tool and connect to the MySQL server. In the database explorer, right-click the database you want to back up and select Backup and Restore > Database Backup. Additionally, the tool allows you to automate the backup process using Task Scheduler.


Is Wikipedia a database?

The coding of Wikipedia relies heavily on PHP and MySQL with almost everything but the images in a MySQL database. The locations of the images are in the database. So yes, in a way, Wikipedia is a database. However a database is a type of software that stores data, while Wikipedia is a wiki, a collaborative editing site.


You would like a free database program?

If you are looking for a Web Database program, then MySQL is the way to go. If you're looking for a free database program (like Microsoft Access) then you can try http://www.openoffice.org/


What are some MYSQL backup methods?

Some of the methods for backups using the MYSQL method are to download programs specifically for ones needs like AutoMySQLBackup. To manually backup the database, the 'noupe' website offers information on how to do this.


How can you connect to an Oracle database using PHP?

Is there an ODBC driver available for your Oracle database? If so, the ODBC functions may be the way to go.


What do you need to do to make PHP and MySQL work together?

The easiest way to get started is to install XAMPP. It comes with MySQL, PHP, Apache, phpMyAdmin (for database management,) and various other tools. To connect from PHP to MySQL database, you use this: $DBconnect = mysql_connect ("localhost","username","password"); mysql_select_db("yourDatabaseName", $DBconnect); ?> That will just connect you ready to use the database, create your tables in phpMyAdmin, it's easier. When you are ready to start adding/viewing data, you could use the following to add data: $sql = "INSERT INTO myTable VALUES('value1', 'value2')"; mysql_query($sql); ?> Then the following to view data: $sql = "SELECT * FROM myTable"; $queryResult = mysql_query($sql); if (mysql_num_rows($queryResult) == 0){ echo "Table Empty"; } else { while ($dbRecord=mysql_fetch_array($queryResult)){ $value1 = $dbRecord['field1']; $value2 = $dbRecord['field2']; echo $value1.', '.$value2.' '; } } } ?> This is a solution and works fine, but if your looking to install it all on your own/manualy. You have to install MYSQL php module. Here is a very nice TUT that will help you if you chose to do so manually: http://www.php-mysql-tutorial.com/install-apache-php-mysql.php Every server I've setup I do it manually. Its just the way I am, I like having control over the whole process.


Why use mysql instead of oracle?

Most people who select oracle over mysql are doing so for a variety of reasons, not one specific feature. Price is usually the most important factor. MySQL is free, and that's why many people choose to use it. Oracle is time-tested/proven, and that is why many people choose it.However, many corporations purchase volume licenses and so the cost of adding an new database/user to an oracle database is not as much as it would be to start your first implementation.Reasons to use oracle instead of MySQL:1.Oracle has many built in functions such as decode that make some queries easier to build.2. Oracle is a private company, and some people argue this means that they will deliver releases/fix defects/etc more regularly, since they rely on the income to survive.3. Oracle has PL/SQL, a built in language that is very powerful. You can also have java stored procedures, this is much more powerful then what MySQL offers.4. Oracle has support for sequences, MySQL does not.5. Mysql does not support table snapshots6. Oracle can be customized and tuned, much more then MySQL can.7. Oracle provides Hot Backup/Standby facility, Mysql provides this facility only for selected engines.8. Oracle provides Clustering Mechanism, where as MYSql does not.9. Oracle Provides two way replication, Mysql provides only one-way replication.10. Oracle provides DB links to connect to a remote oracle server.


How do you connect oracle 10G developer to oracle 9I database?

I hope you can connect your Oracle9i database from Oracle10g as the same way how you connect from Oracle10g itself. But you have to add Oracle9i connection details at your Oracle10g TNSNAMES.ORA file. Simply you copy any other connection setting and change the name, Sid or source name, host name or ip address.


Where can one get a tutorial for Mysql select?

A good place to start for learning mysql is with the dev mysql site. This gives tutorials and a well indexed menu for finding your way around. It is easy to understand which is a bonus.


What are the advantages of PostgreSQL over MySQL?

The main difference that I see is Postgres' advanced support for things like Views, Stored Procedures, Transactions and other more advanced database functions. This is not to say that MySQL does not support these, however Postgres' advanced features are tuned to be highly performative. Also, Postgres supports more concurrent users than MySQL. That all being said, if you web application is a relatively simple, mostly read-only, and doesn't require large number of concurrent connections, MySQL is probably the better way to go, as it is performatively optimized for reading, and is simpler to install, maintain, and has better third-party tool suppport. :)


What is the correct way to connect the ground and hot wires in an electrical circuit?

The correct way to connect the ground and hot wires in an electrical circuit is to connect the hot wire (usually black or red) to the brass-colored screw terminal and the ground wire (usually green or bare copper) to the green screw terminal on an electrical outlet or switch. This ensures proper and safe electrical connection.


What is the correct way to connect the brown and blue wire in an electrical circuit?

The correct way to connect the brown and blue wire in an electrical circuit is to match the brown wire with the live or hot terminal and the blue wire with the neutral terminal. It is important to follow the color coding to ensure proper and safe electrical connections.