Eliana Posted January 6, 2013 Share Posted January 6, 2013 Just recently I watched a video tutorial on created a php database and log in and registration page. I created all the php pages along with the code, I thought I was finished but when I went to style the page as we want it things began to get really confusing. Now I am trying to put the php code information in to the html pages I am making and I getting so many errors I don't know where to begin. Is there anyone out there that I can get to look at the files I created with php and see how I am putting them in the html. I attached the index file we wanted to create for our webpage to include the login and registration php. Eliana Hebrew index.php Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/ Share on other sites More sharing options...
haku Posted January 6, 2013 Share Posted January 6, 2013 People here will almost never download attached files, as they are a security error. And if you post your whole code, it's usually too much to go through to guess which errors you are finding. Post the first error, and the line of code on which it is appearing, as well as a few lines of code before that point (as errors generally exist higher up in the file than the line shown in the error). Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403554 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Oh okay, thanks. But that's just it, I only see one error in my dreamweaver and its on line 117 the code is as follows: <?php if (isset($_GET['success']) && empty ($_GET['success'])){ echo'You\'ve been registered successfully! Please check your email to activate your account'; } else { if(empty($_POST)=== false && empty($errors) === true){ $register_data = array( 'username' =>$_POST['username]'], 'password' =>$_POST['password]'], 'first_name' =>$_POST['first_name'], 'last_name' =>$_POST['last_name]'], 'email' =>$_POST['email]'], 'email_code' =>md5($_POST['username']+ microtime()) ); register_user($register_data); header('Location: register.php? success'); exit(); }else{ if (empty($errors) === false) { echo output_errors($errors);} } ?> Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403557 Share on other sites More sharing options...
haku Posted January 6, 2013 Share Posted January 6, 2013 Which line is 117, and what is the error? Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403562 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Line 117 is the very last line of this code. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403638 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 In Dreamweaver it says that there is a syntax error but because I don't know how to code php, I simply watched a tutorial and wrote what the instructor said to write I don't now exactly how to fix the problem. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403640 Share on other sites More sharing options...
Jessica Posted January 6, 2013 Share Posted January 6, 2013 You have too many } If you don't know PHP, time to learn it. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403641 Share on other sites More sharing options...
PFMaBiSmAd Posted January 6, 2013 Share Posted January 6, 2013 (edited) Your code is missing one or more closing } (that closes the else { on about line 100.) has a bunch of miss-matched opening and closing {} The error message you should be getting, which you didn't post so that someone here could more directly find the cause of the problem, concerns a syntax error/unexpected end of file, which is php's way of telling you that you have something that is not terminated by the time php reached the end of your code. A tutorial for a registration script assumes that you already know enough of the basic php language so that you are not lost on what the php code syntax is or what the code is doing and that you just want to see/learn what a registration script would look like. You need to learn the basics of the php language before you attempt to use it for something like a registration script. Edited January 6, 2013 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403643 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Okay which one is it, do I have too many as stated by Jessica or do I not have enough as stated by PFMABiSMAd? Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403648 Share on other sites More sharing options...
Jessica Posted January 6, 2013 Share Posted January 6, 2013 Properly indent your code and learn PHP syntax. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403649 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Properly indent your code and learn PHP syntax. What? I am trying to learn php syntax, that's why I am asking questions. If you don't want to help please don't respond to my questions. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403652 Share on other sites More sharing options...
Jessica Posted January 6, 2013 Share Posted January 6, 2013 You're going to need to stop using Dreamweaver, probably get some books on PHP and start from the beginning. Us telling you which bracket is out of place (which it's hard to tell without fixing the spacing, indenting, etc) won't help in the long run. You have a } at the end of a line which make it hard to spot. Did the tutorial go over indenting? Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403654 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Well... since I can't start over and get books on php that is not an option. If you can't help I understand but maybe there is someone else on the forum that can better assist me with trying to figure this out. All I am asking for is if you understand the php code to help me learn it through practical application since I already have the code all I need is someone who is patient enough to walk through it with me. If there isn't enough time on the form I can communicate via email. what ever works. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403656 Share on other sites More sharing options...
Jessica Posted January 6, 2013 Share Posted January 6, 2013 You can't start over? Of course you can. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403658 Share on other sites More sharing options...
PFMaBiSmAd Posted January 6, 2013 Share Posted January 6, 2013 No one here is going to help you find where you mis-typed some characters in your code. That isn't learning, that's just you following along with something you saw. If you haven't read a basic php book or tutorial so that you know what the opening and closing {} mean, so that you can identify where they should be at in your code, you need to do that before you try to use a registration tutorial. Also, look at it this way, we have identified what the problem in the code is - missing/mis-matched {}. If you cannot take that information and fix up the code to correct that problem, you will not be able to write any code that does what you want. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403659 Share on other sites More sharing options...
Eliana Posted January 6, 2013 Author Share Posted January 6, 2013 Okay thank for your help. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403661 Share on other sites More sharing options...
Pikachu2000 Posted January 6, 2013 Share Posted January 6, 2013 With the code indented and formatted a bit better, it's much easier to see where these problems are: <?php if (isset($_GET['success']) && empty ($_GET['success'])) { echo'You\'ve been registered successfully! Please check your email to activate your account'; } else { if(empty($_POST)=== false && empty($errors) === true) { $register_data = array( 'username' =>$_POST['username]'], 'password' =>$_POST['password]'], 'first_name' =>$_POST['first_name'], 'last_name' =>$_POST['last_name]'], 'email' =>$_POST['email]'], 'email_code' =>md5($_POST['username']+ microtime()) ); register_user($register_data); header('Location: register.php? success'); exit(); } else { if (empty($errors) === false) { echo output_errors($errors); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403662 Share on other sites More sharing options...
haku Posted January 7, 2013 Share Posted January 7, 2013 Agreed. If you want to code any language, the most important thing is proper formatting (aka indentation). It makes things like this so much easier to debug, as you can see missing (or extra) parentesis and brackets very easily. When the code is not properly formatted, it is difficult to see (as you are finding out). There are different ways of formatting, and usually they are arbitrary (depending on the language), but the most important thing is consitency. Pick a style and always use it. You will then learn to see your code more clearly, and also your code will be more clear to others that you may show it to. Inconsistent formatting/indentation is something you should seek to eliminate right away. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403817 Share on other sites More sharing options...
Christian F. Posted January 7, 2013 Share Posted January 7, 2013 Also, for learning PHP I recommend starting with the basics. Once you know the basic syntax, and the core functions/language constructs, then you can move on to tutorials on how to make systems with the language. Quote Link to comment https://forums.phpfreaks.com/topic/272750-help-with-code-errors/#findComment-1403901 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.