Jump to content

laanes

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Everything posted by laanes

  1. I can't get my head around rewriting my websites URL's. I'd like to rewrite mywebsite.com/page.php to be accessed as: mywebsite.com/page or mywebsite.com/PAGE If there is no such page, then redirect to home page. So i've tried this: RewriteRule ^(\w+)\/?$ $1.php [NC] [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php Result: mywebsite.com/page_that_doesn't_exist - works as intended, takes me to index.php mywebsite.com/page works fine. mywebsite.com/PAGE gives me this - You don't have permission to access /C:/wamp/www/mywebsite.com/PAGE.php/ on this server. Why this kind of error and can i maybe force lowercase on PAGE ?
  2. Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in here: https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action here: http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in here: https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in here: https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me.
  3. laanes

    SQL syntax

    Thank you for your answer. The query was used twice inside of a loop, i removed the single quotes around the id value in the first query but they were still present in the second one, hence the error message - "syntax to use near '= '4879'' at line 1". I would now close this topic but can not find a way to do it. Kind regards, laanes
  4. laanes

    SQL syntax

    Hello, Does anyone spot an error in the following SQL: "SELECT range_id, productId FROM range_idx WHERE productId = 4879 LIMIT 1" I get:
  5. Thanks guys! Now my script is singing and dancing. You are the best! Greetings, laanes
  6. Can anyone help me to figure out a pattern that matches all the underlined zn's ? mnzertainlyzn cznar availznable in zn finznish zn / zn, zn/zn zn umzn:) I tried this: '#\s?zn\s?#' This is close to what i expect but matches also the ones contained inside words which i don't want.
  7. Hmm, yes, i can see what you mean. But how would i get all the songs related to the album i searched for? Since the AI id is unique to every row, it means i can not link songs to albums like this? : "SELECT album, song FROM albums INNER JOIN songs ON albums.id = songs.id" I'd like to get all songs from the album "raccoon" for example.
  8. id is an auto incrementing integer just for a way of sorting the records.
  9. Sorry for not being clear enough. I would like the group the songs somehow for searching by album. So i have created table albums with id, album_id, album. Then i imported the albums from a textfile so that the id field got filled with auto incrementing numbers and albums field with album names. album_id didn't exist in the textfile so it got filled with 0's. I'd like for example song 1-9 to have album_id 1, song 10-19 to have album_id 2 etc. How could i accomplish this?
  10. Hi! I would like to create values for album_id field, so i can link songs with albums. Since there is a big number of songs and albums, I was wondering whether there is a better way to create those id's than going through each song manually? Can you point me to the right direction or share any thoughts about this? Greetings, laanes
  11. I am using this rule: RewriteEngine on RewriteRule cat/(\w+)$ cat=$1 Result: Both of these URLs work: http://localhost/urls/cat/mickey http://localhost/urls/urls.php?cat=mouse I thought the URL will be rewritten when there is a pattern match, in the current case - cat/mickey should be rewritten to cat=mickey ? In fact, even http://localhost/urls/urls.php/cat/and/mouse/are/having/a/fight/over/bacon does not give an error, instead, it is still displaying the content of http://localhost/urls/urls.php What am i missing?
  12. I would like to redirect everything in my root folder to home.php instead of index.php My htaccess file is located in the root folder and contains the following line: RewriteEngine on RewriteRule .* home.php
  13. There is nothing specific that i am trying to do with it yet, just dropping in examples i can find on the web, like changing the default index page to something.html etc. If i put absolute nonsens into the .htaccess, i get:
  14. Hi, I started reading a tutorial on using .htaccess but got stuck at the very beginning. Nothing seems to work, no matter what i write into the file. I have placed it into my WAMP servers root folder and copied examples from the tutorial to test. I can see that it is enabled in the apache modules list and it is loaded via the httpd conf file. How could i get this thing to work?
  15. Also, I have tried to join another table with additional images in the query and it seems that i can not compare the fetched results against the folder because the list i get back contains also some images that excist in both, the images folder and the database. Would i have to compare every database table separately against the folder or can i join the tables and compare them together agains the folder?
  16. Works like expected! I'd like to delete those images from the folder that appear in that list now. Would it be possible to use array_map to call the unlink function on $images? Or should i be looking at some other way of doing it? Thanks! laanes
  17. Hi dcro2 Thank you for your reply! I will give it a try now and get back to you with the results. Thank you for helping me to understand about declaring $clean_fetch as an array first. Also thanks for pointing out that i should only go after the first array index not all of them. Talk to you soon, Thanks
  18. I wrote a piece of code that lists images that don't have a match in the database: $dir_path = '../images/productImages'; $images = scandir($dir_path); $query = "SELECT image FROM Database_table ORDER BY name DESC"; $results = mysql_query($query); $output = "<h1>Missing Images</h1>"; $output .= "<div class=\"missingImages\">"; $output .= "<p>The following data was found in the Database_table.images field but not in /images/productImages:</p>"; $output .= "<div class=\"missingImg\">"; $output .= "<p class=\"fieldName\">Database_table.images:</p>"; while ($fetch = mysql_fetch_array($results)) { $clean_fetch = str_replace("productImages/", "", $fetch); $diff = array_diff($clean_fetch, $images); foreach (array_unique($diff) as $key => $value) { $output .= $value . "<br />"; } } $output .= "</div>"; $output .= "</div>"; echo $output; Works. Now I would like to check whether there are any files in the folder that are not in the database table. I thought it would be as easy as swapping the array_diff parameters around but it's not. When i swap the parameters like so - array_diff($images, $clean_fetch) it gives me a list of ALMOST all the images in the image folder, which i don't understand. Why does it not give me only the images that are present in the folder but not in the database?
  19. Hello, I am trying to build a query that looks into the number of products that are currently in stock, and if that is lower than the quantity entered in the cart then notify me that someone bought more items than in stock. What kind of fields should i link to connect products and orders table? There are: product_id, product_code and order_id in the orders table. product_id, product_code and stock_level in the products table. With thanks, laanes
  20. Many thanks sasa, This is the help i was looking for, trim does the trick indeed. All the best to you, laanes
  21. Hello, All the names in database are uppercase. Would like to run string formating functions before displaying them. $name = ucfirst(strtolower($results[$i]['name'])); It turns everything nicely into lowercase but doesn't capitalize the first letter. Why could that be? Best regards, laanes
  22. So.. something like $query = "SELECT * FROM " .$table. " WHERE 100, 200, 300 NOT IN " .$table. ".cat_id"; ? What would be a better way then?
  23. Hi, i've got a question in my head: How could i improve the WHERE clause in this query? : $query = "SELECT cat_name FROM " . $table . " WHERE cat_id != 300 AND cat_id != 200 AND cat_id != 100"; It works, but i can imagine when there will be more excluded categories, there will be a lot of AND's. Any way to make this query more decent? Kind regards, laanes
  24. Is this an effective way of accessing the $_GET and $_POST properties? I can see that the native $_GET function has been looped through so that $varName would be for example "username" and $value would be "Jeremy". Then they are both stored into an array called $getVars? Is this the best way of doing it, if not then why? foreach($_GET as $varName=>$value) $getVars[$varName]=trim(clean($value, 100)); foreach($_POST as $varName=>$value) $postVars[$varName]=trim(clean($value, 100));[/code] Kind regards, laanes
×
×
  • 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.