Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Posts posted by scootstah

  1. There's nothing in jQuery called $elem, so that is probably a user-created variable, which is expected to be a jQuery object. Sounds like whatever is passing that value has broken; perhaps a selector or something.

     

    If these are external dependencies breaking (like Bootstrap), you're going to want to make sure that they are the latest version, and that they even support jQuery 2.x. Make sure that jQuery is being loaded before anything else.

    • Like 1
  2. Yes, I suppose. I would have much higher expectations if I paid for it though. I would expect high-quality code, good documentation and good support. Otherwise, why the hell am I paying for it?

     

    I was mostly talking about free/opensource stuff.

  3. We're not going to search through your site to discover which parts of it are causing errors. That is your job. Post the errors that you are getting, with relevant code snippets, and then we can help.

  4.  

    SELECT `orders`.*, `resellers`.`reseller_name` FROM `orders` INNER JOIN `resellers` ON `orders`.`resellers_id` = `resellers`.`id` WHERE `orders`.`id` = '46';
    

     

    That is what this will do. This adds the "reseller_name" column to your result set. If you want the surname, you'll have to add that column to the SELECT statement.

    SELECT `orders`.*, `resellers`.`reseller_name`, `resellers`.`reseller_surname` FROM `orders` INNER JOIN `resellers` ON `orders`.`resellers_id` = `resellers`.`id` WHERE `orders`.`id` = '46';
    
  5. What does "breaks the page" mean? And where did you turn error logging on? If it is not turned on in the php.ini itself, then certain types of fatal errors will occur before the error reporting in the code is executed - thus you won't get any errors. Make sure that error_reporting and display_errors are turned on in the php.ini, and then restart apache.

  6. Oups sorry....ahahah

     

    Here it is:

    I tried this but the sql does not work.....
    SELECT 'orders'.*, 'resellers'.'name' FROM 'orders' INNER JOIN 'resellers' ON 'orders'.'resellers_id' = 'resellers'.'id' WHERE 'orders'.'id' = '46';
    
    I am getting
    SELECT 'orders'.*, 'resellers'.'name' FROM 'orders' INNER JOIN 'resellers' ON 'orders'.'resellers_id' = 'resellers'.'id' WHERE 'orders'.'id' = 46
     LIMIT 0, 25 
    
    
    MySQL said: Documentation 
     #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.*, 'resellers'.'name' FROM 'orders' INNER JOIN 'resellers' ON 'orders'.'reselle' at line 1 
    

     

    You're using single quotes when you should be using backticks.

     

    SELECT 'orders'.*, 'resellers'.'name'
    Should be:
    SELECT `orders`.*, `resellers`.`name` ...
    Single/double quotes are only for values. Backticks are used for databases, tables and columns. Backticks are completely optional though, unless you are using reserved keywords as your table/column names.
  7. I have edited my solution with comments, hopefully this will help you understand it better.

    function reverseString($input)
    {
        // initialize the currentWord with an empty string
        $currentWord = '';
    
        // initialize the list of words
        $words = array();
    
        // loop over every character in the input string
        for ($i = 0; $i < strlen($input); $i++) {
            // check if the current character is a space
            if ($input[$i] == ' ') {
                // if the current character is a space, then we know
                // we have completed a word.
                // add the current word to the words list
                $words[] = $currentWord;
    
                // reset the current word, so that we can make the next one
                $currentWord = '';
    
                // break the loop and continue on the next iteration
                continue;
            }
    
            // append the current character to the current word
            $currentWord .= $input[$i];
    
            // if we have reached the end of the string,
            // we need to add the current word to the list of words.
            if ($i == (strlen($input) - 1)) {
                $words[] = $currentWord;
            }
        }
    
        // make sure that there is a list of words
        // just some quick error checking. if a string 
        // was provided with only spaces, we would not have any words
        if (!empty($words)) {
            // initialize the reverse list of words
            $reversed = array();
    
            // loop *BACKWARDS* over the list of words.
            for ($i = (count($words) - 1); $i >= 0; $i--) {
                // since we are starting at the end of the 
                // words list, and moving backwards to the beginning,
                // by appending the current word to the reversed array,
                // we will end up with the opposite of $words...
                // or, a reversed list of the words.
                $reversed[] = $words[$i];
            }
    
            // initialize the output string
            $output = '';
    
            // loop over the reversed array and build the output string
            // note that we could have skipped this step,
            // and just build the output in the previous for() loop.
            // but having the reversed array may help debugging or just
            // enable curious inspection.
            foreach ($reversed as $word) {
                $output .= $word . ' ';
            }
    
            // finally, return the output.
            return trim($output);
        }
    }
    In a nutshell, this is what is happening:

     

    - Take input string, and loop over every character.

    - Build a string with each character until a space is reached, in which case we add that string to a list of words.

    - After we have fully iterated the input and built the list of words, we will loop over the list of words backwards. That means we start with the last index and move backwards towards the first index. By doing this, we can build a string or array of the words in reversed order.

     

    EDIT: And requinix's approach is basically the same, just more condensed.

  8. What you are asking is not even possible. You could "clone" (AKA steal) the HTML, JS, CSS, and images that you see when you view the page, but you are only getting the static content that is generated by the backend. You cannot download the backend code unless you have physical access to it.

  9. Long story short, if you're changing '<?' to '<?php', you shouldn't have any trouble. However, if you're changing '<?=' to '<?php', output will start to disappear.

    And then, never use <? or <?= again. That is by far the stupidest decision the PHP team has ever made.

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