Jump to content

l3rodey

Members
  • Posts

    43
  • Joined

  • Last visited

Contact Methods

  • Website URL
    https://www.sitecentre.com.au/

l3rodey's Achievements

Member

Member (2/5)

1

Reputation

  1. Hi Guys, I have a URL that looks like this: www.example.com/category.php?cat_slug=whiskey/single-malt this shows up everything works fine... I have a htaccess file that is this: RewriteRule ^([0-9a-z-/-A-Z_-]+)?$ category.php?cat_slug=$1 [NC,L] This doesn't work but yet the product does... RewriteRule ^([0-9a-z-/-A-Z_-]+)/([0-9a-zA-Z_-]+)?$ product.php?cat_slug=$1&prod_slug=$2 [NC,L] Which looks like this www.example.com/whiskey/single-malt/haig-club-clubman-70cl once rewritten. The top example doesn't work though which should rewrite to www.example.com/whiskey/single-malt Why would the second one work but not the first one? Please don't get too technical here, I found the code online 2 years ago and have used it ever since. I don't actually understand what it does or why it does what it does, it just works... I know if I put it into a folder like shop/ so RewriteRule ^shop/([0-9a-z-/-A-Z_-]+)?$ category.php?cat_slug=$1 [NC,L] it will work, but for this website I don't want that... Please help me
  2. Thanks, I will look at this and see what I can find but how do I display data? I have the query setup as this: $query = " SELECT p.name , p.slug as prodslug , c.slug as catslug FROM FROM products p INNER JOIN categories c ON p.category_id = c.category_id WHERE p.status='1' AND p.featured='1' ORDER BY p.product_id LIMIT 12 "; if ($result = $liquor->query($query)) { while ($row = $result->fetch_assoc()) { ?> <li><a href="./<?php echo $row->catslug ?>/<?php echo $row->prodslug; ?>"><?php echo $row->name; ?></a></li> <?php } $result->free(); } ?> but nothing shows? what am I doing wrong with the displaying of data?
  3. Hey thanks man! and I am echoing how? <php echo $featured->prodslug; ?> is that correct is that how I echo it? And I am using mysql clearly what is the mysqli option? ( I'm super behind clearly ) just trying to learn.
  4. Hi guys, I am not very good with Joins, and thus I do things what most of you will call discusting. I already know this so go easy. Can someone help me with a join? I have googled it but don't understand as it's not my db. This is what I do. <?php $featuredProducts = mysql_query("SELECT * FROM products WHERE status='1' AND featured='1' ORDER BY product_id ASC LIMIT 12", $liquor); while ($featured = mysql_fetch_object($featuredProducts)) { $category = mysql_query("SELECT * FROM categories WHERE category_id=$featured->category_id LIMIT 1", $liquor); while ($cat = mysql_fetch_object($category)) { $slug = $cat->slug; } mysql_free_result($category); ?> <li><a href="./<?php echo $slug ?>/<?php echo $featured->slug; ?>"><?php echo $featured->name; ?></a></li> <?php } mysql_free_result($featuredProducts); ?> I need to build a URL so I need to know the category slug which is in the db, so I do another lookup make a valuable and use it... but I know you can do a join here and make this so much tidier. Can someone please show me how a join would make the above query proper?
  5. Thanks but this does not answer my question the slugs I am fine with that's great but reading inside the h2 then going back and editing that exact h2 is where I am stuck. I can make a slug that is fine but I am not sure how to read in php what is inside the h2 (then I will slug it) then edit the h2 that the text is in... This is where I'm stuck
  6. Hi Jacques, The PHP file that actually does the compression of HTML actually is a caching tool to cache it more so then compress it. The reason it compresses is to store a smaller cache file on our server more than anything else. It was not an SEO Strategy as such more of a speed issue. The auto-generated ID's is for Anchoring, Our site contains more than 300,000 pages and we are wanting to add a nice following side-bar that has the H2 elements on it and when clicked takes you to where you want to go. I know there is other methods of this but this is the way I wanted to go. I cannot go back and edit 300,000 pages to add the id manually so a PHP script is best.
  7. Hi everyone, Just had a quick question, ( I am not hard-core programmer just know my way around ). I have some PHP that runs in the back of my site that deletes stuff from my html before rendering, Like line breaks and comments to render smaller HTML it uses preg_replace() and str_replace() to do so. What I am wanting to do is something which I feel should be possible but need to know how. I have a <h2>This is the title</h2> On my page and I want to add the following and make it looks like this: <h2 id="this-is-the-title">This is the title</h2> I worked for hours this morning trying to work it out but failed to do anything all I can do is id="1" and + 1 every time and this is not what I want I want it to read the h2 and replace special char and spaces with -. Is there a way of doing this? Here is a couple of my preg_replaces and str_replaces already thee. $start_buffer = preg_replace('/" style=/', '"style=', $start_buffer); $start_buffer = preg_replace('/" class=/', '"class=', $start_buffer); $start_buffer = str_replace("; }", "}", $start_buffer); $start_buffer = str_replace("{ ", "{", $start_buffer); As you can see all this is really doing is removing spaces that are not required. Any help what so ever will be greatly appreciated.
  8. Hi guys, I am trying to play with reddit a little and redesign something ( personal use only ). I have this: $string_reddit = file_get_contents("http://reddit.com/.json"); $json = json_decode($string_reddit); $children = $json->data->children; foreach ($children as $child){ echo $child->data->title; } This get's me all the listing titles of the home page, if you look at the .json file... BUT I now want to get the actually listing so for example... http://www.reddit.com/r/pics/comments/3anqj9/today_my_dad_finally_decided_to_cash_this_chip_in/ That is top of the list right now, if I put .json after it... http://www.reddit.com/r/pics/comments/3anqj9/today_my_dad_finally_decided_to_cash_this_chip_in/.json You can see the file... My code doesn't work for that url though? If I replace the $string_reddit variable with that url it just errors out... What have I done wrong? Thanks in advance
  9. Same problem... <?php require_once '../inc/conn.php'; session_start(); if ($_POST['username']) { $username = $_POST['username']; $password = $_POST['password']; $requestLogin = $retreat->query("SELECT * FROM login WHERE username='$username' AND password='$password'"); while ($row = $requestLogin->fetch_assoc()){ $userID = $row['userID']; $_SESSION['userID'] = $userID; $username = $row['username']; $_SESSION['username'] = $username; header('location: /administrator/'); } } ?>
  10. if ($_POST['username']) { $username = $_POST['username']; $password = $_POST['password']; $requestLogin = $retreat->query("SELECT * FROM login WHERE username='$username' AND password='$password'"); while ($row = $retreat->fetch_assoc()){ $userID = $row['userID']; $_SESSION['userID'] = $userID; $username = $row['username']; $_SESSION['username'] = $username; header('location: /administrator/'); } } Gives out this error Fatal error: Call to a member function query() on a non-object in /home/**/**/**/**/login.php on line 11 Which is this line: $requestLogin = $retreat->query("SELECT * FROM login WHERE username='$username' AND password='$password'");
  11. Hi, I only just worked out (a little slow) that mysql is not redundant and crap =\ Apparently I should be using mysqli. However I need help I tried following a tutorial online but it failed. This is my login script and it doesn't work <?php require_once '../inc/conn.php'; session_start(); if ($_POST['username']) { $username = $_POST['username']; $password = $_POST['password']; $requestLogin = mysqli_query( $retreat, "SELECT * FROM login WHERE username='$username' AND password='$password'"); while($row = mysqli_fetch_array($requestLogin)){ $userID = $row['userID']; $_SESSION['userID'] = $userID; $username = $row['username']; $_SESSION['username'] = $username; header('location: /administrator/'); } } ?> And this is the conn.php ( something hidden for safety, however it does connect correctly. <?php $hostname = 'localhost'; $username = ''; $password = ''; $database = ''; $retreat = mysqli_connect($hostname, $username, $password, $database) or die('Connecting to MySQL failed'); ?> The actual <form> is also correct as it's just normal html and worked before I tried converting to mysqli. After this login I have a script which is this that goes in the header of all admin pages. <?php require_once '../inc/conn.php'; session_start(); if (isset($_SESSION['userID'])) { $username = $_SESSION['username']; $getUser = mysqli_query( $retreat, "SELECT user_rights FROM login WHERE username='$username'"); while($row = mysqli_fetch_array($getUser)){ $user_rights = $row['user_rights']; } } else { include_once 'login.php'; exit(); } ?> I am no coding professional by any means but I get the job done. However this mysqli is sort of new ground.
  12. Hi LeJack The $_Post is being checked because it is working except for the testimonial text area everything else is working. Also look it's a UPDATE not insert so theoretically they shouldn't be blank. This is also designed for an admin panel and everyone knows that the fields need to be put in so no blank data or validation needs to be done. The question is everything works except the testimonial name field.
  13. Can anyone tell me why this will not submit? It's pretty simple code and the reason there is an if else for whether it does a select or update is unrelated. It does however submit, Name, stars and location. However the testimonial will not update. If we update every field everything will update except for testimonial. The only difference I can see is testimonial is a textarea and an input field? Please help it's driving me crazy. if($_POST){ $name = $_POST['name']; $stars = $_POST['stars']; $testimonial = $_POST['testimonial']; $location = $_POST['location']; mysql_query("UPDATE testimonials SET name='$name', stars='$stars', testimonial='$testimonial', location='$location' WHERE testimonialID='$testimonialID'", $retreat); echo '<a href="./">Back Home</a> | <a href="./testimonials">Tesimonials</a><br><br>'; echo 'Yay, Successful. PS: There is no error handling so this really just means you submitted it.'; } else { $getTestimonial = mysql_query("SELECT * FROM testimonials WHERE testimonialID='$testimonialID' LIMIT 1", $retreat); while($row = mysql_fetch_array($getTestimonial)){ $testimonialID = $row['testimonialID']; $name = $row['name']; $stars = $row['stars']; $testimonial = $row['testimonial']; $location = $row['location']; } ?> <a href="./">Back Home</a> | <a href="./testimonials">Tesimonials</a><br><br> <form action="testimonials?p=edit&id=<?php echo $testimonialID; ?>" method="POST"> Name:<br> <input type="text" name="name" value="<?php echo $name; ?>"/><br><br> Stars:<br> <input type="text" name="stars" value="<?php echo $stars; ?>"/><br><br> Testimonial:<br> <textarea type="text" name="testimonial" ><?php echo $testimonial; ?></textarea><br><br> Location:<br> <input type="text" name="location" value="<?php echo $location; ?>"/> <input type="submit" name="submit" value="submit" /> </form>
  14. Hi guys, I never learnt joins, and this is what my code looks like as a result, Can someone just show me how to convert the following from 2 queries to one? It is a blog post and the second query is getting an author I have shortened it for convenience. Thanks in advance. $getBlogs = mysql_query("SELECT * FROM blogs WHERE blogStatus='1'", $retreat); while($row = mysql_fetch_array($getBlogs)){ $blogID = $row['blogID']; $authurID = $row['authurID']; } $getAuthor = mysql_query("SELECT * FROM blog_authurs WHERE authurID='$blogAuthur' LIMIT 1", $retreat); while($row = mysql_fetch_array($getAuthor)){ $authurName = $row['authurName']; }
  15. Hi, So I am building a keyword tracking tool for a friend, All in all it's pretty much done, But for the actual tracker in this case is www.example.com/tracker?keyword=This-is-a-keyword This has a $_GET which pulls the keyword, I also get the geolocation, ip, OS and browser. When my friend used adwords each keyword will link to tracker?keyword= then the keyword and yeah... pretty indepth backend to control it all. What I am wanting to do is run a sql lookup on the IP address each time someone visits it does a lookup in the views and sees if that user has had that keyword under that ip in the past 3 days, if yes then just adds another page view as I monitor how many views each user has done. If they have not seen that keyword in the last 3 days then it inserts it. The problem I am having is I don't know how to do they query this is what I have: $getVisitor = mysql_query("SELECT * FROM keywordViews WHERE ipaddress='$ipaddress' AND DATE(visitdate) BETWEEN DATE(NOW()) AND DATE(adddate(NOW(), INTERVAL 3-DAYOFWEEK(NOW()) DAY))", $tracker); while($row = mysql_fetch_array($getVisitor)) { $viewID = $row['viewID']; } I am not a pro, I get past guessing and trial and error, But I had this code writen for me months ago for another project so I tried to use it and change it but it fails... At this stage all I am trying to do is echo out the viewID for my IP address to see if it's outputting correctly and expand. Can someone please help me fix my query to check ipaddress is entered in keywordViews in the last 3 days if yes then do this if not then do something else? 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.