PHP / MySQL / Apache problem

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 ?
Who is Participating?
Ryan ChongConnect With a Mentor 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?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
First you're using 'short_open_tag' which are "<?" instead of "<?php>.  They are turned off on many hosting companies.
AXISHKAuthor 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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Ryan ChongCommented:
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.
AXISHKAuthor Commented:
Reboot but it doesn't help. There is only one php.ini on the server.

Ryan ChongCommented:
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 DeveloperCommented:
Well, there is a semicolon missing...

btw, instead of attaching files, please embed code and images in future posts.. increases readability..
Julian HansenCommented:
echo '<p>Hello World !! </p>'

Open in new window

Is missing a ';' on the end and you probably have errors turned off.
Dan CraciunConnect With a Mentor IT ConsultantCommented:
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"

Chris StanyonCommented:
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 FavorLinux/LXD/WordPress/Hosting SavantCommented:
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...

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 :


ini_set('display_errors', '1');


to the top of one of the files (scripts) being accessed and see if it gives you anything useful
AXISHKAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.