This is a discussion on Please help a newbie - PHP is running, but code is not executed within the PHP Language forums, part of the PHP Programming Forums category; Hello, I hope someone will be able to help me on this. I am not very experienced with PHP, doing ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I hope someone will be able to help me on this. I am not very experienced with PHP, doing ASP.NET normally. I have a requirement to use a third-party set of PHP pages on a site, and it's not running properly. I don't think the problem is with the pages though, I think PHP might not be running correctly. The server is Windows 2003 Server with IIS and all the latest patches, service packs, etc. I have PHP 5.2.3 running, and if I create a small PHP page with just <?php phpinfo(); ?> in it, I get the expected information. This implies that PHP is running OK. I have tried a couple of other basic PHP scripts, and they seem to run OK as well. I went through the examples in the "simple tutorial" at www.php.net and got exactly the results predicted. However, if I try to run the pages I'm supposed to be installing, PHP doesn't run. The code in the file is sent to the browser as plain text. If I view the source of the page, I can see some (although not all) of the PHP code in there. If I rename the PHP to have a .html extension, it looks exactly the same. This sounds like the page is not being executed. For example, there is code like this in the page... <input type="text" name="db_user" value="<?=$CFG_db_user?>" /> The browser shows a text box with <?=$CFG_db_user?> inside. Obviously the code isn't being executed. Does anyone have a clue what is going on here? I realise it may be hard without seeing the page, but it's not currently on a production server. If there's any more info I can supply, please let me know. TIA -- Alan Silver (anything added below this line is nothing to do with me) |
|
|||
|
Alan Silver wrote:
> Hello, > > I hope someone will be able to help me on this. I am not very > experienced with PHP, doing ASP.NET normally. I have a requirement to > use a third-party set of PHP pages on a site, and it's not running > properly. I don't think the problem is with the pages though, I think > PHP might not be running correctly. > > The server is Windows 2003 Server with IIS and all the latest patches, > service packs, etc. I have PHP 5.2.3 running, and if I create a small > PHP page with just > > <?php phpinfo(); ?> > > in it, I get the expected information. This implies that PHP is > running OK. I have tried a couple of other basic PHP scripts, and > they seem to run OK as well. I went through the examples in the > "simple tutorial" at www.php.net and got exactly the results > predicted. > However, if I try to run the pages I'm supposed to be installing, PHP > doesn't run. The code in the file is sent to the browser as plain > text. If I view the source of the page, I can see some (although not > all) of the PHP code in there. If I rename the PHP to have a .html > extension, it looks exactly the same. This sounds like the page is > not being executed. > For example, there is code like this in the page... > > <input type="text" name="db_user" value="<?=$CFG_db_user?>" /> > > The browser shows a text box with <?=$CFG_db_user?> inside. Obviously > the code isn't being executed. > > Does anyone have a clue what is going on here? I realise it may be > hard without seeing the page, but it's not currently on a production > server. > If there's any more info I can supply, please let me know. > > TIA He he, I could maybe use your help as I am having to do a few asp/MSSQL pages and my experience is php/MySQL. Anyway, your problem is that <? is what is called a "short open tag" and in the more recent releases of php their use is disabled by default. So instead of <?=$CFG_db_user?> use <?php echo $CFG_db_user;?> |
|
|||
|
Alan Silver wrote:
> Hello, > > I hope someone will be able to help me on this. I am not very > experienced with PHP, doing ASP.NET normally. I have a requirement to > use a third-party set of PHP pages on a site, and it's not running > properly. I don't think the problem is with the pages though, I think > PHP might not be running correctly. > > The server is Windows 2003 Server with IIS and all the latest patches, > service packs, etc. I have PHP 5.2.3 running, and if I create a small > PHP page with just > > <?php phpinfo(); ?> > > in it, I get the expected information. This implies that PHP is running > OK. I have tried a couple of other basic PHP scripts, and they seem to > run OK as well. I went through the examples in the "simple tutorial" at > www.php.net and got exactly the results predicted. > > However, if I try to run the pages I'm supposed to be installing, PHP > doesn't run. The code in the file is sent to the browser as plain text. > If I view the source of the page, I can see some (although not all) of > the PHP code in there. If I rename the PHP to have a .html extension, it > looks exactly the same. This sounds like the page is not being executed. > > For example, there is code like this in the page... > > <input type="text" name="db_user" value="<?=$CFG_db_user?>" /> > > The browser shows a text box with <?=$CFG_db_user?> inside. Obviously > the code isn't being executed. > > Does anyone have a clue what is going on here? I realise it may be hard > without seeing the page, but it's not currently on a production server. > > If there's any more info I can supply, please let me know. > > TIA > Paul gave you the reason. Now you should take this back to whomever wrote that junk and make them fix it. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Paul Lautman wrote:
> Anyway, your problem is that <? is what is called a "short open tag" and > in the more recent releases of php their use is disabled by default. > > So instead of <?=$CFG_db_user?> use <?php echo $CFG_db_user;?> Or (less work for you) find php.ini and switch the short open tag option on. -- Toby A Inkster BSc (Hons) ARCS [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux] [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 16 days, 20:58.] Gnocchi all'Amatriciana al Forno http://tobyinkster.co.uk/blog/2008/0...llamatriciana/ |
|
|||
|
In article <na0165-9lc.ln1@ophelia.g5n.co.uk>, Toby A Inkster
<usenet200712@tobyinkster.co.uk> writes >Paul Lautman wrote: > >> Anyway, your problem is that <? is what is called a "short open tag" and >> in the more recent releases of php their use is disabled by default. >> >> So instead of <?=$CFG_db_user?> use <?php echo $CFG_db_user;?> > >Or (less work for you) find php.ini and switch the short open tag option >on. Thanks to both of you for your help. I tried changing php.ini and the pages worked fine. If I went through all the .php files in this collection and did a global find and replace for "<?" to "<?php" would that do the trick, or is there likely to be anything that might get thrown out by this? Obviously I would have to check that they hadn't used any <?php tags, as this change would result in <?phpphp which would probably cause even more problems! Thanks again -- Alan Silver (anything added below this line is nothing to do with me) |
|
|||
|
In article <2YednTuHLtKDyhDanZ2dnUVZ_gSdnZ2d@comcast.com>, Jerry Stuckle
<jstucklex@attglobal.net> writes >Paul gave you the reason. Now you should take this back to whomever >wrote that junk and make them fix it. Don't worry, I will! They tried to convince me that PHP wasn't working, even though I pointed out that my (admittedly simple) test pages had worked fine. Now I know what the problem is, I can address it directly. Thanks -- Alan Silver (anything added below this line is nothing to do with me) |
|
|||
|
Alan Silver wrote:
> If I went through all the .php files in this collection and did a global > find and replace for "<?" to "<?php" would that do the trick, or is > there likely to be anything that might get thrown out by this? Search and replace ought to be fine. Just remember that there are three- types of shorttag: <? ... ?> <% ... %> <?= ... ?> The first two should be replaced with: <?php ... ?> The last one should be replaced with: <?php echo ... ?> The files you need to be careful with are XML files or PHP files that generate XML output -- this is because '<?' is a commonly used construct in XML to introduce a "processing instructions", such as an XML version hint, or link to a CSS stylesheet or XSLT transformation. Indeed, it's because of this '<?' confusion with XML that shorttag is disabled by default in more recent versions of PHP. Careful authors can author XML with PHP with shorttag enabled and not have any problems. But not everyone is careful. ;-) -- Toby A Inkster BSc (Hons) ARCS [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux] [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 16 days, 23:29.] Gnocchi all'Amatriciana al Forno http://tobyinkster.co.uk/blog/2008/0...llamatriciana/ |
|
|||
|
In article <4h9165-9lc.ln1@ophelia.g5n.co.uk>, Toby A Inkster
<usenet200712@tobyinkster.co.uk> writes >Search and replace ought to be fine. <snip> Thanks for that. I have had quite a bit of hassle with this code, even after sorting out the short tags, and it looks like we might just drop the whole thing. The code doesn't seem very good, and the support from the company who wrote it is poor. I think we'll do without it ;-) Thanks for the help. -- Alan Silver (anything added below this line is nothing to do with me) |