PHP / MySQL / Apache problem

AXISHK
AXISHK used Ask the Experts™
on
After moving the php application on another server, I find that a lot of php coding cannot run. Attached is a simple test. Any idea ?
C--temp-Test1.png
C--temp-Test2.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
First you're using 'short_open_tag' which are "<?" instead of "<?php>.  They are turned off on many hosting companies.
http://php.net/manual/en/ini.core.php#ini.short-open-tag
Software Team Lead
Commented:
first possibilities:

1. check if php is installed properly in web server? you can test it by writing a simple php page with:

<?php phpinfo(); ?>

Open in new window


2. do you using short open tag of <? ... ?> ? if yes, then check in your php.ini and see if short_open_tag setting is turned on?

Author

Commented:
PHP Info work perfect. I have also test mySQL and can access the tables through SQL statement.

The tag has been on in php.ini

short_open_tag = on
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Ryan ChongSoftware Team Lead

Commented:
The tag has been on in php.ini

short_open_tag = on
Make sure you edited the correct php.ini? (just in case you got many instances of php.ini in multiple locations)

A reboot for your web server may also need to reflect the changes.

Author

Commented:
Reboot but it doesn't help. There is only one php.ini on the server.

Thx
Ryan ChongSoftware Team Lead

Commented:
I don't have Apache Web Server with me so I can't simulate your issue, but I got tested this with IIS by turning on/off short_open_tag in php.ini and it showed me different result after I made such changes.
ste5anSenior Developer

Commented:
Well, there is a semicolon missing...

btw, instead of attaching files, please embed code and images in future posts.. increases readability..
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
echo '<p>Hello World !! </p>'

Open in new window

Is missing a ';' on the end and you probably have errors turned off.
Commented:
With phpinfo you can see:
1. if short_open_tag is On or not
2. the location of php.ini loaded by the server: "Loaded Configuration File"

2017-11-29-11_40_13-phpinfo--.png
2017-11-29-11_39_38-phpinfo--.png
HTH,
Dan
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
On a side note:

Whilst you may not have a problem yet, you will have pretty soon and your code will fail to work entirely. You are using the old mysql* extension. This was deprecated in PHP 5.5 and completely removed in 7. If your host upgrades your PHP version, your app will fail.

Make the switch to mysqli or PDO as soon as possible.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Ryan asked his question, about correct php.ini file, then reading your other comments it does appear you're editing the wrong php.ini file.

Try this set of commands...

updatedb
locate php.ini

Open in new window


This will locate all php.ini files on your machine.

Then when you think you've found the correct file, you must make sure (never, ever guess) + here's how.

I'll guess that you turned up php.ini files in /etc + /usr/local/etc, so you'd modify this command to match all the toplevel directories where you find php.ini files in your runtime environment.

# In window #1
inotifywait -mrq /etc /usr/local/etc | grep php.ini

# In window #2 do a hard restart of PHP, which will be one of these commands.
# If you run FPM change 7.1 to your version. Likely your Distro version is to old for FPM.

service apache2 restart
service httpd restart
service php7.1-fpm restart

Open in new window


When you issue the restart in Window #2 you'll see each *actual* php.ini file used get listed in Window #1.

_______

To expand on what Chris said...

If you're running mysql_*() rather than mysqli_*() then you're likely running PHP-5.5 or below. All these versions have publicly publishes hacks, which will never be fixed, because all pre-5.6 versions have reached EOL (End of Life).

Worse, an OS which contains PHP-5.5 in it's packaging likely contains a very old Kernel, many of which are effected by a zero day exploit, which has been fixed in recent Kernels.

I'd suggest you first install a recent OS version. I run Ubuntu Zesty for all my hosting clients. Zesty runs Kernel 4.10 (secure, no zero days yet) + PHP versions 5.6 + 7.0 + 7.1 + 7.2 which may be installed together + toggled between to test compatibility.

Start with a solid hosting environment + then start debugging your code.
Try adding :

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

?>

to the top of one of the files (scripts) being accessed and see if it gives you anything useful

Author

Commented:
Thx.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial