how to connect mysql database in php sample code


$db = mysqli_connect("localhost","cpaneluser_dbusername","password","cpaneluser_dbname")
or die('Error connecting to MySQL server.');

<h1>PHP connect to MySQL</h1>


$query = "SELECT * FROM sampletable";
mysqli_query($db, $query) or die('Error querying database.');

$result = mysqli_query($db, $query);



//Step 4


Click Here to learn more About MySQL database Connection settings

How do I create a MySQL database user

Was this answer helpful?

Related Articles

PHP-based Form Mail (Feedback) Script


Perl-based Form Mail (Feedback) Script

 Perl-based Form Mail (Feedback) ScriptUsing a Perl script you may accept feedback from your...

Feedback Form Code / Instructions

Feedback Form Code / InstructionsThe source code for the two files (feedback.php and feedout.php)...

PHP sendmail Settings

Using phpMailer to Send Mail through PHP Download the PHPMailer script First, download...

301 Redirect from non-www to ww -- Without Looping!

o - you want to improve your search engine rankings, and SEO gurus told you that Google might be...