PHP Problem Created 19 years ago2005-06-07 11:41:31 UTC by 96a2107 96a2107

Created 19 years ago2005-06-07 11:41:31 UTC by 96a2107 96a2107

Posted 19 years ago2005-06-07 11:41:31 UTC Post #113095
When i try click the link illistrated in the below code i get a file not found php error because its trying to open only the first letter of the link, anyone got any ideas?

Link:

<a href="index.php?content=work">My Work</a>

Page changing code:

<?
if ((string)$content['content']==NULL)
{
$content['content'] = 'news';
}

include($content['content'] . '.php');
?>

p.s it displays the 'news' page with no problems but when anything is set to 'content' it cocks up :(
Posted 19 years ago2005-06-07 11:53:12 UTC Post #113097
Ohh no worries got it sorted in the end :P code has to look like this for the page change bit:

<?
if ($content==NULL) {
$content = 'news'; }

include($content . '.php');
?>

People using frames still take notice, FRAMES ARE GAY!! use this instead ;)
Posted 19 years ago2005-06-09 09:39:22 UTC Post #113414
I would, but I haven't a notion about frickin databases and without phpmyadmin I'm lost. :
Posted 19 years ago2005-06-09 12:12:25 UTC Post #113428
Its nothing to do with databases and its really pretty simple, its called a 'dynamic include', what it does is use a variable in an include to change the content of your page when a link is clicked, to put it simply if the following link were to be pressed it would declare the variable 'content' on the page 'index.php as 'pic_menu:

<b>http://www.danhall.co.uk/index.php?content=pic_menu</b>

the code on index.php looks as follows:

<b>
<?
if ($content==NULL) {
$content = 'news'; }

include($content . '.php');
?>
</b>

this is placed in the position where you want the content to load, as you can see, this is where the variable 'content' is used.

<u><b>Disection of the code:</b></u>

<b><?</b>

This is the opening wrapper which defines a peice of php code.

<b>if ($content==NULL)
{</b>

This statement means 'if the variable 'content' has nothing in it then..

<b>$content = 'news';
}</b>

considering that the last statement is true then the variable content will contain the value 'news'. (this 'if' statement makes sure that if no value has been passed onto the variable 'content' then it will equal 'news' by default.

<b>include($content . '.php');</b>

This is the actuall include that utilizes the variable 'content'. this is regular php include but it uses a variable ('content') to declare the name of the file to be included, as you can see it adds '.php' to the variable input, and so making a file name

<b>?></b>

The closing wrapper for a peice of php code

<u><b>Recap:</b></u>

To set the variable 'content' with a link:

<b>http://www.danhall.co.uk/index.php?content=forum<b/>

this will open forum.php on index.php

<b>http://www.danhall.co.uk/index.php<b/>

this will open news.php on index.php because it is the default

Hope this helps ypu make yaself a funky site peeps ;)
Posted 19 years ago2005-06-09 13:41:38 UTC Post #113435
( off topic? )
96a2107:
What would you recomend for a beginner, ASP or PHP? :S
Madcow MadcowSpy zappin my udder
Posted 19 years ago2005-06-09 14:24:26 UTC Post #113446
Definitly ASP its much more user friendly, the code uses a more structured english approach so uts best to start with, when youve got your self going with ASP its easy to look at PHP and see whats going on, although ASP was developed by microsoft (the horror) its actually quite good.

a good place to start:

http://www.w3schools.com/asp/default.asp
;)
good luck
Posted 19 years ago2005-06-09 14:31:14 UTC Post #113447
No, no, PHP all the way!

PHP's easy.
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-09 14:31:42 UTC Post #113448
Cocked up the last tut on it, this is easier to read ;)

Its nothing to do with databases and its really pretty simple, its called a 'dynamic include', what it does is use a variable in an include to change the content of your page when a link is clicked, to put it simply if the following link were to be pressed it would declare the variable 'content' on the page 'index.php as 'pic_menu:

http://www.danhall.co.uk/index.p
hp?content=pic_menu


the code on index.php looks as follows:

<?
if ($content==NULL) {
$content = 'news'; }

include($content . '.php');
?>


this is placed in the position where you want the content to load, as you can see, this is where the variable 'content' is used.

Disection of the code:

<?

This is the opening wrapper which defines a peice of php code.

if ($content==NULL)
{


This statement means 'if the variable 'content' has nothing in it then..

$content = 'news';
}


considering that the last statement is true then the variable content will contain the value 'news'. (this 'if' statement makes sure that if no value has been passed onto the variable 'content' then it will equal 'news' by default.

include($content . '.php');

This is the actuall include that utilizes the variable 'content'. this is regular php include but it uses a variable ('content') to declare the name of the file to be included, as you can see it adds '.php' to the variable input, and so making a file name

?>

The closing wrapper for a peice of php code

Recap:

To set the variable 'content' with a link:

http://www.danhall.co.uk/index.php?content=forum

this will open forum.php on index.php

http://www.danhall.co.uk/index.php

this will open news.php on index.php because it is the default

Hope this helps ypu make yaself a funky site peeps ;)
Posted 19 years ago2005-06-09 15:24:51 UTC Post #113455
There's nothing dynamic about it, just simple variables. I would do some sort of if logic so if the page doesn't exist, you can include a 404 page or something.
m0p m0pIllogical.
Posted 19 years ago2005-06-09 15:43:09 UTC Post #113457
Well yeah maybe jus a screwy name on my part, yep thats a good idea ill revise that, at the mo it just comes up with a screwy php cock up message, but actually ill never need it, i dont get dead links ;)
Posted 19 years ago2005-06-10 04:41:33 UTC Post #113510
argh.... nooooo.... dont learn asp!!!!!!

oh 96a2107, just a thought... the navigation on http://www.danhall.co.uk/ has a box around the item, but the only active bit is the text, i recomend either making the whole thing a link, or removing the box.
Posted 19 years ago2005-06-10 08:29:52 UTC Post #113547
Good idea digital..done that, only problem is the back and forward links (yes you say pointless) but they dont just work, this is the code:

<td width="100%" class="menulines" onclick="javascript:history.forward(+1)"><a href="javascript:history.forward(+1)">Forward</a></td>

any ideas? :nuts:
Posted 19 years ago2005-06-10 08:48:04 UTC Post #113549
javascript:history.forward(+1)

Hmmm, I seem to remember using javascriot:history.back(-1) myself?
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-10 09:00:04 UTC Post #113553
Yep thats sor going forward lol this ones for back :P
Posted 19 years ago2005-06-10 12:40:18 UTC Post #113603
if you wanna make the whole thing a link, turn the div tag into an a tag and put display: block; into the class in the CSS.
m0p m0pIllogical.
Posted 19 years ago2005-06-10 14:20:09 UTC Post #113632
Uh, forward(+1) isn't going to make anything go back...
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-10 15:04:52 UTC Post #113647
Try www.codewalkers.com

Follow their News posting system tutorials, and text file databases.

I've my site running on text databases and PHP.

[PIMP] http://www.hlcore.uni.cc/
Posted 19 years ago2005-06-10 16:50:07 UTC Post #113663
Seventh!!! Did you know you can go forward and back in browsers :D its true and amazing, welcome to the internet :lol:

forward 1:

javascript:history.forward(+1)

back 1:

javascript:history.back(-1)

forward 2:

javascript:history.forward(+2)

back 2:

javascript:history.back(-2)

and so on :P
Posted 19 years ago2005-06-10 16:51:30 UTC Post #113664
Uh... you don't want to traverse negatively backward, do you now? That would be going forward.
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-10 21:25:35 UTC Post #113683
Well it works :D try it and see ;)
Posted 19 years ago2005-06-11 01:52:35 UTC Post #113699
Back(-1) goes forward, and forward(-1) goes back. Like I said :|.
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-11 06:12:36 UTC Post #113719
(-1) * (-1) = +1

:

Use Your PHP to do Forward / Back buttons. :P
Posted 19 years ago2005-06-11 07:49:54 UTC Post #113724
Its hard, but your gonna have to forget maths logic! this is php :lol:

testy:

http://www.danhall.co.uk/go forward a page and then utilize the nav buttons on my page ;)
Posted 19 years ago2005-06-11 08:10:59 UTC Post #113726
rather not php doh, javascript hides under rock
Posted 19 years ago2005-06-11 10:08:56 UTC Post #113733
I did test it, and it works as I expected it to :|.
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-06-15 05:38:40 UTC Post #114517
PHP looks harder.. :S
More stuff to remember, and all of those weird signs, ^^

I think I stick to ASP.. =/ but PHP is more "dynamic", right?
you can do more stuff with it, I think..
Madcow MadcowSpy zappin my udder
Posted 19 years ago2005-06-15 07:06:14 UTC Post #114532
ASP is the most popular language out there, it has the majority of web developers using it still, php is fast catching up but is still the smaller language in web development. PHP and ASP are both as 'dynamic' as each other, any task you need to do with PHP can also be done with ASP and vise versa, the trend towards more people using PHP is probably its relations with MySQL databases, yes..they are more powerfull than ms access databases, but honestly you can go with an MSSQL database which is just as powerfull and easy to use with ASP as its a microsoft baby.

ASP tuts:

http://www.w3schools.com/asp/default.asp

PHP tuts:

http://www.w3schools.com/php/default.asp

as you can see even the tutorial section of the W3C uses exclusive ASP just to demonstrate PHP :lol:
Posted 19 years ago2005-06-15 07:18:56 UTC Post #114533
ooh.. Thanks for those links, I'm still a beginer (CTRL + C , CTRL + V, but in a leagal way, lol )
I'll have a look! :D :)
Madcow MadcowSpy zappin my udder
Posted 19 years ago2005-06-15 07:57:31 UTC Post #114540
twhl.co.za/forums.php

atom knows best :P.

Down with MS!
Seventh-Monkey Seventh-MonkeyPretty nifty
You must be logged in to post a response.