Php include mysql settings

PHP Settings — MySQL and MariaDB Support

Since a lot of PHP projects use MySQL (MariaDB) as database software, ExeOutput for PHP provides you with the ability to include a portable MySQL server (which is MariaDB) along your compiled PHP application. The MySQL server is considered as portable because it doesn’t require to be installed as a Windows service in order to work. This behavior is similar to what you can find in «WAMP» distributions, except that we don’t use Apache nor PHP software because they are replaced by ExeOutput for PHP.

Watch our video tutorial about configuring, using and distributing the portable MySQL server with your app.

ExeOutput for PHP will use a portable MySQL server that is provided by the open-source MariaDB project.

The ExeOutput for PHP’s main distribution does not include the portable MariaDB server: use the Web Update utility to download and install the package. Just click the «Check for updates» icon in ExeOutput for PHP to launch the Web Update utility. Then tick «MySQL package for ExeOutput for PHP» and the package will be automatically installed for you.

Читайте также:  Php значение ключа элемента массива

Once the MySQL package for ExeOutput for PHP is installed, files that will be used for each project are stored in the MySQL\Source\mysql subfolder of the ExeOutput for PHP’s main installation folder. Of course, you can update them manually if you want.

Prepare and configure the MySQL Portable Server¶

First, you must have defined the folder where your application EXE file will be created (Output Path). All files required by the MySQL portable server will be copied into a «MySQL» subfolder.

This subfolder must always be placed in the same folder as the application EXE output file, so you must include this entire folder when you distribute your application or create an installer with Paquet Builder for instance.

When you click this button, you will be prompted for two settings: the root password and the connection port (the TCP/IP port number to use for the connection. The default is 3306 ).

Then, all files required by the MySQL portable server are copied to the «MySQL» subfolder and the server is started. ExeOutput for PHP will ask you to click OK when the server is ready and listening.

Finally, ExeOutput for PHP shutdowns the server. The latter is now ready for use with your application.

Do not change the root password yourself. ExeOutput for PHP remembers the root password so that it can shutdown the server when the application closes. If you have to change it, repeat the steps above.

If you want to remember which root password and connection port you used, just click the appropriate links in ExeOutput for PHP named Show configured username and password , and Show configured port .

Create databases and manage them with Adminer¶

The MySQL server used comes from a vanilla distribution. Except the root password, nothing else is modified: you must then configure settings yourself (thanks to the my.ini configuration file in the «mysql» subfolder).

To manage databases of the portable MySQL server, use a MySQL client: some MySQL clients exist in PHP such as phpmyadmin or Adminer.

We compiled Adminer with ExeOutput for PHP into Adminer EXE so that you can run Adminer EXE without requiring any local PHP installation nor WAMP distribution. Furthermore, to help you administer your portable MySQL server, ExeOutput for PHP can place a temporary copy of Adminer EXE in the same folder as your output EXE file and run it. Thus, Adminer will automatically start the portable MySQL server of your PHP application and let you run SQL commands, manage databases and so on. When you close Adminer EXE, the portable MySQL server is also shut down.

When Adminer EXE is started, enter your credentials:¶

When Adminer EXE is started, enter your credentials:

If you changed the connection port, enter localhost:[newport] in the server field.

The username is root by default and the password is the root password you defined in a previous step.

Then choose to create a new database, execute SQL command, import data. ¶

Then choose to create a new database, execute SQL command, import data.

Before distributing your PHP application, remove the Adminer EXE tool from the folder or ignore it.

The ExeOutput for PHP’s main distribution does not include the Adminer EXE tool: you must download and install the package yourself thanks to the Web Update utility. Just click the «Check for updates» icon in ExeOutput for PHP to launch the Web Update utility. Then tick «Adminer package for ExeOutput for PHP» and the package will be automatically installed for you.

Associate your PHP application with the MySQL Portable Server¶

First, be sure to enable the MySQLi PHP extension so that your PHP application can handle MySQL: go to the «PHP Settings -> PHP Extensions» page in ExeOutput for PHP. Then, you can configure your application to automatically start the MySQL server when it is run, and stop it when the application exits: tick Start and stop the MySQL server automatically.

It can take some time before the MySQL server is ready to communicate with your application.

If your application needs to communicate immediately with the data server as soon as it starts, then you may encounter a connection error. That’s why you can add a few extra seconds of delay with the following option: Delay to wait for the server to start (in seconds)

If the server cannot be started for some reason, an error is displayed at startup. You can customize the error message thanks to the Localization tab.

Only one instance of the server can be run at a time: we then recommend that you do the same with your application. Go to Security / Global Options and tick Only one instance of the application can be run at a time .

The PHP application always expects to find the portable server in the » MySQL » subfolder of the application EXE’s location.

Remove MySQL server from your application¶

To remove the portable MySQL server, untick Start and stop the MySQL server automatically and then you can erase the » MySQL » subfolder of the application EXE’s location. That’s enough.

How to detect MySQL server errors?¶

The MySQL server stores a lot of information in its log, including any errors that may occur during its execution. To view this log, you just have to click on the link titled «Open server log» in ExeOutput for PHP

ExeOutput’s MySQL demo sample¶

To prove that ExeOutput for PHP can work with MySQL-based apps, we successfully compiled the famous WordPress app into a portable desktop application. The sample comes with full source and a tutorial! Do not hesitate to check it out.

Источник

Php include mysql settings

Быстрый переход в группу «Пользователи», без надобности написания постов и ожидания.

Маппинг для сервера

Если вы хотите обновить Ваш сервер новыми доработками — то зайдите в наш раздел. Большой выбор готовых решений от наших пользователей

Моды для сервера

Огромный выбор различных модификаций для Вашего сервера. Пролистайте эти темы! Возможно именно там Вы найдете то, что искали уже давно.

Программы для скриптера

Подборка удобных программ для скриптера

Новые темы в этом разделе публикуются автоматически при добавлении файла в менеджер ресурсов.
Ручное создание новых тем невозможно.

Вы используете устаревший браузер. Этот и другие сайты могут отображаться в нём некорректно.
Вам необходимо обновить браузер или попробовать использовать другой.

Untonyst

Изучающий

Здравствуйте, уважаемые пользователи. На одном форуме был вопрос по загрузке данных из файла для использования их как данные для подключения к базе данных. Наверняка это не первый и не последний вопрос на эту тему, да кому-нибудь может тоже станет интересна эта тема. Итак, суть проста. У нас есть файл mysql_settings.txt и в нем перечислены данные (имя, пароль, бд и хост), при запуске мода данные считываются от туда. Огромный плюс этого метода в том, что данные можно изменять не перекомпилиируя свой скрипт.​

К сведению: для работы нужен sscanf2.inc, надеюсь, в гугле или в яндексе вы не заблокированы.

/* Загрузка данных из '../scriptfiles/mysql_settings.txt' для подключения с базой данных Пример содержимого файла mysql_settings.txt: localhost,tensa,123qwe,base хост, имя пользователя, пароль, имя базы данных Аля большой костыль! (C) Copyright 2015, Untonyst =3 */ // если нет инклуда a_mysql.inc, то исключим НАШ инклуд на стадии компиляции #if !defined mysql_included //#error File a_mysql.inc is not included #endinput #endif // если нет инклуда sscanf2.inc, то исключим НАШ инклуд на стадии компиляции #if !defined sscanf //#error File sscanf2.inc is not included #endinput #endif // настройки подключения по умолчанию, если файла настроек не обнаружено #define DEFAUL_MYSQL_HOST "127.0.0.1" #define DEFAUL_MYSQL_USER "root" #define DEFAUL_MYSQL_PASSWORD "" #define DEFAUL_MYSQL_DATABASE "base" // id подключения new cHandle; public OnGameModeInit() // подключение соединения с базой данных при старте сервера < new File:file_handle = fopen("mysql_settings.txt", io_read), buf[20*4+1], mysql_host[20], mysql_user[20], mysql_password[20], mysql_database[20]; if (!fexist("mysql_settings.txt")) // если файла настроек нет, то используем данные по умолчанию < mysql_host = DEFAUL_MYSQL_HOST; mysql_user = DEFAUL_MYSQL_USER; mysql_password = DEFAUL_MYSQL_PASSWORD; mysql_database = DEFAUL_MYSQL_DATABASE; >else < fread(file_handle, buf); sscanf(buf, "ps[20]s[20]s[20]s[20]", mysql_host, mysql_user, mysql_password, mysql_database); fclose(file_handle); // это так, для сведения printf("===============\nХост: %s\nПользователь: %s\nПароль: %s\nБД: %s\n===============\n\n",mysql_host, mysql_user, mysql_password, mysql_database); > cHandle = mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password); if(mysql_errno()) print("[MySQL] Связь с базой данных не установлена\n* Проверьте введенные вами данные\n\n"); else print("[MySQL] Связь с базой данных установлена\n\n"); #if defined MySQL__OnGameModeInit MySQL__OnGameModeInit(); return 1; #endif > #if defined _ALS_OnGameModeInit #undef OnGameModeInit #else #define _ALS_OnGameModeInit #endif #define OnGameModeInit MySQL__OnGameModeInit #if defined MySQL__OnGameModeInit forward MySQL__OnGameModeInit(); #endif public OnGameModeExit() // отключение соединения с базой данных при рестарте сервера < mysql_close(cHandle); print("[MySQL] Связь с базой данных была отключена\nИдет подключение . \n\n"); #if defined MySQL__OnGameModeExit MySQL__OnGameModeExit(); return 1; #endif >#if defined _ALS_OnGameModeExit #undef OnGameModeExit #else #define _ALS_OnGameModeExit #endif #define OnGameModeExit MySQL__OnGameModeExit #if defined MySQL__OnGameModeExit forward MySQL__OnGameModeExit(); #endif

Источник

Оцените статью