Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Posts posted by Jessica

  1.  

    Having these questions and answers hard coded. I want to be able to read them from a text file and load the arrays questions with questions from questions.txt while also read answers array from answers.txt. but at the same time maintain my data structures. How should I go abou this?

     

    Why? Why don't you just leave it as is...? Save those two arrays in a file and then include them.

  2. I'm not using mysql_ functions. I'm not the OP... I just edited his code, didn't really want to get him side-tracked by replacing his mysql_ functions with mysqli functions.

     

    I'm sure you know there's a real_escape_string function for MySQLi aswell. That's what I meant with this: 

     

    Oh... I've been told to use it on each freaking query I make... Well, you learn something every day. Thanks!

     

    You should be using prepared statements in mysqli, NOT escape string.

  3. If you'd explained some of this up front it would have gone a lot faster.

    It probably has to do with the configuration of your relationships, which you haven't shown.

    I suggest you read the links in my signature on how to get help.

     

    David: counterCache is supposed to handle that count automatically - hence why it's trying to update the userCount automatically when the users table is updated. It's a tool for CakePHP.

  4.  

    i think the answer to this vague question might be to use a reference -

    $somekey = 'city';
    
    $root = &$structure[0]['cards'][0]['info'][$somekey]; // form a reference to a point in the structure
    
    echo $root['title']; // use one specific value at the referenced point
    
    // loop over all values at the referenced point
    foreach ($root as $key=>$value){
        if(!is_array($value)){
            echo "Key: $key, Value: $value<br>";
        } else {
            echo "Key: $key, ";
            foreach($value as $skey=>$svalue){
                echo "SubKey: $skey, SubValue: $svalue<br>";
            }
        }
    }

     

    Why would you bother with three lines of code though?

    That's the same as just doing:

    echo $structure[0]['cards'][0]['info']['city']['title']

    Or:

    echo $structure[0]['cards'][0]['info'][$somekey][$someotherkey]

  5. PHPFreaks.com Questions, Comments, & Suggestions

    This is NOT a help forum! Do not post topics asking for help that are not related to the website.

     

     

     

    http://www.phpfreaks.com/page/rules-and-terms-of-service

     

    Users will format posts as best as they can by using proper

    
    
    [/nobbc] or [nobbc]
    
    

    tags and following Proper Code Indentation guidelines.

    Users will post relevant code and information to their question(s).

     

     

    Read the link in my signature on Debugging your SQL. Research using prepared statements.

  6. Which is it? You want just the count, or you want all the rows?

     

    Sorry, I probably could have been more clear.

    I'm not looking to return the results. I just want the count as if that were the query.

     

     

    That's nearly what I want, however since I'm also displaying a list of results it's just making the counts 1 for each row. I want the sum of all rows with that match.

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