We are trying to implement a mailer with an attachment upload option.
It's working great on two of the servers I've uploaded it to.
However, it does not seem to work on my localhost wamp server or even on a different server:
http://203.76.126.68/mailer/
Why am I seeing session values inside the text boxes?
Can anyone point out what seems to be the problem?
Any help would be appreciated.
Thanks!
Short Open Tags might be turned off. The easiest way to fix this is to just do a find and replace and change <?= into <?php echo.
http://php.net/manual/en/ini.core.php#ini.short-open-tag
You can also turn it on (might be possible in .htaccess) in php.ini.
Check if that script is actually processed by PHP.
If it is process by the PHP CGI binary, make sure short_open_tag is set to On. Those <?= ... ?> thingies only work with short_open_tag enabled.
you have shorttags off that's why you have to set it on in php ini or i think you can use the wamp menu and then setting and then turn on shorttags
Related
I've ran into this issue before but don't remember what was causing it. I have a small app that uses the shorthand notation to print variables, <?=$myvar?>, but it doesn't seem to get parsed by the webserver?
Any ideas on what might be wrong here? It's a bit weird since everything else is working ok.
Thanks!
its a short open tag with an echo command (=). since php 5.4 its no longer marked as short open tag and therefore works even with php.ini setting short_open_tags set to off beginning with that version. for earlier versions it depends on that option.
more information:
http://php.net/manual/en/ini.core.php#ini.short-open-tag
you can check that option e.g. using $sot = ini_get('short_open_tags');
It may be turned off in the PHP configuration. Did you try adding this to your script?
<?php
phpinfo();
?>
Anyway, try to avoid short tags because they're good for nothing except creating a portability issue. :)
Not only check for the short_opened_tags but also be sure that AddHandler application/x-httpd-php .php is in your http.conf file. If its not there please add it and restart your apache server.
New to php and taking a class for it. Bought php6 and mysql 6 bible to get started. Of course the hello world script is the first you get and it doesn't show. It just reads part of my script and I'm not sure the problem. Link to test - http://harden6615.com/
I am using a hosted server I bought for class, but I have also check it using MAMP. I figured my script is wrong, but I have copied and pasted and still no Hello World. Any suggestions?
What I copied:
<?php
print("Hello, World<BR />\n");
phpinfo();
?>
Safe the file as index.php instead of index.html.
Checklist:
host allows PHP
file has .php extension
file was edited with a programmer's text editor (not word/wordpad under windows or TextEdit under Mac) because some encode <, > symbols when saving the file
Well actually it isn't, try to use just <?php phpinfo(); ?> If this doesn't show anything - take a look at your webhost if he supports php...
There are a few reasons why PHP may not be being executed.
The most basic error is saving the file as a .html file instead of .php. Make sure you use the correct extension on your file.
Next, make sure your webhost supports PHP. Most free hosts do not, so it's always a good idea to double-check.
There is nothing wrong with your code. If the above two solutions didn't help, try contacting your webhost and asking them why PHP isn't working for you.
Hy!!
I just get a vserver running debian. I just installed apache and php. Now the server should support php.
i uploaded the file index.php:
<?
echo "Hallo";
?>
The problem is if i start a request to the site my browser wants to download a file.
Whats could be the problem?
THX
have you restarted apache after installing PHP?
/etc/init.d/apache2 restart
This could mean that the Mime extension of the File is not registered with the web server which means you will need to check if you have the PHP Interpreter installed as a extension/plugin in your server.
Try:
<?php
echo "Hallo";
The short_open_tags is disabled in may distributions by default. If you have to support legacy pages you can anable them in php.ini, if not then just use the above, your code will be more compatible.
Your server isn't set to parse PHP files before they are output.
Check out these pages:
http://www.phpbuilder.com/board/archive/index.php/t-7100332.html
http://www.petefreitag.com/item/516.cfm
If your page works if you changed that to the <?php tags, then vbence would be right, it could be as shanethehat says that you just need to restart apache if you've already made the change to php.ini, one of the joys of all these things working together you need to work through all the options to find out where these things fall down so you know where to start looking to fix it
(Found why it wasnt displaying, I hadnt put code round the php tags)
I am running 5.2.14. Starting php code code using <? does not work. I must use <?php
For example:
Does not work:
<? phpinfo(); ?>
Does work:
<?php phpinfo(); ?>
Where can I change this setting so <? will work?
edit yout php.ini file, and set short_open_tag = On
you can view the php.ini's path by runing phpinfo(); function...
but, you can just write your scripts starting with <?php
Mike ;]
It is best not to use the short tag <? in place of the normal <?php. If you ever need to host on a server that doesn't support editing the PHP configuration, it is a pain to find and replace the short tags with the standard ones.
From http://php.net/manual/en/ini.core.php:
Tells PHP whether the short form (<?
?>) of PHP's open tag should be
allowed. If you want to use PHP in
combination with XML, you can disable
this option in order to use
inline. Otherwise, you can print it
with PHP, for example: <?php echo
'<?xml version="1.0"?>'; ?>. Also, if
disabled, you must use the long form
of the PHP open tag (<?php ?>).
Yeah as mishunika says change your php.ini file though be warned, if moving to another server later on it might not work. If you don't have access to the php.ini file on the other server you'll have to change them over to
<?php
Any reason you don't want to use the long tag?
I agree with everyone in regards to using short tags. You should for compatibility reasons stay away from short tags. However, there are situations which may call for it. For example, if you are trying to use a PHP script that someone else wrote that uses short tags, then you can either modify the code or enable short_open_tag.
If you do not have writable access to the php.ini file (shared hosting) you may be able to set the flag using the PHP function "ini_set". You can read up on the function here:
PHP ini_set
There are some flags and variables you cannot set with ini_set. I haven't personally tried to set the short_open_tag. Give it a shot.
I Know this is a problem in the php.ini which comes with a default allow_url_fopen = Off and allow_url_include = Off
How could i deal with this... if the hosting place dont change this.. im trying to access an outside url totally diferent from mine, so the server root thing wont work.. what could i do?
Use a HTTP client PHP class to obtain the data:
http://scripts.incutio.com/httpclient/
You can save it as a local file, execute it or do anything. Just be careful not to include some malicious code by mistake (that's why allow_url_include is off by default).