Hello I have created a file name connect.php and code of this file is as below

<?php
$db_server = 'localhost';
$db_username = 'myweb_user';
$db_password = 'Aunhy125$%';
$db_table='main_table';
?>

To connect database I used to include_once() function. What may be the problem for this. Or what would be be best way to connect database. Is there any security problem what I m using. Please help me or suggest me.

That's more or less how most people do it. Just be careful not to ever echo out your password while debugging :)

You could just establish the connection within the include too. Saves you the trouble of having to always do that elsewhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.