roopurt18 Posted June 10, 2006 Share Posted June 10, 2006 I reinstalled XAMPP today on my development machine, set everything up and it works. Except now I have errors about a global error being undefined.I have a global array defined in validate.php[code] $g_pregs['raidname'] = '/^[a-zA-Z0-9 ()]{1,32}$/'; $g_pregs['charname'] = '/^[A-Z][a-z]{1,28}$/'; $g_pregs['username'] = '/^[a-zA-Z0-9]{2,30}$/'; $g_pregs['password'] = '/^[a-zA-Z0-9]{3,20}$/'; $g_pregs['email'] = '/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+(\.[a-zA-Z]{2,4})+$/'; $g_pregs['alpha'] = '/^[a-zA-Z]+$/'; $g_pregs['digit'] = '/^[0-9]+$/';[/code]Then I have a CForm.php that defines a CForm object[code] require_once('validate.php'); class CForm{ // ValidateForm // Do basic form validating, ensuring that all required fields in // $m_required are present, also ensure that all fields in $m_formats // match the required format // RETURN: true on success, false otherwise function ValidateForm(){ global $g_pregs; // Next we check for specific formatting of the fields if( is_array( $this->m_formats ) ){ foreach($this->m_formats as $format){ if( !preg_match($g_pregs[$format[1]], $_POST[$format[0]]) ){ // the format is invalid, add error message $this->AddError($format[2]); $this->AddErrorIndicator($format[0]); } } } /* More function code */ return $value; } }[/code]The problem is now my $g_pregs is empty inside the CForm::ValidateForm method. I'm unsure why. Link to comment https://forums.phpfreaks.com/topic/11669-cant-see-global-variable-in-member-function/ Share on other sites More sharing options...
roopurt18 Posted June 11, 2006 Author Share Posted June 11, 2006 /bumpAnyone? I can't develop my site and I have no idea why this is happening. Link to comment https://forums.phpfreaks.com/topic/11669-cant-see-global-variable-in-member-function/#findComment-44152 Share on other sites More sharing options...
Barand Posted June 11, 2006 Share Posted June 11, 2006 included file needs php tags[code]<?php$g_pregs['raidname'] = '/^[a-zA-Z0-9 ()]{1,32}$/'; $g_pregs['charname'] = '/^[A-Z][a-z]{1,28}$/'; $g_pregs['username'] = '/^[a-zA-Z0-9]{2,30}$/'; $g_pregs['password'] = '/^[a-zA-Z0-9]{3,20}$/'; $g_pregs['email'] = '/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+(\.[a-zA-Z]{2,4})+$/'; $g_pregs['alpha'] = '/^[a-zA-Z]+$/'; $g_pregs['digit'] = '/^[0-9]+$/';?>[/code] Link to comment https://forums.phpfreaks.com/topic/11669-cant-see-global-variable-in-member-function/#findComment-44232 Share on other sites More sharing options...
roopurt18 Posted June 11, 2006 Author Share Posted June 11, 2006 It has them. This is a dev site that has always worked until I reinstalled XAMPP. I'm assuming a php setting was changed which is causing the problem. But I'm not sure what it is.[!--quoteo(post=382459:date=Jun 11 2006, 03:54 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Jun 11 2006, 03:54 AM) [snapback]382459[/snapback][/div][div class=\'quotemain\'][!--quotec--]included file needs php tags[code]<?php$g_pregs['raidname'] = '/^[a-zA-Z0-9 ()]{1,32}$/'; $g_pregs['charname'] = '/^[A-Z][a-z]{1,28}$/'; $g_pregs['username'] = '/^[a-zA-Z0-9]{2,30}$/'; $g_pregs['password'] = '/^[a-zA-Z0-9]{3,20}$/'; $g_pregs['email'] = '/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+(\.[a-zA-Z]{2,4})+$/'; $g_pregs['alpha'] = '/^[a-zA-Z]+$/'; $g_pregs['digit'] = '/^[0-9]+$/';?>[/code][/quote] Link to comment https://forums.phpfreaks.com/topic/11669-cant-see-global-variable-in-member-function/#findComment-44425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.