Jump to content

dalecosp

Members
  • Posts

    471
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by dalecosp

  1. +1 for a development environment.

    I use Oracle's Virtualbox and install a BSD-family OS with Apache+PHP ... you might be able to even find a Docker container or something like that for free out there someplace.

    As far as what will happen, the biggest recent changes to PHP, in terms of effect, at our company were removing the old mysql_* stuff (although most of it was long gone, we found out that some infrequently-used LAN software and reports still had some mysql_* stuff in them, and the removal of mcrypt().

  2. Drag 'n drop is done with an AJAX system; a JavaScript front-end script packages the image data into a FormData object, and the AJAX operation will POST that to a PHP handler script on the server, which then does the work to put it someplace just like we did in the Elder Days when we used a basic upload form in HTML.  So, at the very least you need two scripts, one PHP and one in JS.

  3. Pretty URLs are fairly simple.  Either use mod_rewrite (for Apache servers) or its equivalent on your system to do the complete work, or use it to redirect to a centralized script that reads the URL parameters and shows content based on that parameter.

    At work, we have listings like:  www.ombe.com/listing/2151404/Uninet-Developer-for-use-in-Ricoh-Aficio-200,-250,-345g

    mod_rewrite has this rule:  

    RewriteRule ^listing/([0-9]+)/?.*$ listing?$1 [NC,L]

    "Listing" does something like this:

    $product_num = intval($_SERVER['QUERY_STRING']);

    Of course there's a LOT more, config and security modules before this point, and error handling for invalid query strings, and so on.

     

     

  4. The quid pro quos of going to "MySQLI" include changing your connection string and the query syntax.  The one big "gotcha" to me when converting old to new (MySQL to MySQLI) was the lack of a mysqli_result() function in the older days, but now you can do something like this:

    $data = $result->fetch_row()[0];

    ... which seems fairly handy to me in place of mysql_result.  I'm not sure when this syntax became valid, off the top of my head.

    PDO is generally touted as great for security and portability.  I'm not totally convinced, but the use of prepared statements is preferable to its alternative.

    I had written quite a bit more here, but I think at this point a good read or two would be in order.  I'm not sure there's any 'one size fits all' answer to this issue.

    This is a thoughtful and well-informed take on the subject.    The Reddit comments on it are also kind of interesting.

    SitePoint discussion.

    Jim Westergren tested, and prefers, PDO with ATTR_EMULATE_PREPARES.

    Quora seems to prefer PDO, but there's some really bad info on this page also.

    I've been in your shoes, and our management wanted quick-n-dirty.  I modified everything to MySQLI with a few search/replace operations in the IDE, adapting the connection code, and replacing calls to mysqli_result().  Took very little time at all.

    If they preferred PDO for security and portability, I would've done that. though.

  5. It should be a bit simpler; they are allowing GET requests. Here's a sample you can adapt to your site's architecture:

     

    <?php
    
       $uid    = "My_Userid";   // put your user id here
       $pass   = "My_Password"; // put your password here
       $apikey = "My_API_Key";  // etc.
       $from   = "My_From_Phone_number";
       $to     = "Receiving_Number";
       $msg    = "Test text Message.";
    
       $url    = "https://www.experttexting.com/exptapi/exptsms.asmx/SendSMS?Userid="
                 . $uid . "&pwd=" . $pass . "&APIKEY=" . "&FROM=" . $from ."&To="
                 . $to  . "&MSG=" . $msg;
    
       $send   = file_get_contents($url); //simple HTTP GET request
  6. The fact it's not working on iPad suggests a browser problem, and, therefore by extension, a JavaScript problem?

     

    Can you get a console from the iPad browser and see if JS is throwing some errors? Alternatively, there are "user-agent switchers" for most major browsers that might allow you to imitate an iPad with a browser (Like Chrome or FFox) that has a good console/debugger already built in.

  7. You're echoing "$out" inside the foreach loop ... and you're also concatenating to it with ".=" ... I think you probably want to put the echo statement AFTER the foreach loop?

     

    (That is, after the first bracket and before the bracket that closes your function.)

  8. You've Googled?

     

    http://www.killerphp.com/articles/php-interfaces/

    http://kristopherwilson.com/2015/03/26/using-interfaces-effectively-in-php/

    http://www.davegardner.me.uk/blog/2010/11/21/why-you-should-always-use-php-interfaces/  (Older, fanatic OOPer)

    http://jaskokoyn.com/2013/06/11/interfaces/

    https://www.phpclasses.org/blog/post/300-Using-PHP-Object-Interfaces.html

     

    How should interfaces really be used for these classes?

    If there's a class that you want to *ensure* has specific capabilities (that is, you don't want to forget to implement the $foo method for it), have it implement an interface.

  9. Sounds pretty nefarious, doesn't it?  Given he's also shot-gunned this by asking at PHPBuilder, I do have to wonder about intentions.  What if he's asking "How can I show someone else's site in a IFRAME so that they think they're using another site by they're really still using my site ..."

    Yikes....

  10. There are some problems with your script, as near as I can tell at first glance.

    1.  The array $list_pre was initialized with URL that included an empty variable.  Either just initialize an empty array, or make sure that $keyword3 has a value when the array is initialized.

     

    2.  The first "foreach" loop isn't followed by a bracket.  I'm not sure what the parser will do with that; it might not matter, but for consistency and legibility I would recommend that every foreach use brackets.

     

    3.  You have an errant semicolon here:
     

     

    foreach ($html_pre->find('//*[@id="search-content"]/section[2]/div/h1/span[1]') as $pre_page);



    It's possible that's the source of the issue.

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