Jump to content

l3rodey

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by l3rodey

  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.
  16. noteID | jobID | note 1 | 1 | Testing note 2 | 1 | This is another note jobID | name 1 | John Brown This is my tables, Well what matters anyways, I need to show how many comments in this case 2 for john brown and show the number 2. 2 different tables one which hold all the jobs and one that holds the notes...
  17. Hi, go easy on me please, I am not a pro and I am more than likely doing this the incorrect way. $date = date('Y-m-d 07:00:00', strtotime('-24 hours')); $getJobs = mysql_query("SELECT * FROM jobs WHERE status='1' AND dateofenquiry>='$date'"); while ($row = mysql_fetch_array($getJobs)){ $clientName = $row['name']; $jobID = $row['jobID']; $getNotes = mysql_query("SELECT * FROM notes WHERE jobID='$jobID'"); if (mysql_num_rows($getNotes) == '0'){ $getJobsa = mysql_query("SELECT * FROM jobs WHERE status='1' AND dateofenquiry>='$date'"); $TotalNew = mysql_num_rows($getJobsa); } So this is a snippet of my code, I have a query $getJobs and it runs a fetch array I get the number of notes from another table and then If the job has 0 notes then send me an email, Where it is going wrong is $getJobsa and count rows, My table within the last 24 hours has 6 jobs. But only 1 should be showing as only 1 has 0 notes. But my email says 6 when I echo $TotalNew it shows all of them, I know it's within my query but I don't know how to count the notes and put it in a query. My question is how do I count the number of rows with the jobID as notes and add it to the 1 query?
  18. I have been given a script, and it is a SQL script, I paid for it to be written but I asked for it to be in mySQL and now I am stuck with this junk... Can someone please help me convert this to mySQL as I don't know anything about mySQL update Users set Users.Point = Users.Points +3 WHERE Users.userID in (select userID from Tips inner join Games on Tips.GameID = Games.GameID and Games.Status = 2 and Games.calculated = 0) Please someone help me
  19. Shouldn't be because that should only run from the last clause I ran? I think... If $getJobs = "SELECT * FROM jobs WHERE sent='0' and dateofenquiry<='$date'"; shouldn't that only run only where sent then I run a universal update? if not what about this? $updateJob = mysql_query("UPDATE jobs SET sent='1' WHERE sent='0' and dateofenquiry<='$date'", $conn); That still doesn't work that still updates every row...
  20. <?php require '../../scripts/conn.php'; //open db here $date = ('Y-m-d 00:00:00'); date_sub($date, date_interval_create_from_date_string('14 days')); $getJobs = "SELECT * FROM jobs WHERE sent='0' and dateofenquiry<='$date'"; $result = mysql_query($getJobs); while ($row = mysql_fetch_assoc($result)){ //send email $updateJob = mysql_query("UPDATE jobs SET sent='0'", $conn); if ($updateJob = true){ echo "Successful<br>"; }else { echo "Nope<br>"; } } ?> That is my code not work? When I run this it will update every single row, not just ones which are 14 days after... This is my table maybe that will help id | dateofenquiry | sent 1 | 2014-01-08 13:53:29 | 0 2 | 2013-12-03 00:00:00 | 0 3 | 2013-12-03 00:00:00 | 1 It updates 1 and 2 and leave 3 as sent is 1. But it updates both 1 and 2... it should only update 2 as the timestamp is older then 14 days... and the first date stamp is 2 days? Help I'm crying to why this is not working.
  21. Warning: date_sub() expects parameter 1 to be DateTime, string given in /filename/ on line 5 date_sub($date, date_interval_create_from_date_string('14 days')); That is line 5
  22. Hi Thanks what about this? <?php //open db here $date = date('Y-m-d'); date_sub($date, date_interval_create_from_date_string('14 days')); $query="SELECT * FROM mytable WHERE sent=0 and completed<='$date'"; $result = mysqli_query($link, $query); while ($row=mysqli_fetch_assoc($result)){ //send email } ?> completed is the table row which is a timestamp in the database, Is this correct? It's clearly hard to test without waiting it out...
  23. I need to be able to send an email with PHP after 2 weeks of my timestamp for example my database looks like this: clientID | timestamp | sent 01 | 2014-01-10 | 0 02 | 2014-01-08 | 1 so sent 0 means it has not been sent, 1 means it has, so I will run a php code through a cron job and I need it to be able to check the time stamp if it's 2 weeks after the timestamp to do the following: which I will write I just don't know how to check it the time stamp is over 2 weeks or a 1 week even or anything I have never tried to do this kind of coding before. If someone could help it would be really cool!
  24. Still fails I get this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/therma/public_html/booking/invoice/month.php on line 4 and Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in/home/therma/public_html/booking/invoice/month.php on line 34 The lins are 3. $getEnquiries = mysql_query("SELECT * FROM jobs WHERE userID='$userID' AND MONTH(date) = 4", $thermadoor); 4. $TotalEnquiries = mysql_num_rows($getEnquiries); and 34. while($row = mysql_fetch_array($getEnquiries)) { $clientName = $row['name']; $clientPaid = $row['paid']; $clientPrice = $row['price']; $clientPrice = number_format($clientPrice); $jobID = $row['jobID']; $clientStatus = $row['status']; Not sure what is going on
  25. Hi Everyone, I am having a little trouble, I have not actually done this before or ever tried it which is why I am struggling so much, I am wanting to order a query via month. For example my database looks like this: jobID (int) name (varchar 255) date (timestamp) for example there is 200 results there is 50 each month for the past 4 months... I want to filter the results by just this month so I want: $getEnquiries = mysql_query("SELECT * FROM jobs", $connection); $TotalEnquiries = mysql_num_rows($getEnquiries); So I am running a query now I can display the results I want fine which is all 200 at the moment, I also get the total number and echo that out later to how many enquiries there are. I tried this which I found on google SELECT * FROM jobs WHERE MONTH(current_time) = 4 But yeah... nothing is displaying so I am not sure I don' tactually know what that is doing... Yeah... I honestly just don't know what to do and how to do it... It needs to be via month from 1-29,30,31 and it needs to know the dates... sort of thing... Yep donno. Once I get help on this I will try and work out the week one. If your going to post code please comment what it is this is really confusing.
×
×
  • 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.