php not loaded but the code exist in view source page - php

i was setup my server, unfortunately the php page not loaded in the browser. Looking at the view source pages, i see my php codes. I using centos and install cpanel.
What usually reason for the problem?

It means PHP is not running.
Have you tried reaching localhost in your browser? Generally you should see the PHP index file, which tells you if the server works or not.
A few possibilities :
Is your file in the proper root folder? Is is accessed via localhost (not file system!)
is your file in .php (ex. NOT .html)?
Are you using full <?php ?> tags? Some server configs won't recognise <? ?>

Related

.php pages not working on xampp

I'm running xampp version 2.5 on windows 7 and ftp'd over a website I'm working on (www.dfwcertautos.com). None of the .php pages load, however the .html pages load fine. I created a test.php page with "hello world" and it loaded correctly. Any suggestions for getting it to run properly? The site has no database, however it does have an XML feed coming in to it from another service. I didn't make any changes to the htaccess file.
What FTP client did You use?
It is possible that when copying the files in "Text" and not "Binary" mode there was a special whitespace added on the beginning of each PHP file so the PHP file cannot be executed on APACHE server...
EDIT: another idea - aren't You using PHP short tags <? instead of <?php on Your localhost while on the server the short opening tag (<?) is not permitted...?

web browser not processing PHP code as PHP code

I have Joomla installed in my computer, but recently have been writing php files that aren't related to the Joomla-managed site. For some reason, when I try to open those php files in the web browser using xampp (note: Joomla also is using xampp), the browser doesn't process the code w/in the tags as php code.
For example, after opening a basic page (a page with title "test", no content except in the body tags) in the web browser and going to the source code, the following is shows up in the source code:
<body>
<?php echo "hello"; ?>
</body>
instead of the HTML conversion. (i.e. just "hello")
Does anyone have an idea about what's going on here?
Thanks.
It's probably because PHP module isn't loaded in your apache. Be sure it is enabled
PHP is interpreted in the server, not the browser. Whatever's going wrong, you need to look at the SERVER side to resolve it.
My first guess: maybe you didn't suffix the file ".php" (so the server doesn't recognize it as a PHP file?)
Second guess: is the directory containing your PHP files configured to parse PHP?
If you have Joomla, you probably have PHP. You probably also have Apache.
So check your Apache configuration, and check your file naming conventions.
Is the file extension .php? The server doesn't magically know when you're serving php files, this is a good way to ensure it knows what you're doing.
Apache is looking into your localhost's defined root directory for files it can parse. In this case htdocs. This is the default for XAMPP. As far as Apache is concerned, it will not interpret any files outside of that folder.
if the problem in php module it better to re install php5 in to the system and it will work fine. probably the problem is in php module you should try re installing php in your system.
Just restart httpd service. It will work fine.
sudo systemctl restart httpd.service
if it has not worked please reinstall PHP once again.

I have a problem with my php script

I have a form where it request name,email,zipcode. However the problem is that. when you click on submit. it ask you to open the file it doesn't go to the script.
The website is http://childcarelv.org/newsletter.html
PHP isn't being handled by your server. Instead, it is just being output straight to the browser.
This is a server configuration issue.
Your server is configured with the correct MIME type (it is returning application/x-httpd-php), but isn't set up to actually use PHP to process it.
Since you are using Apache, read the configuration instructions here: http://www.php.net/manual/en/install.unix.apache2.php
Looks like you might be hosting with ipower.com. If that is the case, this is an issue for them to solve.
From your description it seems that server is not able to execute the php script, and thus gives it as download to the client.
You should try to put the following code in a file named testphp.php and place in your public home directory and go to the page to see if php extension is mapped to the php module on your server.
<?
phpinfo();
?>
This is just to verify/prove that there is nothing wrong in your script, and even a simple test script won't work.

Call to PHP prints source, doesn't run when called from another file

I have a quick question that I can't figure out. I've tried searching Google and following examples, but I can't find anything.
I have an HTML form that I'm trying to process with a PHP file, but when I submit the form, it merely prints the source of the PHP file, it doesn't execute it. If I run the PHP file by itself (not indirectly through the HTML button), it works fine.
HTML form header:
<form id="registrationform" name="registrationform" method="post" action="processregistration.php">
Submit button:
<button type="submit" value="Submit" >Create</button>
The PHP form is just <?php print "Hello"; /?
Again, it runs fine if I just run the PHP file, but prints the PHP file (doesn't run) when it gets called through the HTML form.
Any help is appreciated.
edit-Running locally through Coda
edit-Here is the output that I'm getting:
Output when the PHP is called through an HTML action:
</php
print "Hello";
?>
Output when I run the PHP directly through Coda:
Hello
I had the same problem and just fixed it on my coda version 1.7.4
I installed MAMP on my mac and set up the apache path under MAMP preferences to the folder where my sites are located;
/Users/yourUserName/Sites
this points MAMP's 'http://localhost:8888' address to your sites folder, if you paste that on your browser you'll now see your sites folder's content in the browser.
then, all you do is point the local site's connection settings to the site you are testing;
I was going to post an image, but I'm new to the site and wasn't allowed.
Under my site's preferences i set up the addresses as follows;
Root URL : 'http://localhost:8888/yourSiteRootFolder/'
Local URL : 'http://localhost:8888/yourSiteRootFolder/'
Remote Root : /yourSiteRootFolder/
Local Root : /Users/amartinez/Sites/yourSiteRootFolder/
I hope this is related to the problem you're having and helps you fix it.
Line #19 from Coda 1.6 Release notes:
Coda no longer tries to locally
preview a remote PHP file while
editing/previewing
Listed under "Improvement" - doubt they brought it back for the 1.7 release.
I'm running Apache2/PHP5 10.5.8 OS X (no problem reproducing your issue with Coda)
Even when running my form.html and post.php files from /Library/WebServer/Documents folder.
My sample files work fine in the Apache env....I just needed to run them through Coda to "break" them. :-)
Are you sure the html file and the php script are on a server with php support enabled?
I've never used Coda, but you need to be running it through a server (e.g. Apache + PHP). You cannot just open the file itself within Windows.
Try looking at xampp as a quick server for testing.
If it works properly, you should be viewing the PHP file on something like http://localhost/test.php instead of file:///something/test.php.
This may be because you don't have PHP installed on your server. I would check to make sure that your hosting package included PHP, pre installed.
Here are some resources to get you started with that, if not installed:
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml
http://www.php.net/manual/en/install.php
http://www.w3schools.com/PHP/php_install.asp
Edit: actually, I think I may have found it.
If you look at the starting PHP tag, you have a slash instead of a ?. If that's in your script, just change that to <?php. But it may not be, it could be that's just question format-ing.

php silently ignoring include on localhost, but not on external server

I'm running Ubuntu 10.04 with Apache2 and PHP5.
I have a directory structure like this:
\www\
\index.php
\parts
\head.php
\body.php
Inside my index.php I have a command
<?php include("parts/head.php") ?>
and the equivalent for body.
These files both exist and they contain more php and html code.
The only thing that shows up when I test the website on localhost (\var\www) is the html outside of the PHP commands. There is no error message, it's as if the file is included but empty.
It is exactly the same as on the website (not localhost) but it works perfectly on the website. I don't understand what is different. Any help would be appreciated.
Check your php.ini file to see if "." is on the path?
You could also try this:
include(basename(__FILE__).'parts/head.php');
It's almost always about permissions. When you have something working locally, and then upload and find it doesn't work (include is ignoring file) check the remote files/folders so that you have read/write/execute permissions set as required. (You can do this in FTP) - then run the script again and it should work.

Categories