boblan66 Posted November 23, 2010 Share Posted November 23, 2010 Well, when you get one thing solved, another pops up its ugly head. Here's the latest error. Parse error: syntax error, unexpected T_STRING in /home/taft65/public_html/memProtest.php on line 205 Code: <?php // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { line 205--> echo "<div style='width:100%;'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; } ?> I know my eyes aren't great and I'm typing with one finger, but I'll be darn if I see an error. Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2010 Share Posted November 23, 2010 Something prior to that point is causing the problem. Post at least 10 lines of code (not counting blank lines) leading up to that line. Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138208 Share on other sites More sharing options...
boblan66 Posted November 23, 2010 Author Share Posted November 23, 2010 Here is the code you requested. This is another concern - I have created a rester table from which I grab data to populate some areas of this page. My concern is, do I have the open db in the correct place? <?php // Place the results in the proper locations. $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; $dbhost = 'localhost'; $dbuser = 'taft_boblan'; $dbpass = 'taft65_8e83bed3'; $dbname = 'taft65_members'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Unable to connect with Alumni Database. Try again later.); mysql_select_db($dbname); //create a SQL statement to obtain data from table register // populate fields id, email, firstname, and lastname from table register // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { Error---> echo "<div style='width:100%;'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; } Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138533 Share on other sites More sharing options...
robert_gsfame Posted November 23, 2010 Share Posted November 23, 2010 or die ('Unable to connect with Alumni Database. Try again later.); i Guess u miss another single quote or die ('Unable to connect with Alumni Database. Try again later.'); Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138537 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2010 Share Posted November 23, 2010 Missing a closing single quote in the or die() clause. Appear to be missing an opening curly brace for the foreach(). May also be missing other curlies, but it's hard to say for sure. Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138538 Share on other sites More sharing options...
ManiacDan Posted November 23, 2010 Share Posted November 23, 2010 Look at your code now that it's highlighted. The error is quite literally as plain as day. I recommend downloading Eclipse with the PHP editing plugin, it will highlight your code for you. Also, the curl braces for your foreach statement aren't required, but they're recommended. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138543 Share on other sites More sharing options...
boblan66 Posted November 23, 2010 Author Share Posted November 23, 2010 Thank you for the assist. I should have spotted that. No excuse but at 68, my eyes arn't what they use to be. I'm going to enlarge the test with shift +. I'll check Eclipse out and see if that helps. NuSphere cost $200, I hope this is less. Thanks again for putting up with an old guy, but young at heart. Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138638 Share on other sites More sharing options...
ManiacDan Posted November 23, 2010 Share Posted November 23, 2010 Eclipse PDT is free. Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1138671 Share on other sites More sharing options...
boblan66 Posted November 25, 2010 Author Share Posted November 25, 2010 ManiacDan; I pasted the code on my form and made mods to the referencing the form name etc. However I came up with some interesting problems, when I ran the form. I attached the form to this reply for your review. Here are my questions: 1. I noticed that the script was placed directly after the closing form tag, so that's where I placed it in my form. Correct? 2. The radio buttons will not change state. If I select male and decide to change it to female, both buttons are selected. You can't select one. This is the same for any input field that has a radio button, not just the sex buttons. I tried renaming the test file that I'm using to madian_name.html and it changes to: madian_name.html.txt. is this something to do with javascript? I really appreciate your assistance. Believe it or not, I'm learning something. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1139607 Share on other sites More sharing options...
ManiacDan Posted November 29, 2010 Share Posted November 29, 2010 1) I have no idea what you mean. Generally the PHP code is the beginning of the file, and the HTML is the end. It's not a rule per se, but it allows your PHP script to generate errors and default values for your HTML. 2) Name the radio buttons the same NAME and they will be grouped together. You have no named for your inputs (any of them) so your form will never work. Spelling: Maiden, Personal. 3) I don't know what you're trying to do with renaming things, but this is a breakdown of the technology you're using: HTML - A completely client-side markup system, it makes things look pretty and formats text. It also generates "dumb" forms and inputs for the user to type into. HTML can perform NO actions. CSS - An offshoot of HTML, CSS handles stying HTML elements. CSS has "rules" that allow you to make fake dynamics on your site, mouseover actions and the like. Not a programming language. No actual actions. JavaScript - A client-side programming language, JavaScript executes on the USER'S computer, not on your server. Javascript interacts with the current page as it appears on the user's computer. JavaScript has access to what the user types as they type it, but is insecure because the user can modify it. JavaScript should be used to improve the user experience but not replace your server. AJAX, which you're not using, is a subset of javascript that allows you to make asynchronous calls from JavaScript to your webserver to retrieve live information without reloading the page. PHP - PHP is a server-side language. It runs on your server, NOT the user's computer. The user must make an individual request for every PHP page you run. PHP pages start, run, output, then die before the user sees anything. PHP pages are ignorant of each other and have no idea if the user is visiting for the first time or the millionth time. You must build session tracking into your site if you wish to maintain state. As for your file itself, you're using a custom rules-based validation parser (and you appear to be doing it wrong, the include might go after the rules), so I can't help much there. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1140890 Share on other sites More sharing options...
boblan66 Posted November 30, 2010 Author Share Posted November 30, 2010 Dan, Thanks for the lesson. I appreciate that you took the time. Bob... Quote Link to comment https://forums.phpfreaks.com/topic/219521-php-error-when-when-using-echo/#findComment-1141191 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.