|
|
|
|
![]() ![]() |
Nov 17 2007, 10:36 AM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
I am having lots of trouble getting some different php codes to work on traps servers....
CODE <?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... |
|
|
|
Nov 17 2007, 10:51 AM
Post
#2
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,053 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
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: CODE <?php $default = "blah.html"; if ($_GET['id'] == "") { $id = $default; } elseif (isset($_GET['id'])) { $id = $_GET['id']; } ?> That should fix it. |
|
|
|
Nov 17 2007, 12:04 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Ok thank you so much! But what about with this:
http://www.trap17.com/forums/apparantly-is...ing-t53226.html with this problem I just need to use the GET funtion like sonesay said in his reply right? |
|
|
|
Nov 17 2007, 03:20 PM
Post
#4
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,053 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
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:
Most people reassign those variables to others with more logical names and without the GET part, like this: CODE $name = $_GET['name'];
$operatingSystem = $_GET['os']; |
|
|
|
Nov 17 2007, 09:41 PM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
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!!! CODE <?php thanks again!!!
$time = date("g:ia"); $main = <<< html Welcome 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 = <<< html This 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> Trap17<br> <b>Blogs on Network:</b> 1/10<br> <b>Current Time:</b> $time (Central)<br> html; $art = <<< html This page will eventually have artwork on it. But none for now! Come back later please! html; $comp = <<< html This page will eventually have some computer specifications on it. But none for now! Come back later please! html; $about = <<< html This 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; ?> |
|
|
|
Nov 19 2007, 06:02 AM
Post
#6
|
|
|
Desperately seeking "any key" to continue... ![]() Group: Admin Posts: 3,434 Joined: 23-April 05 From: Trap17 storage box Member No.: 6,042 |
rvalkass, you da man!!
Thank you for supporting one of our members' programming question. Topic is resolved. Please PM any moderator to continue this discussion. Until then, this topic is closed. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 25th July 2008 - 09:32 AM |