PDA

View Full Version : Problems with PHP!



Misty-chan
28th March 2006, 3:07 PM
Hii!!! I had a site of aaml and Iīm changing it for php ( only the index page ). And Iīm puting a code for all links open in the same place ( like iframe ).

This code make appear de contents of site inside of index page... and work...

<?php if(empty($page))

{

include("noticias.php");

}

else { include("$page.htm");

}

?>

And this code is for links of site:


index.php?page=banners

But when a click in a link of site, nothing happen xP ! The index page is in php... I donīt know explain it very well hehehe ^^' . Someone could help me? Pleasseee?!?

JKaizer
28th March 2006, 8:54 PM
Not sure if this would work, but go ahead and try it
<?php

if (!$page) { include("noticias.php"); }
else { include("$page.htm"); }

?>

Misty-chan
29th March 2006, 2:50 PM
Thanks for help me, but the problem still the same. The code make show the page of middle, but the links of table donīt open... I donīt know why x] .

Dragonfree
29th March 2006, 3:01 PM
Umm... is that all the PHP you have?

Because you need to define $page as $_GET['page'] somewhere before you can use that...

JKaizer
29th March 2006, 4:10 PM
I didn't think that'd it work, I was just messing with your code a bit.

Try using this, as it works for everyone else:
<?php

$news = "noticias.php";
$error = "error.htm CHANGE THIS I GUESS";
$ext = ".htm";

if(!isset($_GET['page'])){
include $news;
}
elseif($_GET['page'] == "main") {
include $news;
}
elseif(isset($_GET['page']) && file_exists($_GET['page'].$ext)){
include $_GET['page'].$ext;
}
else{
include $error;
}

?>

Misty-chan
30th March 2006, 7:21 PM
Thanks very much, Dragonfree and JKaiser for help me! I was getting crazy with this code... the code that JKaiser show works very well!!! Hehehehehe... now I can breath again xP

Thanks! Thanks! Thanks!

JKaizer
1st April 2006, 3:19 AM
Glad it's working for you now. ^_^

*chuckles as more and more people use my code* =D

Misty-chan
1st April 2006, 1:43 PM
Oh my god!!! I have a new problem!!! Hehehehe... x]

Now the links open in a new window... example:

If a enter in a link called 'banners', work right. But if a enter in a link inside of page banner open in a new window! What I gonna do now?

Sorry for be bore T.T !

Dragonfree
1st April 2006, 2:01 PM
Are you sure the links don't have target="_blank" in their attributes?

Virtual Headache
1st April 2006, 2:15 PM
Instead of

<A
href="project.php?page=enquetes">Enquetes</A>
try using only this:

<A
href="?page=enquetes">Enquetes</A>
on all of your links.

I recommend trying it out for only one of the not working links first, then for the others, since I'm not completely sure if it will help.

You should also take a look at CSS.
You use a lot of HTML code which wouldn't be necessary if you used CSS and would make making the layout a little easier ;)

Misty-chan
1st April 2006, 2:18 PM
No... the others links ( .htm ) is normal:

by example: "page.htm" donīt have target.

Virtual Headache
1st April 2006, 2:21 PM
Did you try out what I suggested?

Misty-chan
1st April 2006, 2:29 PM
Well, before I was using:


?page=banners

But all links are open in a new window! This code:


project.php?page=banners

Only the links of banners open in a new window.

I donīt know very much CSS, but I gonna read a tutorial of this ^^ ! Maybe it gonna help me a little...

Virtual Headache
1st April 2006, 5:20 PM
Are you using frames which might not be seen by others by any chance?
Your site is acting strange for me.

Just put all the PHP code in your main file, but no frames or anything like that and try changing the links to the thing I've mentioned.

JKaizer
1st April 2006, 5:22 PM
<DIV
style="Z-INDEX: 1; LEFT: 0px; WIDTH: 127px; POSITION: absolute; TOP: 186px; HEIGHT: 1190px">
<P align=center></P><FONT face=Arial><FONT size=2><FONT color=#7f7f7f><FONT
color=#7f7f7f><STRONG><FONT face=Tahoma><FONT size=1><FONT color=#7f7f7f>

<P align=right></FONT></FONT></FONT></STRONG></FONT></FONT></FONT></FONT><A
href="project.php?page=banners"><FONT face=Tahoma color=#333333 size=1>Banners /
Buttons</FONT></A><BR><A href="project.php?page=parceria"><FONT face=Tahoma color=#333333
size=1>Fazer Parceria / Parceiros</FONT></A><BR><FONT face=Tahoma size=1><A
href="project.php?page=trabalheaqui">Trabalhe Aqui</A><BR><A
href="project.php?page=enquetes">Enquetes</A></FONT><BR>That's just a bit from your navigation. @_@

I'd suggest trying to simply down that code a bit, sot hat it's actually readable. In it's current state, I can't find what's making the links go to a new page.

Misty-chan
2nd April 2006, 1:37 AM
I found one error! This:
<BASE target=iypp>

Yeah was one target problem =XXXX

Now the links of menu work! This things drives me crazy... hehehehe...
But still had a problem... Example: if I enter in section 'fanfics', and after I enter in some link inside of 'fanfics' open in a new window without target ._.' .

My problems donīt go away... why sad!

Do you are understand me? My english is very bad ;_;

Virtual Headache
2nd April 2006, 1:42 AM
It's working for me.
Which one of the links doesn't work?

Misty-chan
2nd April 2006, 2:18 PM
Well, try enter in the link fanfics ( fanshrine > fanfics ). In the end of page 'fanfics' have a link, enter in it. Well, like you can see the links open in all page, no in the same place of fanfics O.O' ... when I change the link for:


?page=link

Works well, but my site had so many links... More than 80 o.o' ... I want still with others links like html normal.

Somebody save mee... ;_;

Virtual Headache
9th April 2006, 8:13 PM
Please don't double post, it's against the rules.

Do you mean this link?
!!!Clique aqui para visualizar todas as fanfics disponíveis no MistyShrine!!! (http://www.mistyshrine.roxr.com/ffanfics2.htm)

All the pages open fine for me.
However it might cause confusion if you use frames and PHP includes at the same time...

Magma Leader Maxie
12th April 2006, 4:05 PM
I would like to note that using $_GET to receive an id number probably isn't a good idea unless it's really necessary (pages from MySQL databases, in which case the request string at the end of the URL holds a parameter for a query).

People often get annoyed in my experience because of confusing and often hard to remeber URLs.

http://www.something.com/index.php?item=42&bannertype=pink&atotallyrandomnumber=32472347209

^ This is terrible ;_;

However, if there's a necessary value to be taken into consideration...

http://www.something.com/articles.php?id=67

^ This is ok, if for example "articles.php" is a script which allows users to post their articles and read others.

Misty-chan
14th April 2006, 9:32 PM
Please don't double post, it's against the rules.

Do you mean this link?
!!!Clique aqui para visualizar todas as fanfics disponíveis no MistyShrine!!! (http://www.mistyshrine.roxr.com/ffanfics2.htm)

All the pages open fine for me.
However it might cause confusion if you use frames and PHP includes at the same time...

Yes!!! Is this page, hehehehe... Is a little hard understand portuguese, no? But now, I change every links and the problems gone... IUPIIIIIIIIIIIIIII!!!

Thanks one more time guys ^^ !!! You help me very much... thanks thanks thanks thanks thanks thanks hehehehe!

My site is in php now!

PS: sorry for no aswering every posts... I donīt understand some words hehehehehe xP

JKaizer
17th April 2006, 3:42 AM
I would like to note that using $_GET to receive an id number probably isn't a good idea unless it's really necessary (pages from MySQL databases, in which case the request string at the end of the URL holds a parameter for a query).

People often get annoyed in my experience because of confusing and often hard to remeber URLs.

http://www.something.com/index.php?item=42&bannertype=pink&atotallyrandomnumber=32472347209

^ This is terrible ;_;

However, if there's a necessary value to be taken into consideration...

http://www.something.com/articles.php?id=67

^ This is ok, if for example "articles.php" is a script which allows users to post their articles and read others.Sometimes those long URLs can work to our advantage as well. ;p

Can keep away some leechers.

RPG Maker
25th April 2006, 3:54 AM
Is it possible to make it so instead of having a link lead to a page that is in the same folder as the index and that the link could be called from many other folders(to keep things origanized for sites with many pages)?

Magma Leader Maxie
25th April 2006, 4:17 PM
Is it possible to make it so instead of having a link lead to a page that is in the same folder as the index and that the link could be called from many other folders(to keep things origanized for sites with many pages)?

Would you mind rephrasing that? I'm not sure what you mean exactly.

RPG Maker
25th April 2006, 9:52 PM
I want to know how to make it so it looks for a page in a different folder rather then having to have that page in the same folder as the index page.

Virtual Headache
25th April 2006, 11:06 PM
The php below, I want to know how to make it so it looks for a page in a different folder rather then having to have that page in the same folder as the index page.


<?php

$news = "noticias.php";
$error = "error.htm CHANGE THIS I GUESS";
$ext = ".htm";

if(!isset($_GET['page'])){
include $news;
}
elseif($_GET['page'] == "main") {
include $news;
}
elseif(isset($_GET['page']) && file_exists($_GET['page'].$ext)){
include $_GET['page'].$ext;
}
else{
include $error;
}

?>
?page=foldername/filename should work.

JKaizer
29th April 2006, 5:18 AM
Yeah, it will.

<a href="?page=path/to/the/folder/and/then/the/file">This will learn to "file.$ext" in path/to/the/folder/and/then/the/</a>