PHP Knowledge Base Update -- July 7th, 1999

From: Date: Thu, 08 Jul 1999 04:33:16 +0000
Subject: PHP Knowledge Base Update -- July 7th, 1999
Groups: php.kb 
Request: Send a blank email to php-kb+get-11@lists.php.net to get a copy of this message
Pablo Godel announced a new Spanish PHP mailing list: Hemos creado una lista para los amantes de PHP en español. Se pueden suscribir enviando un email a: php-subscribe@listserver.iwcc.com.ar That XML-RPC server class is now available for the latest CVS PHP and a patched 3.0.9 (or above): http://usefulinc.com/xmlrpc/ Cheers, Nathan ------------------------------------------------------------ Why isn't PATH_INFO working? When is data available in PATH_INFO? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/432 ------------------------------------------------------------ Steven Champeon PATH_INFO is only passed when there is some info. http://yourserver.com/your/script/path/info should set PATH_INFO to "/path/info". cf. the CGI "spec": http://hoohoo.ncsa.uiuc.edu/cgi/ or, if you're into such things, the Draft RFC: http://Web.Golux.Com/coar/cgi/ http://Web.Golux.Com/coar/cgi/draft-coar-cgi-v11-03-clean.html#6.1.6 ------------------------------------------------------------ How can I transform a boolean search request into an SQL query? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/434 ------------------------------------------------------------ Kristian Köhntopp PHPLIB has an SQL_Query widget that transforms a graphical representation of a boolean search request into SQL. See http://phplib.shonline.de/showroom/sqlquery.php3 for an example. As an example, please construct the SQL query ( name like '%User%' and changed < '19990701000000' ) by hitting "More" on time. Then set the first row to "Session Name" "contains" "User" and the second row to "Change Date" "<" "19990701000000". ------------------------------------------------------------ How can I use an external mail server from PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/436 ------------------------------------------------------------ Jon Parise You can either exec sendmail (or an equivalent) directly, or you can use one of the many PHP SMTP implementions that open an actual socket connection to the remote mail server. Search the archives or examples sites for code. ------------------------------------------------------------ Are recursive functions supported by PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/437 ------------------------------------------------------------ Joe Walnes Recursive functions are completely valid in PHP. For more information see: http://www.php.net/manual/language.variables.php3 ------------------------------------------------------------ Can I use Javascript to encrypt passwords entered in HTML forms? How can I send a users password from a HTML form back to the server encrypted? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/438 ------------------------------------------------------------ Manuel Lemos The most common technique to do so is to use Javascript to encode the password field right before submitting the form. I have developed a PHP class that generates forms with the necessary Javascript code to do so. The the page located at the URL below you may find the code for that class as well an example to do what you need. The class uses an hidden field to store the encoded version of the password and clears the password field after validating the form. In this case the md5 algorithm is used. This assumes that you will be able to check your password on the server side with the correct password also encoded as md5. You may use other encoding algorithms if you can provide a Javascript to implement them. Note that the ability to encode passwords this way before submitting a form relies on a Javascript enable browser. If the browser does not support Javascript, it will still send the password in clear text. http://phpclasses.upperdesign.com/browse.html?package=1 ------------------------------------------------------------ Can I use an ASP style cookie dictionary in PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/440 ------------------------------------------------------------ Hendrik M.J. Arnoldus, Jason Brooke, Samuel Liddicott, Matthew Clark PHP3 treats cookies as a simple "name"/"value" pair. In ASP, it is possible to treat a cookie like a dictionary: i.e. one cookie can have a set of "name"/"value" pairs for one cookie name; in that case, the cookie is defined as a dictionary and has the property HasKeys as True. A dictionary cookie (URL Encoded) has a structure like: MyCookie ISMEMBER=True&REGISTEREDUSER=True&TCPADDR=111%2E222%2E33%2E44&DEPARTMENT=COMPSCIENCE&LASTNAME=DOE&FIRSTNAME=John&OS=WinNT MyDomain/ 0 1155155072 29280368 647743440 29280360 * This translates to: (changed case for readability) ("MyCookie")("IsMember") = True ("MyCookie")("RegisteredUser") = True ("MyCookie")("TcpAddr") = 111.222.33.44 ("MyCookie")("Department") = "COMPSCIENCE" ("MyCookie")("LastName") = "Doe" ("MyCookie")("FirstName") = "John" ("MyCookie")("OS") = "WinNT" All other parameters as in a normal (non-dictionary) cookie. All the ASP is doing here is reading out the string and arranging the key/pairs for you in an array under the Cookie's name. In Php you get to do it that way if you like, or also any of a number of other ways. See the parse_str() function in the manual for starters - it'd be pretty easy to make a quick small function to mimic what ASP is doing with the cookie using this function. Since the data that can be stored in a cookie is limited in size you may like to consider creating a session for your users and storing the data on the server. See PHPLIB for an implementation: http://phplib.shonline.de ------------------------------------------------------------ Can I use Javascript to determine if the user has a certain plugin installed? How can I work out if a user has the flash plugin installed? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/441 ------------------------------------------------------------ Jørg V. Bryne, Teodor Cimpoesu, Manuel Lemos You need to use Javascript to do determine if a user has certain plugins. Here is a Javascript example on how to detect if the browser has certain plugins. Only change the given example MIME type by application/x-shockwave-flash. http://www.irt.org/script/482.htm ------------------------------------------------------------ Can I execute Oracle stored procedures in PHP? Do I have access to Oracle OUT parameters in PHP? How do I access Oracle stored procedure return values in PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/443 ------------------------------------------------------------ Aaron Leon Kaplan For binding to an stored procedure OUT variable see the documentation for Oracle 8 (OCI) -> OCIBindByName. Perfeclty simple. Return values: I use an extra OUT variable for each stored proc. called errnum. That is my return value. I bet you could do functions with return values in OCI but I havent tried it yet. The other retun value (that you probably don't mean) is the return value of the OCI Execute stmt. That just says if your PL/SQL query worked or if there was some ora-xxxx error. ------------------------------------------------------------ Can an OCIExecute stmt return a failure if you issue a user defined exception in your stored proc? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/446 ------------------------------------------------------------ Mark Britton Try using RAISE_APPLICATION_ERROR in your exception handler. That should return an error status back to the calling program. ------------------------------------------------------------ Why can't I get the PHP debugger to work? How do I enable the debugger for PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/447 ------------------------------------------------------------ Teodor Cimpoesu 1. First, check if you have compiled php with debugger support. You must see a line like "debugger- no aditional information" with phpinfo(). I think 3.0.11 configure script don't really turn it on even if you say --enable-debugger so after configuring take a look in config.h for PHP_DEBUGGER 1 or something. 2. edit php3.ini and set debugger.host = your_host debugger.port = a port ( like 7654) debugger.enabled = true 3. set a listener to that port. I use netcat, given by a pal from the list. I set it like in a script called debugger.sh [debugger.sh] nc -l -p 7654 >> debugger_log echo -e " ------------ end log -----------"; Because after debugger closes connection to the port nc finishes too, I set this line in /etc/inittab: rc:2345:respawn:/path/to/debugger.sh so everytime it dies, a new listener is created. 4. use debugger_on("your_host"); to enable it. 5. run steps 4-1 backward and undo all, cause you don't need all that output from debugger. You cannot set error report level so every notice will be there, most mega with something like "notice: variable unitialized before use" or something. 6. unless you skipped #5 and you really need such a tool for a short time consider using it. Other useful debugging features are system logs (see error_log). ------------------------------------------------------------ How can I convert all entries in an associative array into variables? How can I make variables from the key names in an array? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/449 ------------------------------------------------------------ Rasmus Lerdorf How about something like: while(list($k,$v)=each($array)) { $$k = $v; } ------------------------------------------------------------ How can I run server side includes (SSI) and PHP together? How can I call server side includes from PHP scripts? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/451 ------------------------------------------------------------ Ian Kallen Try this: AddType text/html .shtml AddHandler server-parsed .shtml AddType application/x-httpd-php3 .php3 So then you can say <!--#include virtual="/my/php_thingy.php3" --> and <? require("$DOCUMENT_ROOT/ssi_thingy.html" ?> You can mix and match your content handling as you see fit. Though I can't think of anything I can do with mod_include that I can't do with PHP, but as a migratory/transitional hack, the above will work just swell. ------------------------------------------------------------ Will calling getimagesize() for every image on a page slow things down? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/453 ------------------------------------------------------------ Rasmus Lerdorf getimagesize() will slow things down a bit if you think about it. It has to open up each of those 30 images and read enough of them to figure out the size of the image each contains. ------------------------------------------------------------ Can I escape from PHP code anywhere? Can I mix code and HTML tags? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/454 ------------------------------------------------------------ Mike Wood, Karl Pielorz, Rasmus Lerdorf In PHP you can break out of script execution, insert HTML, and jump back into the script from just about anywhere. By 'switching' off the PHP3 engine for areas of static HTML your actually saving a lot on processing / parsing, i.e. it's a very good thing... if (mysql_num_rows($result) == 0) { ?><p><p> <h2><center>Your search produced no results</center><p></h2> <? exit; } else { $data = mysql_fetch_array($result); ?> <p> <table border=1 BGCOLOR=lightgrey> <tr><td>field1</td> <td>field2</td> <td>field3</td> <td>field4</td> <td>field5</td></tr> <? print("<tr><td>$data[0]</td> <td>$data[1]</td> <td>$data[2]</td> <td>$data[3]</td> <td>$data[4]</td></tr>"); } This is very much intended and encouraged. For often-used blocks you can even do something like the following where we jump out of PHP mode inside a function definition: <? function block($arg) { ?> Here is some straight <b>HTML</b> And perhaps a <a href="<?echo $arg?>">Link</a> <? } ?> Now whenever you need that block of HTML just call block("whatever");

« previous php.kb (#11) next »