Skip to main content
Known Participant
November 29, 2017
Answered

Mysqli connection

  • November 29, 2017
  • 3 replies
  • 1587 views

When I try to create a database connection, I get the message

"Your PHP server doesn't have the MYSQL module loaded or you can't use the mysql_(p)connect functions."

My server uses mysqli and PHP 7

How can I tell Dreamweaver to use these versions to connect?

    This topic has been closed for replies.
    Correct answer Nancy OShea

    Copy & paste this into a new .php file.  Change username, password and database as required.

    <?php

    $con = mysqli_connect("localhost","username","password","database");

    // Check connection

    if (mysqli_connect_errno())

      {

      echo "Failed to connect to MySQL: " . mysqli_connect_error();

            }

            else echo "Successfully connected, happy coding!"

    ?>

    <?php phpinfo() ?>

    Save and Open in browser. See screenshot.

    3 replies

    Nancy OShea
    Community Expert
    Community Expert
    November 30, 2017

    pabirds  wrote

    How can I tell Dreamweaver to use these versions to connect?

    In CC 2018 under Preferences > PHP, you now have a choice of PHP versions to code with.

    Nancy O'Shea— Product User & Community Expert
    Nancy OShea
    Community Expert
    Nancy OSheaCommunity ExpertCorrect answer
    Community Expert
    November 29, 2017

    Copy & paste this into a new .php file.  Change username, password and database as required.

    <?php

    $con = mysqli_connect("localhost","username","password","database");

    // Check connection

    if (mysqli_connect_errno())

      {

      echo "Failed to connect to MySQL: " . mysqli_connect_error();

            }

            else echo "Successfully connected, happy coding!"

    ?>

    <?php phpinfo() ?>

    Save and Open in browser. See screenshot.

    Nancy O'Shea— Product User & Community Expert
    Legend
    November 29, 2017

    pabirds  wrote

    When I try to create a database connection, I get the message

    "Your PHP server doesn't have the MYSQL module loaded or you can't use the mysql_(p)connect functions."

    My server uses mysqli and PHP 7

    How can I tell Dreamweaver to use these versions to connect?

    If you use PHP 7 you can only connect using mysqli (the i standing for improved or you can use PDO) I'm afraid the mysql function is deprecated and no longer works with PHP 7. You would have to drop back to PHP 5.

    You should NOT use the old mysql function for any new project going forward, its well past its sell by date.