Jump to content

cobusbo

Members
  • Posts

    224
  • Joined

  • Last visited

About cobusbo

  • Birthday 01/30/1991

Profile Information

  • Gender
    Male
  • Location
    South Africa, Western Cape
  • Age
    24

cobusbo's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

1

Community Answers

  1. As requested I've tried something new with time() <html> <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); $targetDate = new DateTime('2016-04-01 20:59:00'); $remaining = $targetDate->diff(new DateTime()); $now = time(); // not done if( $now > $targetDate ) { echo $remaining->format('%a D - %H:%I:%S'); //--> 86 D - 19:44:24 } // done else { header("Location: testlogin.php"); exit(); } ?> </html>
  2. That's just an example date I've tested it with current date and time
  3. Hi I'm trying to use my countdown timer to do a certain action when time is reach in this example I want to point users to another page, but seems like I'm going wrong somewhere along the way. When it reaches 0 it just starts counting up from 0 <html> <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); $targetDate = new DateTime('2016-09-29 23:00:00'); $remaining = $targetDate->diff(new DateTime()); // not done if( $remaining > 0 ) { echo $remaining->format('%a D - %H:%I:%S'); //--> 86 D - 19:44:24 } // done else { header("Location: testlogin.php"); exit(); } ?> </html>
  4. Hi I'm trying to run a cron here to remove profile pictures delete users delete private messages delete messages but I need some help to make my code more clean and effective <?php include("chat_code_header.php"); //// Delete profile pictures and users id older than 30 days//// $querybd = "SELECT Username, last_online, pprofilepic FROM Users2 WHERE last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; $resultbd = mysql_query($querybd) or die(mysql_error()); $users = array(); while($rowbd = mysql_fetch_array($resultbd)){ if ($rowbd['Username'] != '') $users[] = $rowbd['Username']; if($rowbd['pprofilepic'] == ""){}else{ $pprofilepic = realpath($rowbd['pprofilepic']); print "\n Pictures Removed:\n" . $pprofilepic . "\n"; unlink($pprofilepic); } } $list = implode('; ', $users); if($list == ""){printf ("Nobody Removed\n");}else{ print "\n Users Removed:\n" . $list . "\n"; } printf("Users Deleted: %d\n", mysql_affected_rows()); $sqldel = "DELETE Users2, StringyChat, pm, namechanges, kicksamount, broadcast, timeban FROM Users2 LEFT JOIN StringyChat ON Users2.mxitid = StringyChat.StringyChat_ip LEFT JOIN pm ON Users2.mxitid = pm.mxitid LEFT JOIN namechanges ON Users2.mxitid = namechanges.userid LEFT JOIN kicksamount ON Users2.mxitid = kicksamount.mxitid LEFT JOIN broadcast ON Users2.mxitid = broadcast.mxitid LEFT JOIN timeban ON Users2.mxitid = timeban.mxitid WHERE Users2.last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; mysql_query($sqldel) or die("Error: ".mysql_error()); //// end of removal/// //// removal of messages//// $query = "DELETE FROM StringyChat WHERE StringyChat_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query); printf("Messages deleted: %d\n", mysql_affected_rows()); //// removal of private messages//// $query1 = "DELETE FROM pm WHERE time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query1); printf("Private Messages deleted: %d\n", mysql_affected_rows()); ?>
  5. I know it would had been much easier to store it seperatly but the info is already stored like that for 900+ users so it will be difficult to reconfigure it like that without losing info and all the info is placed into an array by retrieving a header $_SERVER["HTTP_X_MXIT_PROFILE"]; so its not me cramming it all together
  6. Hi I got a column in my database containing profile information in an array form, but I want to select a specific part the gender of the person from the column and count the males and female values My database column contains the value en,ZA,1991-01-30,Male,1 I know I can explode the values like this $str = explode(',', $query); $answ = $str[3]; but I don't know how to implement it for the database to count the amount of values named Male and Female
  7. Yes I'm trying to run the script as a cron job every 24h http://xxxxxxxx/chat2/profile/images/resized_1380_1448867798.jpg Do I need to include the full path to unlink the file because in the previous I had a file in the profile folder which I just included the $rowbd['pprofilepic'] I will only be able to test the rest of the codes you gave me once there is a user to remove with an image
  8. Not helping <?php include("chat_code_header.php"); $querybd = "SELECT Username, last_online, pprofilepic FROM Users2 WHERE last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; $resultbd = mysql_query($querybd) or die(mysql_error()); $users = array(); while($rowbd = mysql_fetch_array($resultbd)){ if ($rowbd['Username'] != '') $users[] = $rowbd['Username']; if($rowbd['pprofilepic'] == ""){}else{ $pprofilepic = "./profile/".$rowbd['pprofilepic']; print "\n Pictures Removed:\n" . $pprofilepic . "\n"; unlink($pprofilepic); } } $list = implode('; ', $users); if($list == ""){printf ("Nobody Removed\n");}else{ print "\n Users Removed:\n" . $list . "\n"; } printf("Users Deleted: %d\n", mysql_affected_rows()); $sqldel = "DELETE Users2, StringyChat, pm, namechanges, kicksamount, broadcast, timeban FROM Users2 LEFT JOIN StringyChat ON Users2.mxitid = StringyChat.StringyChat_ip LEFT JOIN pm ON Users2.mxitid = pm.mxitid LEFT JOIN namechanges ON Users2.mxitid = namechanges.userid LEFT JOIN kicksamount ON Users2.mxitid = kicksamount.mxitid LEFT JOIN broadcast ON Users2.mxitid = broadcast.mxitid LEFT JOIN timeban ON Users2.mxitid = timeban.mxitid WHERE Users2.last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; mysql_query($sqldel) or die("Error: ".mysql_error()); $query = "DELETE FROM StringyChat WHERE StringyChat_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query); printf("Messages deleted: %d\n", mysql_affected_rows()); $query1 = "DELETE FROM pm WHERE time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query1); printf("Private Messages deleted: %d\n", mysql_affected_rows()); ?> and output is as follow
  9. Hi im running a script to remove files from a directory but seems like I'm doing something wrong with the paths to the file First let me start with the field in my database. its stored as images/filename.jpg The fulle path to the file is chat2/profile/images/filename.jpg The file with the script im trying to run is in the chat2 folder I got the following stored in my script $pprofilepic = "../profile/".$rowbd['pprofilepic']; unlink($pprofilepic); but im getting the error
  10. Hi I have 2 tables I need to update according to the value of the 3rd table field currently I do 2 queries but I'm sure there must be a way to make it 1 query query 1 $sql = "UPDATE Room_users INNER JOIN Users2 u ON u.mxitid = Room_users.mxitid SET Room_users.User = u.Username"; query 2 $sql = "UPDATE Rooms INNER JOIN Users2 u ON u.mxitid = Rooms.mxitid SET Rooms.creator = u.Username"; How can I turn this into 1 query?
  11. $sql = "UPDATE `Room_users` SET `kick` = :kick WHERE kick < UNIX_TIMESTAMP()"; So this is my update query, normally I store the time in the kick field in unix format but there is cases where I store the value "Permanently" in that field as well is there a way to change the query to do nothing if the field value is "Permanently" but if the value is unix time then it should update the query?
  12. Ah sorry I found my problem I had $mod conflicting with another $mod
  13. Hi I'm trying to change my script from mysql to PDO but im struggling Here is my old Mysql code $queryadmin = "SELECT mxitid FROM Users2 WHERE rank = 1"; $resultadmin = mysql_query($queryadmin) or die(mysql_error()); $admin = array(); while($row = mysql_fetch_array($resultadmin)){ if ($row['mxitid'] != '') $admin[] = $row['mxitid']; } And here is my attempt to make it PDO $mod = "SELECT mxitid FROM Room_users WHERE Rank = 2"; $qmod = $conn->prepare($mod); $qmod->execute(); $qmod->setFetchMode(PDO::FETCH_ASSOC); $mod = array(); while ($rmod = $qmod->fetch()) { if ($rmod['mxitid'] != '') $mod[] = $rmod['mxitid']; } But it doesnt seem to work
×
×
  • 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.