skip to Main Content

I just purchased my linux server, and domain on godaddy, but now after i uploaded my files to the file manager. I do not know how to make my “init.php” file connect to the database of that cpanel.

$db->$mysqli_connect('should this be localhost?','what user name?','passwordhere','databasehere');

2

Answers


  1. To create databases

    Log in to your GoDaddy account.

    Click Web Hosting.

    Next to the hosting account you want to use, click Manage.

    In the Databases section of the Hosting Control Panel, click the icon corresponding to the database you want to create.

    Click Add.

    Complete the fields. To allow direct access, click Additional Options.

    More information click here

    Login or Signup to reply.
  2. I just learned about this recently actually. I will give you an example from what I have compiled for the site I am making. It works for me on linux and should work for you. You must also make sure to make a databse. If you have a web manager you can do it or you could do it through SSH. There are a few steps before what you are also trying to accomplish and if you need help with that you can ask me if you have not finished them already.

    So first you have to I guess fill in the variables. You give these ‘variables’ a value. So lets say this is databaseconfig.php

     <?php
    define("HOST", "localhost");     // The host you want to connect to.
    define("USER", "usernamefordatabse");    // The database username.
    define("PASSWORD", "usernamepassword");    // The database password.
    define("DATABASE", "databasename");    // The database name.
    
    define("CAN_REGISTER", "any");
    define("DEFAULT_ROLE", "member");
    
    define("SECURE", FALSE);  
    ?>
    

    I have this in one file. So I am making each of those variables aka PASSWORD, DATABSE, etc.. mean something. What they now mean is the info to connect to your database.

    in another file in have this databaseconnection.php

    <?php
    include_once 'databaseconfig.php';   // As functions.php is not included
    $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
    ?>
    

    I use the to connect to the database. Those are two different php files I made for that and I am unsure if you can combine them.

    So now say in your main page your index.html or wherever your page is located that wants to connect into the database. On top of that page you have to connect it

    <?php
    include_once 'includes/databasebconnection.php';
    ?>
    

    this goes on top of the page that needs to access the database. That databaseconnection is already connected to the configuration file for your database, databaseconfig, which is the first set of code. That is an incomplete line up there. I have another one connected that actually runs everything so depending on the results, they get different feedback.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search