Jump to content

beegro

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

Posts posted by beegro

  1. Assuming you're doing this

     

    session_set_cookie_params(0, "/", ".weblyize.com", false); 
    

     

    in the parent domain.  Then the session should work unless your subdomain is on a different box.  If it's on a separate box you'll have to figure out how you want to share the session files between them.  I'm sure you already know this but I'm just reiterating it to be thorough. 

  2. Try removing the actual numbers out of the html array.  PHP will assign the numeric indexes for you appropriately. 

     

    <input type="text" name="hdds[][hddbrand]" id="hddbrand"><br/>
    Model and/or size,type: <input type="text" name="hdds[][hddtype]" id="hddtype"><br/>
    SN: <input type="text" name="hdds[][hddsn]" id="hddsn"><br/>
    Notes: <input type="text" name="hdds[][hddnotes]" id="hddnotes" size="50">
    

  3. Hi rocky,

     

    The problem you're having is that the isset() function is always evaluating to TRUE because it sees that there is a value for $_POST['sub'].  By nature, when you post a form PHP receives all of the form elements with 'name' attributes in the HTML.  Therefor, the check you are doing

     

    isset($_POST['sub'])

     

    is invalid because it will always evaluate to TRUE when pressing the submit button.  I think the problem you're having is not in the PHP but in the javascript.  To stop your form from being submitted when the javascript evaluates to false, I'd suggest moving the javascript call to the onsubmit event of the form itself.

     

    <form action="add.php" method="post" onsubmit="return check();">

     

    This should allow the return value from the javascript function to override the default action from the "onsubmit" event.  Don't forget that "return" command. 

  4. For the most part, I think your OO approach is correct.  However, I would probably break the validation of the form data out from the class.  In short, handle validation of form data in a PHP page/script and handle argument validation within the class.  This will allow you to send appropriate messages back to the browser for missing/mal-formed/incomplete form entries while your classes manage their attributes and arguments as if they come from a script. 

  5. The extension is actually part of the filename.  It's especially difficult because the native operation of an extension-less name denotes a directory.  Depending on what type of server you're using you may be able to deploy some rewrite rules that actually re-write the URL to point to the php script but this also depends on your directory structure. 

     

    You're in a bit of a fix here.  I'd really suggest grepping through your code and changing links without extensions to links with extensions. 

     

    Anyone else know a better way??

  6. Try this out

     

    $page = file_get_contents('http://www.example.com/');
    $sub = stristr($page, "myid=");
    $num = sub_str($sub, 0, 6);  // assuming the value will always be six characters
    

     

    If you need to find the id for any variable length you'll have to split on the space after the value, but I'm sure you can figure the rest out.

  7. Metacharacters are any characters that have special, interpretable meaning.  In PHP we have (\n, \r, \t, etc.) in strings that are metacharacters.  How you should filter your inputs all depends on what you want to do with those values later.  Are you simply wanting to echo them back to the browser or will you actually be doing something else with them?

  8. Take a look at what the submitThisOnce() function does.  It could do many different things (AJAX, adding additional elements, simply submitting the form, etc.)  If it's a simple submit then you can easily use cURL to send values to the "action" target.

  9. OK, after further investigating the XML document is valid but PHP has trouble handling the ":" character in the tag.  Here's a hack workaround but this is definitely a bug or issue with PHP.

     

    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    
    $request='http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5';
    $string = file_get_contents($request);
    // echo $string;
    $string = str_replace(":", "_", $string);
    // echo $string;
    
    $sxe = new SimpleXMLElement($string);
    if (!$sxe) {
        echo "Failed loading XML\n";
        foreach(libxml_get_errors() as $error) {
            echo "\t", $error->message;
        }
    }
    
    var_dump  ($sxe);

     

    You should be able to see the elements with an "_" character replacing where the ":" was previously.  Hope this helps for now.

     

     

    Revision:  I guess I shouldn't say this is a bug because the ":" character is part of the PHP language construct but it should be handled more gracefully in the SimpleXML object.

  10. It's definitely failing to load the XML despite the XML being valid.  I checked the XML with W3C:

     

    http://www.w3schools.com/xml/xml_validator.asp

     

    AND I tried using the SimpleXMLElement object instead of the function call but got the same results.  This may indeed be a bug but I'll try a few more things first.

     

     

    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    
    $request='http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5';
    $string = file_get_contents($request);
    echo $string;
    
    $oXml = new SimpleXMLElement($string);
    if (!$oXml) {
        echo "Failed loading XML\n";
        foreach(libxml_get_errors() as $error) {
            echo "\t", $error->message;
        }
    }
    
    var_dump  ($oXml);
    

     

  11. First, if a function is "doing nothing" it probably means there are errors.  Do you have error_reporting turned on?

     

    Second, if simplexml_load_file() isn't working as expected but you can verify that the script is getting to the function call it probably means that it is actually returning FALSE because it could not load the XML document.  If the XML document indeed exists it may not be valid XML.  Can you post an example of what the XML doc looks like?  Also, try a var_dump() instead of the print_r().  This will tell you see if the contents of $xml is a boolean value.

  12. I'd try urlencoding your redirect_uri.  The slashes and all the formatting can play crazy games in the query string and is probably preventing the trailing variables from being understood.

     

    $url = 'https://graph.facebook.com/oauth/access_token?client_id=' . $app_id . '&redirect_uri='.urlencode('http://www.mywebsite.com/facebook_connect2.php').'&client_secret=' . $app_secret . '&code=' . $keycode;
       
    header('Location: ' . $url);

  13. Ah yes, PDOs!  I think they are the best way to go when developing OO applications.  It is a simple series of objects (PDO connections, statements, errors, etc) that simplify what a lot of us use to build custom abstraction layers to do.  I highly recommend using the PDOs whenever possible.  However, I made the full plunge into prepared statements on one project only to find some serious issues that I didn't consider when I started. 

     

    When using Postgres, the query engine for prepared statements is different then the engine used to process a query string passed directly through the PDOs query method.  In a couple of cases the database engine took 20+ seconds longer to complete the prepared statement vs. executing the query string directly.  Now I was using the prepared statements for the logical separation of the query string from the query values and not processing bulk queries where prepared statements are vastly faster on an aggregate scale.  I'd probably suggest against using prepared statements for single-run queries because of the differences in the database engines. 

     

    To clarify, and this is only my experience with Postgres and Oracle. 

  14. I've found, especially when using HTTPS, that using cURL is the answer. 

     

    A lot of times there are SSL verification steps that I can't get to work with standard fopen() and file_get_contents() functions due to a back-and-forth between the server and client.  I find that I have a lot more control over the environment (including which headers I send, whether or not to verify an SSL cert, etc.) with cURL. 

  15. Try it this way

     

    while ($unassigned = mssql_fetch_assoc ($unassigned_tickets)){
    
    $pull_date = $unassigned['required_date'];
    
    $req_date = $pull_date;
    $req_date = strtotime($req_date);
    $result = ($req_date >= strtotime("-5 days")) ? 'Yes' : 'No';
    
    echo '<tr><td>$result</td></tr>';
    

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