...

View Full Version : PHP include



bryanfl1001
03-22-2008, 02:31 AM
How do I make the code below work with a dynamic url?:

<?php
print "Latest Blog: ";
include ("http://www.abc.com/aforum/blog.php?styleid=3");
?>

The script above is not recognizing the ?styleid=3 when the script above is saved as blogz.php

Thanks,
Bryan

p4plus2
03-22-2008, 05:41 AM
if the file is in the same directory try this

<?php
print "Latest Blog: ";
include ("/blog.php?styleid=3");
?>

mlseim
03-22-2008, 05:40 PM
<?php
print "Latest Blog: ";
include ("http://www.abc.com/aforum/blogz.php?styleid=3");
?>

p4plus2
03-22-2008, 07:03 PM
blogz is the name of his file with in include in it at least thats what he made it seem like.

bryanfl1001
03-23-2008, 03:29 AM
I tried to use the following script below but it does not show the page http://www.MyWebsite.com/aforum/blog.php?styleid=3

<?php
print "Latest Blog: ";

if($_GET['styleid']==3) {
include("http://www.MyWebsite.com/aforum/blog.php");
}
elseif($_GET['styleid']==3) {
include("http://www.MyWebsite.com/aforum/blog.php");
}
?>

p4plus2
03-23-2008, 03:48 AM
Wait, explain EXACTLY what you want to do with this include it seems like you want to try to include a style in which case do this:


<?php
$styleid = $_GET['style'];
if($styleid == 1){
include('/style1.css');
}
elseif($styleid == 2){
include('/style2.css');
}
else{
include('/default.css');
}
?>

bryanfl1001
03-23-2008, 03:55 AM
This is actually for a url to a forum that has its own style. I tried what you said but it gave me the following error:

Latest Blog:
Warning: main() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/local/lib/php') in /home/admin/domains/MyWebsite.com/public_html/blogpost.php on line 9

This is the script I used from your advise:
<?php
print "Latest Blog: ";

$styleid = $_GET['styleid'];
if($styleid == 3){
include('http://www.MyWebsite.com/aforum/blog.php');
}
else{
include('');
}
?>

p4plus2
03-23-2008, 04:02 AM
because you dont have a file called ''. use this

<?php
print "Latest Blog: ";

$styleid = $_GET['styleid'];
if($styleid == 3){
include('http://www.MyWebsite.com/aforum/blog.php');
}
else{
die("style not found");
}
?>

bryanfl1001
03-23-2008, 04:12 AM
p4plus2 I sent you a private message :)

p4plus2
03-23-2008, 04:17 AM
Check pm I found your problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum