Jump to content

dachshund

Members
  • Posts

    312
  • Joined

  • Last visited

Everything posted by dachshund

  1. Is there any easier way to do it. For example something that says after 12th article show this advert div?
  2. very much appreciate your response! that's gone way over my head though - beyond my current capabilities I think
  3. Hi, On our blog homepage we currently have 12 articles displayed. After 12 articles, I could like to add in an advert, followed by another 12 articles. I just wondered if there's an easy way to do this? Here's our current code: $oldarticles = 12 * $pagenumber - 12; $sql = "SELECT * FROM content WHERE `live` LIKE '0' AND '$today' > `date` ORDER BY date DESC LIMIT $oldarticles,12"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ Thanks
  4. Hi, I have a query which selects posts that are trending (ie. have had more than 600 views after 2 hours of being live), but now I want to be able to add a little label to the trending posts that says "trending" if the ID is included in this query. Hopefully that makes sense. This is the query I have: $sql = "SELECT *, views / HOUR(TIMEDIFF(NOW(), date)) as avg FROM content WHERE date BETWEEN CURDATE() - INTERVAL 30 DAY AND NOW() - INTERVAL 2 HOUR AND views > 600 AND live = '0' ORDER BY avg DESC LIMIT 8";
  5. ok, tried that. in the txt file it says: 2015-07-06 17:42:07.4545 Usr: Rm: POST Get: Array ( => submit ) Post: Array ( [name] => Test => test@test.co.uk [trackingnumber] => test ) Ip: IP was here
  6. Hmm, ok I've testing it loads of times now and it's definitely not due to being clicked twice. Always sends two emails. Here's the full PHP code. I think there must be something that's triggering a double send in there. <?php include "header.php"; if($session){ ?> <div id="control_panel"> <div id="loggedon"> Control Panel </div> <div id="logout"> <a href="logout.php">Log Out</a> </div> <div class="clear"></div> </div> <div id="admin"> <?php include "admin_left_column.php"; ?> <div id="content"> <?php $submit = mysql_real_escape_string($_GET['s']); if ($submit == 'submit') { ?> <?php $email = mysql_real_escape_string($_POST['email']); $name = mysql_real_escape_string($_POST['name']); $trackingnumber = mysql_real_escape_string($_POST['trackingnumber']); $to = $email; $subject = 'Your Order Has Now Been Shipped'; if ($trackingnumber == '') { $message = '<html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="center" width="100%" style="padding:16px 0px;"> <img src="logo.jpg" /> </td> </tr> <tr> <td align="center" style="font-family:Times New Roman, Times; font-size:12.5px; color:#000; padding:16px 0px;"> '.$name.', your order has now been shipped and should arrive in the next few days.<br /><br /> For any addition information about your order, please email <a href="mailto:" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">store@</a> quoting your name and order date and we will reply to you as soon as possible.<br /><br /> Thank you,<br /> </td> </tr> </table> </body> </html>'; }else { $message = '<html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="center" width="100%" style="padding:16px 0px;"> <img src="logo.jpg" /> </td> </tr> <tr> <td align="center" style="font-family:Times New Roman, Times; font-size:12.5px; color:#000; padding:16px 0px;"> '.$name.', your order has now been shipped and should arrive in the next few days.<br /><br /> You can track your order <a href="http://www.royalmail.com/track-trace" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times; target="_blank">here</a> with reference number <u>'.$trackingnumber.'</u>.<br /><br /> For any addition information about your order, please email <a href="mailto:" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">store</a> quoting your name and order date and we will reply to you as soon as possible.<br /><br /> Thank you,<br /> </td> </tr> </table> </body> </html>'; } $headers .= "Content-type: text/html\r\n" . 'From: Store <noreply@blah.co.uk>' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> You have sent a confirmation email to <?php echo $name; ?> at email address <?php echo $email; ?>. <img src="tick.jpg"> <!-- Otherwise --> <?php } ?> <ul> <li> <form method="post" action="?s=submit" name="email" enctype="multipart/form-data"> Name* <p> <input type="text" class="text_input" name="name"> </p> <div class="input_section"> Email* </div> <p> <input type="text" class="text_input" name="email"> </p> <div class="input_section"> Tracking Number </div> <p> <input type="text" class="text_input" name="trackingnumber"> </p> </li> </ul> <div> <input type="submit" value="Send Confirmation" class="submit_order"> </div> </form> <div class="clear"></div> </div> <!-- END CONTENT --> <div class="clear"></div> </div> <?php }else { if(!$_POST['login']){ ?> <div id="login_title"> Admin </div> <div id="login"> <ul> <form method="post" action="#" name="login"> <li> Username <p><input type="text" name="username"></p> </li> <li> Password <p><input type="password" name="password"></p> </li> <li> <input type="submit" class="submit" value="Log In" name="login"> <div class="clear"></div> </li> </form> </ul> </div> <?php }else { $username = $_POST['username']; $password = $_POST['password']; if($username && $password){ $sql = "SELECT * FROM users WHERE `username`='$username'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 1){ $epass = md5($password); $sql2 = "SELECT * FROM users WHERE `username` = '$username' AND `password` = '$epass'"; $res2 = mysql_query($sql2) or die(mysql_error()); $rows = mysql_fetch_assoc($res2); if(mysql_num_rows($res2) == 1){ //success $_SESSION['admin'] = $rows['userid']; echo 'You are logged in as '; echo $username; echo '.'; }else { echo 'Wrong username and/or password'; } }else { echo 'Username does not exist.'; } }else { echo 'Please fill in all fields.'; } } } ?>
  7. Hi, yes it reloads and says "email sent successfully" - but perhaps you are right. On another note, the emails sent include this at the top of the body (picture attached). They didn't used to - any ideas why and how to get rid of it? Thanks in advance
  8. ok thanks for your help that page does show to the client, but only the echoed parts such as: echo ("<div id='completed'>Thank you for your order</div>"); echo ("<div id='completed_total'>Total payment amount: £$amount</div>\n");
  9. Hmm, that's very strange then. Thanks for pointing out potential shortenings of code. I'm having the same multiple email issue with this page, can you spot anything here? Here's all the code: <?php include "template/header.php"; ?> <?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-synch'; $tx_token = $_GET['tx']; $auth_token = "token is here"; $req .= "&tx=$tx_token&at=$auth_token"; // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // If possible, securely post back to paypal using HTTPS // Your PHP server will need to be SSL enabled // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); // read the body data $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets ($fp, 1024); if (strcmp($line, "\r\n") == 0) { // read the header $headerdone = true; } else if ($headerdone) { // header has been read. now read the contents $res .= $line; } } // parse the data $lines = explode("\n", $res); $keyarray = array(); if (strcmp ($lines[0], "SUCCESS") == 0) { for ($i=1; $i<count($lines);$i++){ list($key,$val) = explode("=", $lines[$i]); $keyarray[urldecode($key)] = urldecode($val); } // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment $firstname = $keyarray['first_name']; $lastname = $keyarray['last_name']; $itemname = $keyarray['item_name']; $amount = $keyarray['mc_gross']; $email = $keyarray['payer_email']; echo ("<div id='completed'>Thank you for your order</div>"); echo ("<div id='completed_total'>Total payment amount: £$amount</div>\n"); } else if (strcmp ($lines[0], "FAIL") == 0) { // log for manual investigation } } fclose ($fp); $to = $email; $subject = 'Confirmation of order from our store'; $message = '<html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="center" width="100%" style="padding:16px 0px;"> <img src="image link" /> </td> </tr> <tr> <td align="center" style="font-family:Times New Roman, Times; font-size:12.5px; color:#000; padding:16px 0px;"> '.$firstname.' '.$lastname.', thank you for your order from the store.<br /><br /> You should shortly receive an email from Paypal with your full order details.<br /> For any information about your order, please email <a href="mailto:email" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">email</a> quoting your Paypal Transaction ID and we will reply to you as soon as possible. For delivery information <a href="address" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">click here</a>.<br /><br /> Thank you. </td> </tr> </table> </body> </html>'; $headers .= "Content-type: text/html\r\n" . 'From: HUH. Store <email>' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> <div id="completed_text"> Your transaction has been completed and a confirmation email has been sent to you.<br />For more information about your order please email <a href="mailto:email">email</a>. For information about delivery times please <a href="email">click here</a>. </div> <?php include "template/footer.php"; ?>
  10. Hi, We have a PHP email form but when it's submitted it sends to the recipient three or four times. I've put the form below, if you can see any errors please let me know. Thanks, <div id="content"> <?php $submit = mysql_real_escape_string($_GET['s']); if ($submit == 'submit') { ?> <?php $email = mysql_real_escape_string($_POST['email']); $name = mysql_real_escape_string($_POST['name']); $trackingnumber = mysql_real_escape_string($_POST['trackingnumber']); $to = $email; $subject = 'Your Order Has Now Been Shipped'; if ($trackingnumber == '') { $message = '<html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="center" width="100%" style="padding:16px 0px;"> <img src="image address" /> </td> </tr> <tr> <td align="center" style="font-family:Times New Roman, Times; font-size:12.5px; color:#000; padding:16px 0px;"> '.$name.', your order has now been shipped and should arrive in the next few days.<br /><br /> For any addition information about your order, please email <a href="mailto:our email" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">our email</a> quoting your name and order date and we will reply to you as soon as possible.<br /><br /> Thank you,<br /> </td> </tr> </table> </body> </html>'; }else { $message = '<html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="center" width="100%" style="padding:16px 0px;"> <img src="image address" /> </td> </tr> <tr> <td align="center" style="font-family:Times New Roman, Times; font-size:12.5px; color:#000; padding:16px 0px;"> '.$name.', your order has now been shipped and should arrive in the next few days.<br /><br /> You can track your order <a href="http://www.royalmail.com/track-trace" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times; target="_blank">here</a> with reference number <u>'.$trackingnumber.'</u>.<br /><br /> For any addition information about your order, please email <a href="mailto:our email" style="color:#39c; text-decoration:none; font-family:Times New Roman, Times;">our email</a> quoting your name and order date and we will reply to you as soon as possible.<br /><br /> Thank you,<br /> </td> </tr> </table> </body> </html>'; } $headers .= "Content-type: text/html\r\n" . 'From: Store Name <email@email.com>' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> <?php } ?> <ul> <li> <form method="post" action="?s=submit" name="email" enctype="multipart/form-data"> Name* <p> <input type="text" class="text_input" name="name"> </p> <div class="input_section"> Email* </div> <p> <input type="text" class="text_input" name="email"> </p> <div class="input_section"> Tracking Number </div> <p> <input type="text" class="text_input" name="trackingnumber"> </p> </li> </ul> <div> <input type="submit" value="Send Confirmation" class="submit_order"> </div> </form> <div class="clear"></div> </div>
  11. Hi, I'm having a bit of trouble. I want to order the same 9 results by RAND(). Currently I have them ordered by 'avg' (average views) and that's working fine, but when I add a sub query to make those 9 results scatter by random it's causing some trouble. Code I currently have that works: $sql = "SELECT *, views / HOUR(TIMEDIFF(NOW(), date)) as avg FROM content WHERE date BETWEEN CURDATE() - INTERVAL 30 DAY AND NOW() - INTERVAL 2 HOUR AND views > 600 AND live = '0' ORDER BY avg DESC LIMIT 9"; What I'm trying to achieve but isn't showing any results: $sql = "SELECT * FROM (SELECT *, views / HOUR(TIMEDIFF(NOW(), date)) as avg FROM content WHERE date BETWEEN CURDATE() - INTERVAL 30 DAY AND NOW() - INTERVAL 2 HOUR AND views > 600 AND live = '0' ORDER BY avg DESC LIMIT 9) ORDER BY RAND()";
  12. Hey. Everything in the last 60 minutes would be ideal, although if it is easier just everything in since 11am (if the time is 11:29am).
  13. sorry, me again. it is possible to exclude any articles posted in the last hour?
  14. ah ok, perfect! that works. is there a way to echo out the articles and order them by $averageviews. For example, I have this at the moment. Obviously it doesn't work but hopefully gives you an idea of what I am trying to achieve: $format = 'Y-m-j G:i:s'; $date = date ( $format ); // - 7 days from today $minus3 = date ( $format, strtotime ( '-7 day' . $date ) ); $sql = "SELECT * FROM content WHERE `live` LIKE '0' AND `date` > '$minus3' ORDER BY `views` DESC LIMIT 8"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ $hrs = floor((time() - strtotime($rows['date'])) / 3600); $averageviews = $rows['views'] / $hrs; $sql = "SELECT * FROM content WHERE `live` LIKE '0' AND `date` > '$minus3' ORDER BY '$averageviews' DESC LIMIT 8"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ }
  15. I tried the code below but it didn't echo out anything. $now = new DateTime(); $pubTime = new DateTime('2014-05-26 05:19:00'); $diff = $now->diff($pubTime); $hrs = $diff->days * 24 + $diff->h; //--> 249 echo $hrs;
  16. Thanks for your help so far. The data I have to work with per article is. Total views to date Datetime post was published So what I need to do is take the "datetime post was published" from the current time, work out how many hours there have been since it was published, divide the "total views to date" by the hours. This will give me the average amount of views per hour. Any help with that would be greatly appreciated!
  17. Hi, I have a blog which records the amount of views on each article. I now want to be able to work out the average number of views per hour. How can I work out the number of hours passed from a datetime format? From there I can just do views divided by hours passed. Thanks in advance!
  18. ok i worked it out, it's: $sql = mysql_query("SELECT SUM(views) AS sum FROM table WHERE `date` >= SUBDATE(CURRENT_DATE, 2) AND `date` <= SUBDATE(CURRENT_DATE, 0)");
  19. I have a piece of code which adds up all of the 'views' column from rows added in the past 1 day. I now need a piece of code which adds up all of the 'views' column from rows added the day before that. Any help would be great. Here's my current code. $sql = mysql_query("SELECT SUM(views) AS sum FROM table_name WHERE `date` >= SUBDATE(CURRENT_DATE, 1)");
  20. Hi, In my current online store the basket stores the item's ID and size (1,2,3,4,5) in an array, which can then be echoed back out when the customer is on the basket page before checkout. So the array would look something like this - 918s2,967s3 (the 2 and the 3 being the size). For christmas I now want to add gift cards, for which I need to be able to save the customer's email and personal message in the basket as well. Does anyone have any ideas how I could do this? Thanks,
  21. Like you say "The quality of the responses received is directly proportional to the quality of the question asked." I was always trying to achieve what vinny has helped me do. Sorry if I worded my question badly at first.
  22. thanks vinny, I was echoing out tag_one instead of just tag. thanks for your help.
  23. Psycho, that is not what I am trying to achieve. Let me try to better word this. I'm trying to echo the DISTINCT values from three different columns Like this - SELECT DISTINCT tag1 FROM table - but instead of just tag1 I want it to be tag1, tag2, and tag3.
×
×
  • 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.