LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Nathan Wallace Date: Tue Sep 21 00:35:07 1999 Subject: PHP Knowledge Base Update -- September 20th, 1999
------------------------------------------------------------
Do the OCI functions work with 64 bit Oracle?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/641
------------------------------------------------------------
Wai-Sun Chia
I'm running Oracle-8.0.5 and PHP-3.0.11 on a Digital Unix
4.0f/Alphaserver box and no problems...(and DEC Unix has been 64-bit
since 1995).
------------------------------------------------------------
How can I search a file for a particular string?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/642
------------------------------------------------------------
Rasmus Lerdorf
You have to read the file into a string and search it using strstr().
http://www.php.net/manual/function.strstr.php3
------------------------------------------------------------
How can I select all check boxes in a form?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/643
------------------------------------------------------------
Richard Feather
You'll need to do it with Javascript on the client...
Something like...
function checkAll()
{
for(var i=0;i<document.element.foo.elements.length;i++)
{
var e = document.foo.elements[i];
if (e.name!='allbox')
e.checked = document.foo.allbox.checked;
}
}
where the name of the form is 'foo'... I'm doing this from memory and
it isn't exact (it loops over all elements) so you might need to work
with it a little. But as I look at it it should work okay.
------------------------------------------------------------
Do I have to pass a parameter to --with-mysql when configuring?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/644
------------------------------------------------------------
Richard Lynch
If you don't use the --with-mysql directive, PHP won't know how to talk
to MySQL.
If you use --with-mysql but leave off the =/path/to/mysql/installation,
the installer looks in the standard places for MySQL and hopefully finds
it.
A typical example would look like:
--with-mysql=/usr/local/mysql
------------------------------------------------------------
How can I reset $PHP_AUTH_USER to log out a user?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/645
------------------------------------------------------------
Richard Lynch
Make the user quit the browser.
Unfortunately, the only other option rumored to work is to change realm
out from under the user, while keeping track of who's who on the server,
and what realm[s] they have used. This is so funky, that nobody has
documented it very well how to do it.
------------------------------------------------------------
How can I delete or deallocate an element from an array?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/647
------------------------------------------------------------
Rasmus Lerdorf, Richard Lynch
Try something like:
unset($arr[$index]);
here is the doc:
http://www.php.net/manual/function.unset.php3
** OTHER RANDOMLY SELECTED PHPKB ENTRIES **
------------------------------------------------------------
How cam I sort the contents of a file using PHP?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/541
------------------------------------------------------------
You could use a system call:
exec("sort -o db.txt db.txt");
or you can do the whole thing in PHP using:
$db = file("db.txt");
sort($db);
$dbh = fopen("db.txt","w") || die("couldn't open");
fwrite($dbh,implode($db,"\n");
Probably what you really want though is a database, especially if the
files will be large.
------------------------------------------------------------
How do I connect to an ODBC database?
Where can I get an example of an ODBC session?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/582
------------------------------------------------------------
Code for an ODBC connection:
$myDB = odbc_connect("Movies","","");
$query = "SELECT * FROM MovieList";
$result = odbc_exec($myDB, $query);
$report = odbc_fetch_row($result);
echo odbc_result($result, 1);
odbc_close($myDB);
This code would goto whichever database you have declared as "Movies" in
your System DSN list with no login or password. Then using $query (if
you don't know SQL, write your query using that Access Design View, then
switch to SQL View, and it'll show you the 'code' for it). The rest is
straightforward, just prints out the first field of the first row in the
database.
About the DSN's, if you operate your server, (I'm assuming your on NT :)
just goto ODBC Data Sources in Control Panel and add your database to
System DSN.
Driver = Access.
Data Source Name = (in this example) "Movies".
------------------------------------------------------------
What PHP type is used to hold values from a database?
Why are all results from a database query made into strings in PHP?
I can't convert TEXT in MySQL after retrieve to String in php3. String
parse error occurs. How?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/611
------------------------------------------------------------
It's a feature. PHP has 3 basic data types. Databases have many many
more times that. Attempting to map 50 datatypes into 3 is going to be
extremely messy. PHP2 worked like that and it was extremely confusing.
PHP3 is consistent and always does the same thing, so there is no
confusion. You always get strings and you never lose data nor
precision.
It is better to leave it up to the script writer what to do with the
data than having PHP magically trying to determine what to do.
------------------------------------------------------------
How can I create a cookie that works with both www.mydomain.com and
mydomain.com?
Is a cookie set for www.mydomain.com sent in a query to mydomain.com?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/363
------------------------------------------------------------
Cookies only work for the exact domain name that they are set. For
example:
SetCookie("Cookie",$value,"time()+3600","/dir/","www.mydomain.com",0);
sets a cookie that will only ever be sent by the client to the server if
the server domain name is *www.mydomain.com. The client looks to see if
the cookie domain matches exactly the tail end of the request domain.
Reading the Netscape Cookie Specification:
http://home.netscape.com/newsref/std/cookie_spec.html
you will learn that the domain in the cookie must contain two periods
(.). This is to prevent people setting a cookie that might be sent to
every .com domain for example. That means that a cookie like this:
SetCookie("Cookie",$value,"time()+3600","/dir/","mydomain.com",0);
will not be remembered by the browser.
This is a problem because often people access the same site using both:
http://www.mydomain.com
http://mydomain.com
so neither of the cookie setting techniques above will work.
You can set a single cookie that will work for both of these domains by
including a leading period in the domain name.
SetCookie("Cookie",$value,"time()+3600","/dir/",".mydomain.com",0);
The difference is that ".domain.com" sets a domain-wide cookie (which
will be sent to http://domain.com, http://www.domain.com, and
http://whatever.domain.com). Without the leading ".", it will only
get sent to that specific hostname.
An alternative solution, is to redirect people who log in to
http://mydomain.com
to the site (with www.mydomain.com cookie):
http://www.domain.com
but this may inconvenience some users.
------------------------------------------------------------
How do I reference a variable that is defined inside a class?
http://www.e-gineer.com/e-gineer/phpkb/view.phtml/qid/31
------------------------------------------------------------
You need to do $object->var. For example:
class Foo {
var $i;
function Foo() {
$this->i = new Bar;
}
}
$f = new Foo;
echo $f->i;
| Navigate in group php.kb at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |