• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Mysqli connection

New Here ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

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?

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 29, 2017 Nov 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.

CC-Preview-in-browser.jpg

Votes

Translate

Translate
LEGEND ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

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.

CC-Preview-in-browser.jpg

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

LATEST

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 & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines