Jump to content

php error problem, i'm lost...


Recommended Posts

Guest askjames01
[img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

these codes works very fine recently but now it doesn't? hmmm.

error_messages.php
[code]
<html>
<head>
    <title>    </title>
</head>

<body>
<?php



class error_messages {

    #$temp_message=0;
    #$message="";
    #$message_width=0;

    function program_error_messages($error_num) {

            switch ($error_num) {
            case 1:
                $message = " Username too short! ";
                $message_width = strlen($message) * 7;
                $this->control_message_box($message_width, $message);
                break;
            case 2:
                $message = " Password too short ";
                $message_width = strlen($message) * 7;
                $this->control_message_box($message_width, $message);
                break;
            case 3:
                $message = " This is 2nd last error message! much longer..... ";
                $message_width = strlen($message) * 7;
                $this->control_message_box($message_width, $message);
                break;
            case 4:
                $message = " This is the very, very last message and very long last error message! ";
                $message_width = strlen($message) * 7;
                $this->control_message_box($message_width, $message);
                break;

            }
    }


    //controlling the width of the table box.
    //1. insert to html tag <width="">
    function control_message_box($message_width, $message) {

?>
        <br><br><br><br><br>
        <div align="center">
          <center>
          <table border="1" height="40" width="<?php echo     $message_width; ?>" bordercolor="#FF00FF" bgcolor="#00FFFF">
            <tr>
              <td width="100%" align="center">
              <?php echo "$message"; ?>
              </td>
            </tr>
          </table>
          </center>
        </div>
<?php
        }
}

    $CO_error_messages = new error_messages;
    $CO_error_messages->program_error_messages(4);
?>
</body>
</html>
[/code]


function_request.php
[code]<?php
#require_once($_SERVER['DOCUMENT_ROOT'].'/mygallery/include/error_messages.php');
#echo $_REQUEST['username']."   ---> $ _ request";

require_once("error_messages.php");

class admin_password_class {

    //define and assign variable & function constructor.
    var $new_username_tmp;
    var $new_password_tmp;

    //compute $new_username & $new_password length.
    function compute_length($new_username_tmp, $new_password_tmp) {
        $new_username_len = strlen($new_username_tmp);
        $new_password_len = strlen($new_password_tmp);

        if($new_username_len < 5){
            error_messages::program_error_messages(1);
            }
        elseif($username_len < 5){
            error_messages::program_error_messages(1);
            }
    }
}

$CO_admin_class = new admin_password_class;
$CO_admin_class->compute_length($_REQUEST['new_username'], $_REQUEST['new_password']);

echo "admin_class.php testing!";
?>
[/code]


new-password.php
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">

<html>
<head>
    <title>

    </title>

</head>


<body topmargin="0" leftmargin="0" bgcolor="#808080" text="#FFFFFF">

<br><br><br><br><br>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
<div align="center">
  <center>
  <table border="0" width="250" cellspacing="0" cellpadding="0">
    <tr>
      <td width="100%" bgcolor="#FF00FF">&nbsp;</td>
    </tr>
    <tr>
      <td width="100%" bgcolor="#00FFFF">
        <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"><font color="#000000" face="AvantGarde Md BT"><b>Enter
        New Password</b></font></p>
        <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>

        <form name="form1" action="function_request.php" method="post">
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"><font color="#000000">user
          name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <input type="text" name="new_username" size="20"></p>
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"><font color="#000000">new
          password </font><input type="text" name="new_password" size="20"></p>
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"><font color="#000000">confirm</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="text" name="confirm" size="20"></p>
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
          <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">
          <input type="submit" name="submit" value="Enter password">
        <input type="reset" value="Reset" name="B2"></p>


        </form>
        <p style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center">
        <font color="#000000" face="Arial Narrow">
        <a href="http://www.askjames01.com/photo-gallery/admin.htm">Admin</a></font></td>
    </tr>
    <tr>
      <td width="100%" bgcolor="#FF00FF">
        <p align="center">&nbsp;</p>
      </td>
    </tr>
  </table>
  </center>
</div>


</body>
</html>
[/code]


just put them inside a directory and execute new-password.php and the next files will follow.
I really a little confused with this error message?
I wonder what is missing?

thanks n advance.

Link to comment
https://forums.phpfreaks.com/topic/9450-php-error-problem-im-lost/
Share on other sites

Change the following
[code]if($new_username_len < 5){
            error_messages::program_error_messages(1);
            }
        elseif($username_len < 5){
            error_messages::program_error_messages(1);
            }[/code]
to
[code]$error_messages = new error_messages;

        if($new_username_len < 5)
        {
            $error_messages->program_error_messages(1);
        }
        elseif($username_len < 5)
        {
            $error_messages->program_error_messages(1);
        }[/code]
You have missunderstood the use of the scope resolution operator. You can only use it when calling other methods from the class that is being used in, or when you are extending another class. Not when calling classes from within an different class than the one being used in.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.