Jump to content
xisto Community
KansukeKojima

I Am Having Tonnes Of Trouble.... [resolved]

Recommended Posts

I am having lots of trouble getting some different php codes to work on traps servers....

<?php $default = "blah.html"; if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;} ?><?php include ("$id"); ?><a href="?id=blah2.html">Link</a>

For example, I tried this to creat a link, but it would not work... is there anything I can do that I may not be doing, or that I may be doing wrong, or don't know about? It seemse to happen for a few other things too... :) help me please.

Share this post


Link to post
Share on other sites

To get a variable out of the URL, you need to refer to it as $_GET['variablename'] not just as $variablename.
For example, the first line of your code should read:

<?php$default = "blah.html"; if ($_GET['id'] == ""){	$id = $default;}elseif (isset($_GET['id'])){	$id = $_GET['id'];}?>

That should fix it.

Share this post


Link to post
Share on other sites

Ok thank you so much! But what about with this:

http://forums.xisto.com/topic/53226-apparently-this-isnt-working-help-please/

with this problem I just need to use the GET funtion like sonesay said in his reply right?

Share this post


Link to post
Share on other sites

Yes. $_GET['variablename'] is used for pulling information out of URLs and passing them to variables. So, if in the URL you have index.php?name=rob&os=linux then two variables are automatically created:

$_GET['name'] which has the value "rob"

$_GET['os'] which has the value "linux"

Most people reassign those variables to others with more logical names and without the GET part, like this:

 

$name = $_GET['name'];$operatingSystem = $_GET['os'];

Share this post


Link to post
Share on other sites

Thank you Oh so much!!! I finally got it up and running....Yay!!! I can't thank you enough.

Below is the finished result as far as coding. And it actually works!!!

<?php$time = date("g:ia");$main = <<< htmlWelcome to Kansuke's Blog, powered by 2K ART. There won't really be anything on here for a while, at least not until I get everything set up. Please be patient!html;$writing = <<< htmlThis page will eventually have some poems, songs, etc. on it. But none for now! Come back later please!html;$misc = <<< html<b>Total Posts:</b> 0<br><b>Current Host:</b> Xisto<br><b>Blogs on Network:</b> 1/10<br><b>Current Time:</b> $time (Central)<br>html;$art = <<< htmlThis page will eventually have artwork on it. But none for now! Come back later please!html;$comp = <<< htmlThis page will eventually have some computer specifications on it. But none for now! Come back later please!html;$about = <<< htmlThis page will eventually have some information on it about the user. But none for now! Come back later Please!html;$default = "$main"; if ($_GET['id'] == ""){	$id = $default;}elseif (isset($_GET['id'])){	$id = $_GET['id'];}$template = <<< html<html><head><title>2K Blogs\\ Kansuke's Blog</title></head><body marginwidth="0" topmargin="5" rightmargin="5" leftmargin="5" bottommargin="5" bgcolor="#505050"><link rel="stylesheet" href="css.css" type="text/css"><table border="0" width="780" cellpadding="2" cellspacing="4" align="center"><tr valign="top"><td valign="top" width="780" class="head"><img src="banner.jpg"></td></tr><tr valign="top"><td valign="top" width="780" class="table_class" bgcolor="#727272">[ <a href="index.php?id=$about">About Me</a> <b>·</b> <a href="index.php?id=$comp">Computer Specs</a> <b>·</b> <a href="http://2kart.trap17.com" target="_blank">2K ART</a> <b>·</b> <a href="index.php?id=$misc">Misc. Specs</a> <b>·</b> <a href="index.php?id=$art">Artwork</a> <b>·</b> <a href="index.php?id=$writing">Writing</a> ][ <a href="index.php">Index</a> ]</td></tr><tr valign="top"><td valign="top" width="780" class="table_class" bgcolor="#727272">$id</td></tr><tr valign="top"><td valign="top" width="780" class="table_class" bgcolor="#727272">Copyright © 2007.  All Rights Reserved.</td></tr></table></body></html>html;echo $template;?>
thanks again!!!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.