PHP Issue

ivankoumaev

New Member
Messages
4
Reaction score
0
Points
0
I am trying to add a news page to my site using PHP. But the problem is that, even after I add in the coding, the webpage doesn't show up. I've checked and triple checked the URL's and everything is spelled correctly and working properly. It just won't show up on the page [http://ivankoumaev.exofire.net] for some reason.

I'm using this code:
Code:
<?PHP
$number=15;
include("/home/ikweb/public_html/cutenews/show_news.php");
?>

Does anyone know what I'm doing wrong? Any help would be very much appreciated!
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I am trying to add a news page to my site using PHP. But the problem is that, even after I add in the coding, the webpage doesn't show up. I've checked and triple checked the URL's and everything is spelled correctly and working properly. It just won't show up on the page [http://ivankoumaev.exofire.net] for some reason.

I'm using this code:
Code:
<?PHP
$number=15;
include("/home/ikweb/public_html/cutenews/show_news.php");
?>
Does anyone know what I'm doing wrong? Any help would be very much appreciated!

include's a relative include, which is fine but your path is starting too early.

Since all of your scripts are already being ran out of /home/ikweb/public_html, drop that whole section from your include and try this:

Code:
<?php
$number=15;
include("/cutenews/show_news.php");
?>

The key to remember is the include path defaults to where the calling file is in, ergo if index.php is in /home/ikweb/public_html, don't put that in the include - put the rest and it should work fine :)
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
To add to what Livewire said, make sure your page has some output, otherwise it will be (correctly) a blank page :)
 

ivankoumaev

New Member
Messages
4
Reaction score
0
Points
0
Thank you both for replying so quickly!

I tried shortening the path, but that doesn't seem to help it any. I'm partially convinced that the problem is in my index.html file, because I've been trying to add other images to the same table and they aren't showing up either. Although I'm not exactly sure what output is, which may be part of my problem. Haha, it's been so many years since I did any serious stuff!

Ah, anyway, I hate to post so much on here when I'm sure most of it isn't needed, but here's the code for my index.html page.

Code:
<html>
<head>
<title>The Official Ivan Koumaev Fansite</title>
</head>
<style type="text/css">
<!--
 BODY
.style13 {font-size: 14px}
.style15 {
 font-size: 12px;
 font-weight: bold;
 color:black;
}
.style3 { font-family: Verdana, Arial, Helvetica, sans-serif;
 font-size: 12px;
}
.style5 { font-size: 14px;
 font-weight: bold;
}
a:link {
 color:black;
 text-decoration: none;
}
a:visited {
 text-decoration: none;
 color:black;
}
a:hover {
 text-decoration: none;
 color:lavender;
}
a:active {
 text-decoration: none;
 color:black;
}
.style16 {color:black}
.style17 {
 color:black;
 font-weight: bold;
}
body {
  background: url("/images/background2.png");
}
-->
</style>
<font face=verdana>
<font size=2>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div style="position:absolute; left:0; top:0;">    
<img src="/images/header.png">
</div>
<div style="position:absolute; left:170; top:170; width:150; background;">
<table background="/images/background.png"><tr><td>
<iframe
src="[URL]http://ivankoumaev.exofire.net/home.html[/URL]" id="home" name="home" frameborder=0 allowtransparency="true">
</iframe>
<br><br>
<script type="text/javascript">
//new fadeshow("/opening.html", slideshow_width, slideshow_height, borderwidth, delay, pause (0=no, 1=yes), optionalRandomOrder)
new fadeshow(fadeimages, 140, 225, 0, 3000, 1, "R")
new fadeshow(fadeimages2, 140, 225, 0, 3000, 0)
 
</script>
</tr></td></table>

// Then the rest seems to be working all right.

Thank you both again for taking the time to help me! I'm sure I must be bothersome what with my lack of understanding for anything that I'm doing.
 

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
i think i see your problem

at the beginning of your document paths you have a / that ought not be there try removing those slashes and see if that helps

Code:
body {
  background: url("images/background2.png");
}
 

olliepop

Member
Messages
138
Reaction score
0
Points
16
To go up a level when including files or inserting images you use the ol'
Code:
..

For example, if i had an image at tribalcorp.net/image.gif and i wanted to show it from tribalcorp.net/show/page.php i would do this:

Code:
<?php

echo "<img src='../image.gif' />";

?>
[code]

maybe that helps? if its a directory problem.
and i highly recommend converting the name to index.php if your using cutenews as a part of your site. highly :)
 

David

IRC: For Cool People!
Messages
288
Reaction score
2
Points
0
There is something wrong with the file you're including, I'm going to assume that you're not echo-ing anything from that file. If you were including the wrong file, you would be getting an error such as:

Fatal Error: failed to find file in /path/to/file on line ##

Or something similar to the above, unless you turned off error reporting (on by default).

The way the directories are setup, allows you to do full include file paths from the '/', so he, in fact, was correct, which is why there is not something wrong with his include and something is wrong with the included file.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I am trying to add a news page to my site using PHP. But the problem is that, even after I add in the coding, the webpage doesn't show up.

The cause is that files with extension ".html" are not processed by PHP under default settings. If you examine the source of "home.html", you'll see your PHP code. In my opinion, the best solution not involving radical site redesign is to rename the file "home.php", turn on content negotiation by adding "Options +MultiViews" to your root .htaccess and fix any links by removing the file extension. An alternative is to add "AddHandler application/x-httpd-php5 .html .htm" to your root .htaccess, but this will pass every HTML file through PHP, which is inefficient.

include's a relative include, which is fine but your path is starting too early.

Since all of your scripts are already being ran out of /home/ikweb/public_html, drop that whole section from your include and try this:

If the argument to include() has a leading slash, it's an absolute path where root is the filesystem root. (Only if the web server process has chrooted to the document root will "/cutenews/show_news.php" be the same as "~/public_html/cutenews/show_news.php".) If the path begins with a dot or double dot followed by a slash ("./" or "../"), it's relative to the directory of the including script. Otherwise, PHP searches for the file relative to the entries in include_path and then the current directory. If you want to include a file relative to document root, you can use virtual(), which performs a sub-request to resolve the path as a local URL.

Edit: I second using "cutenews/show_news.php" as the include path as it will make it easier to set up your site on another host, such as a development server (which I highly recommend).
 
Last edited:

cyberbd

New Member
Messages
1
Reaction score
0
Points
0
include's a relative include, which is fine but your path is starting too early.

Since all of your scripts are already being ran out of /home/ikweb/public_html, drop that whole section from your include and try this:

Code:
<?php
$number=15;
include("/cutenews/show_news.php");
?>

The key to remember is the include path defaults to where the calling file is in, ergo if index.php is in /home/ikweb/public_html, don't put that in the include - put the rest and it should work fine :)

well, instead of that do ->
Code:
<?php
$number=15;
include("cutenews/show_news.php");
?>
;)
 
Top