Jump to content

kicken

Gurus
  • Content count

    3,436
  • Joined

  • Last visited

  • Days Won

    83

kicken last won the day on October 25

kicken had the most liked content!

Community Reputation

470 Excellent

About kicken

  • Rank
    Wiser? Not exactly.
  • Birthday 07/19/1985

Contact Methods

  • Website URL
    http://aoeex.com/

Profile Information

  • Gender
    Male
  • Location
    Bonita, FL

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. var editor = $('#' + ed.editor + '.atjs'); That line means it is going to try and find an element with id=ed.editor and class="atjs". So you'd need to write your textarea such as: <textarea id="yourEditor" class="atjs"></textarea> then initialize tinymce on that textarea.
  2. Did you give your editor the atjs class? Did you initialize tinymce on the editor?
  3. kicken

    UNDEFINED INDEX with += Assignment Operator

    Because += involves reading the current value first, and you haven't yet defined any value for that index. $animal['count'] += $value is the same as $animal['count'] = $animal['count'] + $value If you know what keys you are using, then you can just initialize them to zero before your loop. $animal = ['count' => 0];
  4. kicken

    Looping through an array

    You can use explode to split your IP, array_map to do the conversion, and implode to join them back together again. $ipComponents = explode('.', $ip); $ipComponents = array_map('decbin', $ipComponents); $ip = implode('.', $ipComponents); The above would only work for IPv4 addresses. If you need to support IPv6 you'll need to adjust the code accordingly.
  5. kicken

    Sending SMTP email

    PHPMailer is still popular as far as I know, and is probably fine. I prefer SwiftMailer personally. As for why there is no native solution...probably just because there are already excellent third-party solutions and creating a well/full featured internal SMTP client would be more hassle than it's worth. The password functions were added because it's a very common task and one that many people end up doing incorrectly which can have major consequences. It's also something that would have been relatively easy to implement as native functions so the benefit of adding them was well worth the effort required to do so.
  6. When it comes to query parameters, I like to create a parameterize function which generates a placeholder name and adds the value + name to an array then returns the new parameter name. This allows concatenation like one might be used to but uses parameters. function Parameterize($value, &$binds){ static $counter = 0; if (!is_array($binds)){ $binds = []; } if (is_array($value)){ if (count($value) == 0){ return 'null'; } else { $allParams = []; foreach ($value as $v){ $allParams[] = Parameterize($v, $binds); } return implode(',', $allParams); } } else { if (is_bool($value)){ $value = (int)$value; } else if ($value instanceof \Datetime){ $value = $value->format('Y-m-d H:i:s'); } $param = ':param' . (++$counter); $binds[$param] = $value; return $param; } } With that, the query above would look like: // database specific code $sql = "SELECT id, state FROM loc WHERE state LIKE " . Parameterize($_GET['term'] . '%', $binds); $stmt = $pdo->prepare($sql); $stmt->execute($binds); If you want to do multiple queries in a row you need to clear out the variable holding the parameters ($binds above) before each query or you'll get an error due to mismatching parameters. I tend to isolate my queries into their own function which is another way to avoid this problem as each function has it's own scope.
  7. I'm not familiar with Laravel, but I don't see why you'd need two separate textarea fields for this. TinyMCE makes the textarea field you apply it to hidden then adds an iframe for the actual editing UI. When the form is submitted it then copies the edited content into the textarea field. You can copy the content yourself if needed by calling the .save() method of the editor, for example before making an ajax request.
  8. Your inner if statements are incorrect. You're using = (assignment) when you should be using == (compare). As a result, all of your if branches should be getting followed.
  9. kicken

    PHP-generated image WITH html?

    For small images, another alternative would be to generate a data: url using the image data. For example, assuming QRCode::png returns the binary data for your image: $imageData = QRCode::png('Text to encode'); echo 'Here is your QR Code: <img src="data:image/png;base64,' . base64_encode($imageData) . '">';
  10. kicken

    Syntax checking

    One of the lines comes from the engine is controlled by the display_errors ini setting. These are printed on STDOUT. The second line is from the -l setting showing the specific error it encountered. These are printed on STDERR. So, you can do two different things. 1) You could turn off display_errors to prevent one of the messages on STDOUT. You can do this by passing -d display_errors=0 2) You could redirect either STDOUT or STDERR to /dev/null (or elsewhere) to ignore or capture them specifically.
  11. kicken

    pattern help

    This certainly seems like a Mysql problem rather than a Regex problem to me. Can you post the relevant table structures? Some of your joins don't make sense, eg: INNER JOIN trade_departments td ON td.department_id = u.user_id INNER JOIN departments d ON d.department_id = td.user_id Why are you matching department_id to user_id? If you want to find out what users can perform the trades needed for a property_task you should be joining those tables via the common trades. At the end you can GROUP_CONCAT if you want, but that shouldn't be part of your joining process.
  12. kicken

    cURL both a file and POST data

    Looking at that comment on PHP.net linked earlier, it seems like you just need to make sure your $data array is a single dimension. You can use http_build_query to do some of the work of converting your potentionaly multi-dimensional array into a single dimension, then add your files to the end. For example: <?php $data = [ 'name' => 'Kicken' , 'date' => [ 'month' => 10 , 'day' => 15 , 'year' => 2018 ] ]; $files = [ 'photo' => [ 'tmp_name' => '/tmp/blah.jpg' , 'type' => 'image/jpeg' , 'name' => 'blah.jpg' ] , 'cv' => [ 'tmp_name' => '/tmp/cv.txt' , 'type' => 'text/plain' , 'name' => 'cv.txt' ] ]; $postData = []; foreach (explode('&', http_build_query($data)) as $pair){ list($name, $value) = explode('=', $pair, 2); $postData[$name] = $value; } foreach ($files as $name=>$file){ $postData[$name] = new \CURLFile($file['tmp_name'],$file['type'],$file['name']); } var_dump($postData); Output: array(6) { 'name' => string(6) "Kicken" 'date%5Bmonth%5D' => string(2) "10" 'date%5Bday%5D' => string(2) "15" 'date%5Byear%5D' => string(4) "2018" 'photo' => class CURLFile#1 (3) { public $name => string(13) "/tmp/blah.jpg" public $mime => string(10) "image/jpeg" public $postname => string(8) "blah.jpg" } 'cv' => class CURLFile#2 (3) { public $name => string(11) "/tmp/cv.txt" public $mime => string(10) "text/plain" public $postname => string(6) "cv.txt" } } You could also make your own version of http_build_query that's aware of CURLFile if that'd make things easier. Then you could just build up your $data array with the file objects where they need to be and then collapse it with your custom function. edit: Might need to urldecode() the name/value pairs after the http_build_query, not sure on that.
  13. I lost track of the number of of times I've forgotten those dumb bootstrap classes on buttons and wondered "WTF isn't this looking like it should?" I always hated this about css grid setups too. Having 'col', 'row', 'col-x', etc scattered everywhere, but I guess that's what happens why you try and use a generic grid framework. Now that I'm using SCSS more often I'll generally use a grid that includes a scss distribution so I can integrate it into my more meaningful rules. I'm still not perfect, but I'm a lot better now than I was 5 years ago at this stuff.
  14. kicken

    Using array element values to access another array

    Loop over the keys you want to check. If the key exists in the array, set the array to it's value and check the next key. Otherwise return null (or whatever). function getValue($array, $keySpec){ foreach (explode('.', $keySpec) as $key){ if (!isset($array[$key])){ return null; } $array = $array[$key]; } return $array; } $array = [ 'userList' => [ '1234' => [ 'name' => 'Kicken' ] ] ]; var_dump(getValue($array, 'userList.1234.name')); https://3v4l.org/AdcKW
  15. kicken

    display images

    When I mix HTML and PHP I tend to do as requinix did, except I keep the <?php tag at the same indentation as the HTML around it rather than beginning of the line. I find it to be easily readable and understandable. Most of the time these are essentially template files so like 90% html, 10% php. @Argonust, you have some HTML errors in your original post which may or may not be causing you issues. Missing quotes around your class names on the gallery div. Missing a closing </a> on each image. As suggested, check the view-source output to see if your HTML is being built but with no values, or if the HTML is missing all together. If it's built but with no values, then in your foreach loop do var_dump($image) to see what the variable is for each item.
×

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.