web-host not reading php code - php

Sorry if this is a simple question, but I have been having some problems with my website. I have used both HostGator and Godaddy to host my site. But on both site I have been getting a consistent problem, image: http://postimg.org/image/optvm8qy7/ (sorry for links i did not want to clog up the page).
My problem, or what I think that my problem, is that my default file that we website reads is index.php. I know that that is usable and it dose work on my localhost server. But the index.php file contains both php and html code inside it: http://postimg.org/image/79eyw0fvt/ (once again sorry for the link and not an image on the page).
So what I am Thinking is that for some reason the Web host cant read the php code or is reading it as regular text. Because as you can see the title of the webpage is meant to say "Jackpot Battles", but it says <?php echo $tital; ?>. The thing is that it will read the rest of the files and the website correctly just not any php.
If anyone has any ideas on what could be causing this, or would like any extra information please leave a comment.
Thank you for your time.

It looks like the default page for your host is index.html. While index.php might be on the list, because you have an index.html file it is pointing to that. If you delete or rename index.html it will likely work. I can view what looks to be the correct data by going to http://jackpotbattles.pw/index.php

Related

Trying to use PHP to include same header in all site pages (mac)

I've found lots of iterations of this question. Most solutions are something like, "take the header that should be on all pages and turn it into an html file, like this:
(One example that I've tried to put in a file called header.php)
<!--PAGE HEADER-->
<div width="100%">
<img src="images/headerimage.jpg" height="240">
</div>
"Then make that header.php. Then insert the file into each page in the site like this" -
<?php include 'header.php';?>
I have tried and tried many different combinations of file paths, existing php code that I know works, examples off of the internet. It doesn't work. When I view the source code, i just see:
<?php include 'header.php';?>
It shows up red (Firefox inspector). As far as I understand it, I should see the imported page header code in its place.
The code hasn't been imported. And none of the code from header.php gets run.
It looks so easy, I have followed tutorials on Youtube, for them it works, for me, nothing. I have tried setting up Apache server and running it (not really knowing what I was doing though).
welcome to StackOverflow!
You can't run PHP in an HTML document. Try to change the file extension from .html to .php
Hope this helps!
Dang! I just dug the reply notifications out of my junk mail. Sorry!
Yes, I think my understanding was that I could just copy all the header code out of my html files and paste it into an empty document and call it header.php. Then I would insert the php include statement in my code, and that should basically look like it did before to the browser. But what it looks like is just the php include statement, and no code is imported.
To answer the question what tutorials I followed, I followed a billion tutorials, and all of it is starting to meld into my confused brain. I've actually been trying to do this for years on and off and have never figured it out.
I tried the link recommended above, and got hung up when I didn't have a directory called mods-enabled in my apache2 directory. I have almost no understanding of what is going on behind the scenes, so when I run into something that doesn't fit the example, I just get lost.
And though a couple of days ago I went through this procedure to run apache and then check if php was working, it looked like apache was working and so was php, but even the mail send php file doesn't work when testing locally, so I think php not being enabled is probably the issue. I just have found it very difficult knowing exactly what that means.

Change Website from Plain HTML to Wordpress

I have a static html website that I need to convert to Wordpress. I was able to successfully load wordpress on my hosting and configured a theme. However, the front end still displays the original html page. I need the whole website to be converted to wordpress, but I can't figure out where to add the htaccess and index.php files as I read from a blog. Someone help out.
Thanks
Sam
1) you're kind of asking for the whole of how the internet operates. I'm not saying that to be confrontational, just know that you'll likely be downvoted for such an impossible question.
2) more to the point, your server is looking for a directory index. In general, most servers look for index.html, index.htm, index.php, and then others, but in that order. If it encounters index.html in your directory then it stops and says that is the file to load.
3) you can get around this by changing the name of your file.
"index.html" -> "index_OLD.html" (or any name not index.html)
4) you can also change the way your server processes the index order using the DirectoryIndex directive in your HTAccess file. Ask your hosting provider about how to do this and if it's supported (although, I don't recommend you do this, it's just an available option).
5) your wordpress install should be in the root directory. That is to say, your .htaccess and index.php files should live in the same directory that your current index.html file lives in. Once the html file has a different name, the server will locate the php file and use it to server up as the directory index.
6) good luck friend!

Website hosted on 1and1 only display index.php

I recently suscribed to a 1and1 hosting contract. I've been having issues to display my website, so I tried to put some very basic pages online in order to tell wether the issue was in my file or on the server side.
The homepage is named index.php and has a link to another page (page1.html) that is supposed to display a "Hello World".`
Clique
The homepage is online but there are some issues.
The homepage only works when it's called index.php and doesn't work when it's called index.html.
When I click on "Clique", the url changes to mywebsite.com/page1.html but the content is still "Clique" while it should be "Hello World".Also, the CSS file isn't read.
I've read a lot of threads dealing with similar issues and apparently it might be a problem with the .htaccess file. I don't have a .htaccess in the folder where my files are and I don't know much about how it works. Also, the CHMOD is 705 for both files.
Maybe try the 1and1 support for this issue.
I don't think this is the right place to ask.
Do you have root access, or just FTP.
If there is no .htpasswd, try uploading one.
A generator which will help you is just one google away.

Help with Clean URLs

I am very new to php (in fact about 2 days old). After getting ripped off by my last webhost I have decided to move my website to a different host. A friend has been helping me do this as he has a little info but we are now stuck and I have tried finding a soloution on google but most answers are way over my head. My site is a php site with a mysql database. We have moved the database and ftp'd the site and everything is now working on the new server except one thing - my site was designed originally to use clean urls? When I go to my shop page (ie: mywebsite.com and click on the shop link - mywebsite.com/shop/ (shows in the bottom left of my browser) I get a page not found error, yet when I type in the url mywebsite.com/shop.php the page displays fine. In addition, if I go to mywebsite.com/shop/shoes/ (another link which shows the preceding link in the bottom left hand corner) I get a page not found error. Also if I type in mywebsite.com/shop/shoes.php in the address bar I also get a page not found error even though the page shoes.php exists on the ftp server in a folder called templates - if I go to mywebsite.com/templates/shoes.php it shows up) I understand this is called clean urls and I need to add an .htaccess file to sort out the issue. I have looked on the ftp area of my old host and cannot find this file but have been told it is probably hidden. I have been told by my new provider that mod-rewrite is available on the server but I have no idea how to write this htaccess file. Can anyone please give me a step by step on how to do this as I am not a coder.
Additional Details
I have the following files in my root directory: index.php, shop.php, checkout.php, completed.php, contact.php ... I then have a folder called templates and in this folder I have: shoes.php. clothes.php, coats.php ...
The issue I am having is that most of the php files in my root directory already have href-links? pointing to places like mysite.com/shop/ and mysite.com/shop/shoes/ so when I open up the home page in my browser and hover over the links these are the addresses I see and when I click on the links I get page not found as the borwser must be looking for the links in the wrong place. (these links worked fine however on the last host I used). I understand I need an htaccess file to re-direct these links to the correct places. - ie the link for mysite.com/shop/shoes/ is actually linking to a page called shoes.php located in root/templates. I understand this method was used to tidy up the urls?? ie: instead of having mysite.com/templates/shoes.php the urls shows mysite.com/shop/shoes/. I have looked at the code within some of the php pages in the root and they all have lots of links to these 'false' addresses - ie: mysite.com/shop/shoes/ when the actual file should be at mysite.com/templates/shoes.php. I don't want to go through each file one at a time as they are hundreds of links, thus the reason for trying to make this htaccess file. Thanks for your time, Dave
Try to find an option on your FTP client software to show hidden files.
The name of this file is .htaccess (dot htaccess), that is probably the reason you're not seeing it. If the old site is working then the file is probably there. You could also contact somebody to send you the file via e-mail, IM, etc.
You do not need mod_rewrite or .htaccess for this.
Turn on multiviews in your Apache configuration. This will allow you to omit the .php extension from your URLs.

php code displaying on web page instead of working behind the scene

I have an index.html in my wampserver www directory. On this html, there is a link for a user to upload file. When I hit the link, I select files to upload but instead of the uploadmanager.php which i have tested in my eclipse debugg environment to work, it displays the some part of the code on the web page without doing anything thing. This is not what I expect. Can someone please tell me what is wrong? Thank you.
sound like you are using php-short-open-tags (<? instead of <?php) without enabling this in your php.ini. change your php.ini or use the standart open-tags to solve this.
Are you sure you enabled PHP in WAMP?
Try creating a new uploadmanager.php file directly in wamp/www (or whatever subdirectory) and paste the code from your tested uploadmanager script into the new file. Then try to run it in WAMP.
I think it is a permissions problem. I copied an index.php file into a c:/wamp/www/subdirectory and it only displayed the code. Once I created a new index.php file and pasted the contents of the old file into it, it worked perfectly.
Are you posting to the uploadmanager.php page? Are you getting an error or just seeing the code? Can you post the code from the index.html page that handled the form and the part of the php code you're seeing for us to look at?
Every now and then I have Apache serving the .php as downloadable files instead processing them on the server, but only with random requests.
Some reasons, why this might happen, are
PHP misconfiguration
PHP-files in a directory without execute rights
wrong content type sent
timeout from script execution
In my situation the last bullet is the most dangerous, but luckily it seems to show up only immediately after modifying some of the .php files. I haven't tracked the problem any deeper yet, but it seems to relate some filesystem level operations (as the disk I/O is a bottleneck) and presents itself only in testing env.

Categories