Jump to content

Checking user level now not showing value in fields.


mnewberry

Recommended Posts

Below I am checking a user level and if they are  level one they see some of the form, and if level two they see additional options.

 

What they have already filled out is to show in the text field. Before I was doing the user level check it worked fine. Even now if something is put in a field it saves in the DB but it will not show in the fields on the form.

 

// Everyone sees

          <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['FieldA']; ?>">

          </tr>

  <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['FieldB']; ?>">

          </tr>

// Check if level two and display if they are.

    <?php }

if (checkUser()) {

?>

  <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['num1']; ?>">

          </tr>

  <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['num2']; ?>">

          </tr>

  <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['num3']; ?>">

          </tr>

 

  <?php } ?>

// Additional things everyone sees even level one.

  <tr>

            <td><input name="" type="text" id="" value="<?php echo $row_settings['num4']; ?>">

          </tr>

    <tr>

 

So even <?php echo $row_settings['num4']; ?> will not show/work after the <?php } ?>

 

Any thoughts? Thanks in advance everyone.

Link to comment
Share on other sites

@sunfighter, a http 500 error means that the web page did not return a complete response. In the case of a web page produced by php, it generally means that there was a fatal parse or fatal runtime error.

 

Without the php closing }, the code contains a php syntax error and produces a fatal parse error. When the php error_reporting/display_errors settings set such that php errors are not displayed, you get a http 500 error.

Link to comment
Share on other sites

@mnewberry, you should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the php detected errors will be reported and displayed. Setthing those two values in your code won't show fatal parse errors. There would likely be an error, warning, or notice that would help pin down why your page is not doing what you expect.

 

I have read your description of the problem more than once, and I don't have any idea what you are describing. What exactly are you getting for output and what exactly is missing?

Link to comment
Share on other sites

@PFMaBiSmAd the line is '<?php }' That is a closing bracket '<?php' is an opening statement it doesn't need a closing bracket, the code above is html. Why does html need a closing bracket? So my original question 'Why is that bracket there?'. mnewberry's response didn't answer the question.

 

I got my info on 500 error from this site: http://www.checkupdown.com/status/E500.html

and a couple more. The line

 

Fixing 500 errors - general

 

    This error can only be resolved by fixes to the Web server software. It is not a client-side problem.

 

Is what i based my response on.  Maybe he was talking about code that was working before it was uploaded???

Link to comment
Share on other sites

HTML doesn't need any braces. PHP does. Since there's an opening brace earlier in the PHP code, there needs to be a closing brace that corresponds to it. The fact that the PHP tag was closed to output some HTML is irrelevant. The closing brace needs to be there to close the previously issued opening brace.

Link to comment
Share on other sites

I got my info on 500 error from this site ...

 

Programming and solving problems in programming involves a lot of inference and flexibility in thinking. Just because someone got a specific error number when they were doing something in programming does not mean that a 'searched for' answer has anything to do with the problem. Due to the general purpose nature of computers and programming, there is NOT always a fixed one-to-one problem/answer relationship in programming. Depending on the situation, one problem can cause different symptoms and one specific symptom can be cause by many different things.

 

When you don't have specific knowledge about what someone is asking and don't take into account the situation, it is generally best to not repeat information you find on the Internet.

Link to comment
Share on other sites

Sorry many things going on to where I have not replied yet. Thank you to all who have given input so far.

 

Let me try to explain it better than the first time. This is a form where once a user is logged in they are able to edit their information. Some information is supplied to all users and others of a higher user level have more (see more on the page).

 

So I am using:

    <?php }
if (checkUser()) {
?>

 

To get their user level and if they meet the user level they see:

 

<tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num1']; ?>">
          </tr>
        <tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num2']; ?>">
          </tr>
        <tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num3']; ?>">
          </tr>

 

And if not that area is just of course blank.

 

The actual issue is they are not seeing what they already put into those fields. Say a question is 'my favorite color' and they have already answered blue. They text field is blank while 'blue' (the previously submitted answer) is actually sitting in that field in the MySQL database. If they were to edit this with 'red' it would change in the database but once again they would never see the answer from this page.

 

I do believe the problem is I am closing out all the previous request too much, far, or whatever it would be with the <?php } ?> but it has to be there for the userlevel to work and stop where it needs to.

 

So again the issue actually is the previously entered data is not inputing via value="<?php echo $row_settings['num1']; ?>" into its field and remains blank.

 

So in this area do I just need to ping the database again and call for the fields once again between the:

 

    <?php }
if (checkUser()) {
?>
        <tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num1']; ?>">
          </tr>
        <tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num2']; ?>">
          </tr>
        <tr> 
            <td><input name="" type="text" id="" value="<?php echo $row_settings['num3']; ?>">
          </tr>

     <?php } ?>

 

This is probably something simple but I am not claiming to be an expert at PHP and hence why I am here. Oh I did turn on error reporting after posting this question (not sure why I didn't before). Here is what I am getting:

 

Notice: Undefined variable: num1 in /****/****/file.php on line 170

 

This repeats for each field not showing.

 

Again thanks.

 

Link to comment
Share on other sites

Are you sure the error message isn't - Notice: Undefined index: num1 in ... The code you posted would be producing an undefined index error, not Notice: Undefined variable: num1 ...

 

The code you have been posting might be where the symptom is showing up (no values in the field) but that code is being executed (the form has those fields) and doing what it is supposed to be doing, but the variables shown in it don't have any value. Your problem is somewhere before that point, either in the query or in the code that is retrieving the data from the query and putting the values into the expected variables.

Link to comment
Share on other sites

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.