Re: [PHP] Re: need help finding parsing error please

2005-08-05 Thread Jochem Maas

Matthew Weier O'Phinney wrote:

* Bruce Gilbert [EMAIL PROTECTED]:


Hello,

I am getting this on the following code, and I am not sure what is
causing the error and need some pros to take a look at it for me.

the error is:

Parse error: parse error, unexpected '{' in
/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form2.php on
line 161


the error is correct. (that sounds funny)

find the line containing:

if (isset($err_msg) || isset($email_err) { echo

and look _very_ _very_ carefully at it. look again.
see it now?

I don't know if my mail client made a mess of your code layout
or if it was just a mess - if it was a mess to begin with then
I would recommend you try and be more consistent in the way you
present your code - it makes it easier to maintain and debug - granted
php doesn't care about the layout - you can write everything on a single line
if you really want. google on Coding Standards - pick a style your eyes like
and try to stick with it - you wont regret it.




snip

if ($_POST['op']!='ds') { 
   // they need to see the form

   echo $form_block;
   } else if ($_POST[op]  == ds)  {



Where's the end to this elseif? You follow it immediately with the
following lines, which simply won't work (can't define functions inside
if() blocks).


Matthew but it's perfectly valid to define a function inside an if()
block... It generally gets doen in apps where they have to support older 
versions
of php and conditionally define functions if they don't exist e.g.

if (!defined(array_push)) {
function array_push($arr, $val)  { /*stuff*/ }
}





//Function saves time and space by eliminating unneccesary code
function check($fieldname)
{






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: need help finding parsing error please

2005-08-05 Thread Matthew Weier O'Phinney
* Jochem Maas [EMAIL PROTECTED] :
 Matthew Weier O'Phinney wrote:
  * Bruce Gilbert [EMAIL PROTECTED] :
  
   I am getting this on the following code, and I am not sure what is
   causing the error and need some pros to take a look at it for me.
  
   the error is:
  
   Parse error: parse error, unexpected '{' in
   /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form2.php on
   line 161

 the error is correct. (that sounds funny)

 find the line containing:

 if (isset($err_msg) || isset($email_err) { echo

 and look _very_ _very_ carefully at it. look again.
 see it now?

 I don't know if my mail client made a mess of your code layout
 or if it was just a mess - if it was a mess to begin with then
 I would recommend you try and be more consistent in the way you
 present your code - it makes it easier to maintain and debug - granted
 php doesn't care about the layout - you can write everything on a single line
 if you really want. google on Coding Standards - pick a style your eyes like
 and try to stick with it - you wont regret it.

+1 

I personally use PEAR's CS, and made that decision a little over a year
ago. I've never looked back, and code I've had to maintain that predates
that decision gets updated -- simply because it makes maintenance and
debugging a thousandfold easier.

  snip
  
   if ($_POST['op']!='ds') { 
  // they need to see the form
  echo $form_block;
  } else if ($_POST[op]  == ds)  {
  
  
  Where's the end to this elseif? You follow it immediately with the
  following lines, which simply won't work (can't define functions inside
  if() blocks).

 Matthew but it's perfectly valid to define a function inside an if()
 block... It generally gets doen in apps where they have to support older 
 versions
 of php and conditionally define functions if they don't exist e.g.

 if (!defined(array_push)) {
   function array_push($arr, $val)  { /*stuff*/ }
 }

D'oh! I was thinking this was an anonymous function (ala perl), and of
course it's not. Good catch, Jochem.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php