Jump to Navigation

databases

010 - To Connect MySQL

This is a sample to connect MySQL DB.

Example:

mysql_connect("localhost", "username", "password");

mysql_select_db("mydb");

$result = mysql_query("SELECT * FROM user_table");

if ($result && mysql_num_rows($result)) {

$numrows = mysql_num_rows($result);

$rowcount = 1;

print "There are $numrows people in user_table:<br /><br />";

while ($row = mysql_fetch_assoc($resiult)) {

006 - To connect MS SQL Server

This is a sample program for connecting to MS SQL Server.

005 - To connect Oracle 10g XE

<?php
/* oci_fetch_all example */

$conn = oci_connect("hr", "hr", "localhost");

$stmt = oci_parse($conn, "select * from employees");

oci_execute($stmt);

$nrows = oci_fetch_all($stmt, $results);
if ($nrows > 0) {
echo "<table border=\"1\">\n";
echo "<tr>\n";
foreach ($results as $key => $val) {
echo "<th>$key</th>\n";
}
echo "</tr>\n";

Oracle:
Subscribe to RSS - databases


Main menu 2

by Dr. Radut