-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
another stupid mistake on my behalf, forgot to turn on apaches rewrite module.
-
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
-
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()
-
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
-
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?
-
anyone have any ideas?(shameful bump)
-
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.
-
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.
-
never mind, in the script that was generating the error i was using $color again for something other than arrays.
-
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)
-
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?
-
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?
-
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?
-
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?
-
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();
-
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
-
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.
-
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?
-
you suggest a button in the admin section that will delete all attachments that arent being used?
-
that would run the risk of getting the wrong post. sample_post is like sample_post_1
-
basically: the url reads like asimpleforum.co.uk/post/sample_post! so <a href="asimpleforum.co.uk/post/sample_post!"> htaccess is used so the actual url points to view_post.php?post_name=sample_post! that is how you access the post. When you click the link to view the post i run a query to get all of the post information but the query is run from the post name. so posts with a space are replaced with an underscore etc. The only problem is that using the ! in a url breaks it and sends a 404 error "page not found" so i tried using str_replace to replace the ! with %21. This threw the same 404 error. the same thing happened with urlencode.
-
I need to make an attachment system for my forum but i have a big issue. When a user adds an attachment they are added to the server there and then(the way i want it to be so i can have progress bars and such). Then when a user submits their post the content and attachmnet names are added to the database. Simple. But what happens when a user decides not to continue with the post? The attachments have already been added to the server but they arent being used. One thing i can think of is to run a query which checks which attachments are on the server and cross references them with the names in the database. If they are on the server but not in the database then delete the files. However that seems to be quite an intensive way of doing things and adds yet another query to each page load. Any advice or ideas on this?