php-general Digest 16 Jan 2002 09:13:19 -0000 Issue 1114

Topics (messages 80630 through 80671):

Re: Another question - not exactly what i was looking for
        80630 by: mike cullerton
        80631 by: R'twick Niceorgaw
        80633 by: Christopher William Wesley

mysql_insert_id?
        80632 by: Wee Chua
        80639 by: DL Neil
        80640 by: DL Neil

Re: sql question
        80634 by: Janet Valade
        80636 by: Darren Gamble

Re: splitting up an array into lines ...
        80635 by: Martin Towell

PHP, LDAP and OS X
        80637 by: Quinn Perkins

Re: 404 Redirection
        80638 by: FiShcAkE

Re: Search Engine
        80641 by: Greg Schnippel
        80648 by: J Smith

compiling and *translating* template class
        80642 by: Wolfram Kriesing

php modify my javascipt code before output????
        80643 by: Vincent Ma
        80645 by: Bogdan Stancescu
        80646 by: Tino Didriksen

session problems not finding my variables..
        80644 by: Peter Lavender

base64_encode problem while using IMAP
        80647 by: Kathy

Re: Extending PHP
        80649 by: Yasuo Ohgaki
        80652 by: Anas Mughal
        80657 by: Yasuo Ohgaki

Re: NEWBIE IN DISTRESS:  Install Instructions are not work for PHP 4.1.1!!!
        80650 by: Floyd Baker

Question about HTTP_ENV_VARS, PHP, and Apache
        80651 by: Michael Sims
        80653 by: Michael Sims
        80659 by: Rasmus Lerdorf

KISGB Version 3.1 Released - PHP Guest Book
        80654 by: Gaylen Fraley

php 4.1 and DOMXML question.
        80655 by: Aaron
        80656 by: Aaron

dynamic module or static?
        80658 by: Cary Mathews

benchmarking php scripts
        80660 by: Eugene Lee
        80663 by: Yasuo Ohgaki
        80671 by: Eugene Lee

disable_functions... Was: about your mail on php list
        80661 by: Berthold

HTTP AUTHENTICATION Solution
        80662 by: Bharath

Beginner: Open URL
        80664 by: Tommi Trinkaus
        80667 by: Nick Wilson

StripSlashes() & quotes in text boxes
        80665 by: Robert MacCombe

Lazy evaluation?
        80666 by: Alexander Deruwe
        80668 by: Jimmy

Re: Authentication Question
        80669 by: Bharath
        80670 by: Bharath

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
how 'bout something like

$query = 'select * from table_name where ';
$and = '';
if ($lastname != '') {
 $query .= "lastname = $lastname";
 $and = ' and ';
}
if ($firstname != '') {
 $query .= $comma."firstname = $firstname;
 $and = ' and ';
}

and so on

on 1/15/02 1:53 PM, Phil Schwarzmann at [EMAIL PROTECTED] wrote:

> Yo, thanks for all your help.  But it isn't exactly what im looking for.
> 
> Let's say you had a database with the following four columns...
> 
> -LastName
> -FirstName
> -Age
> -Weight
> 
> ...and you wanted a page that would allow a user to search for one or
> more of these fields within the database.
> 
> It would be easy if the user could only pick just one of the fields.
> But let's say that want to search only lastname and firstname, or maybe
> all four, or maybe just one.  How could this be done?
> 
> If I have code that looks like this...
> 
> $query = "select * from table where lastname='$lastname' and
> firstname='$firstname' and age='$age' and weight='$weight'";
> 
> $result  = mysql_query ($query);
> $num_results = mysql_num_rows($result);
> 
> ...the $num_results is ALWAYS zero unless I typed in all four fields.
> 
> Any help?
> 
> Thanks!
> 


 -- mike cullerton   michaelc at cullerton dot com


--- End Message ---
--- Begin Message ---
construct your query like
$query = "select * from table where ";
lastname='$lastname' and
> firstname='$firstname' and age='$age' and weight='$weight'";

if (isset($lastname) and $lastname !="") then
$query.=" lastname=$lastname ";
if (isset($firstname) and $firstname !="") then
$query.=" and firstname=$firstname ";
and so on.......

You may need to do some more checking like if there already been a field
selected earlier  if so then add "AND " before the current field else don't
add the "AND ".
Hope that helps.

----- Original Message -----
From: "Phil Schwarzmann" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, January 15, 2002 3:53 PM
Subject: [PHP] Another question - not exactly what i was looking for


> Yo, thanks for all your help.  But it isn't exactly what im looking for.
>
> Let's say you had a database with the following four columns...
>
> -LastName
> -FirstName
> -Age
> -Weight
>
> ...and you wanted a page that would allow a user to search for one or
> more of these fields within the database.
>
> It would be easy if the user could only pick just one of the fields.
> But let's say that want to search only lastname and firstname, or maybe
> all four, or maybe just one.  How could this be done?
>
> If I have code that looks like this...
>
> $query = "select * from table where lastname='$lastname' and
> firstname='$firstname' and age='$age' and weight='$weight'";
>
> $result  = mysql_query ($query);
> $num_results = mysql_num_rows($result);
>
> ...the $num_results is ALWAYS zero unless I typed in all four fields.
>
> Any help?
>
> Thanks!
>

--- End Message ---
--- Begin Message ---
$where_conditions = array();
if( !empty( $lastname ) ){
        $where_conditions[] = "lastname like '%${lastname}%'";
}
if( !empty( $firstname ) ){
        $where_conditions[] = "firstname like '%${firstname}%'";
}
if( !empty( $age ) ){
        $where_conditions[] = "age = ${age}";
}
if( !empty( $weight ) ){
        $where_conditions[] = "weight = ${lastname}";
}

$where_clause = "";
$num_conditions = sizeof( $where_conditions );
if( $num_conditions > 0 ){
        $where_clause = "where ";
        for( $c = 0; $c < $num_conditions; $c++ ){
                $where_clause .= $where_conditions[$c];
                if( $c < $num_conditions - 1 ){
                        $where_clause .= " && ";
                }
        }
}

$query = "select * from table ${where_clause}";

...

that should be flexible enough for you to add new
fields to check, by only having to add "column = $value"
values to the $where_conditions array.

        g.luck,
        ~Chris                           /"\
                                         \ /     September 11, 2001
                                          X      We Are All New Yorkers
                                         / \     rm -rf /bin/laden

On Tue, 15 Jan 2002, Phil Schwarzmann wrote:

> Yo, thanks for all your help.  But it isn't exactly what im looking for.
>
> Let's say you had a database with the following four columns...
>
> -LastName
> -FirstName
> -Age
> -Weight
>
> ...and you wanted a page that would allow a user to search for one or
> more of these fields within the database.
>
> It would be easy if the user could only pick just one of the fields.
> But let's say that want to search only lastname and firstname, or maybe
> all four, or maybe just one.  How could this be done?
>
> If I have code that looks like this...
>
> $query = "select * from table where lastname='$lastname' and
> firstname='$firstname' and age='$age' and weight='$weight'";
>
> $result  = mysql_query ($query);
> $num_results = mysql_num_rows($result);
>
> ...the $num_results is ALWAYS zero unless I typed in all four fields.
>
> Any help?
>
> Thanks!
>



--- End Message ---
--- Begin Message ---
Hi,
Is it possible that I would get the wrong ID (Not the ID I just inserted in
Auto_Increment field) by using mysql_insert_id function if someone is also
inserting record at the same time? How does mysql_insert_id work accurately?

Thanks,
Wee
--- End Message ---
--- Begin Message ---
Hi Wee,

> Is it possible that I would get the wrong ID (Not the ID I just inserted in
> Auto_Increment field) by using mysql_insert_id function if someone is also
> inserting record at the same time? How does mysql_insert_id work accurately?


=A couple of things here:

1 if the field is defined as "Auto_Increment" then YOU will not insert an ID. Leave 
the field out of the INSERT
statement or transfer NULL, and MySQL will insert the correct ID value according to 
the 'increment' policy.

The construction of the mysql_insert_id() looks like this:
$AutoIncrementId = mysql_insert_id( $MySQLConnection );
Note that the function argument is the connection to MySQL (not the db/tbl !). Thus 
the ID is a by-product of
the connection (and the most recent INSERT it handled) - re-read the appropriate page 
in the manual for more
information, if required.

2 because the (function argument) controlling feature is the connection, it is not 
possible for another
concurrent user to 'steal' your ID or influence the ID returned to you - it's all 
yours!

The only way to get the "wrong" ID is to perform two IDs and then (vainly) try to get 
hold of the previous ID -
only the latest ID is available.

Clear now?
=dn



--- End Message ---
--- Begin Message ---
Hi Wee,

> Is it possible that I would get the wrong ID (Not the ID I just inserted in
> Auto_Increment field) by using mysql_insert_id function if someone is also
> inserting record at the same time? How does mysql_insert_id work accurately?


=A couple of things here:

1 if the field is defined as "Auto_Increment" then YOU will not insert an ID. Leave 
the field out of the INSERT
statement or transfer NULL, and MySQL will insert the correct ID value according to 
the 'increment' policy.

The construction of the mysql_insert_id() looks like this:

$AutoIncrementId = mysql_insert_id( $MySQLConnection );

Note that the function argument is the connection to MySQL (not the db/tbl !). Thus 
the ID is a by-product of
the connection (and the most recent INSERT it handled) - re-read the appropriate page 
in the manual for more
information, if required.

2 because the (function argument) controlling feature is the connection, it is not 
possible for another
concurrent user to 'steal' your ID or influence the ID returned to you - it's all 
yours!

The only way to get the "wrong" ID is to perform two IDs and then (vainly) try to get 
hold of the previous ID -
only the latest ID is available.

Clear now?
=dn




--- End Message ---
--- Begin Message ---
select * from tbl_lit where lit_source like "c%"

Janet

----- Original Message ----- 
From: "Wolf-Dietrich von Loeffelholz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 15, 2002 12:09 PM
Subject: [PHP] sql question


i want that a select query display me all words beginning with an a ..
like select * from tbl_lit where lit_source = 'c*' .. 
 
thnx bSue


--- End Message ---
--- Begin Message ---
Good day,

This isn't a PHP question, but hey...

This is dependant on the database platform that you're using.  The suggested
statement would work on MySQL.  On Informix, for example, you would say
'where lit_source matches "c*" '.

You should consult your database manual for more information.

============================
Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


-----Original Message-----
From: Janet Valade [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 3:04 PM
To: Wolf-Dietrich von Loeffelholz; [EMAIL PROTECTED]
Subject: Re: [PHP] sql question


select * from tbl_lit where lit_source like "c%"

Janet

----- Original Message ----- 
From: "Wolf-Dietrich von Loeffelholz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 15, 2002 12:09 PM
Subject: [PHP] sql question


i want that a select query display me all words beginning with an a ..
like select * from tbl_lit where lit_source = 'c*' .. 
 
thnx bSue



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
The problem is that this line:
    $rpm_list = `rpm -qa`;
gives back a string, so use this:
    $rpm_list = `rpm -qa`;
    $rpm_list = explode("\n", $rpm_list);
and see how that goes

Martin

-----Original Message-----
From: Neil Mooney [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 16, 2002 12:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] splitting up an array into lines ...


I want this code to work thru a large cluster and put the rpm information
into a db ,
it all works apart from the foreach loop.

why doesnt my code work ( in particular the foreach loop ) ,

// get hostname
$host = `hostname`;

// get a list of rpms

$rpm_list = `rpm -qa`;

// open a db connection and insert them into the db

include "db.php";


print "working on host : $host\n";

$test = mysql_query ("SELECT * FROM machine_info WHERE host = '$host'");
$test1 = mysql_fetch_object ($test);

print "TEST: $test1->host\n";

if ($test1->host == "")
        {
        print "machine doesnt exists in the db , adding an entry for
$host\n";
        $add_machine_to_table = mysql_query("INSERT INTO machine_info (host)
VALUES ('$host')");
        }

// get the rpm list a line at a time

foreach($rpm_list as $rpm)
        {

        $query = "UPDATE machine_info SET rpm = '$rpm' WHERE host =
'$host'";

        if (!(mysql_query($query)))
                {
                print "Mysql could not do the update query - for host
$host";
                }
        }

------------

i get :

X-Powered-By: PHP/4.0.6
Content-type: text/html


working on host : lxplus038

TEST: lxplus038

<br>
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>
get_rpm_info.php</b> on line <b>29</b><br>


--

many thanx in advance

Neil
:)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
The frustrating part is, I had this working on OS X 10.0.4. I am now 
running 10.1.2 Server.

I successfully build OpenLDAP and it is working fine.

I successfully built a version of PHP 4.0.6 for OS 10.1 with the 
instructions found at 
http://developer.apple.com/internet/macosx/php.html. It compiled without 
error using:

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var 
--mandir=/usr/share/man --with-apxs --with-zlib --with-
ldap=/Users/quinn/Desktop/Services/ldap/ldap --disable-pear 
--enable-trans-sid

After moving the libphp4.so and editing the httpd.conf file, I started 
the web server, but got the following error:

dyld: /usr/sbin/httpd Undefined symbols:
_ldap_add_s
_ldap_bind_s
_ldap_compare_s
_ldap_count_entries
_ldap_count_values
_ldap_count_values_len
_ldap_delete_s
_ldap_dn2ufn
_ldap_err2string
_ldap_explode_dn
_ldap_first_attribute
_ldap_first_entry
_ldap_first_reference
_ldap_get_dn
_ldap_get_option
_ldap_get_values
_ldap_get_values_len
_ldap_initialize
_ldap_memfree
_ldap_modify_s
_ldap_msgfree
_ldap_next_attribute
_ldap_next_entry
_ldap_next_reference
_ldap_open
_ldap_parse_reference
_ldap_parse_result
_ldap_perror
_ldap_rename_s
_ldap_result
_ldap_search
_ldap_search_s
_ldap_set_option
_ldap_unbind_s
_ldap_value_free
_ldap_value_free_len
/usr/sbin/apachectl start: httpd could not be started

Now...my OpenLDAP works fine. My PHP with LDAP compiled without error. 
Anyone have any ideas as to what might be wrong?

- Quinn
--- End Message ---
--- Begin Message ---
Thanks Mike,

I think that is what I want to do, i'll give it a go

Thanks
Lee  :-)


"Mike Cullerton" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> on 1/13/02 6:07 AM, FiShcAkE at [EMAIL PROTECTED] wrote:
>
> > Try that again, without pressing ctrl-enter this time!!
> >
> > As I said, I have got the usual script:
> >
> > <?
> > if(isset($action))
> > {
> > $include = $action;
> > } else {
> > $include = "home";
> > }
> > include($include. ".inc");
> > ?>
> >
> > but, how do I put in a custom error page instead of seeing:
>
> if i understand what you are asking, you might try something like
>
>  if (is_file($include. ".inc")) {
>    include($include. ".inc");
>  } else {
>    include(custom_error.inc);
>  }
>
> you may need to execute is_file($include. ".inc") inside a loop so that it
> checks in all your inlude_directories.
>
>  foreach($dirs as $dir) {
>   if (is_file($dir.'/'.$include. ".inc")) {
>    blahblahblah
>   }
>
>
> otherwise, if you know 'all' the valid files, you could create an array of
> filenames and compare $include to elements of the array.
>
> >
> > Warning: Unable to access anyotherpage.inc in
> > /var/virt/home/stuffwefound-co-uk/public_html/index.php on line 70
> >
> > Warning: Failed opening 'anyotherpage.inc' for inclusion
(include_path='') in
> > /var/virt/home/stuffwefound-co-uk/public_html/index.php on line 70
> >
> > I have got an error page for any other url i.e.   apagenotfound.php  but
I
> > dont know how to overcome the above.
> >
> > Thanks in advance
> >
> > Lee
> >
>
>
>  -- mike cullerton   michaelc at cullerton dot com
>
>


--- End Message ---
--- Begin Message ---

> * On 15-01-02 at 12:09 
> * Yogesh Mahadnac said....
> 
>>     Hi all! I want to develop a search engine in PHP for a 
>> portal that I'm working on at the moment, and I'd be glad if 
>> someone could please show me how to do it, or if anyone knows 
>> of a link where i can find a tutorial for that.
>
> I don't think PHP is really a very good language for a genuine www
> search engine. (although it works very well on site-wide basis)
> I'm sure more knowledgeable people than I can make some alternative
> suggestions but I'm certain that PHP won't be the best tool 
> for the job.

I would concur with what everyone else is saying. If you need a search
engine and you have system-level access on your machine, your best
bet is to set up either htdig or mnogosearch (open source search
engine packages) because they already have done the hard work of 
figuring out fuzzy matching and search ranking.

http://www.htdig.org/
http://mnogosearch.org/

Alternatively, if you are using a database you can use some tricky sql 
statements to search your records for the user's search query. Here's 
a good tutorial that should get you started on this route:

http://www.devshed.com/Server_Side/PHP/Search_Engine/page1.html


-schnippy
--- End Message ---
--- Begin Message ---

PHP isn't totally bad for a search engine. Here's my story.

I was in a bit of a predicament when I first started work, because I had to 
develop a search engine for online video objects. My company is essentially 
a video re-purposing venture, where we take reams of analog, tape-based 
videos, encode them into something like MPEG or ASF or whatever, create 
clip indexes (i.e. a 30 minute clip is broken up into 10x 3-minute clips, 
with each clip described and categorized) and provide a search engine and 
interface to watch clips or videos on the web via a broadband connection. 

(An added bonus is that you can create your own "video" via personal 
playlists -- you can take 10 different clips from 10 different videos and 
run them together into one playlist, all online. In a few months, you'll be 
able to create your own clips if you don't like our predefined ones.)

Anyways, the search engine thing was my deal. I'm the only programmer 
(*period*) on our team, and I basically had to write a search engine, web 
site backend, admin interface and all that jazz for our app alone. I was 
hired March 6, 2001 or so, and I had until, oh, April 15, 2001 to do it. 
Plus there were a few conditions -- like, it should be portable and 
inexpensive.

PHP seemed like a good choice -- it was portable (Win32, *ix, whatever), it 
was cheap ($0) and it isn't too bad for rapid development.

So off I was. I did manage to finish the search engine and back end by 
April 15, but it was a mess. It wasn't exactly a stellar search engine, but 
more of a proof of concept, which was the whole point of the project -- to 
show that we could provide high quality streaming video through a browser 
with a relatively good interface.

After the proof-of-concept project, we started to get serious, and I 
dropped most of the code base and started again from scratch. 

Pretty much the entire search engine now is in PHP, with the sole 
exceptions being the keyword indexer (Perl, as PHP was a lot slower doing 
the indexing) and a few extensions to the PHP engine. 

The search engine itself is fairly fast -- it can do a keyword search on a 
collection of nearly 8,000 video objects in an average of 0.02 to 0.20 
seconds or so, depending on the complexity of the query. It's features 
include:


* "Boolean"-type searches. Okay, not really, as in you can't use AND, OR 
and NOT, but you can use +/- style prefixes like in mnoGoSearch and 
whatnot. Words are automatically OR'ed, +'d words are AND'ed and -'d words 
are NOT'ed.

* Decent search times. On a PIII 500 with 128 MB of RAM, it still averages 
less than 0.20 seconds for a collection of 8,000 video objects and over 
100,000 keywords.

* Filtering. We're mostly an education-based site, so you can filter by 
things like subject (Physics, Chemistry, etc.) and grades (Kindergarden, 
grade 10, college, etc.)

* Spellchecking and somewhat fuzzy searches. Spellchecks work okay, but the 
fuzzy searches is kind of lame. (Porter stemming.) I might shoehorn in 
something like Metaphone-type stuff eventually. 

* Search ranking. Yes, keywords are given weights, everything is ranked and 
all that jazz. You know, inverse document frequencies, collection 
distribution, all that stuff. In the end, video objects returned in a 
search are given a ranking of 1 to 4 based on how well they match your 
query. It's not terribly advanced, and could use some tuning, but it's 
surprising how well it works.

* XML-based. The search engine itself runs as it's own daemon on either 
it's own server or along side the web site, and just waits for connections 
via a UNIX domain socket or a TCP socket. When it receives a query, and 
sends back an XML document containing the search results. This is 
especially nice -- you can use it with anything for any purpose, not just a 
web site, i.e. you can build an native app for Windows and you can still 
use the search engine, and just format the results via an XSL or whatever.


There are a lot of other nifty features, like being able to do remote admin 
via telnet or whatever. But in the end, it's still just a decent search 
engine and definitely not Google or even htdig. It's very focused on our 
specific task, the searching of online educational videos, so something 
using something like htdig would have required a lot of hacking to get it 
to where we wanted it.

So the morale I guess is, sure, you can make a half-decent search engine 
out of PHP. Ours gets the job done. But remember, I only had, like, a scant 
few months to write one, plus a web-based app to go around it, and I was 
alone on this one. PHP was great for RAD, and the damn thing even works to 
boot. My search engine could handle a web site easily enough, maybe even a 
group of sites, but it would totally suck ass as a WWW indexer/spider-type 
search engine. 

So there ya go.

J



Greg Schnippel wrote:

> 
>> * On 15-01-02 at 12:09
>> * Yogesh Mahadnac said....
>> 
>>>     Hi all! I want to develop a search engine in PHP for a
>>> portal that I'm working on at the moment, and I'd be glad if
>>> someone could please show me how to do it, or if anyone knows
>>> of a link where i can find a tutorial for that.
>>
>> I don't think PHP is really a very good language for a genuine www
>> search engine. (although it works very well on site-wide basis)
>> I'm sure more knowledgeable people than I can make some alternative
>> suggestions but I'm certain that PHP won't be the best tool
>> for the job.
> 
> I would concur with what everyone else is saying. If you need a search
> engine and you have system-level access on your machine, your best
> bet is to set up either htdig or mnogosearch (open source search
> engine packages) because they already have done the hard work of
> figuring out fuzzy matching and search ranking.
> 
> http://www.htdig.org/
> http://mnogosearch.org/
> 
> Alternatively, if you are using a database you can use some tricky sql
> statements to search your records for the user's search query. Here's
> a good tutorial that should get you started on this route:
> 
> http://www.devshed.com/Server_Side/PHP/Search_Engine/page1.html
> 
> 
> -schnippy

--- End Message ---
--- Begin Message ---
a stable version of the template class
and other stuff PEAR-like-made are available at

http://wolfram.kriesing.de/programming


especially the   _template_class_   which can also *translate* your
templates without the need of wrapping every string in a function
call or something
the translation can also be used with other template engines, like
smarty i guess

see example at:
http://wolfram.kriesing.de/libs/php/examples/SimpleTemplate/fullFeatured/


--
Wolfram
--- End Message ---
--- Begin Message ---
Hi everyone :

  I got a amagzing problem about javascipt after integrate to php.  PHP will
modify the ouput of javascipt, produce the error when first load that page.
However, reload this page, no error.

Orginal javascipt:

function f31(v31,v23,ocjs,hrck,cn)
{
  return "<a onclick=\""+ocjs+"\"

Become :

function f31(v31,v23,ocjs,hrck,cn)
{
  return "<a onclick="\"""+ocjs+"\"



Add extra " "............., this produce error...... but reload is
alright........

And i try this page file extension to .htm then everything is ok....
therefore i think php did some pre-process before send ouput.

I try to turn off magic quote setting in php.ini but still have a problem.

Thank for you help

Vincent Ma


--- End Message ---
--- Begin Message ---
Posting the actual PHP doing the job would help...

Bogdan

--- End Message ---
--- Begin Message ---
When you echo or print to the HTML stream, strings are delimited by " or '.
Your case, return "<a onclick=\""+ocjs+"\", is correct JS but not PHP.

When you want to echo this in PHP you must echo it as
return \"<a onclick=\\\"\"+ocjs+\\\\
in order to counter the strings being ended before time.

More info:
http://www.php.net/manual/en/language.types.string.php

Another function you might want to look at is stripslashes():
http://www.php.net/manual/en/function.stripslashes.php

--|--
Tino Didriksen
http://ProjectJJ.dk/


--- End Message ---
--- Begin Message ---
Hi everyone,

I'm not sure what I have done wrong here.  I haven't been sucessful in
finding anything that points to what the cuase could be.

What I find interesting is that I have used session in another area of the
web site with out problems.  The only difference between it and the way I
have done it here is that I'm using the header function in this bit of code,
where as the session is started and variables registered and the processing
is done on another page.

Anyway here is the code for the log in page:

<?php
session_start();
file://session_unset();

include('./connectDB.php');
include('./commonfunctions.php');
?>

function checkdetails($db, $HTTPVARS) {
    //check if allowed access
    $user = $HTTPVARS['uid'];
    $passwd = $HTTPVARS['passwd'];

    $sql = "select * from tbl_maxware where loginID = '$user' and password =
'$passwd';";
    $result = $db->query($sql);
    checkError($result, $db, "Error in checkDetails");

    if ($result->numrows() == 0) {
        echo "<html><body>";
        echo "<h2>Error Loging In</h2>";
        echo "<br>Not a valid login try again or contact the admin<br>";
        echo "<a href=\"./login.php\">Try Again</a>";
        echo "</body></html>";
        exit();
    } else {
        // matched in the maxware table
        $result->fetchinto($success);
        $UID = $success[0];
        $logUID = $success[1];
        $logName = $success[2];
        //echo session_save_path();
        session_register("UID", "logUID", "logName");
        // send them to the main page
        header("Location: ./supportau.php");
    }

} // end checkdetails

if (array_key_exists( "uid", $HTTP_POST_VARS ) ) {
    checkdetails($db, $HTTP_POST_VARS);
} else {
    login();
}
?>



Code for the following "main page"

<?php
session_start();
include( './connectDB.php' );
include('./commonFunctions.php');
?>
<html>
<head>
<title></title>
<style>
    <!--
        @import url(./max.css);
        @import url(./supportAU.css);
        @import url(./link.css);
    -->
</style>
</head>
<body>
<h2>Support Database</h2>
<center>
<table width="90%" border="1">
<tr><td rowspan="2" width="30%">
<!--<table width="100%" border="1" bgcolor="#887766">
<tr><td> -->
<?php
echo "Name= $logName";



<snip>

This returns an error:

 PHP Warning: Undefined variable: logName in
c:\inetpub\wwwroot\supportau\supportau.php on line 25

Thanks,

Pete



--- End Message ---
--- Begin Message ---
I've been trying to decode an attached image in an email using imap.

Parse error: parse error, expecting `T_VARIABLE' or `'$''  in "imapTest.php"
on line 80

$image = trim(@imap_fetchbody($mbox, "2", "2"));
$64image = base64_encode($image);

I've also tried:

$image = trim(@imap_fetchbody($mbox, "2", "2"));
$64image = imap_base64($image);

Can someone tell me what I'm missing?


--- End Message ---
--- Begin Message ---
Anas Mughal wrote:
> I am looking into building a dynamically loadable
> module under PHP4. The documentation on extending PHP4
> is unclear or is missing instructions on how to
> generate dynamic loadable module file. I have followed
> the instructions but I can't seem to be able to create
> the module. 
> (I even looked at Sterling Hughes article on
> WebTechniques.) 
> Is there a step that I am missing or what?
> Do I need to modify the m4 file or the makefile?
> Please advise...
> 

Most basic thing you need is explained in Zend API Doc.
Visit www.zend.com for the document.

BTW, api docs in source dist is too old. It does not
worth to read :)

-- 
Yasuo Ohgaki

--- End Message ---
--- Begin Message ---
I presume you have created dynamically loadable
modules in PHP4.
If so, how do you create your module file?
Do you run a specific make command or do you build it
manually?

Thanks for your help...



--- Yasuo Ohgaki <[EMAIL PROTECTED]> wrote:
> Anas Mughal wrote:
> > I am looking into building a dynamically loadable
> > module under PHP4. The documentation on extending
> PHP4
> > is unclear or is missing instructions on how to
> > generate dynamic loadable module file. I have
> followed
> > the instructions but I can't seem to be able to
> create
> > the module. 
> > (I even looked at Sterling Hughes article on
> > WebTechniques.) 
> > Is there a step that I am missing or what?
> > Do I need to modify the m4 file or the makefile?
> > Please advise...
> > 
> 
> Most basic thing you need is explained in Zend API
> Doc.
> Visit www.zend.com for the document.
> 
> BTW, api docs in source dist is too old. It does not
> worth to read :)
> 
> -- 
> Yasuo Ohgaki
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 


=====
Anas Mughal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Tel: 973-249-6665

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- End Message ---
--- Begin Message ---
Anas Mughal wrote:
> I presume you have created dynamically loadable
> modules in PHP4.
> If so, how do you create your module file?
> Do you run a specific make command or do you build it
> manually?
> 
> Thanks for your help...
> 

Again, read Zend API manual...
You are also interested in README.EXT_SKEL file that can
be find under PHP source root.

There is a nice program that create skelton for new
modules :)

If you are plainning to marge PHP source dist, use CVS
source instead of source distribution.

-- 
Yasuo Ohgaki


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

--- End Message ---
--- Begin Message ---



I'm stuck here too.  Don't know that much in the first place except
that I did get it together once.  Apache/php4/mysql on win32...  Now
to upgrade it's all new again.  

I'm sure php config files are ok to the point where apache picks it
up.  There is no 4.1.1 file as called for in the apache loadmodule
line.  Instead of /sapi/php4dll, the closest I find is
/sapi/apache/php4dsp.  I can also remember some file extensions being
renamed but can't find anything on that now..  Any clue where I'm
losing it will be very helpful I'm sure.  

Thanks.

Floyd








On Sun, 6 Jan 2002 00:35:39 -0600, you wrote:

>Nothing noted in the error log.  The lines I have tried using are the EXACT
>ones stated in the install.txt file.  I basically copied them from the
>install doc and pasted it into the httpd.conf file.
>
>Mark
>
>"Brian Clark" <[EMAIL PROTECTED]> wrote in message
>20020105034518.GH17616@ganymede">news:20020105034518.GH17616@ganymede...
>> * Mark ([EMAIL PROTECTED]) [Jan 04. 2002 12:14]:
>>
>> [...]
>>
>> > the Module version (Get a "Requested Operation Failed" message).  can
>> > someone please help?????  My system is as follows:
>>
>> > Windows 2000 SP2
>> > Apache 2.0.28 (I have also tried version 1.3.22 with same results as
>>
>> People had problems in that past with 2.x; I don't know if the php-dev's
>> have worked that out yet.
>>
>> > mentioned above)
>> > PHP 4.1.1
>> > MDAC 2.7
>> > MySQL 3.23.46a
>>
>> Are there any hints in Apache's error_log? What is your exact LoadModule
>> line you're using in httpd.conf?
>>
>> --
>> Brian Clark | Avoiding the general public since 1805!
>> Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
>> In politics, stupidity is not a handicap.
>>

--

--- End Message ---
--- Begin Message ---
This may be more of an Apache question, but I was hoping that someone here 
would have an idea about this.

I tracked down a bug in one of my scripts that was caused by environment 
variable that was being registered as global without my knowledge (due to 
the register_globals setting).  My script was depending on this variable 
not being set in certain conditions but I didn't take into account the fact 
that it could be set via an environment variable.

While troubleshooting this I was looking through the output of phpinfo() 
and I found something curious in the environment variables across the three 
different servers that I administer.  All three are running Redhat, Apache 
1.3.19, and PHP 4.0.4.pl1, with PHP compiled as an Apache module 
(--with-apxs).  One of the servers is Redhat 7.0, the other two are Redhat 
7.1.  On both the Redhat 7.1 servers, phpinfo() reports the following 
environment variables:

user: michaels
logname: michaels
bash_env: /home/michaels/.bashrc
mail: /var/spool/mail/michaels

"michaels" is the user account that I use on these servers to do a majority 
of my work, only su'ing to root when absolutely necessary.

I'm confused as to why these variables exist.  I know for a fact that 
Apache is running as "nobody".  That's what the httpd.conf file is 
configured for and I can verify that by viewing the output of "ps aux"  I 
did build apache and php as this user, but I su'ed to root for the "make 
install" portion.  I launched apache with "apachectl" as root.

On the Redhat 7.0 machine these env vars don't exist.

Can anyone enlighten me or perhaps point me to a source of more info?  Any 
help would be appreciated...

--- End Message ---
--- Begin Message ---
At 09:32 PM 1/15/2002 -0600, Michael Sims wrote:
>On both the Redhat 7.1 servers, phpinfo() reports the following 
>environment variables:
>
>user: michaels
>logname: michaels
[...]
>I'm confused as to why these variables exist.  I know for a fact that 
>Apache is running as "nobody".  That's what the httpd.conf file is 
>configured for and I can verify that by viewing the output of "ps aux"  I 
>did build apache and php as this user, but I su'ed to root for the "make 
>install" portion.  I launched apache with "apachectl" as root.

Following up to my own post:

Apparently these variables are set whenever Apache is started (via 
"apachectl start").  Whatever environment variables exists in the context 
that apachectl is called in will apparently be put in HTTP_ENV_VARS (and 
subsequently be made global if register_globals is on).

On the servers that have my username as "LOGNAME" I apparently started 
Apache by first logging in as "michaels", then using "su" to get to root, 
then starting Apache.  Since I didn't log in as root or su using the "-" or 
"-l" options, whatever environment variables were set as my normal user 
stayed in effect, and thus Apache picked them up when the httpd daemon was 
started.

What had confused me before was that these vars didn't change after an 
"apachectl restart" but I've since found out that this only causes Apache 
to re-read it's configuration (SIGHUP)...it doesn't actually kill the 
process and restart it.

Sorry for the semi-off-topic info, but I'm posting this just in case 
someone read my original message and was similarly confused.

--- End Message ---
--- Begin Message ---
This has been discussed a number of times here. Apache will always inherit
the environment of the user that starts it. You should start it with a
clean environment. ie. add "env -i" to whatever script starts your httpd
server.

-Rasmus

On Tue, 15 Jan 2002, Michael Sims wrote:

> This may be more of an Apache question, but I was hoping that someone here
> would have an idea about this.
>
> I tracked down a bug in one of my scripts that was caused by environment
> variable that was being registered as global without my knowledge (due to
> the register_globals setting).  My script was depending on this variable
> not being set in certain conditions but I didn't take into account the fact
> that it could be set via an environment variable.
>
> While troubleshooting this I was looking through the output of phpinfo()
> and I found something curious in the environment variables across the three
> different servers that I administer.  All three are running Redhat, Apache
> 1.3.19, and PHP 4.0.4.pl1, with PHP compiled as an Apache module
> (--with-apxs).  One of the servers is Redhat 7.0, the other two are Redhat
> 7.1.  On both the Redhat 7.1 servers, phpinfo() reports the following
> environment variables:
>
> user: michaels
> logname: michaels
> bash_env: /home/michaels/.bashrc
> mail: /var/spool/mail/michaels
>
> "michaels" is the user account that I use on these servers to do a majority
> of my work, only su'ing to root when absolutely necessary.
>
> I'm confused as to why these variables exist.  I know for a fact that
> Apache is running as "nobody".  That's what the httpd.conf file is
> configured for and I can verify that by viewing the output of "ps aux"  I
> did build apache and php as this user, but I su'ed to root for the "make
> install" portion.  I launched apache with "apachectl" as root.
>
> On the Redhat 7.0 machine these env vars don't exist.
>
> Can anyone enlighten me or perhaps point me to a source of more info?  Any
> help would be appreciated...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

--- End Message ---
--- Begin Message ---
Version 3.1 of my Keep It Simple Guest Book (KISGB) has just been released.
Many major and minor enhancements.  Please
visit my web site for details!
--
Gaylen
[EMAIL PROTECTED]
PHP KISGB v3.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/



--- End Message ---
--- Begin Message ---
How the hell do I get the content of a node....

before all I had to do was go $node->content

now it doesnt seem to work.

I know they changed $node->name to $node->tagname.

I tried, content, tagcontent, value, mmm some other things. I give up,
couldnt find any info anywhere either...

theres a set_content() method but doenst seem to be a get_content()
method :(.


--- End Message ---
--- Begin Message ---
How the hell do I get the content of a node....

before all I had to do was go $node->content

now it doesnt seem to work.

I know they changed $node->name to $node->tagname.

I tried, content, tagcontent, value, mmm some other things. I give up, 
couldnt find any info anywhere either...

theres a set_content() method but doenst seem to be a get_content() 
method :(.

--- End Message ---
--- Begin Message ---
I am attempting to build a dynaminc module loadable by apache 1.3.x. But
once the (./configure, make, make install, cp php.ini-dist, configure
httpd.conf) process is complete, I restart apache, and try to access a php
page (<? phpinfo() ?>) and I am asked if I would like to download the
page, which is not the expected or desired behavior. :/

Reading through the INSTALL file and the php.net FAQs, I did notice that
there was a mention of copying the compiled httpd directly over the
existing one. Would that not indicate a static module had been compiled?
Else where it appears a libphp4.so is created and placed in the modules/
directory. When I attempt to put a LoadModule directive in my httpd.conf
file to tell apache about the module, I get the following error from
apachectl configtest:
 Syntax error on line 205 of /usr/local/apache/conf/httpd.conf:
 API module structure `php4_module' in file
 /usr/local/apache/modules/libphp4.so
 is garbled - perhaps this is not an Apache module DSO?
I read this one of two ways, a) 'php4_module' is not the correct way to
refrence this module, or b) the libphp4.so module is corrupted, somehow.
Is either one of these right?

I've recompiled twice now, and still no luck.  If I comment out the
LoadModule directive, it starts, but my browser asks if I want to download
the php page instead of displaying it.

Has anyone encountered this before?

Cary Mathews




--- End Message ---
--- Begin Message ---
Is there a way to benchmark a PHP script to see how intensive it is?
For example, execution time, CPU/RAM/disk usage, etc.  Thanks in advance.


-- 
Eugene Lee
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Eugene Lee wrote:
> Is there a way to benchmark a PHP script to see how intensive it is?
> For example, execution time, CPU/RAM/disk usage, etc.  Thanks in advance.
> 


Try APD.

http://apd.communityconnect.com/

It's a degugger and profiler.
It does not show all of bench you want,
but it works well for profiling.

For CPU/RAM/DISK, you can take system bench
while you are accessing scripts.

-- 
Yasuo Ohgaki

--- End Message ---
--- Begin Message ---
On Wed, Jan 16, 2002 at 05:41:34PM +0900, Yasuo Ohgaki wrote:
: 
: Eugene Lee wrote:
: > 
: > Is there a way to benchmark a PHP script to see how intensive it is?
: > For example, execution time, CPU/RAM/disk usage, etc.  Thanks in advance.
: 
: Try APD.

Thanks.  It'll be a decent start.  Getting a few million hits per day is
really taking a toll on our server.


-- 
Eugene Lee
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hello,

disable_functions still works ONLY via setting in php.ini.
I think this is a bug.

ini_set("disable_functions", "phpinfo");
has no effect,

php_value_admin disable_functions phpinfo
shows the correct output from phpinfo with one line for
disable_functions phpinfo...
At least this is a bug.

prune wrote:

> Hi,
> 
> I'm having the same problem as you mentionned.
> I can't find any answer on the list archives...
> 
> is the problem still happening with php 4.1 ?
> is this a bug, or a feature ?
> 
> Thanks,
> Cheers,
> 
> Prune
> 
> 
> ----------------------------------
> List:     php-general
> Subject:  [PHP] Problem with disable_functions
> From:     "Berthold Tenhumberg" <[EMAIL PROTECTED]>
> Date:     2001-09-20 9:29:53
> [Download message RAW]
> 
> Hi all!
> 
> Did I find a bug?
> 
> Disabling the function 'system' per php.ini works well. OK.
> 
> Disabling the same function per Apache-directive does not. Why?
> 
> php_admin_value disable_functions system
> --=20
> =20
> (live long and prosper...)
> 
> 
> 
> 


-- 
Berthold

--- End Message ---
--- Begin Message ---
Here is a solution I developed for the HTTP AUTHENTICATION on that buggy
Internet Explorer.
I want some feedbacks, improvements, Comments...


Bharath
(B. h.  Loh.)
bharath_b_lohray (at) yahoo.com



Please correspond via email for my convinience and
also on the News Group for the benifit of the Php Developers...


=================== START OF SOURCE CODE [lohauthsol.php]===================
<?php
//Username and password verification function
//takes (username,password) returns TRUE/FALSE
function verify($un,$pw)
{
    //Verify against a database etc....
    if
((($un=="bharath")&&($pw=="password1"))||(($un=="tom_dick_harrypotter")&&($p
w=="password2")))
    {
        $ok=TRUE;
    }
    else
    {
        $ok=FALSE;
    }
    return $ok;
}

//Procedure to display a standard error if login
//fails
function er($err)
{
    echo "<html><head><title>$err</title></head><body bgcolor=\"#FFFFFF\"
text=\"#000000\"><p><font face=\"Courier New, Courier, Terminal\"
size=\"3\"><font size=\"5\">$err</font><br><br>Could not log you in. <a
href=\"lohauthsol.php\">TRY AGAIN</a></font></p></body></html>";
}

//Procedure to ask username and password by
//HTTP AUTHENTICATION
function ask()
{
    header("WWW-Authenticate: Basic realm=\"1024x1024.net
Administration\"");
    header("HTTP/1.0 401");
    er("Unauthorized");
    exit;
}

//BEGIN MAIN PROGRAMME
if ((!isset($PHP_AUTH_USER))||(!verify($PHP_AUTH_USER,$PHP_AUTH_PW)))
{
    ask();
}
else
{
    echo "OK";
    exit;
}
?>
=================== END OF SOURCE CODE ===================


--- End Message ---
--- Begin Message ---
Hi over there,

i'm just beginning with php and i wonder if it is possible to show another
url in the current window like the <a> Tag in HTML.
Thanks for any answer...

tommi


--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* On 16-01-02 at 09:50 
* Tommi Trinkaus said....

> Hi over there,
> 
> i'm just beginning with php and i wonder if it is possible to show another
> url in the current window like the <a> Tag in HTML.
> Thanks for any answer...

I'm not sure what you mean can you be a little more detailed?
I can tell however that PHP is *not* a substitute for HTML. If you want
something like the <a> tag then *use* the <a> tag.

HTH
- -- 

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8RUEkHpvrrTa6L5oRAhHHAJ49g3T89zgjW2wxypuqkt3Qwz5cqwCfd0sF
RpYr1yo504a7JW9VN+uAbXQ=
=at90
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Hi,
I have had a few problems retrieving MySql entries that contain quote marks.
Slashes have been added before storing an item description such as:
17" SVGA Monitor.
They've been removed before display too - and the description appears
correctly on a page except when displaying in a text box (for an
administrator to edit the item description. When displayed in a text box the
description just shows 17. The only solution I can find is to swap the quote
marks for &quot; when storing the item initially and when any update has
been submitted by the user.
Is this the best way, and are there any other characters waiting to cause
the same problem that I don't know about yet?
Thanks,
Robert MacCombe


--- End Message ---
--- Begin Message ---
Hey all,

Does PHP support lazy evaluation? Meaning that if:

if (isset($HTTP_POST_VARS['submit']) 
        && $HTTP_POST_VARS['submit'] == 'create')
        
does PHP stop evaluating after the first condition if $HTTP_POST_VARS is
not set?

(please CC me in replies)

Thanks in advance,

--
Alexander Deruwe ([EMAIL PROTECTED])
AQS-CarControl
--- End Message ---
--- Begin Message ---
Hi Alexander,

> Does PHP support lazy evaluation? Meaning that if:

Yes, it does.

--
Jimmy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Got a dictionary?  I want to know the meaning of life.

--- End Message ---
--- Begin Message ---
Create another table with info of accounts.....

Auth_table
username(varchar)
password(varchar)
acno(int)

accounts_info_table....
acno(int)
info1
info2()

Pass a query
======================
select * from accounts_info_table where acno==$abc
======================
here $abc is the info you extract from the fauth_table during the login
process.....

Hope this is what you wanted to know....
I am intrested in your problem.....
Please correspond.....

Bharath Bhushan Lohray

bharath_b_lohray (at) yahoo.com

--- End Message ---
--- Begin Message ---
Create another table with info of accounts.....

Auth_table
username(varchar)
password(varchar)
acno(int)

accounts_info_table....
acno(int)
info1
info2()

Pass a query
======================
select * from accounts_info_table where acno==$abc
======================
here $abc is the info you extract from the fauth_table during the login
process.....

Hope this is what you wanted to know....
I am intrested in your problem.....
Please correspond.....

Bharath Bhushan Lohray

bharath_b_lohray (at) yahoo.com


--- End Message ---

Reply via email to