Page 1 of 1

PHP code issues...

Posted: Wed Apr 11, 2007 9:09 pm
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 :)

Posted: Wed Apr 11, 2007 10:33 pm
by aaronhall
Looks like you're missing a semicolon after each $pageLinks assignment.

Posted: Thu Apr 12, 2007 6:13 am
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

Posted: Thu Apr 12, 2007 7:17 am
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.

Posted: Thu Apr 12, 2007 12:59 pm
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

Posted: Thu Apr 12, 2007 1:07 pm
by aaronhall
Read on about variable scope -- you'll probably also want to read about function arguments and return values.

Posted: Thu Apr 12, 2007 1:27 pm
by Shaggy
will do, thanks :)

Posted: Thu Apr 12, 2007 1:30 pm
by aaronhall
Happy to help :)

Posted: Thu Apr 12, 2007 2:00 pm
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.

Posted: Thu Apr 12, 2007 9:42 pm
by Shaggy
k i got things working... ill prob be posting here a bunch more times.... thanks for the help all :D

Posted: Fri Apr 13, 2007 2:06 am
by RobertGonzalez
You got it. Welcome to the PHPDN forums.