Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> I Am Having Tonnes Of Trouble.... [resolved]
KansukeKojima
post 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... sad.gif help me please.
Go to the top of the page
 
+Quote Post
rvalkass
post Nov 17 2007, 10:51 AM
Post #2


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,053
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
KansukeKojima
post 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?
Go to the top of the page
 
+Quote Post
rvalkass
post Nov 17 2007, 03:20 PM
Post #4


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,053
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



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:

CODE
$name = $_GET['name'];
$operatingSystem = $_GET['os'];
Go to the top of the page
 
+Quote Post
KansukeKojima
post 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

$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>&nbsp;<b>&middot;</b>&nbsp;<a href="index.php?id=$comp">Computer Specs</a>&nbsp;<b>&middot;</b>&nbsp;<a href="http://2kart.trap17.com" target="_blank">2K ART</a>&nbsp;<b>&middot;</b>&nbsp;<a href="index.php?id=$misc">Misc. Specs</a>&nbsp;<b>&middot;</b>&nbsp;<a href="index.php?id=$art">Artwork</a>&nbsp;<b>&middot;</b>&nbsp;<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 &copy; 2007.  All Rights Reserved.</td></tr>
</table>
</body>
</html>
html;

echo $template;

?>
thanks again!!!
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Nov 19 2007, 06:02 AM
Post #6


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,434
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



rvalkass, you da man!! smile.gif

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.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Trouble With Rpgmaker Xp(19)
  2. Runescape Through A Proxy(2)
  3. Cms?(2)
  4. Mime Type Trouble(3)
  5. Having Trouble Installin Half Life 1 On Windows Xp(8)
  6. Windows Update Trouble(7)
  7. Cpanel Help, Trouble Logging In.(4)
  8. Neomail, Horde, Squirrelmail(4)
  9. Nasal Irrigation For Sinus Trouble(4)
  10. Trouble Creating Hosting Account(20)
  11. School Giving You Too Much Trouble?(1)
  12. Wordpress Login Trouble [resolved](8)
  13. [php/mysql]id Trouble [resolved](3)
  14. Login Trouble [resolved](3)
  15. Logo Trouble(4)
  1. Cpanel Login Trouble!(4)
  2. Php An Js Window.open Pages Trouble.(3)
  3. Trouble Logging Into Cpanel(0)
  4. Window Media Player License.(1)
  5. Trouble With Phpbb Email(1)
  6. New Arisen Site Problem(2)
  7. Important ! I Am Having A Lot Of Trouble Setting Up My...(0)
  8. Having Trouble Installing Smf(3)
  9. Frontpage Extensions Trouble(1)
  10. Css Trouble(7)
  11. Trouble With Php(4)
  12. Ftp Trouble(3)
  13. Unable To Set Up(6)
  14. Having Trouble Cancelling My Account.(1)
  15. Accessing Server(4)


 



- Lo-Fi Version Time is now: 25th July 2008 - 09:32 AM