View Full Version : PHP help
geniuscrew
01-20-2003, 10:34 PM
I'm trying to change the way I make my site by using PHP. [ trying to anyway lol]
Please can someone tell me what's wrong with this.
Thanks
<HTML>
<HEAD>
<TITLE>Spells Season 1
</TITLE>
</HEAD>
<BODY>
<b>Something Wicca This Way Comes<b><p>
<?php
echo "<a href=\"spells1.php?action=101\">To become witches</a>
if ($action=="101") {
echo
"Hear now the words of the witches
The secrets we hid in the night
The oldest of gods are invoked here
The great work of magic is sought
In this night and in this hour
I call upon the ancient power
Bring your powers to we sisters three
We want the power
Give us the power.";
}
?>
</BODY>
</HTML>
well your missing the quote and semi colon on the first echo and you should use print, instead of echo
geniuscrew
01-20-2003, 10:48 PM
Thanks. I'll try again
What's the main difference between print and echo?
joelrotunda85
01-21-2003, 01:25 AM
There is none, to my knowledge.
print just displays the info and echo returns true if it does false if not.....or something like that, try php.net, but i learned to use print because i used to do echo too
Xenon
01-21-2003, 01:06 PM
also specialchars like \n are treatened different in echo and print AFAIK
geniuscrew
01-23-2003, 11:20 PM
Just when you thought I'd gone...lol
1. What is \n?
2. I have now managed to display a spell underneath the link when you click on it! [go me - this is a big advancement for me]
I have seen loads of files which have several <body> and <html> tags with a php page.
What I wanna do is do the same - when you click on a link, it will show the spell as if it's on a new page, ie just on it's own.
How would I do that?
Thanks for all your help guys
so you want it all contained in one php file but looks like a different page?
if (!$spell) { // this means if spell is not defined in the url display the links
print "<a href=\"thispage.php?spell=fire\">Fire</a>";
print "<a href=\"thispage.php?spell=water\">Water</a>";
}
if ($spell == "fire") {
//Display HTML for fire spell
} elseif ($spell == "water") {
//Display HTML for water spell
}
this will always display the links but only display the spell info if the spell equals something in the url....do you get the genreral idea?
also, \n is like a <br> so you'd do
print "This is first line \n This is second line";
edit: fixed stuff
geniuscrew
01-24-2003, 01:35 AM
Yes I totally get it!
It's just a case of where to put the code you've stated :/
ie. where do the <HTML> and <BODY> tags etc. go?
where i have the display html part, and you can open the tags on both because it will only execute one of the options so it won't duplicate any of the tags
so you could do
<?php
print "<a href=\"thispage.php?spell=fire\">Fire</a>";
print "<a href=\"thispage.php?spell=water\">Water</a>";
//repeat as needed
if ($spell == "fire") {
//Do fire HTML, ex
print "<html><body>This is fire stuff</body></html>";
} elseif ($spell == "water") {
//Do water HTML, ex
print "<html><body>This is water stuff</body></html>";
}
this will make a basic page with links that will stay at the top and other info that will only appear if the spell variable equals something
edit: finished editing
geniuscrew
01-24-2003, 01:47 AM
Thanks for your help Mr e!
I'll try it out =)
Xenon
01-24-2003, 11:33 AM
\n means new line, it the same as when you press enter. but it's not the same as <br>
nevertheless there is a function in php nl2br which converts \n into <br>
geniuscrew
01-25-2003, 08:28 AM
Works like a charm Mr e - thanks a lot mate!
Thanks everyone too
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.