Jump to content

Hobbyist_PHPer

Members
  • Posts

    119
  • Joined

  • Last visited

Posts posted by Hobbyist_PHPer

  1. Hi, I have a bit of an issue with my application, I didn't notice until today, Sunday... Apparently PHP sees Sunday as the first day of the week, which I cannot fathom where it got hat notion from... but anyway, so I have the following samples of my code:

        $mondayoflastweek = date('Y-m-d H:i:s', strtotime('monday last week'));
        $sundayoflastweek = date('Y-m-d 23:59:59', strtotime('sunday last week'));
    

     

    The crazy and very troublesome thing about the results of that code is that if you run that today, Sunday, it shows today as last week... So therefore, the next bit of code is just as problematic:

        $mondayofthisweek = date('Y-m-d H:i:s', strtotime('monday this week'));
        $sundayofthisweek = date('Y-m-d 23:59:59', strtotime('sunday this week'));
    

     

    As you can imagine, for payroll, this is causing a big problem... My week starts at precisely 12:00 am on Monday and ends at precisely 11:59 pm on Sunday...

     

    Could someone please help me out with this...

  2. Hi, I have a jQuery function that loads a page inside of a DIV, that page shows an availability status button, only when that status is set to available, the status button becomes a link... here's that link...

        if ($row['AgentLoggedState'] == "available")
        {
            echo '<a href="javascript:void(0);" onclick="showElem(\'RedeemAuthorizationCode\');"><img src="http://xxxxxxxx.xxx/images/status_'.$row['AgentLoggedState'].'.png" alt="'.$row['AgentLoggedState'].'" /></a>';
        }
        else
        {
            echo '<img src="http://xxxxxxxx.xxx/images/status_'.$row['AgentLoggedState'].'.png" alt="'.$row['AgentLoggedState'].'" />';
        }
    

     

    Then on the main page, I have these 2 jQuery functions...

    <?
    session_start();
    include '../../connection.inc';
    $query = "SELECT AgentLoggedState FROM Agents WHERE AgentID = '1'";
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result)
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
            <link href="http://xxxxxxx.xxx/StyleSheet.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript">
            var showElem;
            showElem = function( showID ) {
            div = (( document.getElementById ) ? document.getElementById( showID ) : document.all[ showID ] );
            try {
            div.className = (( div.className === "hide" ) ? "show" : "hide" );
            } catch( e ) {
            div.style.display = (( div.style.display === "none" ) ? "block" : "none" );
            }
            };
            </script>
            <script src="http://code.jquery.com/jquery-latest.js"></script>
            <script>
            $(document).ready(function() {
                    $("#responsecontainer").load("../../response.php");
            var refreshId = setInterval(function() {
                $("#responsecontainer").load('../../response.php');
            }, 1000);
            $.ajaxSetup({ cache: false });
            });
            </script>
        </head>
    

     

    What I need to happen is, when this link, <a href="javascript:void(0);" onclick="showElem(\'RedeemAuthorizationCode\');">, is clicked, I need the main page to first reload, so that it can fire the PHP/MySQL query prior to showing the hidden DIV...

     

    Any suggestions would be greatly appreciated... Thank You

  3. I figured it out... Yeah!

     

    $RequestMadeDateTime = date('Y-m-d H:i:s', strtotime($row['RequestMadeDateTime']));
    $currentDateTime = date('Y-m-d H:i:s');
    
    echo 'Request Made Date Time: ' . $RequestMadeDateTime . '<br />
        Current Date Time: ' . $currentDateTime . '<br /><br /><br />';
    
    $theRequestMadeDateTime = strtotime($RequestMadeDateTime);
    $theCurrentDateTime = strtotime($currentDateTime);
            
    echo 'Request Made Date Time: ' . $theRequestMadeDateTime . '<br />
        Current Date Time: ' . $theCurrentDateTime . '<br /><br /><br />';
    
    $theDifferenceInSeconds = 600 - ($theCurrentDateTime - $theRequestMadeDateTime);
    
    if ($theDifferenceInSeconds > 60)
    {
        $minutesLeft = (floor ($theDifferenceInSeconds / 60));
        $secondsLeft = $theDifferenceInSeconds - ($minutesLeft * 60);
    }
    else
    {
        $minutesLeft = 0;
        $secondsLeft = $theDifferenceInSeconds;
    }
    
    echo 'Minutes Left: ' . $minutesLeft . '<br />
        Seconds Left: ' . $secondsLeft . '<br /><br /><br />';
    

  4. It expects a DateTime object. it has nothing to do with the fact that your mysql datatype is datetime or not.

     

    Oh, I feel stupid... the PHP docs weren't very intuitive on this function... Don't suppose you have a quick and dirty solution at the top of your head, do ya, for getting the difference in minutes and seconds? If not, that's cool... I'll keep searching and playing....

  5. Hi, so I am trying to get how many minutes and seconds are left from the datetime entry in the database and the current datetime, but I'm having issues...

     

    Here's my code:

    $query = "SELECT RequestMadeDateTime FROM TempAwaitingClients WHERE PSOID = '2'";
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $RequestMadeDateTime = $row['RequestMadeDateTime'];
    $currentDateTime = date('Y-m-d H:i:s');
    echo 'Request Made Date Time: ' . $RequestMadeDateTime . '<br />';
    echo 'Current Date Time: ' . $currentDateTime . '<br />';
    echo date_diff($RequestMadeDateTime, $currentDateTime);
    

     

    What I'm getting those is this, "Warning: date_diff() expects parameter 1 to be DateTime" ... Which I don't get because both variables are DateTime...

  6. minutes = math.floor( seconds/60 );
    countseconds = seconds % 60;
    text = "You have " + minutes + ":" + ( countseconds < 10 ? "0" : "" ) + countseconds + " remaining.

     

    I appreciate your response, and it would seem that your code should work, but so much as even adding the minutes variable anywhere, breaks the function.

  7. Hi, I have a JQuery script that I am using part of, partially, and I could use some help with it... Right now it counts down and displays in seconds, I am hoping someone can show me how to make it display in minutes and seconds... Then the next function in it is a submit form function... that's the part that I'm not currently using, but need to for the next step... So, here's what I have...

     

                if ($row['CallTaken'] == "No")
                {
            ?>
                    <script>
                        $(function() {
                        var seconds = 600;
                        setTimeout(updateCountdown, 1000);
    
                        function updateCountdown() {
                            seconds--;
                            if (seconds > 0) {
                                $("#countdown").text("You have " + seconds + " seconds remaining");
                                setTimeout(updateCountdown, 1000);
                            } else {
                                submitForm();
                            } 
                        }
                        });
                        // Here the operator has not answered the call within 10 minutes, need to take action...
                        function submitForm() {
                        document.forms[0].submit();
                        }
                    </script>
            <?
                }
                else 
                {
                ?>
                    <script>
                        $(function() {
                        $("#countdown").text("You have accepted the call.");
                        });
                    </script>
                <?
                }
    

     

    The submit form section, I would like to know if that would allow me to put a hidden form in the page, name or id it, and then have that function submit it?

  8. Here's the whole page, it's rather small... :

    <?
    session_start();
    include 'includes/connection.inc';
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
            <script src="http://code.jquery.com/jquery-latest.js"></script>
            <script>
                finished = false;
                
                $(document).ready(function() {
                    setTimeout("Refresh()", 5000);
                });
                
                if (!finished) {
                    function Refresh() {
                        location.reload();
                    };
                }
            </script>
        </head>
        <body>
            <div>
                <?
                $query = "SELECT * FROM TempAwaitingClients WHERE PSOID = '{$_SESSION['user_id']}'";
                $result = mysql_query($query);
                $rowCounter = mysql_num_rows($result);
                if ($rowCounter > 0)
                {
                    while ($row = mysql_fetch_assoc($result))
                    {
                ?>
                finished = true;
                <?
                        // Condition is true, need to stop the page refreshes
                        echo '<iframe id="audiblealert" name="audiblealert" height="0" width="0" src="telephone-ring-4.wav"></iframe>';
                        echo '<a href="" target="audiblealert">Mute Ringer</a>';
                        echo 'Phone Number: ' . $row['ClientPhoneNumber'] . '<br />
                            Purchased Time: ' . $row['ClientPurchasedMinutes'] . ' minutes<br />';
                    }
                }
                else
                {
                    echo 'No Clients Yet.';
                }
                ?>
            </div>
        </body>
    </html>
    

  9. finished = <?php echo $somephpvar; ?>;

     

    I hope I understood you correctly, here's what I did, it did not work... :

                    while ($row = mysql_fetch_assoc($result))
                    {
                ?>
                finished = true;
                <?
                        // Condition is true, need to stop the page refreshes
                        echo '<iframe id="audiblealert" name="audiblealert" height="0" width="0" src="telephone-ring-4.wav"></iframe>';
                        echo '<a href="" target="audiblealert">Mute Ringer</a>';
                        echo 'Phone Number: ' . $row['ClientPhoneNumber'] . '<br />
                            Purchased Time: ' . $row['ClientPurchasedMinutes'] . ' minutes<br />';
                    }
    

  10. Hi, this is a bit of a PHP and a JQuery question, so I wasn't sure which forum to post it in, but here it is...

     

    I need a way to asynchronously change a jQuery variable with PHP when a condition becomes true, without user action.

     

    I have the following JQuery:

            <script src="http://code.jquery.com/jquery-latest.js"></script>
            <script>
                finished = false;
                
                $(document).ready(function() {
                    setTimeout("Refresh()", 5000);
                });
                
                if (!finished) {
                    function Refresh() {
                        location.reload();
                    };
                }
            </script>
    

     

    Then I have the following PHP code accessing the MySQL database every time the page refreshes... Here's that code:

                <?
                $query = "SELECT * FROM TempAwaitingClients WHERE PSOID = '{$_SESSION['user_id']}'";
                $result = mysql_query($query);
                $rowCounter = mysql_num_rows($result);
                if ($rowCounter > 0)
                {
                    while ($row = mysql_fetch_assoc($result))
                    {
                        // Condition is true, need to stop the page refreshes
                        echo '<iframe id="audiblealert" name="audiblealert" height="0" width="0" src="telephone-ring-4.wav"></iframe>';
                        echo '<a href="" target="audiblealert">Mute Ringer</a>';
                        echo 'Phone Number: ' . $row['ClientPhoneNumber'] . '<br />
                            Purchased Time: ' . $row['ClientPurchasedMinutes'] . ' minutes<br />';
                    }
                }
                else
                {
                    echo 'No Clients Yet.';
                }
                ?>
    

     

    Anyone have an suggestions or help?

     

    EDIT: I forgot to mention, it's the JQuery variable "finished" that I need to set to TRUE

  11. It's very easy to do this with jquery.

    Every time you post "It didn't work" without more explanation, God kills a kitten.

    When you post code without code tags, He just teases a puppy. But it's still sad.

     

    And when you reply to a post, the way you did to mine, I want to kill God, because he created you.

  12. Hi everyone, I'm new to AJAX, but I thought perhaps this question might fit in here...

     

    Currently I have a set up to where my webpage has a meta tag refresh of every 5 seconds, which queries the MySQL database to get the current Availability status of the employees... The employees simply update their status via a form to the MySQL database of, Available, On A Call, or Unavailable... Then that obviously is queried and shown on the webpage for their statuses...

     

    So my question is, is there a better way to do this, someway with AJAX perhaps that would make more sense, and if so, could you point me in the right direction? I have Googled by brain off searching for AJAX status buttons, but have yet to find anything... well, that's not Skype related anyway...

  13. Not sure how serious you are with that website. I will admit they so have good tutorials. But they also have problems with their teachings. If you'd like to readinto what I am saying, visit http://www.w3fools.com

    I post this for your learning

     

    Actually use it quite often, but I do use php.net as well, but thanks for info, I'll check it out...

  14. If you are looking to find the keys that are in both arrays, array_diff() is the exact opposite of what you want to use. Sounds like you will want to use array_intersect()

     

    Thank you, didn't find that function... that worked...

  15. Hi everyone... I have one last last question, for now anyway :)

     

    Ok, so I have 2 arrays with ProfileIDs in them, what I need to find are the ProfileIDs that are in both of them... From what I've researched, I can't find a PHP function that returns an array of keys or values from comparing more than one array...

     

    Example array:

    Array

    (

        [3] => 3

        [4] => 4

        [8] => 8

    )

  16. If you mean how do you get them into the query from PHP (I'm assuming they are integers)

    $sql = "SELECT ProfileID FROM table
    WHERE ProfileID IN (" . implode(",", $profile_id_array) . ")
    AND Interest IN (" . implode(",", $interest_array) . ")
    GROUP BY ProfileID HAVING COUNT(*) = " . count($interest_array);
    

     

    If you mean, how do you get them as a column returned by the query ...

    $sql = "SELECT ProfileID, GROUP_CONCAT(Interest SEPARATOR ',') AS Interests FROM table
    WHERE ProfileID IN (" . implode(",", $profile_id_array) . ")
    AND Interest IN (" . implode(",", $interest_array) . ")
    GROUP BY ProfileID HAVING COUNT(*) = " . count($interest_array);
    

    I guess that second statement is redundant since they will be the same as provided in the query.

     

    The Interests array are not integers, will that not work then?

  17. Here's what the SQL could look like. Execute this once to get all the matching profile IDs.

    SELECT ProfileID FROM table WHERE ProfileID IN (3, 4,  AND Interest IN (9, 8, 7, 6) GROUP BY ProfileID HAVING COUNT(1) = 4

    (That 4 is the number of interests.)

     

    This assumes the table has no duplicate rows.

     

    So how would I get the array values listed out like that in the array, in the query? (3, 4, 8) & (9, 8, 7, 6)

    The count I figure I can do sizeof() function to get that...

     

  18. Hello everyone... I have spent about 2 weeks trying to solve this problem... Here we go...

     

    I have an array of ProfileIDs that looks like this...

    Array

    (

        [3] => 3

        [4] => 4

        [8] => 8

    )

     

    I have a table that looks like this...

    ProfileID | Interest

     

    Every ProfileID could have multiple Interests, so multiple rows...

     

    What I need to do is query that table that searches for those ProfileIDs as well as second set of Array Values, called Interests, and some how end up with only those IDs that ONLY have ALL of the second set, the Interests, of Array Values...

     

    So here's an example of kind of where I'm at right now...

     

    $firstProfileID_Array[] = '';
    foreach ($RemainingProfiles_Array as $RemainingProfile_Member) {
        foreach ($Interest_Array as $Interest_Element) {
            $query = mysql_query("SELECT * FROM Interests WHERE ProfileID = '$RemainingProfile_Member' AND Interest = '$Interest_Element'");
            while ($row = mysql_fetch_assoc($query)) {
                $firstProfileID_Array[$row['ProfileID']] = $row['ProfileID'];
            }
        }
    }
    

     

    But what that leaves me with, as I'm sure you can imagine, is a list of all ProfileIDs that contain AT LEAST ONE of the Interests...

  19. 5.0.92-community

     

    Hi everyone, I'm trying to create a simple match making site, and I've come across a problem in which I can't figure out the logic for...

     

    There's the following tables:

    Profiles

        ProfileID

        ProfileSexType

     

    FantasyTypes

        FantasyType

     

    Fantasies

        Fantasy

     

    ProfilesSeekingSexTypes

        ProfileID

        ProfileSeekingSexType

     

    ProfilesFantasyTypes

        ProfileID

        FantasyType

     

    ProfilesFantasies

        ProfileID

        Fantasy

     

    The problem comes into when I want to search for profiles that meet selected criteria... So like this first part of the query matches the sex of the person they are looking for and the sex of person that the other person is looking for...

     

                            $FantasyType_Array = $_POST['FantasyType'];
                            $Fantasy_Array = $_POST['Fantasy'];
                            $query = mysql_query("SELECT Profiles.ProfileID FROM Profiles LEFT JOIN ProfilesSeekingSexTypes ON Profiles.ProfileID = ProfilesSeekingSexTypes.ProfileID WHERE Profiles.ProfileSexType = '{$_POST['ProfileSexType']}' AND ProfilesSeekingSexTypes.ProfileSeekingSexType = '{$_POST['ProfileSeekingSexType']}'");
                            while ($row = mysql_fetch_assoc($query)) {
                                $RemainingProfiles_Array[] += $row['ProfileID'];
                                
                            }
                            echo '<pre>';
                            print_r($RemainingProfiles_Array);
                            echo '</pre>';
    

     

    Now the part that I can't seem to figure out the logic for is, how do I narrow those results down to those ProfileIDs that have the "FantasyType" and the "Fantasy" matches? Obviously the other person's profile can contain other criteria, but it must contain at least the criteria that the person is searching for... As you can see from the tables, a profile can have many "ProfilesFantasyTypes" and many "ProfilesFantasies"

  20. MySQL Version --> 5.0.76-standard

     

    Hi everyone, I have a situation which I'm sure can't be that uncommon, but here it is... I have a front end web server where I run "Software as a Service" application, which utilizes a backend MySQL server... For security reasons, I don't have any other services running on the MySQL server, other than MySQL...

     

    I have a private network between the 2 servers, the front end server is 192.168.1.2 and the MySQL server is 192.168.1.3

     

    The way my Software as a Service application operates is that each client has their own database and their own database user, so each time that a client signs up, the way that I currently have to go about setting them up is to SSH in and perform the following commands:

     

    mysql> create database attorney_thedatabasename;
    
    mysql> grant all privileges on attorney_thedatabasename.* to attorney_thedatabasename@192.168.1.2 identified by "thepassword";
    
    mysql> use attorney_thedatabasename;
    
    mysql> source acsdumpfile.sql;
    
    mysql> INSERT INTO `Users` (`UserID`, `UserName`, `UserPassword`, `UserEmail`, `UserFirstName`, `UserLastName`, `UserType`, `UserPermissionAdd`, 
    
    `UserPermissionEdit`, `UserPermissionDelete`, `UserPermissionAdministrate`, `UserDirectory`, `UserDatabase`, `UsersCustomerID`) VALUES
    (6, 'Admin', '014605b3bc77b3077b3ebd31a9917e34', 'Admin', '', '', '', 0, 0, 0, 1, 'thedatabasename', 'thedatabasename', thecustomerid);
    

     

    It's not that, that is such a horrible thing, but I would much prefer a graphical interface, especially being able to see the databases, users and tables... So I was wondering, does anyone know of a GUI that I can install on my front end server, that will perform the above mentioned necessities, via remote access?

  21. I thought I found a solution... I opened /etc/my.cnf and edited it to this...

     

    [mysqld]

    user=mysql

    pid-file=/var/run/mysqld/mysqld.pid

    socket=/var/run/mysqld/mysqld.sock

    port=3306

    basedir=/usr

    datadir=/var/lib/mysql

    tmpdir=/tmp

    language=/usr/share/mysql/English

    bind-address=192.168.1.2

     

    Now, I can't restart MySQL

     

    The entire file looks like this...

    [mysqld]

    user=mysql

    pid-file=/var/run/mysqld/mysqld.pid

    socket=/var/run/mysqld/mysqld.sock

    port=3306

    basedir=/usr

    datadir=/var/lib/mysql

    tmpdir=/tmp

    language=/usr/share/mysql/English

    bind-address=192.168.1.2

    Default to using old password format for compatibility with mysql 3.x

    # clients (those using the mysqlclient10 compatibility package).

    old_passwords=1

     

    # Disabling symbolic-links is recommended to prevent assorted security risks;

    # to do so, uncomment this line:

    # symbolic-links=0

     

    [mysqld_safe]

    log-error=/var/log/mysqld.log

    pid-file=/var/run/mysqld/mysqld.pid

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    ~

    "/etc/my.cnf" 21L, 571C

×
×
  • 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.