Excellent Programming Tricks

Database Connection Check | mySql | PHP

<?php

$hostname = "localhost";
$username = "root";
$pass = "";

$conn = mysql_connect($hostname, $username, $pass);
 
if(! $conn ) {
   die('Could not connect: ' . mysql_error());
}
 
$sql = 'SELECT ID FROM RECORD';
mysql_select_db('egp');

$result = mysql_query( $sql, $conn );
 
echo 'Numver of rows: '.mysql_num_rows($result).'  <br>';

if(! $result ) {
   die('No Data: ' . mysql_error());
}
 
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "ID :{$row['ID']}  <br> ".
         "--------------------------------<br>";
}
 
echo "Successfully Execute\n";
 
mysql_close($conn);
?>

No comments:

Post a Comment


Authentic аnd Excellent

Website

HTML Template

Wordpress Theme

Database applications

OR

Application services?

Excellent Programming Tricks (EPT) || Iftekhar-IT || We develops the Web applications and the WordPress templates. || Excellent Programming Tricks (EPT)

© 2020 Blogger Theme by Iftekhar IT || Excellent Programming Tricks

Execllent Programming Tricks. Powered by Blogger.