Jump to content

JakkkeM

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by JakkkeM

  1. Yeah I'll give it a try. It's so confusing because it seems so random... I thought perhaps there was a character limit on the whole from header but it doesn't appear to have one.
  2. Tried fake addresses, huge address' and all sorts... For some reason, on some address' it removes the from header completely! There doesn't appear to be any other patterns...
  3. None-the-less it's still not sending the message for some abstract reason...
  4. Tried that. The only "unusual" thing, was I expected it to print the <noreply@crossfitstmarys.com.au> on the page, but it gets eaten for some reason. Nothing unexpected anywhere else.
  5. By fail - echo no and not send the email.
  6. Not at the moment it's not - but I'm using all different address' and it works. I.e. crossfit.com worked I have: if(mail($to, $subject, $message, $headers)){ echo "YES"; }else{ echo "NO"; } To debug. Seems to work fine.
  7. Hi all, I'm sending an email with php as a part of my user registration process, and for some reason the mail script begins to fail when I use my full desired email in my headers. I use the standard PHP Manual headers for email: // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Jake M*** <**********@gmail.com>' . "\r\n"; $headers .= "From: CFS <noreply@crossfitst.com>" . "\r\n"; Now, if I make my last header: $headers .= "From: CFS <noreply@crossfitstmarys.com>"."\r\n"; It fails! As soon as I put the m in on CrossfitStMarys it fails the whole script. Any ideas? Cheers. P.S. I have real data in for my Jake M, just censored it out because I don't want everyone having my email haha.
  8. Had no need for a body tag - it was being echo'd onto a page with body tags already. Solved the problem. Had to make the function return rather than echo. Cheers for the string replace tip though!
  9. The String: <div class="cfs_container"> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <!-- Top Bar Content --> <div class="span4">[element="title"]</div> <div class="span8"> <div class="btn-toolbar" style="float:right;"> [menu] </div> </div> </div> </div> <div class="row-fluid"> <div class="span12">[element="scroll"]</div> </div> <div class="row-fluid"> <div class="span3" style="background-color:#000; padding:10px; color:#FFF;"> <!--Left content--> [element="left"] </div> <div class="span6" style="background-color:#000; padding:10px; color:#FFF;"> <!--Central content--> </div> <div class="span3" style="background-color:#000; padding:10px; color:#FFF;"> <!--Right content--> [element="right"] </div> </div> </div> <div class="container-fluid"> <span class="span12" style="color:#FFF; padding:10px;"> <center> [element="copyright"] </center> </span><!-- SPAN END --> </div><!-- CONTAINER FLUID END --> </div> <?php /* Functions to create dropdown menus dynamically for items in DB using twitter bootstrap markup */ class Menu { public static function makeMenu() { echo "<div class=\"btn-toolbar\" style=\"margin: 0; float:right;\">"; try{ $getAllMenus = DB::get()->query("SELECT menu_id FROM menus"); $result = $getAllMenus->fetchAll(); } catch (PDOException $e){ die("Query Error: ".$e->getMessage()); } foreach($result as $menu){ self::getMenu($menu['menu_id']); } echo "</div>"; } static function isDropdown($menu_id) { try{ $dropDownCheck = DB::get()->prepare("SELECT COUNT(*) FROM links WHERE assoc_menu = :assoc_menu"); $dropDownCheck->bindParam(':assoc_menu', $menu_id, PDO::PARAM_INT); $dropDownCheck->execute(); $result = $dropDownCheck->fetch(); } catch (PDOException $e){ die("Query Error: ".$e->getMessage()); } return ($result[0] > 0); } static function getMenuItems($menu_id) { // get Link data from the database try{ $linkData = DB::get()->prepare("SELECT * from links WHERE assoc_menu = :assoc_menu"); $linkData->bindParam(':assoc_menu', $menu_id, PDO::PARAM_INT); $linkData->execute(); $links = $linkData->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e){ die("Query Error: ".$e->getMessage()); } return($links); } public static function getMenu($menu_id) { // get Menu data from the database try{ $menuData = DB::get()->prepare("SELECT * from menus WHERE menu_id = :menu_id LIMIT 1"); $menuData->bindParam(':menu_id', $menu_id, PDO::PARAM_INT); $menuData->execute(); $menu = $menuData->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e){ die("Query Error: ".$e->getMessage()); } if(!self::isDropdown($menu_id)){ // if the menu doesn't contain dropdown items $markup = "<div class=\"btn-group\"> <a class=\"btn ".$menu['btn_type']."\" href=\"#\">".$menu['title']."</a> </div>"; } else { // otherwise create dropdown items $links = self::getMenuItems($menu_id); $markup = "<div class=\"btn-group\"> <a class=\"btn ".$menu['btn_type']." dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">".$menu['title']." <span class=\"caret\"></span></a> <ul class=\"dropdown-menu\"> <!-- dropdown menu links -->"; // generate link for each dropdown item foreach($links as $link){ $markup.= "<li><a href=\"".$link['link_url']."\">".$link['link_title']."</a></li>"; } $markup.= "</ul></div>"; } echo $markup; } } ?>
  10. Replaced that - no change :/
  11. Hi, I'm using a preg_replace to change [menu] into Menu::makeMenu(); , but when it executes the replace, for some reason it's sending my code to the first line after the <body> tag rather than where the [menu] was in the first place. Preg Replace: function formatPage($transform){ $a = array( "/\[element=\"(.*?)\"\]/ise", "/\ /ise", "/\[menu]/ise", "/\[login-button]/ise", ); $b = array( "elementCreate(\"$1\");", "pageCreate();", "Menu::makeMenu();", "loginBtn();", ); $transform = preg_replace($a, $b, $transform); return $transform; } I can copy out the whole function and stuff for the Menu:: but I don't think it'll matter. Please help! Cheers.
  12. Managed to get a working solution. Had my friend make up an OOP Code...
  13. Still null. Why is this so difficult?!
  14. That's the source code
  15. <h1>Test Page</h1><div class="btn-toolbar"><div class="btn-group"><a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#">View the WOD<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="?page=home">View the WOD</a></li> <li><a href="?page=home">WOD Archives</a></li> <li><a href="?page=home">Benchmakrs</a></li> </ul> </div> <div class="btn-group"><a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#">Who, What, When, Where and Why?<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="?page=home">Who, What, When, Where and Why?</a></li> <li><a href="?page=home">Services and Pricing</a></li> <li><a href="?page=growth-of-sport">Growth of Sport</a></li> <li><a href="?page=what-is-crossfit">What is CrossFit?</a></li> </ul> </div> <div class="btn-group"><a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#">What You Need To Know<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="?page=need-to-know">What You Need To Know</a></li> <li><a href="?page=contacting-us">Contacting Us</a></li> <li><a href="?page=health-assessment-and-waiver">Health Assessment and Wavier</a></li> </ul> </div> <div class="btn-group"><a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#">How it Works<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="?page=how-it-works">How it Works</a></li> </ul> </div> </div>Array ( [1] => Array ( [0] => Array ( [link_id] => 1 [link_title] => View the WOD [link_url] => ?page=home [title] => View the WOD [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 1 [m_assoc_menu] => 0 [menu_url] => ) [1] => Array ( [link_id] => 2 [link_title] => WOD Archives [link_url] => ?page=home [title] => WOD Archives [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 1 [m_assoc_menu] => 0 [menu_url] => ) [2] => Array ( [link_id] => 3 [link_title] => Benchmakrs [link_url] => ?page=home [title] => Benchmakrs [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 1 [m_assoc_menu] => 0 [menu_url] => ) ) [2] => Array ( [0] => Array ( [link_id] => 4 [link_title] => Who, What, When, Where and Why? [link_url] => ?page=home [title] => Who, What, When, Where and Why? [btn_type] => btn-inverse [dropdown] => 0 [stacking] => 2 [m_assoc_menu] => 0 [menu_url] => ?page=login ) [1] => Array ( [link_id] => 5 [link_title] => Services and Pricing [link_url] => ?page=home [title] => Services and Pricing [btn_type] => btn-inverse [dropdown] => 0 [stacking] => 2 [m_assoc_menu] => 0 [menu_url] => ?page=login ) [2] => Array ( [link_id] => 6 [link_title] => Growth of Sport [link_url] => ?page=growth-of-sport [title] => Growth of Sport [btn_type] => btn-inverse [dropdown] => 0 [stacking] => 2 [m_assoc_menu] => 0 [menu_url] => ?page=login ) [3] => Array ( [link_id] => 7 [link_title] => What is CrossFit? [link_url] => ?page=what-is-crossfit [title] => What is CrossFit? [btn_type] => btn-inverse [dropdown] => 0 [stacking] => 2 [m_assoc_menu] => 0 [menu_url] => ?page=login ) ) [3] => Array ( [0] => Array ( [link_id] => 8 [link_title] => What You Need To Know [link_url] => ?page=need-to-know [title] => What You Need To Know [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 3 [m_assoc_menu] => 0 [menu_url] => ) [1] => Array ( [link_id] => 9 [link_title] => Contacting Us [link_url] => ?page=contacting-us [title] => Contacting Us [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 3 [m_assoc_menu] => 0 [menu_url] => ) [2] => Array ( [link_id] => 10 [link_title] => Health Assessment and Wavier [link_url] => ?page=health-assessment-and-waiver [title] => Health Assessment and Wavier [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 3 [m_assoc_menu] => 0 [menu_url] => ) ) [4] => Array ( [0] => Array ( [link_id] => 11 [link_title] => How it Works [link_url] => ?page=how-it-works [title] => How it Works [btn_type] => btn-inverse [dropdown] => 1 [stacking] => 4 [m_assoc_menu] => 0 [menu_url] => ) ) )
  16. Almost! So close! The last button - should be a link...
  17. It's returning it absolutely fine! Just without the correct values in the there? I.e. my titles are not 1, V, ? etc...
  18. <div class="btn-group"> <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#"> WOD <span class="caret"></span> </a> <ul class="dropdown-menu"> <!-- dropdown menu links --> <li><a tabindex="-1" href="http://www.google.com.au">View the WOD</a></li> <li><a tabindex="-1" href="#">WOD Archives</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Benchmarks</a></li> </ul> </div> ??
  19. Closer than I've ever gotten. But where the hell these values are coming from I have no idea? Image One - The Dropdown Image Two - The Buttons $sql = "SELECT `link_id`, `links`.`assoc_menu` as `assoc_menu`, `link_title`, `link_url`, `title`, `type`, `btn_type`, `dropdown`, `stacking`, `menus`.`assoc_menu` as `m_assoc_menu`, `url` as `menu_url` FROM `menus` INNER JOIN `links` ON (`links`.`assoc_menu` = `menus`.`menu_id`) WHERE `link_permissions` = '1'"; $query = mysql_query($sql) or die(mysql_error()); $startList = mysql_fetch_assoc($query); $refactorList = array(); foreach($startList as $line){ $refactorList[$line['assoc_menu']][] = array( 'link_id' => $line['link_id'], 'link_title' => $line['link_title'], 'link_url' => $line['link_url'], 'title' => $line['link_title'], 'btn_type' => $line['btn_type'], 'dropdown' => $line['dropdown'], 'stacking' => $line['stacking'], 'm_assoc_menu' => $line['m_assoc_menu'], 'menu_url' => $line ['menu_url'] ); } foreach($refactorList as $menu){ echo '<div class="btn-group"><a class="btn '.$menu['0']['btn_type'].'\n\r dropdown-toggle" data-toggle="dropdown" href="#">'.$menu['0']['title'].'<span class="caret"></span></a><ul class="dropdown-menu">'; // echo '<div class="your-ui-menu-class">'.$menu['0']['title']."\n\r <ul id=\"{$menu['0']['title']}\"> \n\r"; // ^ echo to output each menu title and start the <ul> foreach($menu as $link){ echo "<li><a href=\"{$link['link_url']}\">{$link['link_title']}</a></li>\n\r"; // ^ echo to output each link within the menu } echo "</ul> \n\r </div> \n\r"; }
  20. The only problem with this, is I don't have a set amount of values - in your example you used two, I have no set amount of links that could be assigned to a menu. Does that matter?
  21. Well, I'm essentially trying to get the function to return multiple solutions when they're (to my understanding) designed to output one. Image of the Menu Table Image of the Link Table Hope that helps For the record - the table names are "menus" and "links"
  22. If you REALLY want it: echo "<h1>Test Page</h1>"; // Fetch MENUs $fetch_menu = mysql_query("SELECT * FROM `menus` ORDER BY `stacking`"); // Function for LInks function linkCreate($menu_id){ // Fetch Links $fetch_links = mysql_query("SELECT * FROM `links` WHERE `assoc_menu` = '".$menu_id."'"); $num_links = mysql_num_rows($fetch_links); while($LINK = mysql_fetch_array($fetch_links, MYSQL_ASSOC)){ $return_link = "<li><a tabindex=\"-1\" href=\"#\">Health Assessment and Wavier</a></li>"; } return $num_links." ".$return_link; } while($MENU = mysql_fetch_array($fetch_menu, MYSQL_ASSOC)){ echo $MENU['title']."<br>"; echo linkCreate($MENU['menu_id']); } This comes close but only returns the first link... Probably because it's a function and I'm an idiot for using a function but hey. // Do the query for all the menus $query = mysql_query("SELECT * FROM `menus` LEFT JOIN `links` ON `menus`.`menu_id` = `links`.`assoc_menu`"); // Set some functions function createButton($btn_type, $btn_title, $TYPE, $standard_url){ if($TYPE == "1"){ // If it's a drop down execute: $button = "<a class=\"btn ".$btn_type." dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">".$btn_title." <span class=\"caret\"></span></a>"; }elseif($TYPE == "0"){ // If it's a standard button execute: $button = "<a class=\"btn ".$btn_type."\" href=\"".$standard_url."\">".$btn_title."</a>"; }else{ // If it's not specified, error: $button = "<a class=\"btn btn-warning\" href=\"#\">Button Error</a>"; } return $button; } function createDropdown(){ } // Set the $prev_title variable to prevent repeating the button $prev_title = ""; // Execute an array for all menus while($MENU = mysql_fetch_array($query, MYSQL_ASSOC)){ // If this is a new button - print the button if($MENU['title'] != $prev_title){ // If the titles are not the same, THIS IS THE BUTTON $return_menu = $MENU['title']."<br>"; }elseif($MENU['title'] == $prev_title){ // If the titles are the same, THIS IS A LINK. $return_menu = $MENU['link_title']."<br>"; } // Print whatever is necessary echo $return_menu; // Reset the prev_title for the next menu $prev_title = $MENU['title']; } This returns mostly OK, but removes the first link, and I can't put the links in the UL as required.
  23. Hi all, I'm experiencing a lot of trouble trying to create a script for my website. I'm making a database dependant menu, and I've spent a couple of days doing trial and error much to no prevail. I'm using Twitter Bootstrap if anyone is familiar with it, and creating a drop down menu. The code for each of these buttons is: <div class="btn-group"> <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#"> WOD <span class="caret"></span> </a> <ul class="dropdown-menu"> <!-- dropdown menu links --> <li><a tabindex="-1" href="http://www.google.com.au">View the WOD</a></li> <li><a tabindex="-1" href="#">WOD Archives</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Benchmarks</a></li> </ul> </div> So, what I need to be able to do is call each menu that I have in the database, (I have 5), determine if it's a drop down, and if it is, echo the links for it inside of the <ul class="dropdown-menu"> It seems simple to me, but I cannot get it right. Please help! Cheers.
×
×
  • 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.