Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. im trying to run a query which will get posts from the database that have tags similar to the current ones. Unfortunatly the echoed result isnt displaying as it should. $query = $link->query("SELECT t.*, p.* FROM ".TBL_PREFIX."topics t JOIN ".TBL_PREFIX."posts p ON (p.p_tid = t.t_tid) WHERE t.t_name = '".decode_url($_GET['t_name'])."' LIMIT 1") or die(print_link_error()); $row = $query->fetch(PDO::FETCH_ASSOC); $tag_query = $link->query("SELECT p_name FROM ".TBL_PREFIX."posts WHERE MATCH (p_tags) AGAINST ('".$row['p_tags']."' IN BOOLEAN MODE) ")or die(print_link_error()); $result = $tag_query->fetch(); foreach($result as $key => $value) { echo 'Name = '.$result[$key]['p_name'].'<br />'; } i have done a dump of result and it shows: $ => Array (2) ( ['p_name'] = String(12) "File Updates" ['0'] = String(12) "File Updates" ) but there should only be one item in this array(p_name). I dont know where the second is coming from. The query has pulled the right results, it just isnt displaying it right.
  2. im making a custom tag list where a user can enter tags into an input and seperate them with a comma. when they hit the comma key i want the name of the tag to be appended to a tag list. This is what i have so far but everytime a comma is inserted it adds all of the tags that are in the input field to the list rather than the one they have just added. $j('#post_tags').keyup(function(e){ if(e.which == 188) { var tags = $j(this).val().split(','); var length = tags.length; $j(tags).each(function(i){ $j('#tag_list').append(tags[i]); }); } });
  3. another stupid mistake on my behalf, forgot to turn on apaches rewrite module.
  4. i have recently bought a new samsung netbook so i downloaded the latest version of WAMP to develop my site. However when i run my site i get the internal server error associated with the htaccess file. The thing is that this file works on my desktop pc. The version i have of WAMP on this netbook is newer than the one i have at home, socould this be the problem? i can post the contents of the htaccess file if you think it will help, its just a lot of rewrite rules. Thanks
  5. im trying to initialize a class within another class but it says the class cant be found: class template { public function create_sidebar($type) { include($config['asf_root'].'functions/forum_functions.php'); $forum_tree = new forum_display; } } and the forum_display class does exist in the included file: class forum_display { public $forums = array(); function get_forum_listing()
  6. I have a system on my forum where the admin can change the colors of certain elements. Take the divs with and id of header for example. They can change the color of these and the value is added to the database. Then in my initialize file which is always called with every page, i set the color for the headers to the database value: $color['headers'] = $row['headers']; but then i have to go to every header div and add <div id="header" style="color:'.$color['headers'].'";> this means doing this for every header div and i dont just allow them to change the font color, but also background color and borders. Would there be a better way of doing this without adding these variables to the style attr of the element? when i view the code in firebug there are alot of style attr with all of these variables and it makes the code look a mess, and also makes it tedious work to add these variables to every element. Thanks
  7. im trying to do a complex(i think) prg replace but i keep getting the error: Failed evaluating code: $lang->showing-1,1 the code i am trying to replace is: <asf: lang[showing-<asf: var[num_report_alerts]>,<asf: var[num_report_alerts]>]> and the preg_replace is: $content = preg_replace('|\<asf: lang\[(.*?)-(.*?)\]\>|e', '$lang->replace_vars($lang->//1, array(\\2))', $content); its supposed to take everything inside <asf: lang[]> and echo \\1 which would be "showing" and then add \\2 into an array which would be "array(1,1)". So the output would be showing 1 of 1. Anyone know where im going wrong?
  8. thanks for the replies. both very good ideas, but i think i will go with the latter. this system is form my forum software so the poeple editing the language files will be users who contribute new languages or users who want to edit certain phrases. therefore i think the variables with meaning will work best. Thanks.
  9. Add more public vars like $username then in page2 function set them like so $this->username = $row['username']; then in the file you wish to display them use $book = new book(); echo $book->username;
  10. At the minute i am using variables in my tpl files in place of plain text so users can change the language the page is shown in. eg. the tpl file would include: $lang->hello; and the replacement would be $lang['hello'] = 'hello'; the php file would include the language class which replaces the variable in the language file with the array value in the relevant language file. but what happens when i have a phrase with a needed variable in the middle? $lang['msgs'] = 'you have '.$msgs.' messages'; i cant have 'you have' and 'messages' as seperate lang variables as phrases are constructed differently in other languages? so how do i accomplish this? hopefully i habe explained this ok.
  11. never mind, in the script that was generating the error i was using $color again for something other than arrays.
  12. Im getting the following error on this line: Fatal error: Cannot use string offset as an array $array['headers_style'] = 'color:'.$color['headers_text']['text'].'; background-color:'.$color['headers']['background'].';'; This error only occurs on one page, others that use this line dont have a problem. So i tried to delete parts of the code from the page causing the error but it still exists. So i deleted a huge peice of the code and the error vanished. So i eliminated portions of the huge code 1 at a time but the error stays until i delete all of the code. Anyone know why this page doesnt like the error? i could post the code but its a huge chunk(around 600 lines)
  13. thanks for the help. Im using this to start my own MVC but there is one thing left. What im doing is taking a file which has content like: $title = 'This is a test'; $array = array('title' => $title); $template->render('./test_template_tpl.php', $array); the render function then looks for content like: <asf: var[title]> in the tpl file and replaces it with the array item that equals var[title]. It then echos the array item, which works fine. But it is then supposed to write the new content to a cache file. I have another example which does that: public function render($path, $array) { $file = fopen($path, 'r'); $content = fread($file, filesize($path)); $content = preg_replace('|\<asf: header\[(.*?)\]\>|', '<div class="header">\\1</div>',$content); $cache_file = './cache/cache_test.php'; $file = fopen($cache_file, 'w'); fwrite($file, $content); return include($cache_file); fclose($file); that turns: <asf: header[testing]> into this and writes it to the new cache file: <div class="header">Testing</div> but the <asf: var[title]> tag still appears in the cache file when i need it to be overwritten with the array item. Anyone follow?
  14. thanks for the reply. this is what im using but i get an error: $content = preg_replace('|\<asf: var\[(.*?)\]\>|e', "{$array['\\1']}", $content); the error is undefined index \1 so its not working as i thought. I used your code: $content = preg_replace('|\<asf: var\[(.*?)\]\>|e', "$array[\\1]", $content); and got a parse error. where am i going wrong?
  15. I need to select an array item based on my preg result. for example: $content = 'test-1'; $match = preg_replace('|test-([0-9])|', $array['\\1'], $content); is this possible?
  16. hi, im using the following code to read the content of a file, and then add a line to the end of the file. $file = dirname(dirname(dirname(__FILE__))).'/includes/settings.php'; $read = fopen($file, 'r')or die('Opening Error'); $content = fread($read, filesize($file)); fclose($read)or die('Close Error'); if(isset($_POST['cat_bg'])) { $write = fopen($file, 'w')or die('Opening Error'); $cat_bg = $_POST['cat_bg']; $new_content = $content.'$color[\'cat_header\'][\'background\'] = '.$cat_bg.';'; fwrite($write, $new_content)or die('Write Error'); fclose($write); } however i would like to delete a line from the file before the content in inserted as the new line i am inserting is a duplicate variable with a different value. Can anyone help?
  17. am i on the right lines with this: $query = $link->query("SELECT * FROM ".TBL_PREFIX."posts GROUP BY FROM_UNIXTIME(p_time_posted) "); $row = $query->fetchAll();
  18. i realise now that this was a bad way to save times but i never intended to use them this way so i didnt think it mattered. Thanks for the advice
  19. i need to sort my database results by the day they were added to the database. There is a column with the timestamp of when they were inserted but how do i group them by the day they were inserted so i can display them as such: Mon 14th: 5 records Tues 15th: 11 records etc.
  20. I have a section on my website where the url points to www.example.com/some_page#some_element #some_element is used by javascript to load the element in question into the parent element. However i need pagination done on this loaded element. How should i go about it? would it work? obv i cant use www.example.com/some_page#some_element/page/2. Any tips or advice?
  21. you suggest a button in the admin section that will delete all attachments that arent being used?
  22. that would run the risk of getting the wrong post. sample_post is like sample_post_1
×
×
  • 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.