Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2006, 10:10 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help needed: the PHP parser don't work!

Hello friends,

I am a beginner of php. I configured a MySQL database and a HTTP Server (Apache 2.0) on a Windows 2000 machine. I was going to start with my first test program but I have a bad surprise with my first simple code below:

<html>
  <head>
    <title=CSCR></title>
  </head>
  <body>
    <p>This is going to be ignored.</p>
    <?php echo 'While this is going to be parsed.'; ?>
    <p>This is also be ignored.</p>
  </body>
</html>

The displayed HTML page shows only the two lines below:

This is going to be ignored.
This is also be ignored.

It seems that the PHP parser don't work but I have no idea to determine the reason. Could anybody help me?
Many thanks in advance,

Piergiorgio

 
Old January 4th, 2006, 02:16 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

If PHP is not installed, Apache should've displayed PHP code as it is. I guess, PHP is installed; perhaps there's an error in Apache/PHP configuration. Or you may've errored in naming you PHP file.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old January 4th, 2006, 04:45 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by anshul
 If PHP is not installed, Apache should've displayed PHP code as it is. I guess, PHP is installed; perhaps there's an error in Apache/PHP configuration. Or you may've errored in naming you PHP file.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
Many thanks for your interest in my request. I confirm that PHP is installed on my server. I can use the parser php.exe to execute the code in my message and I obtain the following output in the MSDOS shell:


<html>
  <head>
    <title=CSCR></title>
  </head>
  <body>
    <p>This is going to be ignored.</p>
    While this is going to be parsed. <p>This is also be ignored.</p>
  </body>
</html>;


The above demonstrate that PHP works well! Probably the problem regards the configuration of Apache/PHP. I modified my httpd.conf file and I added the following lines:


LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php .php3 .php4 .phtml .inc
Action application/x-httpd-php c:/php/php.exe


Do you think the above is sufficient for a correct configuration? Do you have any suggestion?

Please note I have modified my php.ini file as follows:


extension_dir = "c:\php\ext"
extension=php_mysql.dll


but the above is only required for the use of PHP with MySQL.
I think I have done all the required steps to configure Apache/PHP, but it's strange that I have no output from PHP code and no errors. Do you have any suggestion in order to determine the reason of this? Is there a way to know the possible cause by using a debugger (which one?)?
Many thanks in advance for your reply.

Kind regards.

Piergiorgio



 
Old January 4th, 2006, 07:34 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

First, ensure that Apache is not executing all/any of your PHP scripts.
Or you've problem with only this mentioned script.

If you're on Windows, a file something named [like] php4ts.dll need be copied into Apache2 bin directory.

Few things can be read here, [quickly].

Regards,

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old January 4th, 2006, 10:54 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by anshul
 First, ensure that Apache is not executing all/any of your PHP scripts.
Or you've problem with only this mentioned script.

If you're on Windows, a file something named [like] php4ts.dll need be copied into Apache2 bin directory.

Few things can be read here, [quickly].

Regards,

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
Many tnanks for your comments above. I checked my configuration file and I am sure the file php5ts.dll is in Apache2/bin directory.
Moreover I have carried out a test removing the directives which permit the execution of php code in my httpd.conf file. The result is the same: the php code is not executed.
I modified my html code as follows:


<html>
  <head>
    <title=CSCR></title>
  </head>
  <body>
    <script language="php">
       echo 'TRY THIS CODE;
    </script>
    <p>This is going to be ignored.</p>
    <?php echo 'While this is going to be parsed.'; ?>
    <p>This is also be ignored.</p>
  </body>
</html>


but the result has not changed. It's clear that php code is not executed, but I have no possibilities to understand the reason. I tried a lot of changes but the result doesn't change. Any other suggestion? Please be advised I am testing my code on the local machine. Could this be the cause of this behaviour?

Many thanks in advance for your help.

Piergiorgio

 
Old January 8th, 2006, 12:17 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried for 2 weeks to get wamp working and to be honnest I was going to shot myself in the head!! I could never get mysql to work with php ... no idea why. mysql would respond to command line but wouldn't respond to php.

However.. I now use wamp5 , its a simple install which has apache mysql and php5 already pre configured.
http://www.wampserver.com/en/index.php
 
Old January 10th, 2006, 04:47 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Mantis
 I have tried for 2 weeks to get wamp working and to be honnest I was going to shot myself in the head!! I could never get mysql to work with php ... no idea why. mysql would respond to command line but wouldn't respond to php.

However.. I now use wamp5 , its a simple install which has apache mysql and php5 already pre configured.
http://www.wampserver.com/en/index.php
Hello,
many thanks for your interest to my problem, but I have not yet experimented problems with MySql because - as you can see - this topic refers to a configuration problem. I have had a suggestion from "anshul" (please look at the topic .php files vs .html files and not my .html file are parsed correctly. Now I am trying to write code for interaction with MySql... I'll keep you up to dated with my problems (if you want).

Cheers.

Piergiorgio

 
Old January 10th, 2006, 10:55 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I was trying to explain is:
If you are unable to configure your server properly (in your case PHP), instead of waisting 3 weeks like me, there is a wamp version pre-configured which is free and work.
 
Old January 12th, 2006, 07:32 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Mantis
 What I was trying to explain is:
If you are unable to configure your server properly (in your case PHP), instead of waisting 3 weeks like me, there is a wamp version pre-configured which is free and work.
Hi Mantis,

I appreciated your suggestion. I'll keep it in mind... I cannot waste my free time and I appreciate all suggestions I receive in this forum. Many thanks.

Piergiorgio






Similar Threads
Thread Thread Starter Forum Replies Last Post
php does not work help!!! p2ptolu PHP How-To 2 March 23rd, 2005 03:51 AM
php parser fakhrul Pro PHP 9 August 10th, 2004 11:34 AM
Chapter 7 p 214 code didn't work, changes needed.. jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 June 20th, 2004 09:06 PM
Getting PHP and Apache to work together. russell_lacy BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 June 7th, 2004 03:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.