Thanks for all the help everyone

-----Original Message-----
From: Hutchins, Richard [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 11:14 AM
To: [EMAIL PROTECTED]
Cc: '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] passing variables


Eddie, whenever I start having problems with variables, I drop this code in:

begin code snip...
<?
  // these lines format the output as HTML comments
  // and call dump_array repeatedly

  echo "\n<!-- BEGIN VARIABLE DUMP -->\n\n";

  echo "<!-- BEGIN GET VARS -->\n";
  echo "<!-- ".dump_array($HTTP_GET_VARS)." -->\n";

  echo "<!-- BEGIN POST VARS -->\n";
  echo "<!-- ".dump_array($HTTP_POST_VARS)." -->\n";

  echo "<!-- BEGIN SESSION VARS -->\n";
  echo "<!-- ".dump_array($HTTP_SESSION_VARS)." -->\n";

  echo "<!-- BEGIN COOKIE VARS -->\n";
  echo "<!-- ".dump_array($HTTP_COOKIE_VARS)." -->\n";

  echo "\n<!-- END VARIABLE DUMP -->\n";

// dump_array() takes one array as a parameter
// It iterates through that array, creating a string
// to represent the array as a set

function dump_array($array)
{
  if(is_array($array))
  {
    $size = count($array);
    $string = "";
    if($size)
    {
      $count = 0;
      $string .= "{ ";
      // add each element's key and value to the string
      foreach($array as $var => $value)
      {
        $string .= "$var = '$value'";
        if($count++ < ($size-1))
        {
          $string .= ", ";
        }
      }
      $string .= " }";
    }
    return $string;
  }
  else
  {
    // if it is not an array, just return it
    return $array;
  }
}
?>
...end code snip

Actually, I have it as a separate file that I include when I need to.
Anyway, it'll list every single variable and array passed to the page along
with its value(s).

It is entirely possible that your variable exists, but does not have a
value. In which case, your

if ($register_clients){
        //your HTML stuff here
}

code should evaluate to true because it exists, but doesn't have a value. As
Ryan suggested, the proper thing to do would be to use

if(isset($register_clients)){
        //your HTML stuff here
}

That's all assuming you have register_globals set to on. Otherwise, you'll
have to switch to the $_REQUEST['register_clients'] notation (or $_POST or
$_GET, or etc.) if register_globals is set to off.

Either way, try using the code snippet and look at what your values are
actually set to (you'll have to view the source of the page into which you
place the snippet). That may give you some further insight into what's
happening with your script.

Hope this helps and that I haven't misinterpreted your post.

> -----Original Message-----
> From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 09, 2002 10:44 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] passing variables
>
>
> I missed the part where he was using an image. Without a
> value property, I don't see how it could pass anything at all....
>
> A note on my recent post, to emulate register_globals do this:
>
> if (!empty($_SERVER))
>   extract($_SERVER);
>
> if (!empty($_GET)) {
> extract($_GET);
> } else if (!empty($HTTP_GET_VARS)) {
> extract($HTTP_GET_VARS);
> }
>
> if (!empty($_POST)) {
> extract($_POST);
> } else if (!empty($HTTP_POST_VARS)) {
> extract($HTTP_POST_VARS);
> }
>
>
> This registers all of the different arrays.
>
> <>< Ryan
>
> -----Original Message-----
> From: Jonathan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 09, 2002 8:40 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] passing variables
>
>
> One of many possible things.
>
> Dependent on the version of PHP you are using, you might have
> register_globals set to off in your php.ini file, which is preferable.
> In which case you'll have to use
>
> If($_REQUEST['variable'])
>
> Or
>
> If(isset($_REQUEST['variable']))
>
> Second possible is:
>
> I've never really used an image within a link to submit a
> form.  What I
> usually do is make the image a submit button, e.g.,<input type="image"
> src="path to your image" height="XX" width="XX" border="0"> You could
> name it or create a hidden field <input type="hidden" name="register"
> value="register">
>
> Then upon form submission (<form action="<? Echo $_SERVER['PHP_SELF']
> ?>">)
> You would look for register
>
> If(isset($_REQUEST['register']))
> {
>       //whatever
> }
> hope one of them works.
>
> -----Original Message-----
> From: Edward Peloke [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 09, 2002 9:33 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] passing variables
>
> Hello all,
>
> I have a login/register screen for my php/mysql db.  When the page
> opens,
> the user sees the log in screen but I have a button and
> reloads the same
> page, hopefully with the register screen.  I know I can
> simply check to
> see
> if a variable is set with
>
> if ($variable){} .  This does not seem to work when I give an image a
> name
> and link it to the same page.  The image is named register
> and it links
> back
> to the same page, so the page loads, I click on the register
> image , the
> page reloads but the variable is not set.
>
>
> Any ideas?
>
> Thanks,
> Eddie
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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

Reply via email to