PHP code issues...

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!

Moderator: General Moderators

Post Reply
Shaggy
Forum Newbie
Posts: 7
Joined: Wed Apr 11, 2007 9:01 pm

PHP code issues...

Post by Shaggy »

ok so... heres the code that i have

Code: Select all

<?php
include ("variables18.php");
$pageNumber = 1;
pageNameANDlinks();

and so on...
and here is variables18.php

Code: Select all

<?php
$pageTitle;
$pageLinks;

$message1 = "Hello 1";
$message2 = "Hello 2";
$message3 = "Hello 3";
$message4 = "Hello 4";
$message5 = "Hello 5";
$message6 = "Hello 6";
$message7 = "Hello 7";
$message8 = "Hello 8";
$message9 = "Hello 9";
$message10 = "Hello 10";

$sideMessage1 = "Hello 1";
$sideMessage2 = "Hello 2";
$sideMessage3 = "Hello 3";
$sideMessage4 = "Hello 4";
$sideMessage5 = "Hello 5";
$sideMessage6 = "Hello 6";
$sideMessage7 = "Hello 7";
$sideMessage8 = "Hello 8";
$sideMessage9 = "Hello 9";
$sideMessage10 = "Hello 10";

function pageNameANDlinks() {
	
	if (pageNumber == 1) {
		$pageTitle = "Home";
		$pageLinks = '<b>Home</b><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 2) {
		$pageTitle = "The Parish";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <b>The Parish</b><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 3) {
		$pageTitle = "Bulletin";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <b>Bulletin</b><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 4) {
		$pageTitle = "Calendar";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <b>Calendar</b><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 5) {
		$pageTitle = "Pictures";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <b>Pictures</b><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 6) {
		$pageTitle = "Ministries";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <b>Ministries</b><br>
					  <a href="history.php">History</a><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	elseif (pageNumber == 7) {
		$pageTitle = "History";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <b>History</b><br>
					  <a href="contacts.php">Contacts</a>'
	}
	
	else {
		$pageTitle = "Contacts";
		$pageLinks = '<a href="home.php">Home</a><br>
					  <a href="theParish.php">The Parish</a><br>
					  <a href="bulletin.php">Bulletin</a><br>
					  <a href="calendar.php">Calendar</a><br>
					  <a href="pictures.php">Pictures</a><br>
					  <a href="ministries.php">Ministries</a><br>
					  <a href="history.php">History</a><br>
					  <b>Contacts</b>'
	}
	
	endif;
	
	}
	


?>
so im still a complete noob at all of this...
im editing this in zend development environment and its giving me these errors...

Parsing Error: H:\Zend\Apache2\htdocs\Website\variables18.php line 39 - parse error, unexpected '}'
Debug Error: H:\Zend\Apache2\htdocs\Website\test18.php line 4 - Call to undefined function pageNameANDlinks()

would the second error be caused by the first error?
whats up with the unexpected curly brace?
before i put in all the curly braces in the conditional statements it gave me an error of an unexpected ELSEIF which was the first elseif...
any clues? and thanks in advance :)
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Looks like you're missing a semicolon after each $pageLinks assignment.
Shaggy
Forum Newbie
Posts: 7
Joined: Wed Apr 11, 2007 9:01 pm

Post by Shaggy »

omg i hate little errors like that... :D use to spend hours in computer science figuring out wth is wrong with my program than i find out its just a semicolon... omg... lol thanks a ton :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"pageNumber" won't exist in pageNameANDLinks().

$pageTitle and $pageLinks will not be transmitted from the function either. Essentially, the function is doing nothing.
Shaggy
Forum Newbie
Posts: 7
Joined: Wed Apr 11, 2007 9:01 pm

Post by Shaggy »

so how do i get what i wana get done?
im basicaly assigning each webpage a number to determine where the user is and with that other file it will determine the title of the page... and what the navigation menu should look like, and i want to have this in one separate file like this if i want to change something it will affect all webpages and i dont have to go one page at a time...

im just starting with PHP so im still a noob :P
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Read on about variable scope -- you'll probably also want to read about function arguments and return values.
Shaggy
Forum Newbie
Posts: 7
Joined: Wed Apr 11, 2007 9:01 pm

Post by Shaggy »

will do, thanks :)
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Happy to help :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

pageNumber is also used throughout the function without being made a variable (no dollar sign $). PHP Will read this as a constant that it can't find.
Shaggy
Forum Newbie
Posts: 7
Joined: Wed Apr 11, 2007 9:01 pm

Post by Shaggy »

k i got things working... ill prob be posting here a bunch more times.... thanks for the help all :D
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You got it. Welcome to the PHPDN forums.
Post Reply