www.webdeveloper.com
Page 13 of 14 FirstFirst ... 311121314 LastLast
Results 181 to 195 of 198

Thread: My questions thread.

  1. #181
    Join Date
    Jan 2009
    Posts
    3,346
    Maybe you don't need to setImageFormat?

    http://php.net/manual/en/imagick.readimage.php

  2. #182
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Hmm, didn't help. I also tried doing it this way, and I still got the writeblob failed error:

    PHP Code:
    $image = new Imagick('/home/website/generator/bg1.png');
    $image->writeImage('home/website/public_html/images/tmp/5.png'); 
    the tmp folder's permissions are 777 now, by the way.
    Last edited by evenstar7139; 12-26-2012 at 07:36 PM.

  3. #183
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    I emailed my host again and they noticed that I'd forgotten to put a / at the beginning of the file path. It's working now.

    I'm just posting this in case somebody finds this on Google and wants to know the answer

  4. #184
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Oh, hey guys, I was wondering: Where can I find information about how to do PHP programming projects with multiple programmers? I've always coded by myself, but I might have some other programmers helping me in the near future. I have no idea how to work with other programmers =\

  5. #185
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,536
    one important thing is to choose a source code control system you like and that provides good team support, such as Git.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #186
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    +1 for git. The next thing to be concerned with is assignments, no 2 people should be working on the same file(s) at the same time as this can cause serious headaches when merging changes together.

  7. #187
    Join Date
    Jan 2013
    Posts
    7
    Threads are one of several technologies that make it possible to execute multiple code paths concurrently inside a single application. Although newer technologies such as operation objects and Grand Central Dispatch (GCD) provide a more modern and efficient infrastructure for implementing concurrency, OS X and iOS also provide interfaces for creating and managing threads.

  8. #188
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    I will check out Git, then.

    Anyway, new question:

    I ran across something that I've never seen before. It's on line 4. How does that code work? Is it similar to when I do return ($a < $b) ? TRUE:FALSE?

    PHP Code:
    <?php
    foreach ($_POST as $key => $value) {
      
    // assign to temporary variable and strip whitespace if not an array
      
    $temp is_array($value) ? $value trim($value); //line 4
      // if empty and required, add to $missing array
      
    if (empty($temp) && in_array($key$required)) {
        
    $missing[] = $key;
      } elseif (
    in_array($key$expected)) {
        
    // otherwise, assign to a variable of the same name as $key
        
    ${$key} = $temp;
      }
    }
    This code was written to find empty fields in a form.
    Last edited by evenstar7139; 04-14-2013 at 08:58 PM.

  9. #189
    Join Date
    Jul 2012
    Location
    Vancouver
    Posts
    61
    Quote Originally Posted by evenstar7139 View Post
    I will check out Git, then.

    Anyway, new question:

    I ran across something that I've never seen before. It's on line 4. How does that code work? Is it similar to when I do return ($a < $b) ? TRUE:FALSE?

    PHP Code:
    <?php
    foreach ($_POST as $key => $value) {
      
    // assign to temporary variable and strip whitespace if not an array
      
    $temp is_array($value) ? $value trim($value); //line 4
      // if empty and required, add to $missing array
      
    if (empty($temp) && in_array($key$required)) {
        
    $missing[] = $key;
      } elseif (
    in_array($key$expected)) {
        
    // otherwise, assign to a variable of the same name as $key
        
    ${$key} = $temp;
      }
    }
    This code was written to find empty fields in a form.
    Yes, it's a shorthand ternary..

    $temp = $value (if value is array) if its not array, trim the whitespace from value.

    edit.. $temp = if statement ? true do this : false do this

  10. #190
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    Oh, ok, so he's using that shorthand if statement right after the assignment operator for $temp. Cool. I've never seen anybody do that.

    Learning new things about PHP is fun Thanks

  11. #191
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    New questions:

    #1 I heard that MySQL's charset is important when using mysqli::real_escape_string(); What charset should I be using if my site is all in English? UTF-8?

    #2 Also, PHPMyAdmin is saying the charset is "UTF-8 Unicode (utf8)" but if I do print_r($mysqli->get_charset()) in a script, it says it's latin1. Which one will mysqli::real_escape_string() use?

  12. #192
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,536
    After connecting to your DB and before doing anything else, submit this query:
    Code:
    SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'
    This lets MySQL know you'll be "talking UTF-8" to it from this point on in the session. Since the MySQL "real" escape functions in PHP actually call the MySQL DB's API, that should take care of it for you.

    Of course, if you're using MySQLi, you should seldom, if ever, need to use the PHP escape function, since you're using prepared statements with bound parameters, right?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  13. #193
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    #1 Will every page have to send that query?

    #2 I'm torn on whether to use prepared statements or not. Some people tell me they can't live without them, others tell me they hate them because they're slower than regular queries. In the past I have had problems with slow queries bogging down my server (I was not using prepared statements) and that experience has left me speed-conscious. So, currently I am leaning away from prepared statements. However, if you would like to argue in favor of me using prepared statements, I will consider what you say.

  14. #194
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,536
    #1: If you can modify the MySQL config to default to those settings, then no. It's very low overhead, though.

    #2: We use prepared statements all the time at work (via PDO connecting to a PostgreSQL DB), and I have no evidence it's a noticeable performance bottleneck (if at all). Poorly configured tables (in particular with regard to proper use of indexes) and inefficient SQL will be a much, much, much bigger issue. I believe in coding first for clarity, maintainability, re-usability, and security; not worrying about a millisecond here and a microsecond there (hardware is fast and relatively cheap these days). Don't worry unduly about optimization* until you know you have a problem, and then address it by testing and metering to find out where the primary issues are and addressing them then.
    __________
    * Yes, you want to avoid obviously stupid things like foreach() loops that repeat the same query over and over when you could do it with one query instead. When you see optimization opportunities that do not conflict unduly with your other coding objectives, then by all means use them -- but also be aware there is a lot of questionable info out there about how inefficient one technique is over another, often not supported with any empirical measurements
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  15. #195
    Join Date
    Jun 2006
    Location
    Under your bed
    Posts
    357
    #1 Has PHP's implementation of regular expressions changed since 2007?

    #2 I know somebody who is learning to do regular expressions with preg_match(). I would like to link her to a tutorial that I used in the past and found easy to follow. However, it was written in 2007. This is it: http://weblogtoolscollection.com/regex/regex.php Does anything jump out at you as outdated or inaccurate?

    #3 Should I always do: if (preg_match('regex here', $str) === 0) instead of: if (!preg_match('regex here', $str))

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles