Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. Another note: divs are displayed as block by default. You don't need to do anything with CSS to get that functionality.
  2. If I understand, then you're trying to create a drop-down list where each item is a checkbox followed by a label. These controls are often supported in languages like Java or Microsoft's Visual XYZ. However this is a web page that displays HTML; therefore you're limited to what you can make in HTML. However if you want to get fancy you can create your own control using a combination of HTML, JavaScript, CSS, and DOM manipulation. It'll take many hours in and of itself and is rightfully its own project. Or you can see if such a control is implemented in one of the popular JavaScript frameworks such as YUI, jquery, mootools, dojo, etc. Once you do this, the page will only work correctly if the user has JavaScript enabled.
  3. isset($_POST['ConsentCheckbox']) ? $_SESSION['Consented']=true; header('Location: http://www.mySite.com/welcome') : Syntax error at the first semi-colon.
  4. My experience with shuffling files to remote locations is to: 1) Split the file into smaller chunks; I typically use ~2MB 2) For each chunk i) Send chunk, on failure sleep for a timeout and try again a) If excessive failures kill process and shoot out a notice e-mail Now if the server they're sent to is the final destination, just assemble the chunks on the remote server. However if the remote server is a holding area and the file is going to be downloaded elsewhere, leave it in pieces and essentially repeat the process you used to put the file there, except download instead of upload. Anything long-lived over a network connection has a chance to fail so its almost always best to divide and conquer.
  5. Shame on them for their beta software not working properly! And shame on the flash developers for not making their plug-in work flawlessly in a beta container! Inconceivable!
  6. 50% of the time this crops up you're going to realize you made the wrong choice six months later.
  7. If you did want to compress the keys yourself (via script or program), you'd probably want to use something like "ON UPDATE CASCADE." http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html I would explore alternative solutions though.
  8. Not to mention there is still software in use that only supports IE6.
  9. <form action="" method="post" name="myForm"> <div> <input type="text" name="person[0][name]" /> <input type="text" name="person[0][email]" /> </div> <div> <input type="text" name="person[1][name]" /> <input type="text" name="person[1][email]" /> </div> <div> <input type="text" name="person[2][name]" /> <input type="text" name="person[2][email]" /> </div> <input type="submit" name="button" id="button" value="Submit" /> </form> <?php // $_POST will then essentially look like this array: $arr = array( array( 'name' => 'Bob', 'email' => 'bob@domain.com' ), array( 'name' => 'Sally', 'email' => 'sally@domain.com' ), array( 'name' => 'Fred', 'email' => 'fred@domain.com' ) ); // Make your sql statement $insert_sql = "insert into `mytable` ( `name`, `email` ) values "; // Add values parts $parts = array(); foreach( $arr as $person ) { $parts[] = sprintf( "( '%s', '%s' )", mysql_real_escape_string( $person[ 'name' ] ), mysql_real_escape_string( $person[ 'email' ] ) ); } // Append the parts $insert_sql .= implode( ', ', $parts ); // Run query $rv = mysql_query( $insert_sql ); // ... ?>
  10. Well PostgreSQL is a database just like MySQL. You create tables, store data, build indexes, and retrieve the data later. The primary advantages of PostgreSQL, IMO, is that it hasn't recently been acquired by Oracle and is still very much supported. MySQL isn't going anywhere soon, but it's future is a little uncertain as far as I'm concerned now that it's owned by a proprietary company that already has a proprietary database product. PostgreSQL also supports some features that I'm not sure you get in MySQL, such as a variety of a database programming languages, the ability to make your own aggregates, database schemas, advanced storage types, inherited tables, etc. The PostgreSQL community is also very active should you have support issues. I converted from MySQL to PostgreSQL for my projects at work about 2 years ago and haven't used MySQL since, nor have I wanted to.
  11. For a time sensitive application I would consider storing everything in GMT time and convert it to user's timezone upon display. (edit) Additionally if you're going to be importing datetime data from outside sources consider very carefully if you want to save those columns with timezone information. For example I have a PostgreSQL database that a mirrors a FoxPro database. The FoxPro database does not store timezone information but I made all of my PostgreSQL columns timestamp (0) with time zone. Eventually this turned out to be a serious bug and it was a nightmare to correctly fix all of the imported data.
  12. It sounds like you're still in the research stages so I recommend looking at PostgreSQL instead of MySQL. If you have a host that supports PostgreSQL 8.x then I wouldn't bother with MySQL.
  13. Think carefully about whether it really makes a difference. Try not to micro-optimize to the point that your code is difficult to read and maintain.
  14. In my experience with PDO/PgSql, my code ends up looking like: <?php class PDO_PgSql extends PDO { /** * @param string $host * @param string $port * @param string $user * @param string $password * @param [string] $dbname * @param [string] $port * @param [bool] $throw_exceptions * @param [bool] $ssl_mode * @return PDO_PgSql */ public function __construct( $host, $user, $password, $dbname = null, $port = null, $throw_exceptions = true, $ssl_mode = false ) { // // Build the connection string if( $port === null ) { $port = '5432'; // Default pgsql port } $dsn = sprintf( 'pgsql:host=%s port=%s user=%s password=%s', $host, $port, $user, $password ); if( $dbname !== null ) { $dsn .= ' dbname=' . $dbname; } if( $ssl_mode === true ) { $dsn .= ' sslmode=require'; }else{ $dsn .= ' sslmode=disable'; } // // Driver options $driver_opts = array(); if( $throw_exceptions === true ) { $driver_opts[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION; }else{ $driver_opts[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_WARNING; } // // Create parent::__construct( $dsn, null, null, $driver_opts ); // // Custom PDOStatement class $this->setAttribute( PDO::ATTR_STATEMENT_CLASS, array( 'PDOStatement_PgSql' ) ); // // Throw exceptions. Yes, set it in two places if( $throw_exceptions === true ) { $this->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } } ... } ?> You'll notice that I turn on exception handling via options in the constructor as well as explicitly calling the setAttribute() method. It doesn't seem to hurt anything and its the only way I was able to get it to work uniformly on Windows and Linux with the versions of PHP I run. Hope that helps.
  15. No. $foo is not created. <?php // some stuff if (some_conditional) { // something happens here and returns or exits echo var_export( isset( $foo ), true ) . PHP_EOL; exit(); } // we never get here $foo = array(); exit(0); ?>
  16. HTTPS must be used for any sensitive data. Any site that isn't doing so is at major risk of major problems.
  17. Are you trying to create a PHP function that works like JavaScripts setInterval or setTimeout methods? If so you'll have to look into shared memory and pcntl_fork(). If you're trying to do this on Windows I recommend a different programming language.
  18. roopurt18

    Idiots.

    You're supposed to change all of the necessary passwords before you go on vacation so they can't do these sorts of things.
  19. I use PDO and PostgreSQL on Linux servers for fairly data intensive processes and analysis and performance has always been acceptable. The advantage to prepared statements, regardless of PDO or another extension is primarily repeated queries will perform better. In addition, the arguments will also be correctly escaped by the database wrapper as well; this eliminates your need as the developer to insert mysql_real_escape_string() calls all over the place (at least this is true with PDO/PostgreSQL). This is only true to some extent. Once you start using SQL syntax supported by only one flavor you still end up writing if-else or switch statements. However at least the method names and error handling can be somewhat consistent.
  20. IPs can be spoofed. You need to use sessions.
  21. I wouldn't bother with any "drag-n-drop" editors. They tend to add 10 times more markup than is necessary to make anything work. PhpED from nusphere is what we develop with at work.
  22. Your code is vulnerable to SQL-injection attacks. Read the PHP manual for mysql_real_escape_string() for examples and assistance.
  23. I can't help you much as I don't really know cURL. Some of my PHP applications do communicate with web servers as if they were a browser though and I use the HttpRequest() object for that. The documentation is a little buried so I'll link that to you: http://php.he.net/manual/en/class.httprequest.php More specifically the documentation for the send() method has some examples: http://php.he.net/manual/en/function.httprequest-send.php In my applications that use HttpRequest, I generally do the following: 1) Create a single HttpRequest object 2) Perform the initial POST to log in to a page 3) Check the response for any cookies from the web server and add them to the HttpRequest object Now if I want to make future requests to the site, I can reuse the HttpRequest object that has the set cookies by doing the following: 1) Change the URL on the HttpRequest object 2) Change the method, GET or POST, as necessary 3) Add any POST data or files to upload 4) Call send 5) Check the response I frequently use this method to write small export applications that upload data to web sites via HTTPS. Following is a small code snippet from my code that you can adjust to set the object up: <?php class some_app{ public function __construct() { // snippet... $http = new HttpRequest( $this->_url, HTTP_METH_POST ); $http->addPostFields( array( 'client' => $this->_cfg['www']['client'], 'key' => $this->_cfg['www']['key'] ) ); $http->send(); $cookies = $http->getResponseCookies(); foreach( $cookies as $cookie ) { $http->addCookies( $cookie->cookies ); } $json = json_decode( $http->getResponseBody() ); $this->_continue = $json->Continue; $this->_http = $http; // snippet } /** * Clears the HTTP request for another send operation. Call this method from * elsewhere in your class to communicate with the web site you've logged into. * * @param string $url * @param array $post * @param array $postfiles * @param bool $send * @return stdClass|bool */ private function httpRequest( $url, $post, $postfiles = null, $send = false ) { $this->_http->setUrl( $url ); $this->_http->setPostFields( $post ); $this->_http->setPostFiles( $postfiles === null ? array() : $postfiles ); if( $send !== true ) { return false; } $this->_http->send(); return json_decode( $this->_http->getResponseBody() ); } } ?> Now I should mention some other things: 1) HttpRequest() is just a wrapper for cURL so you can accomplish all of the same with cURL. 2) In my case I control both the client (the program simulating the browser) and the server (the website). Hence I know that I don't have any special handling such as URL redirects, accepting any cookies past the initial login, or worrying about session ID changes. 3) The php_http extension is required for HttpRequest() and can be difficult to locate. I believe it is part of PECL, but I've found DLLs for Windows. I hope that helps you some.
  24. Optionally cURL may have an option to perform redirects for you, so you might look into that.
×
×
  • 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.