Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.