Connection to mysql database (adapt file dreamweaver)

Status
Not open for further replies.

jabahoeoe

New Member
Messages
2
Reaction score
0
Points
0
hey,

I'm totaly noob in working with databases.
at this moment I'm testing my site and database, on my local wamp-server.
everything works fine.
Dreamweaver created a file

connections/ecards.php



Code:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ecards = "localhost";
$database_ecards = "ecards";
$username_ecards = "xxxx";
$password_ecards = "xxxx";
$ecards = mysql_pconnect($hostname_ecards, $username_ecards, $password_ecards) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

Now I uploaded my site to http://timds.x10hosting.com/
I edited my connectionfile:

Code:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ecards = "[COLOR=red]localhost[/COLOR]";
$database_ecards = "[COLOR=red]timds_ecards[/COLOR]";
$username_ecards = "[COLOR=red]timds_xxxx[/COLOR]";
$password_ecards = "[COLOR=red]xxxx[/COLOR]";
$ecards = mysql_[COLOR=red]c[/COLOR]onnect($hostname_ecards, $username_ecards, $password_ecards) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

while surfing site (when it comes to connect the database...) I get:
No database selected



I hope someone can halp me

tim d.s.
 

Alejandro

Staff
Staff member
Community Support
Messages
9,436
Reaction score
1
Points
38
Yes, you need to select a db after connecting to the mysql server. In order to do so add the following line after the mysql_connect() function:

PHP:
mysql_select_db('DATABASE');
 

jabahoeoe

New Member
Messages
2
Reaction score
0
Points
0
Thanks for your fast reply Alejandro,

so it must be ???

Code:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ecards = "localhost";
$database_ecards = "timds_ecards";
$username_ecards = "timds_xxxx";
$password_ecards = "xxxx";
$ecards = mysql_connect($hostname_ecards, $username_ecards, $password_ecards) or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_select_db('timds_ecards');
?>



does not work :(
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Did you create the database, create a user, then assign the user to the database with permissions?
 
Status
Not open for further replies.
Top