开发者

php script is ouputting php code, not sure why

I have a simple modal dialog that I developed on my own linux server, running php 5.3. The script (shown below) runs fine on my server. However, I moved it to my client's linux server and instead of echoing the text/html that it apparently is supposed to do, it echos ALL the actual php code from the > (greater than) character on. Does anyone know why it would echo the actual code? Is there a php.ini setting that causes this? or file encoding difference in the two setups?

<?php


$to_email = 'myname@myemail.com';
 $link = $_GET['link'];
 if(!$link){
  echo '<p>Have a suggestion?<br />Enter the URL below!</p>';
 }else if(strlen($link) > 256 || !preg_match('/^(http:\/\/)?subdomain\.somesite\.com\/(somedir\/)?anotherdir\/(.+)/',$link) && !pre开发者_JAVA百科g_match('/^(http:\/\/)?somedomain2\.com\/somedir2\/(.+)/',$link)){
  echo '<p class="error">Whoops, the URL entered doesn\'t <br />match the criteria.</p>';
 }else{
  $link = str_replace("\n.", "\n..", $link);
  if(!preg_match('/^http:\/\//',$link)){
   $link = 'http://'.$link;
  }
  mail($to_email, 'New URL Suggestion', "A new URL has been suggested from your site:\n\n".$link,"From: ".$to_email."\r\n");
  echo '<p>Thank you for submitting this URL! <br />It should be live within 24 hours.</p>';
 }
?>

The result on my client's server is:

256 || !preg_match('/^(http:\/\/)?subdomain\.somesite\.com\/(somedir\/)?anotherdir\/(.+)/',$link) &&
!preg_match('/^(http:\/\/)?somedomain2\.com\/somedir2\/(.+)/',$link)){ echo '
Whoops, the URL entered doesn\'t 
match the criteria.

'; }else{ $link = str_replace("\n.", "\n..", $link);
if(!preg_match('/^http:\/\//',$link)){ $link = 'http://'.$link; } mail($to_email,
'New URL Suggestion', "A new URL has been suggested from your site:\n\n".$link,"From:
".$to_email."\r\n"); echo '
Thank you for submitting this URL! 
It should be live within 24 hours.

'; } ?>


Sounds like the other server isn't configured to run PHP. Does it have a line like this in the config?

AddType application/x-httpd-php .php .html .htm


If you are running apache your httpd.conf file probably doesnt have the php module enabled.


As mentioned in the other errors, this is probably a server configuration problem.

If you are using Apache (you probably are), you should go take a look at httpd.conf on their machine, which is probably located in /etc/apache2/.

If you are running PHP as a module (by default you are), then you need to make sure that there is a line in it that looks like this:

LoadModule php5_module modules/libphp5.so

(That's what it looks like on mine, the path/filename may be different)

If you are running PHP with Fast-CGI, I'm not sure, as I've never used it :D

Either way, you also want to do what @Alex Howansky suggests and check httpd.conf for a line that looks like

AddType application/x-httpd-php .php .html .htm

This configures Apache to associate the specified extensions with PHP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜