Page 1 of 1

parse errors

Posted: Wed Jun 11, 2003 12:51 pm
by m3rajk
i don't understand why i'm getting certain parse errors. the page is suppossed to go through the if statements and create 5 different pages. it's giving me issues on the first one (i haven't tested the others yet)

the errors:
Warning: Wrong parameter count for header() in /usr/users/m3rajk/WWW/JMT/randomTest/signuptest/signup.php on line 59
Fatal error: Cannot redeclare header() in /usr/users/m3rajk/WWW/JMT/randomTest/signuptest/signup.php on line 66
while they seem simple, i don't understand why i'm getting them. here's the begining of the code that decides which functions to call:

Code: Select all

<?php

/* ******************************************
   ** call to (the main profile table of the) database **
   ******************************************* */

/* get a list of usernames from the db, set it to array: $uns */

/* *****************************************
   ** set any and all variables that need **
   ** to be set                           **
   ***************************************** */

$step=$_POST['step']; $un=$_POST['un']; $email=$_POST['email']; # set step/username/email
$pw=$_POST['pw']; $conf=$_POST['conf']; $waist=$_POST['waist']; # set password/confimation code/waist size
$eye=$_POST['eye']; $lbs-$_POST['weight']; $religion=$_POST['religion']; # set eye color/weight/religion
$ethnicity=$_POST['ethnicity']; $city=$_POST['city']; $aim=$_POST['aim']; # set ethnicity/city/aim sn
$mirc=$_POST['mirc']; $icq=$_POST['icq']; $yim=$_POST['yim']; #set mirc/icq uin/yim sn
$main=$_POST['main']; $t1=$_POST['t1']; $t2=$_POST['t2']; # set main/thumb1/thumb2
$t3=$_POST['t3']; $t4=$_POST['t4']; $salute=$_POST['salute']; # set thumb3/thumb4/salute

/* *******************************************************
   ** find where we are and call the creation functions **
   ******************************************************* */
if(isset($step)){
  if($step>1){
    if($step==3){
      /* check for username against database */ /*
      for($i=0;$i<count($uns);$i++){
	if($un==$uns[$i]){ $err='yes'; $step=2; break; } # set $err, drop $step, and leave the for loop
      } */
    }elseif($step==5){
      /* check the confirmation code */
      if($_SESSION['uid']!==$conf){
	$err='yes'; $step=4; # set err and decrement step
      } /*
      else{
	## process files uploaded, set $err if something goes wrong
      } */
    }
  }
  
  if($step==1){ # we're starting the sign up
    sus(); header(); su1();
  }elseif(($step==2)&&($err !== 'yes')){ # we're in the second step for the first time
    header(); su2();
  }elseif($step==2){ # we must have an error
    header(); su2e();
  }elseif($step==3){ # 3rd step
    header(); su3();
  }elseif(($step==4)&&($err !== 'yes')){ # we're on the 4th step for the first time
    header(); su4();
  }elseif($step==4){ # we must have an error
    header(); su4e();
  }else{ # we must be done signing up
    header(); su5();
  }
}else{ # we need to start the sign up
  $step=1; sus(); header(); su1();
}
here's the functions that should be called:

Code: Select all

function header(){  # create a header for each page
  ?><html>
       <head>
         <title>FindYourDesire.com Signup page -- <?php echo "$step"; ?></title>
         <meta name="Author" content="coded by: Josh Perlmutter; images by Morgan O'Brien-Bledsow & Tamara Collette all rights reserved">
         <style type="text/css">
           <!-- this comment is for non-css compliant browsers
           {text-decoration=none}
           end of css -->
	 </style>
       </head>
       <body bgcolor="#000000" text="#c8c8c8" alink="#fc00ff" vlink="#00e0c4" link="#ffffff">
       <center><p>&nbsp;</p>
  <?php
}
function sus(){
  session_start(); // start a session
  $_SESSION['uid']= uniqid(microtime(),1); // create a unique id for the session.
}
function su1(){
  ?>
 <h1>THIS IS A TEST. IT DOES NOT HAVE A DATABASE CONNECTION NOR DOES IT CHECK USERNAMES. THIS LINE WILL BE REMOVED IN THE REAL ONE </h1>
    
    <p>Thank you for your interest in signing up for FindYourDesire.com. Before you can sign up, you need to agree to a few baisc terms of service</p>
    <form name="step1" action="<?php echo "$_SERVER[PHP_SELF]"; ?>" method="POST" onSubmit="return validate();">
    <input type="hidden" name="step" value="2">
    <table frame="void" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000">
    <tr><td>I have read and agree to the <a name="#privacy" href="#privacy" onClick="window.open('faq.php?seek=privacy', 'faq', 'height=250,width=500,scrollbars=yes');">Privacy Policy</a></td><td><input type="checkbox" name="privacy" value="agree"></td></tr>
    <tr><td>I have read and agree to the <a name="#fcc" href="#fcc" onClick="window.open('faq.php?seek=fcc', 'faq', 'height=250,width=500,scrollbars=yes');">Forum Civilty Code</a></td><td><input type="checkbox" name="fcc" value="agree"></td></tr>
    <tr><td>I have read and agree to the <a name="#gtu" href="#gtu" onClick="window.open('faq.php?seek=gtu', 'faq', 'height=250,width=500,scrollbars=yes');">General Terms of Use</a></td><td><input type="checkbox" name="gtu" value="agree"></td></tr>
    <tr><td>I have read and agree to the <a name="#lw" href="#lw" onClick="window.open('faq.php?seek=lw', 'faq', 'height=250,width=500,scrollbars=yes');">Liabilty Waiver</a></td><td><input type="checkbox" name="lw" value="agree"></td></tr>
    <tr><td><input type="submit" value="Go To The Next Step"></td><td><input type="reset" value="Restart This Step"></td></tr>
    </table></form>

    <script language="javascript">
    function validate(){
    if(document.step1.privacy.checked !== true){alert("You MUST agree to the Privacy Policy to continue"); return false;};
    else if(document.step1.fcc.checked !== true){alert("You MUST agree to the Forum Civility Code to continue"); return false;};
    else if(document.step1.gtu.checked !== true){alert("You MUST agree to the General Terms of Use to continue"); return false;};
    else if(document.step1.lw.checked !== true){alert("You MUST agree to the Liability Waiver to continue"); return false;};
    else{return true};}
    </script>
    </center></body></html>
 <?php
}
incase you want to look at the actual page's output in use, i've placed it here: http://people.brandeis.edu/~m3rajk/JMT/ ... signup.php

Posted: Wed Jun 11, 2003 12:57 pm
by cactus
The header() method is reserved, since it's part of PHP, rename your header() method to _header(), this way PHP won't confuse your methods with it's own

:)

Regards,

Posted: Wed Jun 11, 2003 1:00 pm
by cactus

Posted: Wed Jun 11, 2003 1:25 pm
by volka
just as addition:
You cannot overwrite any global function. Once defined you cannot redeclare it in the same context.
only methods of parent-classes can be overwritten

Code: Select all

<?php
function myFunc()
{
	return true;
}


function myFunc() // won't work, redeclaration
{
	return false;
}

function myFunc($a) // won't work either (in php)
{
	return $a;
}

class CParent
{
	function myFunc()
	{
		return true;
	}
}

class CChild extends CParent
{
	// you can overwrite parents methods
	function myFunc()
	{
		return false;
	}
}

$c = new CChild;

?>
same with built-in functions like header()

Posted: Wed Jun 11, 2003 1:31 pm
by m3rajk
cactus wrote:The header() method is reserved, since it's part of PHP, rename your header() method to _header(), this way PHP won't confuse your methods with it's own

:)

Regards,
thanx. i didn't realize that. i guess the fact i'm a newb at this shows.

side note: is there a list of pre-defined functions anywhere?

Posted: Wed Jun 11, 2003 1:34 pm
by cactus
No worries, we were all newbies once (and again, if you join new forums :))

Posted: Wed Jun 11, 2003 1:52 pm
by twigletmac
The best way to check if a function name already exists in PHP is just to do a search for it in the manual at php.net.

Mac

Posted: Wed Jun 11, 2003 2:22 pm
by cactus
But Mac is right. :(

Posted: Wed Jun 11, 2003 2:41 pm
by m3rajk
i'll tell you how it worked out once the server's back up

btw: i'm looking at sort trying to see how it would sort a multi-dimensional array... does anyone know how i can specify the feild to sort by?

Posted: Wed Jun 11, 2003 3:06 pm
by volka
you won't believe it but http://php.net/array_multisort does ;)

Posted: Wed Jun 11, 2003 3:49 pm
by m3rajk
volka wrote:you won't believe it but http://php.net/array_multisort does ;)
that sounds like it takes each row as an array and sorts it.

i want to compare the first item of each row and sort all the rows based on the first item

ie: array is set up so there's a number of entries each in the format: score, username, gender

i want to sorat so the highest score is at the top and it goes in descending order to the lowest, with original correlation between the arrays kept in tact

that soulds like it sorts each array withink the array


edit: server's back. changing off from header worked wonders.

now if someone could tell me why the javascript only works on the first page when it's set nearly the same on the second page, i'd appreciate that

take a look and let me knwow hat you think of it so far (design wise) it's be nice to have feedback form those that have done design before
http://people.brandeis.edu/~m3rajk/JMT/ ... signup.php

Posted: Wed Jun 11, 2003 4:06 pm
by cactus
Have you got a var_dump() of your array ??

Regards,