Jump to content

xProteuSx

Members
  • Posts

    476
  • Joined

  • Last visited

Everything posted by xProteuSx

  1. I am extremely unfamiliar with date comparisons in MYSQL. I've googled it, and I cannot find anything (though I am sure there must be something out there) that works for my particular situation. Here it is: I have a 'timestamp' field in my database. The format of the field is like this: 2014-02-17 05:39:32 Now, I am trying to find all entries that are less than a month old. Here is what I have been able to find, but have not been able to make work: SELECT * FROM my_table WHERE tbl_time < date_sub(now(), interval 1 month); It does not seem to matter where I have either of these: SELECT * FROM my_table WHERE tbl_time < date_sub(now(), interval 1 month); SELECT * FROM my_table WHERE tbl_time > date_sub(now(), interval 1 month); Both of these queries return the same results. How can this be?
  2. Found ANOTHER dumb move on my part. nation.html was not accepting a variable named 'id'; it was looking for a variable named 'country'. I simply changed the rewrite rule to this: RewriteRule ^country/([0-9]+)-([a-z_-]+)/?$ nation.html?country=$1&title=$2 [L,NC] Now everything is peachy! Thanks guys.
  3. Man, I sure hope you guys can help me out with this one. I have tried to apply the dual mod-rewrite rules, and only the first works. However, each link is unique, so I don't see the problem. Here is what I've got for the two rules: RewriteRule ^country/([0-9]+)-([a-z]+)/?$ nation.html?id=$1&title=$2 [L,NC] # rewrite for country RewriteRule ^banknote/([0-9]+)-([a-z0-9_-]+)/?$ viewnote.html?id=$1&title=$2 [L,NC] # rwrite for banknote So the links for the first rewrite rule look like this: banknote/2634-cambodia-p5b-20-riels-from-1956 They work perfectly! The links for the second rewrite rule look like this: country/84-french-afars-and-issas This second link takes me to a 404. Also, I noticed something strange. When one of the 'country' links involves a country that has a single-word name (ie. Poland, Canada, Argentina) the link will take me to a 404, but the address bar will be the referring page. So, for example, if I have the link: country/2-france on page somepage.html, I will get a 404 error on somepage.html. However, if the 'country' link involves a country that has a multi-word name (ie. Papua New Guinea, New Zealand, United States) the link will take me to a 404, but will reflect the initial link. So, for example if I have the link: country/12-new-zealand on page somepage.html, I will get a 404 error on country/12-new-zealand. Anyways, I can't continue working on my project until I get this resolved, as it has almost completely killed the functionality of the site. Please help ASAP!! Its urgent. Thank you in advance.
  4. I am trying to track visitors by IP to certain pages on my site, but I would like to exclude bots/spiders. Is there any way to do this with php? Is there any way to do this without excluding bots/spiders to the site using the robots.txt file? Thanks in advance.
  5. That is fantastic. Thank you for actually writing an entire script ... that's awesome. So obviously you know what you're doing ... Now what if I am pulling the images from a mysql database using php? Can I just do a <?php echo $img; ?> within the javascript? Can I do this? echo "var images = ['" . $img1 . "', '" . $img2 . "'];";
  6. I have never done any jQuery programming before, and I am having a hell of a time finding a tutorial to do what I would like. Maybe I am looking for the wrong thing? I have this scenario: I have a product that has two or more images. I have one div where the product image is displayed. What I would like to do is have a 'next' and 'previous' button that cycles through the product images. I would love to use a professional gallery with transitions etc, but the image sizes vary, and so the div size must be dynamic like the image sizes. I was thinking of simply changing the contents of a div to change images. Something like this: <div id="imagediv"><img src="1.jpg" /></div> --> *next* button is clicked --> jQuery updates the div so that its contents become: <div id="imagediv"><img src="2.jpg" /></div> Is this possible? If the image sizes are different, is this possible? Cheers.
  7. Oh, I should mention that my links look like this: www.mysite.com/82-paper-money-from-equatorial-african-states Of course, this should display gallery number 82 (paper money from equatorial african states, which is sub-gallery number 82) but instead shows me product 82 on the page).
  8. So, I am learning tons about Mod Rewrite, but unfortunately I still cannot figure much of it out on my own, and I always seem to be searching Google for the wrong things. In this case, I would like to add some additional mod rewrite rules to my .htaccess file. In this case, which is different from my previous inquiries, I am looking to set up specific SEO friendly URLs for specific pages. So, for example www.mysite.com/booger_page.html --> www.mysite.com/all-about-boogers www.mysite.com/sleeve_wipe.html --> www.mysite.html/boogered-sleeves In this case there are no variables. I want to tell the server that when someone visits a regular .html page with no ?id=xxx and no ?id=xxx&title=xxx Also, I wanted to add a bunch of these, all different pages being re-directed to different SEO friendly URLs. How can I accomplish this?
  9. Hi guys! I am trying to expand on this mod_rewrite idea, and am trying to implement two rules. However, it seems as though only the first is being implemented, even for the second example. Here is what I have in my .htaccess file: ---------------------------------------------------------------------------- RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9]+)-([a-z0-9_-]+)/?$ viewnote.html?id=$1&title=$2 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9]+)-([a-z]+)/?$ nation.html?id=$1&title=$2 ---------------------------------------------------------------------------- Both link formats are the same. The first re-write rule is used to display specific products within a segment of the gallery. The second re-write rule is supposed to display a sub-segment of the gallery (in this case a country). Both rules utilize a numerical id (each product and each country both have a numerical value associated with them) and a descriptive title. How can I get mod_rewrite to differentiate between 'sub-segment of gallery' and 'specific product'?? At present, if I click on a link that is supposed to send me to a sub-gallery, it will send me to a specific product page if the id numbers for the product and the country are both the same, otherwise I get a MySQL error. ie. If the id number for the sub-gallery is 10, and a product with id number 10 exists then it sends me to product with id 10 page, instead of sub-gallery with id 10 page. ie. If the id number for the sub-gallery is 22, and there is no product with id number 22 then I get a MySQL error (because there is a MySQL query which requires a valid id). Cheers.
  10. Yay! I finally got it. Its probably so ridiculous that you guys never considered a human being who is smart enough to use a keyboard to be dumb enough to get this wrong: I was using links like this: mysite.com/viewnote.html?id=10000&title=armenia-p1-10-rubles-from-1919 Instead of using links like this: mysite.com/10000-armenia-p1-10-rubles-from-1919 I was under the impression that you had to have the prior to produce the latter. As it turns out, you skip that step and move right onto the latter link (SEO Friendly one). Cheers, and thank you very much.
  11. I'm kind of going to take a shot in the dark here, because I have to go right away, but I came up against this issue when I first started with sessions: If you want to use session variables on ANY PAGE, you have to use session_start(); on that page. So, you probably have a single page where all of these variables are created and set, but if you want to use those variables on another page, you have to simply include the session_start(); code at the top of that page. This will make all session variables available to any of the code on that page. Hoping that solves your problem. Cheers.
  12. Actually, the way I am trying to do things, and the way I thought I had it set up was a link like this: mysite.com/viewnote.html?id=10000&title=armenia-p1-10-rubles-from-1919 Would generate a URL like this: mysite.com/armenia-p1-10-rubles-from-1919 But it would also send the following to that page: $_GET["id"] = 10000; The ID should not show up in the SEO Friendly URL at all ... its in the original URL just so that the page that is being linked to actually has this value.
  13. Well, if you have all of your friends in an array (which is what it seem you have) then that is quite simple. <?php $friends = Friends::getFriendsForUser($data->id); $totalFriends = count($friends); echo 'I have ' . $totalFriends . ' following me.'; ?> Of course, that means that your friends are stalkers, unless you guys are at a parade.
  14. Just realized another thing. You said that the result was based on $_GET['cat_id'] but you were using $_GET['id'] in your query ...
  15. How about a "for" loop? for ($i = 0; $i <= 10; $i++) {echo "<li>" . $array[$i] . "</li>";} I don't recall, but that might display the first 11 items. If that is so, simply change "$i <= 10" to "$i < 10". Cheers.
  16. If you are new to WordPress, then you've probably dug a little too deep. WordPress can be quite confusing for someone who is new to it, and often changes and alterations are to be made from the Admin page, and not within the code of the theme itself. When you play with php within WordPress, unless you're experienced and/or careful, you're probably going to make a colossal blunder (in my experience). However, if you truly must play with the code then here is my take: This piece of code does have something to do with an image. However, this seems to set a bunch of variables, but does not actually produce any HTML which displays an image. It seems to me like either your question is too vague/confusing to me, or you're looking in the wrong place. As far as I can tell the last four lines of code basically check whether you have the rights and privileges required to set the main image. Sorry that I can't be of more help.
  17. What error do you get as output? You've got some error checking code in there, but you don't specify it to help us out. I suggest that you take a look at the MySQL query itself. As you've got it it is: $sql = "SELECT cat_name, cat_description FROM category WHERE cat_id = " . $_GET['id']; I think that might be the problem. Try something like this: $sql = " SELECT cat_name, cat_description FROM category WHERE cat_id = $_GET[id]"; I think the issue might have been your use of " and ' within the query. Hope this helps. Cheers!
  18. @Ch0cu3r Thank you for your reply. I have followed the instructions in your post (accurately, I think), but cannot achieve the desired result. Here is what I've got: .htaccess file: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9]+)-([a-z0-9_-]+)/?$ viewnote.html?id=$1&title=$2 Here is a sample of the formatting of my links: <a href="viewnote.html?id=10000&title=armenia-p1-10-rubles-from-1919">Click Here</a> When I click on the link I simply get: mysite.com/viewnote.html?id=10000&title=armenia-p1-10-rubles-from-1919 Ofcourse, the desired result is: mysite.com/armenia-p1-10-rubles-from-1919 (with the "id" being passed to that particular page so that the relevant content is displayed). Where have I gone wrong?
  19. And I have a couple more questions (THANK YOU FOR YOUR PATIENCE!!!) When we use this code which you've provided above: RewriteRule ^article/([a-z0-9-]+)$ article.php?slug=$1 [L] What the heck does "$1 [L]" mean?? Also, can I change to regex to [A-Za-z0-9-] so that I can use caps and lower case??
  20. Duh ... now I have just understood something: I need to change the URL's on the pages to something like: http://www.mysite.com/slug=this-page-is-awesome-1 and http://www.mysite.com/slug=this-page-is-awesome-2 etc. etc. then I can use the method above. However, I have come across another related issue. I still need to pass the product ID to the pages that we are going to, so that those pages can display the relevant content. So if I have a page, product.html, it takes a variable "id" and uses that to display the relevant content. The current URL is something like this: http://www.mysite.com/product.html?id=12345 If I change the URL to http://www.mysite.com/slug=this-page-is-awesome-1 then the PHP gets confused because I do not have a value for "id". Do I have to do this: http://www.mysite.com/slug=this-page-is-awesome-1&id=12345 Or is there something different that I can do?
  21. Thank you all for your replies. @neil.johnson: you are absolutely right -- I am looking to create 'SEO Friendly URLs'. I didn't even know that that was what they were called, so I have kind of been looking but maybe for the wrong things. Your explanation of it all is perfectly clear, and it has really opened my eyes quite a bit. I completely understand what you are referring to, as I have tried it on my site and have had success with your example. However, there is a slight twist to the data that I am pulling from the database to create this SEO Friendly URL, as I am pulling data from multiple fields end even a couple of different tables to create the 'slug'. So as it stands the particular page of the site goes something like this: http://www.mysite.com/product?id=12345 So obviously the slug is not in the URL. The slug is actually created on the page using PHP and is displayed as the page title. So maybe there is something that I am not understanding, or your example must be modified beyond my understanding, or both As it stands, here is the code which generates the title for the page, depending on the product id number: <title><?php echo $name . ' p' . $pick . ': ' . $denomination . ' ' . stripslashes($currency) . ' from ' . $year;?></title> Each of the variables used above is drawn from separate fields in the database and the variable $name is actually drawn from a separate table altogether. So, the issue as I see it is that I am unable to produce a URL that contains the desired 'slug' without doing some sort of crazy re-direct. The way I see it, the way to do this using your example is to do this: - set the mod-rewrite as you have it - go to page "http://www.mysite.com/product.html?id=12345" - this page would then generate the slug based on the id number 12345 (ie. http://www.mysite.com/info.html?slug=Azerbaijan-p18b-100-Manat-from-1993) - it would re-direct you http://www.mysite.com/azerbaijan-p18-100-manat-from-1993 Is this right? Is this the most efficient way to achieve this goal? Ultimately the goal is to have SEO Friendly URLs, but based on a string created from several fields in the database. Thank you in advance, and cheers.
  22. Hi guys, and thanks for your replies. I did not realize that you guys left some ideas here, and I re-posted this little mission of mine with some additional details here: http://forums.phpfreaks.com/topic/284295-php-generated-title-custom-url/ Ironically, the link above is almost exactly what I am trying to do (they made the title of the post part of the URL). What you guys have answered for me is great, but I guess I was not clear enough with the details as I am trying to use the page title (which is PHP generated from a MySQL database) to create the URL. Please refer to the topic above for details, and thank you for your input and help.
  23. I have a website where products each have two images that users are able to view. Currently the images are displayed one under the other on the page -- standard HTML type stuff. However, what I would ABSOLUTELY LOVE to have is something that displays 'image 1' then a mouseOver triggers 'image 1' to transform into 'image 2'. There is plenty of stuff like this on the web, however I have been unable to find something that allows for flexible sizing. This is crucial to me as the images are almost never the same exact dimensions, though they are generally quite close. Any ideas or suggestions? Pointers? Thanks ... I've been combing the interwebs for quite a while with no luck. Cheers.
  24. Hi folks I've got a bit of a whopper (I think), especially since I am really unfamiliar and uncomfortable with regex ... I have a website with 46,000+ products. For each product you get a URL that is something like this: http://www.mywebsite.com/viewitem.html?id=12345 Also, because the items are all in a MySQL database, I have PHP generate a <title></title> for each and every product, so for the link above it would be something like this: <title>Silly Shoes: Blue Laces Size 2</title> I would absolutely LOVE to know how to do something like this: MySQL Description -> PHP Title -> custom URL. I am looking to do somethink like what eBay does: http://www.ebay.com/itm/UK-SCOTLAND-10-Pounds-15-11-2007-CLYDESDALE-BANK-PLC-/ Except I would like a url like this: http://www.mywebsite.com/shoes/silly-shoes-blue-laces-size-2/ Is it possible to go from MySQL to PHP to custom URL in one shot? If so, how can I do this? As always, thank you in advance, and 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.