PHP and MySQL FAQs
This section provides frequently asked questions (FAQs) related to DWebPro support for PHP and MySQL.
-
PHP doesn't work at all and returns only an empty page! Why is that?
-
Why I get the Warning "PHP Startup: xxxx Unable to initialize module"?
-
Why I get many "Notice: Undefined variables …" notices in my PHP scripts?
-
How do I resolve include(), require(), include_path, absolute paths, and URL issues?
-
How can I activate the ImageMagick software in DWebPro (for example, for the Typo3 Web site)?
-
How do I solve the "Your PHP installation does not support PostgreSQL..." error message?
-
Can I make PHP execute .HTM and .HTML web pages (like Apache AddType directive)?
-
Why you don't include PHP and MySQL in the DWebPro install package?
-
Why don't $HTTP_POST_VARS, $HTTP_GET_VARS and all the $HTTP_*_VARS predefined array work?
-
Why this simple PHP script doesn't work: <? echo("Hello World!"); ?> ?
-
Can I execute PHP script with Ioncube Cerberus, Zend Encoder or another PHP encoder?
|
Can I use PHP session on CD/DVD? |
|
By default, PHP saves all the data of the user's sessions in
a file in the directory specified by the Here it is an example of session_save_path() usage: <?php
session_save_path(dwebpro_getvar('DWEBPRO_TEMP'));
session_start();
?>
In the above sample, PHP will save the session data in the temporary
directory specified by the |
|
|
Can I use the GD extension or any other PHP extension? |
|
Of course you can. All of our preconfigured PHP packages (see Add-On Packages topic) include the standard PHP extensions and the official collection
of PECL modules. To enable a PHP extension, you have to open the extension=php_gd2.dll If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. We suggest that you to add this code in the |
|
|
Where is the php.ini file? |
|
When you install PHP with one of our preconfigured packages (see Add-On Packages topic), you can decide to install it as ISAPI or CGI. We recommend you to install PHP as ISAPI because it is much faster than CGI, especially when you execute DWebPro and PHP on a CD/DVD. Depending on the way you have installed PHP, you can find the
If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
Why doesn't $PHP_SELF (or $GLOBALS['PHP_SELF']) work? |
|
Our preconfigured packages are provided with the default PHP configuration, except for some minor changes required for the stand alone behavior. This configuration includes the following directive: register_globals = Off The If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
PHP doesn't work at all and returns only an empty page! Why is that? |
|
Our preconfigured packages are provided with the default PHP configuration, except for some minor changes required for the stand alone behavior. This configuration includes the following directives: display_errors = Off display_startup_errors = Off With this configuration, PHP does not return any error message
that can help you to solve the problem. To correct this, edit the display_errors = On display_startup_errors = On Check the Where is the php.ini File? FAQ for help
in identifying the If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
Why I get the Warning "PHP Startup: xxxxx Unable to initialize module"? |
|
This error message is raised when the PHP engine is trying to load an extension compiled for a different version of PHP (i.e. using a PHP 4.4 extension with PHP 5). If the
|
|
|
Why I get many "Notice: Undefined variables …" notices in my PHP scripts? |
|
Our preconfigured packages are provided with the default PHP configuration, except for some minor changes required for the stand alone behavior. This configuration includes the following directive: error_reporting = E_ALL This directive tells PHP to show any error, warning, or notice
encountered by the PHP scripts. If you prefer not to see these notices,
edit the error_reporting = E_ALL & ~E_NOTICE You can find more information about error reporting in the PHP
online manual (see http://www.php.net/error_reporting and http://www.php.net/manual/en/ref.errorfunc.php). Refer to the Where is the php.ini File? FAQ for
help in identifying the If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
How can I send an email with PHP in DWebPro? |
|
DWebPro includes a stand alone SMTP server that enables you to send emails directly from the hosted Web site as you do on the Internet. By default, DWebPro starts the SMTP server on the first empty
port to avoid conflicts with other servers running on the same machine.
If you want to send an email from your PHP code using the <?php
ini_set('smtp_port', dwebpro_getvar('DWEBPRO_SMTPSERVER_PORT'));
?>
After this, you can use the Note that, to send emails through the DWebPro SMTP Server, you have to configure DWebPro to start the SMTP server (refer to the SMTP Server topic). |
|
|
How can I protect my PHP source code from being stolen? |
|
DWebPro supports almost all of the commercial and free PHP encoders available on the market, such as:
DWebPro also includes the DWebPro Encoder Software, which is a PHP/ASP Classic 3.0 encoder that provides an entry level solution for source code protection. |
|
|
How do I resolve include(), require(), include_path, absolute paths, and URL issues? |
|
Moving a Web site from one server to another typically results in problems related to includes and paths. The biggest problem is related to the use of absolute paths for inclusion and recursive inclusions. There are various solutions to help solve the includes issue. You can change your code to use something like the following for includes/requires: <?php include(dirname(__FILE__) . '/folder/include.php'); // or include(dirname(__FILE__) . '/../include.php'); ?> Using An alternative is to set the PHP <?php
ini_set('include_path', dirname(__FILE__ ) . PATH_SEPARATOR .
ini_get('include_path'));
?>
Sometimes, especially when using CMS or third party scripts,
you have to edit a configuration file that contains references to
absolute paths and URLs. Here is an excerpt from the Moodle (http://moodle.org/) $CFG->dirroot = '/home/example/public_html/moodle'; This way of configuring Web scripts works very well when you install the scripts on a Web server for the Internet. However, when you have to distribute the same script to hundreds or thousands of different machines, you have to set these configuration fields at runtime because fixed values will not work everywhere (such as because of the change of the CD/DVD drive letter and so on). Under DWebPro there are two main ways you can achieve this runtime
configuration task. The first one is the same used for the includes
and consists of the use of $CFG->dirroot = dirname(__FILE__); The second way uses DWebPro's internal functions and constants: $CFG->dirroot = dwebpro_getvar('DWEBPRO_DOCUMENTROOT') . '/moodle';
Another typical issue using third party scripts is related to
absolute URLs. Here is another excerpt from the Moodle (http://moodle.org/) $CFG->wwwroot = 'http://example.com/moodle'; By default, DWebPro starts the primary Web server on the first empty port to avoid conflicts with other servers running on the same machine. DWebPro also allows you to set a more user friendly domain name that will be shown to the user in the Web browser address bar. With these features in use, the absolute URL of the hosted Web site is not fixed and should be set at runtime. Here is how you can achieve this: $CFG->wwwroot = 'http://' . dwebpro_getvar('DWEBPRO_HOSTNAME') . ':' .
dwebpro_getvar('DWEBPRO_WEBSERVER_PORT') . '/moodle'; |
|
|
How can I activate the ImageMagick software in DWebPro (for example, for the Typo3 Web site)? |
|
ImageMagick (see http://www.imagemagick.org/) is "a software suite to create, edit, and compose bitmap images." Many CMS and Web scripts use ImageMagick for runtime image manipulation, one CMS of which is Typo3 (see http://typo3.org/). For installing ImageMagick for Typo3, follow these steps:
This last step is required because Typo3 code contains hard coded references to the typo3temp folder and there isn't any configuration field that provides a way to change these references. When running Typo3 from CD/DVD, the typo3temp folder will not be writable and this will prevent the Web application from executing correctly. |
|
|
How do I solve the "Your PHP installation does not support PostgreSQL..." error message? |
|
The "Your PHP installation does not support PostgreSQL.
You need to recompile PHP using the --with-pgsql configure option."
error message can be solved by editing the To do this, open the ;extension=php_pgsql.dll Replace that line with: extension=php_pgsql.dll You can find more information on PHP extension activation in
the official PHP manual (http://www.php.net/manual/en/install.pecl.php). Refer to the Where is the php.ini File? FAQ for
help in identifying the If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
How do I resolve the "Warning: PHP Startup: Unable to load dynamic library 'php_mysql.dll' - The specified module could not be found. in Unknown on line 0" error? |
|
This error occurs when DWebPro finds an incompatible |
|
|
How can I know when the web application is running under DWebPro (i.e. for conditional configuration)? |
|
DWebPro sets the <?php This feature is useful if you want to use the same code base for your online and CD based web application. For instance you can use a code like the following for your configuration file: <?php
if (preg_match('#dwebpro#si', @$_SERVER['SERVER_SOFTWARE'])) {
// Insert here the DWebPro configuration
define('DB_HOST', '127.0.0.1:' . dwebpro_getvar('DWEBPRO_MYSQL_PORT'));
} else {
// Insert here the Apache/IIS configuration
define('DB_HOST', '127.0.0.1');
}
?>
|
|
|
Can I make PHP execute .HTM and .HTML web pages (like Apache AddType directive)? |
|
Of course you can! Open the ; PHP 5.2 ISAPI configuration sample [ISAPI1] Path=##DWEBPRO_PATH##\engine\php5\php5isapi.dll Extensions=.php|.php3|.phtml|.php4 or like the following:; PHP 5.2 CGI configuration sample [CGI0] Path=##DWEBPRO_PATH##\engine\php5\php-cgi.exe Extensions=.php|.php3|.phtml|.php4 Params= The above configurations tells DWebPro to make PHP execute the files specified in the Extensions field ( To make PHP execute the ; PHP 5.2 ISAPI configuration sample [ISAPI1] Path=##DWEBPRO_PATH##\engine\php5\php5isapi.dll Extensions=.php|.php3|.phtml|.php4|.htm|.html ; PHP 5.2 CGI configuration sample [CGI0] Path=##DWEBPRO_PATH##\engine\php5\php-cgi.exe Extensions=.php|.php3|.phtml|.php4|.htm|.html Params= Refer to the ISAPI and CGI topics for more information about Server Side Languages support and configuration. |
|
|
Why you don't include PHP and MySQL in the DWebPro install package? |
|
Distributing MySQL with a closed source software requires an OEM License otherwise it's illegal. The cost of the OEM License will prevent us to release our product under a “FREE for non commercial use” agreement. We have found a much more flexible solution. We provide a different preconfigured package for each server side language and database so the user can decide by itself what install. Another benefit is related to the size of the DWebPro installer that is only 9 Mb. This means less time to download, less space to archive and so on. |
|
|
Why don't $HTTP_POST_VARS, $HTTP_GET_VARS and all the $HTTP_*_VARS predefined array work? |
|
The use of If your code still relays on the long predefined array you can enable them editing the register_long_arrays = Off Replace that line with: register_long_arrays = On You can find more information on PHP predefined variables in
the official PHP manual (http://www.php.net/variables.predefined). Refer to the Where is the php.ini File? FAQ for
help in identifying the If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
Why this simple PHP script doesn't work: <? echo("Hello World!"); ?> ? |
|
By default, PHP is distributed with the If your code uses the short open tag ( short_open_tag = Off Replace that line with: short_open_tag = On You can find more information on PHP predefined variables in
the official PHP manual (http://www.php.net/variables.predefined). Refer to the Where is the php.ini File? FAQ for
help in identifying the If you are using PHP as ISAPI module you have to stop DWebPro and restart it to make the PHP engine aware of the configuration change. |
|
|
Can I execute PHP script with Ioncube Cerberus, Zend Encoder or another PHP encoder? |
|
DWebPro supports all of the major PHP encoders available on the market. It supports:
In addition to these encoders, the DWebPro includes the DWebPro Encoder, a PHP and ASP Classic 3.0 encoder with AES-based encryption. To execute a PHP script encoded with one of the above encoders you need to enable the relative extension in the If you are using one of our PHP preconfigured packages you need only to open the ; PHPShield Extension ;extension=phpshield.5.2.win ; SourceGuardian Extension ;extension=ixed.5.2.win ; PHTMLEncoder Extension ; PHTMLEncoder doesn't support PHP 5.2 ;extension=phtmlenc5.1.4.dll ; Nu-Coder Extension (http://www.nusphere.com/products/nucoder.htm) ; Check the Nu-Coder EULA (nu-coder_eula.txt) ;extension=nu-coder-php-5.2.dll ; eAccelerator Extension ;zend_extension_ts = engine/php5/ext/eAccelerator095_5.2.0.dll ;eaccelerator.shm_size = "64" ;eaccelerator.cache_dir = "" ;eaccelerator.enable = "1" ;eaccelerator.optimizer = "1" ;eaccelerator.debug = "0" ;eaccelerator.check_mtime = "1" ;eaccelerator.filter = "" ;eaccelerator.shm_max = "0 ;eaccelerator.shm_ttl = "0" ;eaccelerator.shm_prune_period = "0" ;eaccelerator.shm_only = "1" ;eaccelerator.compress = "1" ;eaccelerator.compress_level = "9" ;eaccelerator.keys = "shm_only" ;eaccelerator.sessions = "shm_only" ;eaccelerator.content = "shm_only" ;eaccelerator.admin.name="yourusername" ;eaccelerator.admin.password="yourpassword" ; Ioncube Encoder ; To enable Ioncube Encoder Extension you have to disable Zend Optimizer ;zend_extension_ts = engine/php5/ext/ioncube_loader_win_5.2.dll ; Zend Optimizer [Zend] ;zend_extension_manager.optimizer_ts="engine\php5\optimizer" ;zend_extension_ts="ZendExtensionManager.dll" ;zend_optimizer.optimization_level=15 |
|
|
Where is the my.ini file? |
|
When started by DWebPro, the MySQL engine doesn’t relay on a configuration file (i.e. |
|
|
How can I set a MySQL system variable? |
|
When started by DWebPro, the MySQL engine doesn’t relay on a configuration file (i.e. As described in MySQL official manual (see http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html and http://dev.mysql.com/doc/refman/5.1/en/using-system-variables.html) you can change the MySQL system variables passing them as parameters. Under DWebPro you can achieve this editing the For instance, if you want to set the lower_case_table_names system variable to 2 you have to add the " CustomParams=--skip-innodb --lower_case_table_names=2 In the above example, " Remember to restart DWebPro to make it aware of the change. |
|
|
How can I resolve a codepage error with data saved in the MySQL database? |
|
If your web site reads data with a character set different from http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html For instance, if your web site uses Cyrillic characters you have to configured the CustomParams=--skip-innodb --character-set-server=cp1251 In the above example, " Remember to restart DWebPro to make it aware of the change. |
|

