jfarthing Posted February 6, 2008 Share Posted February 6, 2008 I have racked my brain and can't figure why I'm getting a parse error from the following code. switch($_REQUEST["action"]) { //logout case "logout": wp_clearcookie(); if(get_option("jk_logout_redirect_to")) $redirect_to = get_option("jk_logout_redirect_to"); else $redirect_to = "wp-login.php"; do_action('wp_logout'); nocache_headers(); if ( isset($_REQUEST['redirect_to']) ) $redirect_to = $_REQUEST['redirect_to']; wp_redirect($redirect_to); exit(); break; //lost lost password case 'lostpassword': do_action('lost_password'); $header_files = get_option("jk_login_header_files"); foreach((array)$header_files as $header_file) include(TEMPLATEPATH . '/' . $header_file); echo get_option("jk_login_after_head_html"); ?> <div id="login"> <h2><?php _e(get_option("jk_login_forgotpw_form_text")); ?></h2> <p><?php _e('Please enter your information here. We will send you a new password.'); ?></p> <?php if ($error) {echo "<div id='login_error'>$error</div>";} ?> <form name="lostpass" action="wp-login.php" method="post" id="lostpass"> <p> <input type="hidden" name="action" value="retrievepassword" /> <label><?php _e('Username:'); ?><br /> <input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label> </p> <p><label><?php _e('E-mail:'); ?><br /> <input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br /> </p> <p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> »" tabindex="3" /></p> </form> <ul> <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?'); ?>">« <?php _e('Home') ?></a></li> <?php if (get_settings('users_can_register')) { ?> <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register'); ?></a></li> <?php } ?> <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login'); ?></a></li> </ul> </div> <?php echo get_option("jk_login_before_foot_html"); $footer_files = get_option("jk_login_footer_files"); foreach((array)$footer_files as $footer_file) include(TEMPLATEPATH . '/' . $footer_file); die(); break; //lost retrieve password case 'retrievepassword': $header_files = get_option("jk_login_header_files"); foreach((array)$header_files as $header_file) include(TEMPLATEPATH . '/' . $header_file); $user_data = get_userdatabylogin($_POST['user_login']); // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; if (!$user_email || $user_email != $_POST['email']) { echo get_option("jk_login_after_head_html"); echo sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.'), 'wp-login.php?action=lostpassword'); echo get_option("jk_login_before_foot_html"); $footer_files = get_option("jk_login_footer_files"); foreach((array)$footer_files as $footer_file) include(TEMPLATEPATH . '/' . $footer_file); die(); } do_action('retreive_password', $user_login); // Misspelled and deprecated. do_action('retrieve_password', $user_login); // Generate something random for a password... md5'ing current time with a rand salt $key = substr( md5( uniqid( microtime() ) ), 0, 50); // now insert the new pass md5'd into the db $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'"); $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; $message .= get_option('siteurl') . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n"; $m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message); echo get_option("jk_login_after_head_html"); echo " <div id=\"login\">\n"; if ($m == false) { echo "<h1>There Was a Problem</h1>"; echo '<p>' . __('The e-mail could not be sent.') . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...') . "</p>"; } else { echo "<h1>Success!</h1>"; echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>'; } echo " </div>\n"; echo get_option("jk_login_before_foot_html"); $footer_files = get_option("jk_login_footer_files"); foreach((array)$footer_files as $footer_file) include(TEMPLATEPATH . '/' . $footer_file); die(); break; It says the error is at the line case 'retrievepassword': Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/ Share on other sites More sharing options...
kenrbnsn Posted February 6, 2008 Share Posted February 6, 2008 What is the exact error message? Ken Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460166 Share on other sites More sharing options...
revraz Posted February 6, 2008 Share Posted February 6, 2008 Quite a few IFs and Loops don't have their {} brackets, which is fine if you just want to run the one line after it. But go back and make sure you didn't add a } somewhere and the switch is closing. Also, I dont see a } closing the switch at the end. Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460167 Share on other sites More sharing options...
jfarthing Posted February 6, 2008 Author Share Posted February 6, 2008 It's not the whole switch statement, because its rather long. if youd like to see the whole thing.... Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460169 Share on other sites More sharing options...
kenrbnsn Posted February 6, 2008 Share Posted February 6, 2008 I took the code you posted, put a "<?php" before and a "}?>" after and got no syntax errors. Ken Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460171 Share on other sites More sharing options...
jfarthing Posted February 6, 2008 Author Share Posted February 6, 2008 I did the exact same thing and got the same syntax error. ??? Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460176 Share on other sites More sharing options...
jfarthing Posted February 6, 2008 Author Share Posted February 6, 2008 Interesting.... I uploaded it to my server and no problems at all, however on my computer I get the error. Any ideas? Im running PHP 5.2.5 and my webserver is running PHP 5.2.3..... Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460183 Share on other sites More sharing options...
jfarthing Posted February 6, 2008 Author Share Posted February 6, 2008 LOL, I figured it out. It was because one of the php openings was only <? instead of <?php Is that a server configuration? Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460194 Share on other sites More sharing options...
revraz Posted February 6, 2008 Share Posted February 6, 2008 php.ini for short tags. Use <?php in all your code and you'll be alright. Quote Link to comment https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/#findComment-460221 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.