Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. correct
  2. when i use strtotime('+3 HOURS') everything is fine. so why cant i use strtotime('+3.5 HOURS')? what would be the proper way to do this?
  3. i appear to be getting closer but not all database results are displayed using: $cat_name = array(); $forum_name = array(); foreach($result as $key => $val) { if($result[$key]['f_pid'] == 0) { $cat_name[$c] .= $result[$key]['f_name']; $c++; } else { $forum_name[$f] .= $result[$key]['f_name']; $forum_desc = $result[$key]['f_description']; $f++; } } for($c=0; $c<count($cat_name); $c++) { echo '<b>'.$cat_name[$c].'</b><br />'; var_dump($cat_name); } for($f=0; $f<count($forum_name); $f++) { echo '<em>'.$forum_name[$f].'</em><br />'; } the var_dump($cat_name) shows: array(2) { [""]=> string(7) "General" [1]=> string(7) "Testing"} "General" is missing from the display, for some reason the key for it is "" instead of 0.
  4. i tried this but it didnt work: $cat_name = array(); $forum_name = array(); foreach($result as $key => $val) { if($result[$key]['f_pid'] == 0) { $cat_name[$c] .= $result[$key]['f_name']; $c++; for($c=0; $c<count($cat_name); $c++) { echo $cat_name[$c]; } } else { $forum_name[$f] .= $result[$key]['f_name']; $forum_desc = $result[$key]['f_description']; $f++; for($f=0; $f<count($forum_name); $f++) { echo $forum_name[$f]; } } }
  5. do you mean: $cat_name = array(); $forum_name = array(); foreach($result as $key => $val) { if($result[$key]['f_pid'] == 0) { $cat_name[] .= $result[$key]['f_name']; } else { $forum_name[] .= $result[$key]['f_name']; } $forum_desc = $result[$key]['f_description']; }
  6. but appending all of the forum names to 1 variable would print: forum1forum2forum3forum4 I need it to output something like forum1(f_pid=0) forum2 forum3 forum4(f_pid=0) forum5 forum6it may help to state that i am using the modified preorder tree traversal system to store heirachal data using th eleft and right ids like phpbb.
  7. $array1[0] = $array1[0].$array2[0];
  8. for better clarification here is how i display a page: $template->replace( array( '{CATEGORY}' => '', '{F_ICON}' => '', '{F_NAME}' => $forum_name, '{F_DESC}' => $forum_desc, '{SITE_ROOT}' => $config['asf_root'] ), 'forum_list'); and the function public function replace($array, $file) { $file = './html/'.$file.'.html'; $file = file_get_contents($this->template.$file); foreach ($array as $key => $val) $file = str_replace($key, $val, $file); echo $file; return; } and the html file forum_list.html <div class="category_header"> {CATEGORY} </div> <ol class="forum_list"> <li class="forum"> <div class="forum_info"> <span class="forum_icon"> <img src="{SITE_ROOT}templates/default/icons/forum.png" /> </span> <div class="forum_text"> <h3 class="forum_name"> {F_NAME} </h3> <h4 class="forum_description"> {F_DESC} </h4> </div> </div> </li> </ol>
  9. yes
  10. here is my code which is supposed to return all forums from the database and then display them in their respective categories. however it only shows one of the forums and not all of them. Anyone know why? function display_forum_list($crumbs) { global $link, $template, $settings, $lang, $config, $user; $template->replace( array( '{CRUMBS}' => display_crumbs($crumbs) ), 'index_page'); $query = $link->query("SELECT * FROM ".TBL_PREFIX."forums ORDER BY f_lid ASC"); $result = $query->fetchAll(); foreach($result as $key => $val) { if($result[$key]['f_pid'] == 0) { $cat_name = $result[$key]['f_name']; } else { $forum_name = $result[$key]['f_name']; } $forum_desc = $result[$key]['f_description']; } $template->replace( array( '{CATEGORY}' => $cat_name, '{F_ICON}' => '', '{F_NAME}' => $forum_name, '{F_DESC}' => $forum_desc, '{SITE_ROOT}' => $config['asf_root'] ), 'forum_list'); }
  11. do you have any current code i could work off? it will be easier to help you if i can see what you currently have.
  12. so what is date 1 and date 2 in the database? is it the practicedate table column DATE? if so then what is value 1 and value 2 in the database?
  13. so to clarify: All Paddler First Name List Here Paddler First Name -------------------------------------------- | pushup 1 | pushup 2 | pushup 3 | pushup 4| -------------------------------------------- | date 1 | date 2 | date 3 | date 4 | -------------------------------------------- is that right?
  14. jquery would work good for this. add an id to each of your forms(for simplification i am going with 1,2,3). add an include at the top to include the jquery file(lets call it form validation) and then create the js file(form_validation.js). in this file do something like: jQuery(document).ready(function() { jQuery("#1").submit(function() { jQuery.post("your_process_file.php",{ forename:jQuery("#forename").val(), surname:jQuery("#surname").val(), email:jQuery("#email").val(), address1:jQuery("#address1").val(), address2:jQuery("#address2").val(), town:jQuery("#town").val(), county:jQuery("#county").val(), postcode:jQuery("#postcode").val() } ,function(data) { if (data == 1) { IF EVERY THING IS OK CONTINUE TO NEXT STEP } else { OR SHOW THE ERRORS } }); return false; }); jQuery("#2").submit(function() { jQuery.post("your_process_file.php",{ userfile:jQuery("#userfile").val(), fakeuserfile:jQuery("#fakeuserfile").val() } ,function(data) { if (data == 1) { IF EVERY THING IS OK CONTINUE TO NEXT STEP } else { OR SHOW THE ERRORS } }); return false; }); }); and then in your_process_file.php add the validation. if the validation checks out ok in this file then echo 1 to show its ok. $error = ''; if(strlen($_POST['username'] >= { $error = ''; } else { if (empty($error) { $error = 'Wrong Length Username'; } } if (empty($error) { echo '1'; } else { echo $error; }
  15. can you write exactly how you want it to look when you open the webpage?
  16. without having access to the SMF(software phpfreaks uses) database its hard to figure out. the cookie names generated by SMF arent clear about what they are but theres only about 4 or 5 of them so i dont think its cookies.
  17. well if its working thats news to me but it is bad coding practice. it should be: $x="INSERT INTO user_id (name,uname,password,email,contact) VALUES ('".$_POST['name']."','".$_POST['uname']."','".$_POST['password']."','".$_POST['email']."','".$_POST['contact']."')";
  18. <?php // your string $str = 'this is a post post post post'; // Count the number of occurences: $count = preg_match_all( '/post/', $str, $blank); // print occurences echo "Count is: $count<p>$str</p>"; ?>
  19. $row[name] means nothing, it would throw up the error use of undefined constand because name hasnt been defined. however $row['name'] is the right way to use it. consider: $array = array('one', 'two'); echo $array[one]; echo $array['two'] the first echo would cause an error stopping the script entirely(depending on your error handling) but he second echo is correct. Make sense? also '$row[name]' would just print $row[name] and not the actual array value since anything in single quotes isnt parsed by php.
  20. for a better chance of seeing the error do this. replace the top php code with: $connection=mysql_connect("localhost","root",""); mysql_select_db("forum",$connection); $select=mysql_query("SELECT * FROM user_id WHERE uname='".$_REQUEST[uname]."'") or die(mysql_error()); $row=mysql_fetch_array($select); if($row) { if($row['password']==$_REQUEST['password']) { session_start(); $_SESSION['name']=$_REQUEST['uname']; } else { header("Location:err-login.php"); } } else { die('Query Failed'); } i have added the mysql_error() function which will show any errors within your query. I have also fixed your query. in the bit where you call $_SESSION['name'] replace it with: if(isset($_SESSION['name'])) { echo "Welcome ".$_SESSION['name']; } else { echo 'No Username Set Into Session[\'name\']'; } this will say if there is no session set. I must say though your code is a mess. split the css, html and php into different files. also on html attributes like: <p align=center> use quotes on the values: <p align="center"> or for better markup use proper css styling: <p style="text-align:center;">
  21. where are you getting $_REQUEST[uname] from? is it a form on a different page? also this line is wrong: $select=mysql_query("SELECT * FROM user_id WHERE uname='$_REQUEST[uname]'",$connection); it should be: $select=mysql_query("SELECT * FROM user_id WHERE uname='".$_REQUEST['uname']."'"); is user_id the name of the database table?
  22. i think people have been getting confused by what you meant. am i to understand you want to check if a registered user has read a post(something that they chose to be notified about or are following) like when phpfreaks shows you new replies to your posts, then once you have read them the links dissapear. if so then cookies is the way to go.
  23. firstly, dont ask someone to rewrite your code for you. you may annoy some people. instead ask for help or tips. the above post is correct but you can also do it via css. in your css add: input#login { border:0; background:url(your_image_here) no-repeat top left; }
  24. im sure some forums differ in their methods but yes cookies is one option and the logical one.
  25. so simple i should have thought about it(just finished night shift so theres my excuse). Thanks
×
×
  • 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.