Connect to MySQL on WIMP in Visual Studio 2017

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

Connect to MySQL on WIMP in Visual Studio 2017

Postby noCodeMonkey » June 30th, 2018, 2:16 am

I am using the same connection information that I use in another PHP editor with no problem. However in VS with DevSense PHP I can not make a connection.

When debugging the app hangs at:
$mysqli = new mysqli("localhost", "root", "password","dbName", port<int>, null);

I hope you will not come back with a reply that says connecting to php is outside your support scope. Using PHP without database support is useless.
noCodeMonkey
 
Posts: 3
Joined: June 30th, 2018, 1:59 am

Re: Connect to MySQL on WIMP in Visual Studio 2017

Postby Jakub Misek » June 30th, 2018, 9:18 am

Does it hang with an error or a warning?

When using "mysqli" you have to have enabled "mysqli" PHP extension in "php.ini" configuration file.

To locate the file, open project properties and navigate to Server tab. There is an actual path to the configuration file. Uncomment or add line
Code: Select all
extension=php_mysqli.dll
You do not have the required permissions to view the files attached to this post.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2085
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Connect to MySQL on WIMP in Visual Studio 2017

Postby noCodeMonkey » July 4th, 2018, 7:33 pm

I am posting this reply for others who may be setting up the same environment. The errors I was experiencing had nothing to do with connecting to MySql. It turned out that PHP7.2 has a number of changes from v7.1 that broke a lot of code.

Visual Studio 2017 with DevSense makes it relatively straight forward to debug the code. In fact it makes it super easy to switch back and forth between different versions of PHP.
Image

You can also run different servers if desired. You can run the built in server with the settings below.
Image

You can also run the IIS server that comes with the Ultimate versions of Windows, with the following settings. Make sure to add the port number that Visual Studio generates for you (not 12345 as shown).
Image

Connecting to MySql is also straight forward. My mistake was in including the port number in the connection string. Even though VS runs on a specific port, do not include the port in the connection string.

As per php.net the proper connection string is:
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

I found that the default settings were all fine but if there are problems check the following.
The php.ini file should point to the correct extensions directory which must contain:
extension=php_mysqli.dll

Congratulations to DevSense for making a terrific, bug-free PHP add-on for Visual Studio.
noCodeMonkey
 
Posts: 3
Joined: June 30th, 2018, 1:59 am


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 4 guests

cron

User Control Panel

Login

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 89 on October 15th, 2018, 4:06 pm

Users browsing this forum: No registered users and 4 guests
Phalanger