PHP Knowledge Base Update -- September 15th, 1999

From: Date: Thu, 16 Sep 1999 05:13:10 +0000
Subject: PHP Knowledge Base Update -- September 15th, 1999
Groups: php.kb 
Request: Send a blank email to php-kb+get-33@lists.php.net to get a copy of this message
I'm settled at a friends house in Ottawa for a little while so the daily summaries are back again. Welcome to everyone who has joined this list in the last few weeks. I apologise for the database problems that e-gineer has been experiencing this week. Cheap web hosts are great until you need technical support. I'm in the process of moving e-gineer to a dedicated machine so things will be a lot more reliable. Cheers, Nathan ------------------------------------------------------------ How do I set up PHP so the mail() function works with qmail? Why won't the mail() function work with qmail? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/618 ------------------------------------------------------------ Sheamus Nulty Try making qmail's "sendmail" wrapper available to MUAs and leave your php3.ini as it was for sendmail. Here are sample unix commands: # ln -s /var/qmail/bin/sendmail /usr/lib/sendmail # ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail ------------------------------------------------------------ How can I work out what version of PHP I'm using? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/621 ------------------------------------------------------------ Richard Lynch Create a page with just this line: <?php phpinfo() ?> The resulting output should tell you what version of PHP is running. ------------------------------------------------------------ How can I get the URL of the current page that the script is processing? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/622 ------------------------------------------------------------ Rasmus Lerdorf The variable: $PHP_SELF stores the URL of the current page being served. ------------------------------------------------------------ How can I execute multiple unix commands with one system call? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/623 ------------------------------------------------------------ John Millaway, Richard Lynch, Teodor Cimpoesu Try this: system("cd /etc ; ls -l"); or this: chdir("/etc"); system("ls -l"); or this: system("cd /etc \n ls -l"); or these bash variations: system("ls -l /etc"); system("cd /etc && ls -l"); ** OTHER RANDOMLY SELECTED PHPKB ENTRIES ** ------------------------------------------------------------ What sort of array does mysql_fetch_array return? Why does each() return every column twice after a query? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/170 ------------------------------------------------------------ Read the manual: http://www.php.net/manual/function.mysql-fetch-array.php3 The optional second argument result_typ in mysql_fetch_array() is a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. MYSQL_ASSOC will return an array that is keyed by the names of the columms. eg: array(col1=>val1, col2=>val2). MYSQL_NUM will return an array that is keyed by order in which the columsn are returned. eg: array(0=>val1, 1=>val2). MYSQL_BOTH gives you the best of both worlds. eg: array(0=>val1, col1=>val1, 1=>val2, col2=>val2). Be careful when using MYSQL_BOTH. If you try to use the each() function in a while loop you will get all of the values back in turn. http://www.php.net/manual/function.each.php3 ------------------------------------------------------------ How do I stop PHP pages from being stored in the browser's cache? What is the Cache-control header used for? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/281 ------------------------------------------------------------ header("Cache-control: no-cache"); header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); The first header is for HTTP/1.1 compatible proxies/clients. The second is for HTTP/1.0. The Cache-control header is the HTTP/1.1 equivilant of the HTTP/1.0 header Pragma: no-cache. It causes the client (most specifically, proxies) to not cache the document. You would use this on something like a realtime banking session or most any page where the user has been authenticated. Cache-Control: also adds more features than Pragma. no-store, max-age=? max-stale=?, min-fresh=?, and only-if-cached. For more information see the HTTP/1.1 specification at: http://www.w3.org/Protocols/Specs.html ------------------------------------------------------------ How can I redirect different browsers to different pages? How can I show a different page to each different browser? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/556 ------------------------------------------------------------ I guess you could use $HTTP_USER_AGENT to get the browser and then: if($browser == 'netscape') { Header("Location: http://the.server.com/netscape.html"); } elseif ($browser == 'ie'{ Header("Location: http://the.server.com/explorer.html"); } else { Header("Location: http://the.server.com/default.html"); } I know netscape.com has a pretty uptodate javascript on their server that you might have a look at to see exactly how the matching should be done. ------------------------------------------------------------ Why does $HTTP_REFERER return an empty string? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/32 ------------------------------------------------------------ Are you trying to use HTTP_REFERER inside a function? If so, you'll need to add a 'global $HTTP_REFERER;' line to your function to get at the variable from the global scope. In order for $HTTP_REFERER to work, there needs to be a HTTP_REFERER header. This header does not exist if someone types in the URL directly (ie: does not follow a link to the page). It only exists when someone clicks on a link from another page. ------------------------------------------------------------ I have added a function to file.c and recompiled. Why doesn't it exist in PHP? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/253 ------------------------------------------------------------ Did you add it to the function list at the top of the file? It has to make itself known to php or it is just text in a file.

« previous php.kb (#33) next »