mnewberry Posted March 26, 2011 Share Posted March 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/ Share on other sites More sharing options...
sunfighter Posted March 26, 2011 Share Posted March 26, 2011 // Check if level two and display if they are. <?php } Why the curly bracket at the end? Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192575 Share on other sites More sharing options...
mnewberry Posted March 26, 2011 Author Share Posted March 26, 2011 It will give a 500 error without. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192666 Share on other sites More sharing options...
sunfighter Posted March 26, 2011 Share Posted March 26, 2011 That bracket should not be there. A 500 error is a server problem. Are you running this on the web? Then you might think about changing servers. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192669 Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 @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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192688 Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 @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? Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192689 Share on other sites More sharing options...
sunfighter Posted March 27, 2011 Share Posted March 27, 2011 @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??? Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192853 Share on other sites More sharing options...
Pikachu2000 Posted March 27, 2011 Share Posted March 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192858 Share on other sites More sharing options...
PFMaBiSmAd Posted March 27, 2011 Share Posted March 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192907 Share on other sites More sharing options...
mnewberry Posted March 27, 2011 Author Share Posted March 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1192984 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2011 Share Posted March 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1193528 Share on other sites More sharing options...
mnewberry Posted March 29, 2011 Author Share Posted March 29, 2011 No that is the error code. I just double checked. Hoping to work through it more tonight. Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1193530 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2011 Share Posted March 29, 2011 Then the actual code where the error is occurring at is not what you have posted or the file where the error is occurring at is not what you have posted or the error is occurring before a form has been submitted, not after... Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1193532 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2011 Share Posted March 29, 2011 An Undefined variable: num1 in ... error would be coming from code that is referencing a variable named $num1. Something like - $abc = $num1; Quote Link to comment https://forums.phpfreaks.com/topic/231744-checking-user-level-now-not-showing-value-in-fields/#findComment-1193535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.