Web and database

Status
Not open for further replies.

evaldas6899

New Member
Messages
3
Reaction score
0
Points
0
is it able somehow to connect web with MySql database? i tryed to do it... i needed to write DB Host, so wrote localhost and for me says that "Cannot connect to database" so maybe DB host is not localhost, just i can't find any other
 

Skizzerz

Contributors
Staff member
Contributors
Messages
2,928
Reaction score
118
Points
63
It is localhost, make sure you set up the database beforehand via the MySQL database wizard in cpanel
 

evaldas6899

New Member
Messages
3
Reaction score
0
Points
0
Hm i gues i'll recreate database, afterall i need 2 of them :/ and then maybe something will work

---------- Post added at 08:27 PM ---------- Previous post was at 08:16 PM ----------

Hm i gues i'll recreate database, afterall i need 2 of them :/ and then maybe something will work

EDIT: recreated database... still getting same error "I cant connect to localhost server." I wrote "localhost" in "DB Host:" section
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
This is a script on your x10 account?
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Give this a try

PHP:
<?php
$username ='jondoe';
$password = '12345678';

$database = 'jondoe_mydatabase';
// NB the full db name is your username plus whatever you called the database



$con = mysql_connect("localhost",$username,$password);
				if (!$con)
				  {
				  die('Could not connect: ' . mysql_error());
				  }
				mysql_select_db($database, $con);
 

echo 'database connected';
?>
 
Last edited:
Status
Not open for further replies.
Top