Jump to content

verbose execution without slash happy selfmutilation?


Augury

Recommended Posts

OK if I have bracket enclosures like

 

{{{}}{}}{{{}{}{{}}{{}}

 

whats the game theory on finding the offending bracket?  Is it possible?

 

 

...working under the assumption that that open lines will soon be closed.  Unisex enclosures could be evading my text editors.

there is the error 



Parse error: syntax error, unexpected '$noob' (T_VARIABLE), expecting function (T_FUNCTION) in /var/www/CampKojak.com/ck/NoobMember1.php on line 279

this is the $noob who did not fulfill expectations.



}///////CLASS END


		$noob = new NoobMember;
		$noob->PostData();


?>

with out the $noob stuff there 

Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION) in /var/www/CampKojak.com/ck/NoobMember1.php on line 283

I've got gedit and emacs.  They do a good job of highlighting,  I think emacs will even jump the page up briefly.  Not seeing anything.

That error is a result trying to execute code within a class definition that's outside of a method.

 

IOW you are basically doing this:

class NoobMember {
  function __construct($data) {
  
  }

  function PostData() {
    echo "something";
  }

  $noob = new NoobMember; // bad
  $noob->PostData();      // bad

}
IOW basically you have lost track of your opening/closing brackets and have put that code inside your class definition where it doesn't belong.

with out the $noob stuff there 

Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION) in /var/www/CampKojak.com/ck/NoobMember1.php on line 283
I've got gedit and emacs.  They do a good job of highlighting,  I think emacs will even jump the page up briefly.  Not seeing anything.

 

And this further affirms that you've lost track of your opening/closing brackets. More specifically, you're missing a closing bracket somewhere

There are plenty of IDEs and code editors out there that highlight opening/closing bracket pairs, as well as "fixes" or "beautifies" code (indenting properly) which makes it a lot easier to visually find out which one you are missing.

Where?  :-\:lol:

<html>
<body>

<?php
//html pages may need to reset 'submit' indexes!
$email = $username = $password = $firstname = $lastname = $homephone = $address = $address2 = $city = $state = $zip = $cellphone = $submit = $Routed = "";

session_start();

class Member {
public function __construct()
{
$member = array('id'=>'', 'usertype'=>'', 'username'=>'', 'email'=>'', 'pass'=>'', 'firstname'=>'', 'lastname'=>'', 'validation_code'=>'', 'address'=>'', 'city'=>'', 'state'=>'', 'zipcode'=>'', 'flag'=>'');
//public $member = array_fill_keys($mymember, '')
$member[2] = 'entryErr';
$member['username'][4] = $member['email'][4] = $member['firstname'][4] = $member['lastname'][4] = 'required';
}
}

class NoobMember extends Member {

private $hasErr = NULL;
private $postmember = NULL;
private $member = NULL;
private $logmein = NULL;

function PostData()
{
$postmember = $_POST;
$some = array();
$member = self::MemberDataCheck($postmember, $hasErr);
$_SESSION['field'] = $member;
$_SESSION['hasErr'] = $hasErr;
var_dump($hasErr);
var_dump($member);
session_write_close();
echo '<br><br> heres session';
var_dump($_SESSION);
if (empty($hasErr)) {
self::MemberRouter($member['submit']); }
else {
self::MemberRouter("routeback"); }

}

function MemberDataCheck (&$member, &$hasErr)
{
echo 'member data check';
try { $atributestable = new PDO('snip'); } catch (Exception $e) { echo "Unable to connect: " . $e->getMessage() ."<p>"; }

$sth = $atributestable->prepare("SELECT member_keys, required FROM AtributesT;");
$sth->execute();
$sth->bindColumn('member_keys', $memkey);
$sth->bindColumn('required', $reqval);
$req = array();
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $required[$memkey] = $reqval; }

$sth = $atributestable->prepare("SELECT member_keys, errmessage FROM AtributesT;");
$sth->execute();
$sth->bindColumn('member_keys', $memkey);
$sth->bindColumn('errmessage', $errval);
$req = array();
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $errmessage[$memkey] = $errval; }

$sth = $atributestable->prepare("SELECT member_keys, regxfilter FROM AtributesT;");
$sth->execute();
$sth->bindColumn('member_keys', $memkey);
$sth->bindColumn('regxfilter', $regxval);
$req = array();
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $regxfilter[$memkey] = $regxval; }

$sth = $atributestable->prepare("SELECT member_keys, formsubmit FROM AtributesT;");
$sth->execute();
$sth->bindColumn('member_keys', $memkey);
$sth->bindColumn('formsubmit', $fsv);
$formsubmit = array();
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $formsubit[$memkey] = $fsv; }

$some = array();
$hasError = self::BiancaData($member, $some);
$member_keys = array_keys($member);

foreach ($member_keys as $k)
{
if (empty($_POST[$k])) {
if (!empty($required[$k])) { if ($required[$k] <> 'false' || $required[$k] == "not required" || $required[$k] == NULL) {
$hasErr[$k] = "REQUIRED FEILD";
}} else { $hasErr[$k] = ""; $member[$k][0] ="";}
} else {
switch($k)
{
case $k === ('username' || 'firstname' || 'lastname'):
if (!preg_match("/^[a-zA-Z \-]*$/",$_POST[$k])) {
$hasErr[$k] = "may only contain letters, numbers, spaces and hyphen";
$_POST[$k] = "";
$member[$k] = "";
} else { $member[$k][0] = $_POST[$k];}
break;
case $k === 'email':
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$_POST[$k])) {
$hasErr[$k] = "not a vaild e-mail address";
$_POST[$k] = "";
$member[$k] = "";
} else { $member[$k][0] = $_POST[$k];}
break;
default:
if (!preg_match("/^[a-zA-Z 0-9\-]*$/",$_POST[$k])) {
$hasErr[$k] = "may only contain letters, numbers, spaces and hyphen";
$_POST[$k] = "";
$member[$k] = "";
} else { $member[$k][0] = $_POST[$k];}
break;
}

if (!empty($regxfilter[$k])) {
if (!preg_match($regxfilter[$k],$_POST[$k])) {
var_dump ($regxfilter[$k]);
$hasErr[$k] = "may only contain letters, numbers, spaces and hyphen";
$_POST[$k] = "";
$member[$k] = "";
} else { $member[$k][0] = $_POST[$k];}
}
}
}


return $member;
}

function MemberRegister () { $Registernoob = "";
try { $MembersTable = new PDO('snip'); } catch (Exception $e) { echo "Unable to connect: " . $e->getMessage() ."<p>"; }
$sth = $MembersTable->prepare("SELECT username, email FROM MemberT;");
$sth->execute();
$sth->bindColumn('username', $users);
$sth->bindColumn('email', $em);
$sth->bindColumn('password', $pass);
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $username[$users] = $password; $email[$em] = $password;

if ($_SESSION['field']['username']) {
$registerme = FALSE;
$_SESSION['hasErr']['username'] = 'SORRY, USER NAME IS TAKEN';
} else { $registerme = TRUE; }
if ($_SESSION['field']['email']) {
$registerme = FALSE;
$_SESSION['hasErr']['email'] = 'SORRY, THIS EMAIL IS ALREADY REGISTERED -- get your password!';
}
}
return $Registernoob;
}

function MemberLogin () { $Logmein = "";

try { $MembersTable = new PDO('snip'); } catch (Exception $e) { echo "Unable to connect: " . $e->getMessage() ."<p>"; }
$sth = $MembersTable->prepare("SELECT username, email FROM MemberT;");
$sth->execute();
$sth->bindColumn('username', $users);
$sth->bindColumn('email', $em);
$sth->bindColumn('password', $pass);
while ($row = $sth->fetch(PDO::FETCH_BOUND)) { $username[$users] = $password; $email[$em] = $password;

if (!empty($_SESSION['field']['username'])) {
$Logmein = password_verify($_POST['password'], $username[$_SESSION[$username]]);
}
if (!empty($_SESSION['field']['email'])) {
$Logmein = password_verify($_POST['password'], $username[$_SESSION[$username]]);
}
}

//password nullify //disconnect db
/*
$noob = new NoobMember;
if ($noob->MemberEntry($giveMember)) { MemberRoute($outAction); }
else {
MemberRoute('login', $Routed);
if ($noob->MemberVerify()) { $noob->MemberLogin(); }
else { echo 'denied service!!!'; }
}
*/


return $Logmein;
}

function MemberRouter ($routeme, $hailPostData) { $Routed = "";
switch ($routeme) {
case "routeback":
$Routed = '$_SERVER["PHP_SELF"]';
break;
case "login":
if (($halePostData === 1) || (self::PostData())) {
if (self::MemberLogin ()) {
$_SESSION['AMember'] = array('loggedin' => 'true', RID => '', Username => $_SESSION['field']['username'], ipaddress => '', time => ''); //need site/server prob.
self::MemberRouter('loggedin');
break; } else {
self::MemberRouter("routeback");
$Routed = "loginFAILED -- possible miss 1 lo";
} }
break;
case "loggedin":
if ($_SESSION['AMember']["loggedin"] == 'true') {
if (!empty($hailPostData) && $hailPostData !== 1) { $Routed = $hailPostData; break; }
else { $Routed = "CKmembers.php"; break; }
} else { }
break;
case "register":
if ($halePostData == 1 || self::PostData()) {
self::MemberRegister ();
$Routed = "login.php";
break;
}
return $Routed;
$_SESSION['Routed'] = $Routed;
}

function MemberFormType ($FormTYPE, $giveMember, $outAction, &$whoMember) {
switch ($FormTYPE) {
//case login:


//break;

case register:
$noob = new NoobMember;
if ($noob->PostData()) {
self::MemberRegister ($giveMember);
echo "FUCK";
} else {
echo "CONGRADULATIONS";
}
break;
}
}

function BiancaData ($mymember, $yourmember) {
$themember = NULL;
$mymember_keys = array_keys($mymember);
$yourmember_values = array_values($yourmember);
foreach ($mymember_keys as $i) {
$themember = array ('$i' => '$yourmember_values[$i]'); }
return $themember; }

function BiancaDataDefault ($mymember, $yourmember) {
$themember = NULL;
$mymember_keys = array_keys($mymember);
$yourmember_values = array_values($yourmember);
for ($i = 0; $i <= count($mymember) - 1; $i++) {
$themember[$mymember_keys[$i]] = $yourmember_values[$mymember_keys[$i]];
if (!$themember[$mymember_keys[$i]])
{$themember[$mymember_keys[$i]] = $mymember[$mymember_keys[$i]]; }
return $themember; }
}

function MemberHTMLone () {
$FLine[0] = array('Your e-mail Address', 'text', 'email');
$FLine[1] = array('Choose Your Login Name', 'text', 'login');
$FLine[2] = array('Your Site Password', 'text', 'password');

echo ' <table>';
echo ' <p><span class="error">* required field.</span></p>';
for ($m = 0; $m <= count($FLine) - 1; $m++) {
echo '<tr><th>' ,
$FLine[$m][0] ,
'</th><th><input type="' ,
$FLine[$m][1] ,
'" name="' ,
$FLine[$m][2] ,
'" value="' ,
$member[$FLine[$m][2]] ,
'"></th><th><span class="error">' ,
$hasError[$FLine[$m][2]] ,
'</span><br></th></tr>';
}
}
}///////CLASS END


$noob = new NoobMember;
$noob->PostData();


?>

go through your code and properly indent it manually then. You'll find the missing bracket soon enough. Sorry, I'm not going to do that for you. That's one of the points of getting into the good habit of indenting your code!

well i'm willing to believe some of the indention might have been lost in posting, but I can tell from your code that you aren't properly indenting anyways. copy/paste issues wouldn't put several closing brackets and lines of code on one line while leaving the same type on others like that.

 

I'll give you a hint: Looks like the issue is missing closing brackets in function MemberRouter

well i'm willing to believe some of the indention might have been lost in posting, but I can tell from your code that you aren't properly indenting anyways. copy/paste issues wouldn't put several closing brackets and lines of code on one line while leaving the same type on others like that.

 

I'll give you a hint: Looks like the issue is missing closing brackets in function MemberRouter

 

oooo thats sound like it could where it is!

 

I don't like to line break but my tabs have been well kept.   loose convention

Say, in the if () conditional, will it stop at the first TRUE in an *or ||* clause.

 

ie line one, its not going to go for that PostData() return will it?



			if (($halePostData === 1) || (self::PostData())) {
				if (self::MemberLogin ()) {
					$_SESSION['AMember'] = array('loggedin' => 'true', RID => '', Username => $_SESSION['field']['username'], ipaddress => '', time => '');
					self::MemberRouter("loggedin");

if (($halePostData === 1) || (self::PostData())) {
if the first part: ($halePostData === 1) is true, it will not evaluate the rest of the condition, since only 1 of them have to be met. This is called short circuiting. logical operators

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.