PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, I am a new programmer and having some issues with my PHP website. I am a gigantic nooby so please have pity on me.
<?php
include ('db_config.php');
include ('header.php');
echo "<p>YEA</p>";
echo "<a href=/eclipse_projects/?page=about>About</a><br>";
include ('footer.php');
if ($page == 'about')
{
include ('header.php');
echo "<p>We're the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a>";
include ('footer.php');
}
?>
When I click on the link it doesn't send me to the new page, it reloads the same one with different parameters. Can someone please help
I'm running this in WAMP if that helps
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by fwc on Mon Aug 06, 2007 10:59 pm, edited 3 times in total.
All if your page is going to run, meaning if you do get the about page, you're going to have header - content - footer, header - content - footer (two times).
You need a switch, if/else/elseif, die(), exit, or something.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
scottayy wrote:All if your page is going to run, meaning if you do get the about page, you're going to have header - content - footer, header - content - footer (two times).
You need a switch, if/else/elseif, die(), exit, or something.
Thanks very much
If I were to use die or exit, where would I put them?
scottayy wrote:All if your page is going to run, meaning if you do get the about page, you're going to have header - content - footer, header - content - footer (two times).
You need a switch, if/else/elseif, die(), exit, or something.
Thanks very much
If I were to use die or exit, where would I put them?
I don't think you really need die or exit for what your trying to do, i think he was just giving you some options, but, your main concern is setting $page, which obviously isnt being done. So your code, with an ELSEIF (for example) would look more like this.
<?php
// The linked you clicked on what something like 'mysite.com?page=about'
include ('db_config.php');
$page = $_GET['page']; // You need this somewhere before your IF statement
if ($page == 'about')
{
include ('header.php');
echo "<p>YEA</p>";
echo "<a href=/eclipse_projects/?page=about>About</a><br>";
include ('footer.php');
}
elseif ($page == 'anotherPage')
{
include ('header.php');
echo "<p>We're the smurf!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a>";
include ('footer.php');
}
?>
If I do it that way, when i run index.php nothing runs, i have to put in parameters for my homepage. Is this the usual practice or is there any way around it?
If so, syntax error (I think) most likely, you may have missed a semicolon at the end of a line, a bracket somewhere, or maybe a curly brace. If you can't see it anywhere after a while, post it up, might just need a fresh pair of eyes.
iknownothing wrote:nothing runs as in 100% completely white screen??
If so, syntax error (I think) most likely, you may have missed a semicolon at the end of a line, a bracket somewhere, or maybe a curly brace. If you can't see it anywhere after a while, post it up, might just need a fresh pair of eyes.
so when you type in your domain (eg. http://youdomain.com), does index.php not come up??
If thats whats happening (I'm not sure, because I'm pretty confused) then you need to set your index's in Plesk/CPanel, or whatever other back-end control panel you have. Most likely, the only ones currently set are index.html and/or index.htm
iknownothing wrote:so when you type in your domain (eg. http://youdomain.com), does index.php not come up??
If thats whats happening (I'm not sure, because I'm pretty confused) then you need to set your index's in Plesk/CPanel, or whatever other back-end control panel you have. Most likely, the only ones currently set are index.html and/or index.htm