Boo-urns Posted January 15, 2009 Share Posted January 15, 2009 I just moved my form to a new server when i was working locally with MAMP. Now the form fields are displaying the php code that I am outputting in the field. For example: <input type="text" name="email" id="email" value="<?= displayFormVal($email); ?>" /> In the form it's displaying: <? echo displayFormVal($email); ?> in the input. What needs to be changed in the configuration? Thanks! -Corey Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/ Share on other sites More sharing options...
dennismonsewicz Posted January 15, 2009 Share Posted January 15, 2009 I would change: <input type="text" name="email" id="email" value="<?= displayFormVal($email); ?>" /> to: <input type="text" name="email" id="email" value="<?php echo displayFormVal($email); ?>" /> <?= is PHP Shorthand and not all servers are set up for this. I am not sure how to set up your configuration to accept this but the above should work Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737685 Share on other sites More sharing options...
Daniel0 Posted January 15, 2009 Share Posted January 15, 2009 To use short tags you must set short_open_tag to On. It's better to fix the code in the way dennismonsewicz said though. Edit: On Linux you can write a small shell script like this to do it quickly: #!/bin/sh grep -rl <\?= /path/to/script/root | while read filename do { sed "s/<\?=/<?php echo/g;" $filename > $filename.new mv -f $filename.new $filename rm -f $filename.new } done I didn't test it and you might want to backup your files first. Don't mind that the syntax highlighting is messed up though. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737690 Share on other sites More sharing options...
dennismonsewicz Posted January 15, 2009 Share Posted January 15, 2009 To use short tags you must set short_open_tag to On. It's better to fix the code in the way dennismonsewicz said though. Thanks! I was wondering how one goes about setting that up. I have used either way and as a good practice, imo, I got out of doing it cause I quickly found out that not all servers are setup for this config. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737691 Share on other sites More sharing options...
RussellReal Posted January 15, 2009 Share Posted January 15, 2009 shorttags are awesome though do what daniel said, and when in doubt do what dennis said, but I really like shorttags so I dun vote against em Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737692 Share on other sites More sharing options...
abdfahim Posted January 15, 2009 Share Posted January 15, 2009 i think when you code, you should always use full php tag, not the shorttag .. coz it's always safer .. u may not have access to php.ini always .. so better to use full tag, whether the shorttag is on or off. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737696 Share on other sites More sharing options...
Daniel0 Posted January 15, 2009 Share Posted January 15, 2009 but I really like shorttags so I dun vote against em The issue is with portability. It's turned off by default in PHP5+ so you risk that your script will not work in other environments. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737697 Share on other sites More sharing options...
Boo-urns Posted January 15, 2009 Author Share Posted January 15, 2009 Yea i agree it is a better bet to just echo it out instead of the short tag. I do have access to the php.ini file so i changed the short_open_tag to on. However, before that I did try just to do the echo which was my first guess as well as many here but, it still outputted it in the field. When i changed the .ini file short_open_tag line it worked just fine. So even if I used just regular echo output, why would it show up in the field? i.e.<?php echo $someVar; ?> Thanks for the quick responses everyone! -Corey Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737700 Share on other sites More sharing options...
Daniel0 Posted January 15, 2009 Share Posted January 15, 2009 Perhaps you haven't installed PHP properly. Do other pages get parsed? Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737702 Share on other sites More sharing options...
trq Posted January 15, 2009 Share Posted January 15, 2009 I think your using <? echo instead of <?php echo, which still wont work with short tags disabled. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737705 Share on other sites More sharing options...
RussellReal Posted January 15, 2009 Share Posted January 15, 2009 do this <?php phpinfo(); ?> if it works php works.. if not you have to set apache up tow ork with php, not just have it installed.. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737770 Share on other sites More sharing options...
Boo-urns Posted January 15, 2009 Author Share Posted January 15, 2009 @thorpe oh you did get me lol i was using <? i forgot to throw in php after it. Quote Link to comment https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/#findComment-737829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.