Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Connect to MySQL from a PHP Script
How To Connect to MySQL from a PHP Script? - PHP Script Tips - Working with MySQL Database
✍: FYIcenter.com
If you want access the MySQL server, you must create a connection object first by calling the mysql_connect() function in the following format:
$con = mysql_connect($server, $username, $password);
If you are connecting to a local MySQL server, you don't need to specify username and password. If you are connecting to a MySQL server offered by your Web hosting company, they will provide you the server name, username, and password.
The following script shows you how to connect to a local MySQL server, obtained server information, and closed the connection:
<?php
$con = mysql_connect('localhost');
print(mysql_get_server_info($con)."\n");
print(mysql_get_host_info($con)."\n");
mysql_close($con);
?>
If you run this script, you will get something like this:
5.0.2-alpha localhost via TCP/IP
2007-04-18, 5308👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...
How To Return Top 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If you want ...
Should synchronization primitives be used on overrided bean methods? No. The EJB specification speci...
What Is the Text Paragraph Formatting Model? - CSS Tutorials - HTML Formatting Model: Block, Inline ...
What Is a TD Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "td" elemen...