Database issues

Discussion in 'The Lounge' started by Bgermain, Mar 17, 2018.

  1. Bgermain

    Bgermain New Member

    It's been awhile since I created a new database and connected to it. A couple of questions.
    I created a new database and found an information schema there. Is this a new thing or did I do something wrong?

    When I attempt to connect to the database, I get the error "database not found."
    I have always connected with this:
    $DBASE="database name but now with the new prefix appended";
    $DBASEUSER="username but now with the new prefix appended";

    Is this correct?

    Thank you for your time in helping me.
  2. Bgermain

    Bgermain New Member

    forgot to add:
    @mysql_connect("localhost", "$DBASEUSER", "$DBASEPASSWORD");
  3. Peter Bernard

    Peter Bernard New Member

    I think @mysql_connect was deprecated in PHP5.5, try mysqli instead or PDO_mysql instead. Happy learning!!! :)

    // Old way
    @mysql_connect("localhost", "$DBASEUSER", "$DBASEPASSWORD");
    // New way
    $connection = mysqli_connect("localhost", "$DBASEUSER", "$DBASEPASSWORD");

    // Old way
    mysql_query('CREATE TEMPORARY TABLE `table`', $connection);
    // New way
    mysqli_query($connection, 'CREATE TEMPORARY TABLE `table`');

    Not sure if it is ' or " needed.
  4. Bgermain

    Bgermain New Member

    Found out about mysqli. Still doesn't work. I am still very confused about referencing the database name and username. Do I need to use the generated prefix or just the database name and username I assigned? I suspect that is part of my issue too.
  5. WBW

    WBW Member

    Yes, you need to use the entire db and username. It should look like (assuming Cpanel) "account_database", and "account_username", with "account" being the user account the db was created using/for.
  6. Bgermain

    Bgermain New Member

    WBW, thank you for that clarification.

Share This Page