Jump to content

kicken

Gurus
  • Content Count

    3,510
  • Joined

  • Last visited

  • Days Won

    89

kicken last won the day on May 18

kicken had the most liked content!

Community Reputation

484 Excellent

1 Follower

About kicken

  • Rank
    Wiser? Not exactly.

Contact Methods

  • Website URL
    http://aoeex.com/

Profile Information

  • Gender
    Male
  • Location
    Bonita, FL
  • Age
    33

Recent Profile Visitors

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

  1. I'd probably just go with essentially option one. I don't see any real benefit to using a shell object. class OptionOne { private $clientList; public function __construct() { $this->clientList = new SplObjectStorage;; } public function clientConnects($stream) { $client=new UnregisteredClient($stream); $stream->setClient($client); $this->clientList[$stream] = $client; } public function clientRegisters($stream, $data) { $client=new NewClient($stream, $data); $stream->setClient($client); $this->clientList[$stream] = $client; } }
  2. You can just re-attach it to change the data, or just use it as an array. //Option 1 $storage->attach($obj, new dataB); $data = $storage[$obj]; var_dump($data); //Option 2 $storage[$obj]=new dataC; $data = $storage[$obj]; var_dump($data); offsetSet is there because SplObjectStorage implements ArrayAccess which means you can just read/write keys like any other array. The offset* functions are not really intended to be called directly.
  3. Does that mean if you access the url http://example.com/public/index.php then things work? If so then you'll either need to re-configure your server so that the document root points to the public folder or setup a .htaccess file in your project folder to redirect requests to the public folder. Otherwise, if you mean adding a different .php file to the public folder and it works but the index.php file does not, then as mentioned above you probably have an error. The best way to find out is to check the error log, either for your server or a separate php error log depending on how it's configured. Create a file that executes the phpinfo() function to see how things are configured.
  4. The values would be coming into PHP as part of the $_POST array so you'd check if they exist there and if so echo the value back out. <?php $count = 10; echo "<tr>"; for($j=0; $j<$count; $j++) { $value = $_POST['reply'][$j] ?? ''; echo "<td> <input type='text' name='reply[]' class='ansbox' value='" . htmlspecialchars($value) . "'></td>"; } echo "</tr>";
  5. kicken

    pass a php array into js

    Trying to inject code directly into JS like in your original post is risky. Someone may be able to use it to inject html/js into the document. The better approach is to insert the JSON data into your HTML document (with normal HTML escaping applied) and then parse it. A hidden input is one way to do that, another way is with a data attribute which is what I typically do (jQuery will auto-parse json data attributes). <script src="/js/something.js" data-rs="[[1,2,3],[2,3,4],[3,4,5]]"></script> var rs = $(document.currentScript).data('rs'); document.currentScript needs to be read during the initial script load, you can't put it in an event handler for example. According to caniuse.com, it also doesn't work in IE. If that's a concern, there are alternative methods / polyfills that exist.
  6. First off, for form fields you use the name attribute to define the name they are submitted as, not the id attribute. Secondly you can't have multiple elements with the same id attribute in html. ID's have to be unique. Once you fix that, then you can either query for them by the name or by giving them all a common class and using a class selector. <input type='text' name='reply[]' value=''> var test_arr = $('[name="reply[]"]');
  7. kicken

    Uncaught PDOException: could not find driver...

    Sometimes there are separate ini files for cli, cgi, and apache modules. The phpinfo() output will also tell you which php.ini file it's looking at so you know which one to edit. Look for a line similar to
  8. kicken

    Uncaught PDOException: could not find driver...

    Create a page with the code <?php phpinfo(); and check it's output for a PDO section. It should show a line saying: If it doesn't, then you haven't loaded the proper extensions.
  9. You can make it a color that's really close to black. For example, rgb(0,0,1); A person wouldn't be able to tell the difference. It's not rgb(0,0,0) though so the browser doesn't change it to the normal disabled gray.
  10. It just looks like part of the animation to me. As the pieces slide together you get a smaller and smaller gap between them. Just before it finishes the gap would only be a pixel or two so it looks some lines.
  11. kicken

    Auto populate price based on selected product

    I agree with the others that your initial approach sounds flawed and you should change it, likely making the original request unnecessary. However, to accomplish what you wanted initially the easiest way is just to attach the price per item as a data attribute to your item input and then have some javascript that reads that and the quantity whenever the change and update a total somewhere. In the case of a select list with your products, you'd attach the price to the <option> elements. For example: <select name="item" id="item"> <option value="1" data-price="10">First item</option> <option value="2" data-price="15">First item</option> <option value="3" data-price="20">First item</option> <option value="4" data-price="25">First item</option> </select> x <input name="quantity" id="quantity"> = <span id="totalPrice"></span> Then a simple script to do the calculation //Uses jQuery for simplicity function updateTotal(){ var pricePer = $('#item').find('option:selected').data('price'); var quantity = $('#quantity').val(); var total = pricePer * quantity; $('#totalPrice').text(total); } $('#item').change(updateTotal); $('#quantity').change(updateTotal);
  12. kicken

    Is HSLA supported in Edge ?

    For me, edge only seemed to work when not using a unit specifier, in which case it defaulted to degrees. Trying to add any of the unit specifiers caused edge to consider the rule invalid and ignore it.
  13. kicken

    PHP in multiple new windows

    You can do what you want by dynamically setting the form's target as you had guessed. I've done this a few times in the past to submit a form into a popup window. For example: <form action="https://aoeex.com/datetime.php" target="_blank" id="theForm"> <ul> <li><button type="submit" name="which" value="first">First button</button></li> <li><button type="submit" name="which" value="second">Second button</button></li> <li><button type="submit" name="which" value="third">Third button</button></li> </ul> </form> var $form = $('#theForm'); $form.find('button').click(function(e){ var target = $(e.target); var windowName = target.val(); window.open('', windowName, 'width=450,height=100,scrollbars,resizable'); $form.attr('target', windowName); }); It's not possible to detect which button submitted a form during the submit handler so you have to instead attach your event listener to each button. In the click handler you can open your new window with an appropriate window name and then set the form's target attribute to that name. If a popup blocker stops your window.open from functioning then your form will instead open in a new tab/full window due to the target attribute.
  14. If you look at the list of file open modes, you'll see that mode w is So when you re-open your file you're deleting everything you'd previously written to it. Mode w also doesn't allow reading so any fread call would return nothing anyway. You want mode r to read back your contents. As requinix mentioned though, the whole file bit seems pointless if you're just going to write data to it then read it all back out.
  15. kicken

    php & nodejs sodium - compatibility

    Output your strings using bin2hex in PHP and sodium.to_hex in JS. Then you can compare them easily. Take your hex string that PHP outputs and use sodium.from_hex in the JS to import it.
×

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.