Closed Thread
Results 1 to 5 of 5

Thread: Web and database

  1. #1
    evaldas6899 is offline x10Hosting Member evaldas6899 is an unknown quantity at this point
    Join Date
    Nov 2011
    Posts
    3

    Web and database

    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

  2. #2
    Skizzerz's Avatar
    Skizzerz is offline Contributors Skizzerz will become famous soon enough
    Join Date
    Nov 2007
    Location
    Texas
    Posts
    2,153

    Re: Web and database

    It is localhost, make sure you set up the database beforehand via the MySQL database wizard in cpanel
    Ryan Schmidt | Level 2 Support
    █ 888-X10-9668 - ryan[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  3. #3
    evaldas6899 is offline x10Hosting Member evaldas6899 is an unknown quantity at this point
    Join Date
    Nov 2011
    Posts
    3

    Re: Web and database

    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 ----------

    Quote Originally Posted by evaldas6899 View Post
    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

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Web and database

    This is a script on your x10 account?
    Nothing is always absolutely so.

  5. #5
    cybrax's Avatar
    cybrax is offline x10 Elder cybrax is on a distinguished road
    Join Date
    Aug 2009
    Location
    UK
    Posts
    699

    Re: Web and database

    Give this a try

    PHP Code:
    <?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 by cybrax; 11-29-2011 at 03:00 PM.
    The code must flow.
    Project 157: Latest UK Jobs direct to your mobile phone
    New Domain under construction: Lovelogic.net
    home for some new projects that we can't keep here ;)


Closed Thread

Similar Threads

  1. Replies: 6
    Last Post: 09-06-2011, 01:10 AM
  2. Replies: 4
    Last Post: 05-14-2010, 10:35 AM
  3. Replies: 5
    Last Post: 04-25-2010, 04:02 PM
  4. Replies: 1
    Last Post: 04-17-2010, 12:26 PM
  5. HOWTO: Auto-backup database | transfer database (with pics)
    By galaxyAbstractor in forum Tutorials
    Replies: 3
    Last Post: 02-21-2010, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers