Jump to content

Connecting


DamienG

Recommended Posts

Hi,

 

When connecting yo a MySql database I do the following witch works

 

<?php
//information
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'db';

//connect
$connect = @mysql_connect ($host,$user,$pass) or die (mysql_error () );

$select = @mysql_select_db ($db, $connect) or die (mysql_error () )
?>

 

Now last time I checked that works, is that the best way to do it?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/188369-connecting/
Share on other sites

depends on what and how you wanna connect to db in your files. you can put it all in some xy.php and inside create a function which hits the connect querry. then in next .php just include the xy file and write the name of the connecting function... but the process of connecting like this is the correct one!

Link to comment
https://forums.phpfreaks.com/topic/188369-connecting/#findComment-994539
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.