Database connection string?

Status
Not open for further replies.

jtwhite

Community Advocate
Community Support
Messages
1,381
Reaction score
30
Points
0
I'll just write you a new one? :)

PHP:
<?php
// Let's connect to the database server
mysql_connect('localhost', 'databaseuser', 'userpassword') or die('Error connecting to the database, MySQL returned: ' . mysql_error());

// Now let's select (access) the database
mysql_select_db('database_name') or die('Error selecting database, MySQL returned: ' . mysql_error());
?>
 

martynball

New Member
Messages
60
Reaction score
0
Points
0
That will do, cheers :)
Edit:
Another question, no point making another thread.

'userpassword'

I put my password for the database there, well. Can't the public just select view source code and see the password?
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
That will do, cheers :)
Edit:
Another question, no point making another thread.

'userpassword'

I put my password for the database there, well. Can't the public just select view source code and see the password?

No, you can't see PHP scripts in your browser. You only get the HTML source
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
And it is better to separate the mysql connection and data extraction in a file and call them in main file. Those mysql connection file can be set with less permissions.
 
Status
Not open for further replies.
Top