php-general Digest 26 Jan 2003 20:47:35 -0000 Issue 1846
Topics (messages 133162 through 133192):
Re: __LINE__,__FILE__ + custom error handlers
133162 by: Jason k Larson
Re: OO2relation mapping
133163 by: Dominik Wittenbeck
133164 by: Manuel Lemos
133165 by: Manuel Lemos
xtemplate & windows
133166 by: Cenk Uysal
133167 by: rush
133172 by: John W. Holmes
CRLF in file
133168 by: Malcolm Brownell
133171 by: Jason Wong
133174 by: Malcolm Brownell
133175 by: Malcolm Brownell
133177 by: Jason Wong
Problems to compile php (cvs)
133169 by: Robert Mena
133176 by: Evan Nemerson
go to detail page problem
133170 by: WMB
Perl Includes when executed with php....
133173 by: Mike Morton
human language detection
133178 by: Marco Bleeker
133180 by: Jason Wong
Using MySQL user variables in PHP
133179 by: Jim MacCormaic
133181 by: Jason Wong
133183 by: John W. Holmes
133184 by: Mark Charette
133185 by: Jim MacCormaic
133186 by: Jason Wong
Combine 3 MySql rows into one PHP output row ?
133182 by: CF High
Re: Masive mail Advice
133187 by: Maciek Ruckgaber Bielecki
Predefined Variables In Classes
133188 by: . Nilaab
133189 by: Philip Olson
Problem solved
133190 by: WMB
Java call on object causes segfault.
133191 by: John Wells
PHP And Apache
133192 by: Beogradjanin
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 ---
from: http://www.php.net/manual/en/function.set-error-handler.php
string set_error_handler ( callback error_handler)
The user function needs to accept 2 parameters: the error code, and a
string describing the error. From PHP 4.0.2, an additional 3 optional
parameters are supplied: the filename in which the error occurred, the
line number in which the error occurred, and the context in which the
error occurred (an array that points to the active symbol table at the
point the error occurred).
example:
function myErrorHandler ($errno, $errstr, $errfile, $errline,
$errcontext) {...}
HTH,
Jason k Larson
electroteque wrote:
hi guys i am trying to create callback error functions handlers , i was
wondering if there was a way to get the file and line caught in a error
function say with a database abstraction query without having to explicitly
put the line and number in the query function , at the moment if i put line
and file inside the error handler it will only display where the error was
caught inside the handler itself :|
--- End Message ---
--- Begin Message ---
I am targeting a more slim solution though, solving a very specialized
problem. As a developer I simply hate needing to change a database table,
splitting it up, to make it fit the customers needs. I causes all those SQL
statement to be revised.
With the oo2rel mapping layer I have put much thought into the possibility
that a project's datastructure actually might need a change when it is live
and filled with data. I cannot simply change the structure, recompile my
classes and submit them. I somehow need to preserve integrity within the
data model as well. I know I cannot come up with a comprehensive tutorial,
not even working examples, but this is the background in front of which I
need to operate and somehow I feel I am not the only one
I am going to keep basic SQL statements, since that's the way developers,
not having a degree think in those relational SQL structures as they
understand them more easily. Why take something away from them they know.
SQL will just be adapted to OO-state in a manner that is readable and
understandable at first glance.
As I said: not as comprehensive and complete as your project, but I think
its targeting a more specific solution, that occurs often enough in everyday
life to need support. You didn't discourage me at all, but rather give me an
idea, where thing might be going for me in the future. Tnx! I will have a
look into MetaL, that's for sure, but I will also continue with the OO2REL
project ;-)
"Manuel Lemos" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> On 01/25/2003 01:40 PM, Dominik Wittenbeck wrote:
> > I am currently developing a object to relational mapping layer for PHP.
It's
> > NOT a simple treat all databases like one kind of layer (although it
does
> > involve it to preserve extensibility) but an XML based intermediate
layer
> > that creates both, table structures, following a conventional scheme and
PHP
> > classes that allow, OO access to these tables.
> > I have enclosed the XML file that represents the intermediate layer. Its
> > pretty readable even without the XML schema.
> > I am currently under development, so don't expect anything useful in
less
> > than a few weeks
> >
> > Question:
> > Does anyone of you know anyone who has tried something similar, because
my
> > research on the subject grows thin? Is something like this of public
> > interest at all, or would you prefer accessing your datastructure the
old
> > fashion way?
>
> You have pretty much describe Metastorage. It is basically a generator
> application that lets you model classes of objects that are mapped and
> stored in relational database database.
>
> You just need to to describe your classes also in a XML file with the
> class variables, validation rules, relationships between classes and the
> types of functions that your application needs to manipulate the classes
> objects.
>
> Metastorage generates all the code for the classes ready to use in your
> applications. That includes also a separate class with code to install
> the database schema. The resulting classes API is database independent.
> This means that you do not need to change your application to use the
> same classes with different types databases. Many types of databases are
> supported. Still, you do not need to write absolutely any SQL in
> anywhere. Metastorage generates adequate code for you where needed.
>
> I do not mean to discourage from continuing your work, but since there
> is a great deal of overlap between Metastorage and what you have in
> mind, you are most welcomed at least to eveluate Metastorage if not also
> contribute in anyway to its development.
>
> Metastorage is Open Source and is avaliable here:
>
> http://www.meta-language.net/news-2002-12-09-metastorage.html
>
> http://www.meta-language.net/metastorage.html
>
>
> --
>
> Regards,
> Manuel Lemos
>
--- End Message ---
--- Begin Message ---
Hello,
On 01/26/2003 02:59 AM, Dominik Wittenbeck wrote:
Sounds most interesting (and far more ambicious, than what I had in mind).
I'll probably do you wrong by not grasping the full extend of the project,
but in short, did I get it right:
XML2UML2ProgrammingLanguage
Don't be mislead by this page. Generation of UML class diagrams is just
a bonus feature. It is not even a core feature. It is just helpful to
explain and document your project class relationships.
The main goal is to generate code in a few seconds that otherwise would
take you days or weeks to write, test and debug manually.
http://www.meta-language.net/news-2002-12-09-metastorage.html
--
Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---
Hello,
On 01/26/2003 03:20 AM, Dominik Wittenbeck wrote:
I am targeting a more slim solution though, solving a very specialized
problem. As a developer I simply hate needing to change a database table,
splitting it up, to make it fit the customers needs. I causes all those SQL
statement to be revised.
With the oo2rel mapping layer I have put much thought into the possibility
that a project's datastructure actually might need a change when it is live
and filled with data. I cannot simply change the structure, recompile my
classes and submit them. I somehow need to preserve integrity within the
data model as well. I know I cannot come up with a comprehensive tutorial,
not even working examples, but this is the background in front of which I
need to operate and somehow I feel I am not the only one
That is a feature provided by Metabase schema management. Currently,
Metastorage generates code that use Metabase database API. Metabase lets
you define database schemas using a simple XML format that is database
independent. Metabase takes care of the installation of such schema.
If you change the XML schema definition, Metabase will apply the changes
without affecting the data that was added to the database after it was
installed for the first time or updated for the last time. If you are
providing such feature in your project, basically you are replicating
that capability that Metabase provides for about 4 years now when it was
started being developed.
I am going to keep basic SQL statements, since that's the way developers,
not having a degree think in those relational SQL structures as they
understand them more easily. Why take something away from them they know.
SQL will just be adapted to OO-state in a manner that is readable and
understandable at first glance.
There are plenty of reasons to prevent developers to use SQL by hand.
First because Metastorage has all the information it needs to retrieve
the objects from the database using appropriate SQL code that is
statically embedded in the generated classes.
If you are going to let the developer specify SQL by hand, your code is
more likely to be buggy because your application will not verify if the
developer specified SQL code is appropriate and correct.
Also, if it is the developer that enters the SQL code, you prevent the
possibility to perform context specific optimizitions that the code
generator could perform statically.
Anyway, the most important point is that if the developer still has to
supply the SQL code, you are not taking much of his work and so the
developments will still take a long time, the main reason why so many IT
projects fail.
The solution of Metastorage is to let the developer control everything
from high level. If you need to specify details that usually would
require SQL, like specifying filtering conditions, Metastorage provides
an high level syntax for specifying such conditions in the classes XML
definition. That lets Metastorage verify the validity of the conditions
and generate optimized code.
As I said: not as comprehensive and complete as your project, but I think
its targeting a more specific solution, that occurs often enough in everyday
I am not sure what you mean about targeting a more specific solution .
life to need support. You didn't discourage me at all, but rather give me an
idea, where thing might be going for me in the future. Tnx! I will have a
look into MetaL, that's for sure, but I will also continue with the OO2REL
project ;-)
No, problem. I just thought you would like to know about the overlap of
the projects, so you just don't duplicate efforts re-inventing the
wheel. If your project provides something better of something that
Metastorage does not provide, I would most certainly would like to know.
--
Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---
hi,
i try to run xtemplate on my windows machine but i get errors such
like :
undefined index main...(main is the name of block <!-- BEGIN: main
-->)
it seems it can not process blocks in template. theres no error in
unix machine.
does anyone knows the solution?
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
"Cenk Uysal" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> hi,
>
> i try to run xtemplate on my windows machine but i get errors such
> like :
hi, I am not fluent with xtemplate, but it does not seems likely that your
problem is related to windows. It could be that you have not installed
everything needed on it?
rush
--
http://www.templatetamer.org/
--- End Message ---
--- Begin Message ---
> i try to run xtemplate on my windows machine but i get errors such
> like :
>
> undefined index main...(main is the name of block <!-- BEGIN: main
> -->)
>
> it seems it can not process blocks in template. theres no error in
> unix machine.
>
> does anyone knows the solution?
One solution would be to use Smarty. The other would be to try and find
an xtemplate list/forum and ask on there.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
Hello,
I'm having trouble with /r/n when I try to write to a file.
Here's my code ;
The array I want to write -
$ch =array(
"$SQL_HOST"=> $SQL_HOST,
"SQL_USER"=> $SQL_USER,
"SQL_PWD"=>$SQL_PWD);
and the code I'm using to write the file
$fp = fopen ("newfig.txt", "w");
if (!($fp))
{
print ("ERROR file not open!");
exit;
}
{
fputs($fp,$ch);
foreach($ch as $key => $val) {
fputs($fp,"$$key = $val/r/n");
}
fclose ($fp);
};
Here's a sample of the file this produces -
$host = host/r/n$SQL_USER = user/r/n$SQL_PWD = dbpass/r/n
What I want is to have crlf after each var like this -
$host = host
$SQL_USER = user
$SQL_PWD = dbpass
I must be doing /r/n wrong.
My host is Apache on Sun OS.
--- End Message ---
--- Begin Message ---
On Sunday 26 January 2003 22:13, Malcolm Brownell wrote:
> Hello,
>
> I'm having trouble with /r/n when I try to write to a file.
It's "\r\n" that you want.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
If wishes were horses, then beggars would be thieves.
*/
--- End Message ---
--- Begin Message ---
awww geeze ! Thank you sir.
Again I embarass myself and slink away
On Mon, 27 Jan 2003 00:35:01 +0800, [EMAIL PROTECTED] (Jason Wong) wrote:
> On Sunday 26 January 2003 22:13, Malcolm Brownell wrote:
> > Hello,
> >
> > I'm having trouble with /r/n when I try to write to a file.
>
> It's "\r\n" that you want.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> If wishes were horses, then beggars would be thieves.
> */
>
--- End Message ---
--- Begin Message ---
Thank you Jason,
If you'll bear with me for one more question --
The /\ fix did what I wanted but now the word Array
appears before the first var -- the text file looks like this -
Array$hostname = hostname
$SQL_USER = username
$SQL_PWD = dbpass
I know this is php telling me the data is an array but can I supress this somehow so
all I'll
print is the keys and vals?
thanks
malcolm
On Mon, 27 Jan 2003 00:35:01 +0800, [EMAIL PROTECTED] (Jason Wong) wrote:
> On Sunday 26 January 2003 22:13, Malcolm Brownell wrote:
> > Hello,
> >
> > I'm having trouble with /r/n when I try to write to a file.
>
> It's "\r\n" that you want.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> If wishes were horses, then beggars would be thieves.
> */
>
--- End Message ---
--- Begin Message ---
On Monday 27 January 2003 01:27, Malcolm Brownell wrote:
> Thank you Jason,
> If you'll bear with me for one more question --
> The /\ fix did what I wanted but now the word Array
> appears before the first var -- the text file looks like this -
>
> Array$hostname = hostname
> $SQL_USER = username
> $SQL_PWD = dbpass
>
> I know this is php telling me the data is an array but can I supress this
> somehow so all I'll print is the keys and vals?
> fputs($fp,$ch);
Remove the above line.
> foreach($ch as $key => $val) {
> fputs($fp,"$$key = $val/r/n");
> }
> fclose ($fp);
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
"I just want to be a good engineer."
-- Steve Wozniak, co-founder of Apple Computer, concluding his keynote speech
at the 1988 AppleFest
*/
--- End Message ---
--- Begin Message ---
Hi, I usually fetch php from cvs a couple of times in
order to try new features etc.
Unfortunately since the beginning of this week I have
been unable to compile, no matter what I do.
I have been cvsing daily, buildconf and the same
./configure settings I have been using for ages.
./configure --with-apxs2 --enable-gd-native-ttf
--with-xml --with-openssl --with-zlib --with-dom
--with-gd --with-ttf
The error :
home/php4/ext/standard/basic_functions.c: In function
`php_simple_ini_parser_cb':
/home/php4/ext/standard/basic_functions.c:2827:
`ZEND_INI_PARSER_POP_ENTRY' undeclared (first use in
this function)
/home/php4/ext/standard/basic_functions.c:2827: (Each
undeclared identifier is reported only once
/home/php4/ext/standard/basic_functions.c:2827: for
each function it appears in.)
Any tips ?
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
I'll bet you're trying to mix v4 and v5... Make sure you're using the latest
anoncvs instructions, as they have changed recently...
On Sunday 26 January 2003 07:52 am, Robert Mena wrote:
> Hi, I usually fetch php from cvs a couple of times in
> order to try new features etc.
>
> Unfortunately since the beginning of this week I have
> been unable to compile, no matter what I do.
>
> I have been cvsing daily, buildconf and the same
> ./configure settings I have been using for ages.
>
> ./configure --with-apxs2 --enable-gd-native-ttf
> --with-xml --with-openssl --with-zlib --with-dom
> --with-gd --with-ttf
>
> The error :
>
> home/php4/ext/standard/basic_functions.c: In function
> `php_simple_ini_parser_cb':
> /home/php4/ext/standard/basic_functions.c:2827:
> `ZEND_INI_PARSER_POP_ENTRY' undeclared (first use in
> this function)
> /home/php4/ext/standard/basic_functions.c:2827: (Each
> undeclared identifier is reported only once
> /home/php4/ext/standard/basic_functions.c:2827: for
> each function it appears in.)
>
> Any tips ?
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
--
I am convinced that the teaching of the church is in theory a crafty and evil
lie, and in practice a concoction of gross superstition and witchcraft
-Leo Nikolaevich Tolstoy
--- End Message ---
--- Begin Message ---
Hope Í'm at the right place to ask this question.
Am using DMX and encounter following problem:
Have a connection to a database with plenty of data.
On a page which shows part of these records (10 max) I have a go to detail
page action which works fine when called from the 1st 10 records, but when
called from any other page (not the 1st 10 records any more) it suddenly
sends the following header:
quote--
http://blabla.com/detailshowpage.php?pageNum_Recordset1=2&totalRows_Recordse
t1=1130&lidnummer=515
unquote--
and now the detailshowpage doesn't work correctly,
while when done from the 1st page with the 1st ten records it only sends:
quote--
http://blabla.com/detailshowpage.php?lidnummer=515
unquote--
on the page I am using the recordset paging functions, and this is pbly
causing it but just don't know how to solve my little problem here.
Your help is appreciated, thanks,
Martin
--- End Message ---
--- Begin Message ---
I have a perl script that needs to be executed using the exec command. This
perl script had a use for another library. When executing this perl script
from the consol - there is no problem - the library from the use is picked
up from the proper directory (the included library is in the same directory
as the perl script) - but when executing it from within php, the library
cannot be found. In the past I have worked around it successfully by
putting the library in the perl libs directory - but on this shared host
provider they will not allow that.
I am at a loss first of all why the file cannot be found in the perl script
where executed using php, and second of all how to get the perl script to
execute successfully through php.
The php code is:
exec("/home/vtccanada/psigate/processor.cgi \"secure.psigate.com\" \"1139\"
\"ConfigFile=teststore&KeyFile=./teststore.pem&ChargeType=1&UserId=TEST&Oid=
&Bname=John Q. Public&Bcompany=PSiGate&Baddr1=6725-6 Millcreek
Drive&Bcity=Mississauga&Bstate=Ontario&Bzip=L5N
5V2&Bcountry=Canada&Amount=1.99&Comments=NO
COMMENTS&[EMAIL PROTECTED]&CardNumber=4111111111111111&ExpMonth=04&
ExpYear=05\"",$results);
foreach($results as $x) {
print "$x<br>";
}
The Perl bit that is giving trouble is:
sub process_order {
use ClearLink;
# Unique order number. Leave blank to have the API assign one.
$oid = $input{'Oid'};
Etc...
}
Specifically the use ClearLink line.
I know that this is not a perl list - but if anyone has suggestions on how
to get that file included, or executed properly through php, I would
appreciate it - keeping in mind that I have no access to perl library
directories.
Thanks.
--
Cheers
Mike Morton
"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey
--- End Message ---
--- Begin Message ---
Hi, I am creating a bilingual website (Dutch and English) and I wonder how
I would best detect the human language of a visitor. I am attempting
several things, but I am sure there must be a generally accepted
alternative. Can anyone point me to more info?
I am tinkering around with HTTP_REFERER and HTTP_USER_AGENT and a bit in
JavaScript which only works with Netscape browsers. But detection usually
fails. I was wondering, my server provides a REMOTE_ADDR value, but not a
REMOTE_HOST. From the last I could look voor a ".nl" extention. Is there a
way to (inline) translate a IP address to something readable? It's a remote
server on which I can't control the settings.
Why is this so difficult? It should be a basic feature of any
international software... or am I missing something?
Thanks, Marco
--
Marco Bleeker, Amsterdam, NL.
Please do not distribute my email address to a third party
Refer to www.ecocam.com for an email form (and more)
--- End Message ---
--- Begin Message ---
On Monday 27 January 2003 01:39, Marco Bleeker wrote:
> Hi, I am creating a bilingual website (Dutch and English) and I wonder how
> I would best detect the human language of a visitor. I am attempting
> several things, but I am sure there must be a generally accepted
> alternative. Can anyone point me to more info?
The most practical way to do this is to default to one language (that of your
majority target audience) then let the user choose if they want to select a
different one, and keep their selection in a session or cookie.
Trying to second-guess a user's preference from their browser settings/IP
address/whatever is IMHO a waste of time.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Men use thought only to justify their wrong doings, and speech only to
conceal their thoughts.
-- Voltaire
*/
--- End Message ---
--- Begin Message ---
I'm currently developing a PHP/MySQL project, one aspect of which
involves displaying a default set from the database which picks out all
records for whichever individual is associated with the most recent
date. I know this is a very general description, but I don't think it's
necessary to burden list members with further detail, nor to pass on
details of my table structures.
Suffice it to say that I successfully achieved my goal with MySQL from
the command line, but I'm not sure how to write this functionality into
my PHP code.
In MySQL, the following sequence of commands works the magic:
SELECT @most_recent:=MAX(date)
FROM presenters;
SELECT @recent_presenter:=presenter
FROM presenters
WHERE date = @most_recent;
SELECT p.date, p.theme, p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date AND p.presenter = @recent_presenter
ORDER BY p.date DESC;
So how do I transfer all this to PHP?
I've tried a number of approaches:
1. $presenterQuery = "
SELECT @most_recent:=MAX(date) from presenters;
SELECT @recent_presenter:=presenter
FROM presenters WHERE date=@most_recent;
SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date AND p.presenter = @recent_presenter
ORDER BY p.date DESC";
2. $tempQuery1 = "
SELECT @most_recent:=MAX(date) from presenters";
$tempQuery2 = "
SELECT @recent_presenter:=presenter FROM presenters WHERE
date=@most_recent;
$presenterQuery = "
SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date AND p.presenter = @recent_presenter
ORDER BY p.date DESC";
3. $tempQuery1 = "
SELECT @most_recent:=MAX(date) from presenters";
$tempQuery1Result = mysql_db_query($database, $tempQuery1,
$connection) or die ( mysql_error() );
$tempQuery2 = "
SELECT @recent_presenter:=presenter FROM presenters WHERE date =
\"$tempQuery1Result\"";
$tempQuery2Result = mysql_db_query($database, $tempQuery2,
$connection) or die ( mysql_error() );
$presenterQuery = "
SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date AND p.presenter = \"$tempQuery2Result\"
ORDER BY p.date DESC";
All of these options are followed by
$presenterResult = mysql_db_query($database, $presenterQuery,
$connection) or die ( mysql_error() );
All queries indicate that they have been successfully executed when I
add relevant debug code, but it seems that rather than substitute the
variable values, either a variable literal (e.g. @recent_presenter) or
a value like Resource ID#2 is being used instead.
Is it possible to do what I desire. If so, where am I going wrong?
Jim MacCormaic
Dublin, Ireland
iChat/AIM : [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On Monday 27 January 2003 01:51, Jim MacCormaic wrote:
> I'm currently developing a PHP/MySQL project, one aspect of which
> involves displaying a default set from the database which picks out all
> records for whichever individual is associated with the most recent
> date. I know this is a very general description, but I don't think it's
> necessary to burden list members with further detail, nor to pass on
> details of my table structures.
>
> Suffice it to say that I successfully achieved my goal with MySQL from
> the command line, but I'm not sure how to write this functionality into
> my PHP code.
>
> In MySQL, the following sequence of commands works the magic:
>
> SELECT @most_recent:=MAX(date)
> FROM presenters;
>
> SELECT @recent_presenter:=presenter
> FROM presenters
> WHERE date = @most_recent;
>
> SELECT p.date, p.theme, p.presenter,
> c.itemNo, c.composer, c.composition, c.note
> FROM presenters p, compositions c
> WHERE p.date = c.date AND p.presenter = @recent_presenter
> ORDER BY p.date DESC;
>
> So how do I transfer all this to PHP?
>
> I've tried a number of approaches:
>
> 1. $presenterQuery = "
> SELECT @most_recent:=MAX(date) from presenters;
> SELECT @recent_presenter:=presenter
> FROM presenters WHERE date=@most_recent;
> SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
> p.presenter,
> c.itemNo, c.composer, c.composition, c.note
> FROM presenters p, compositions c
> WHERE p.date = c.date AND p.presenter = @recent_presenter
> ORDER BY p.date DESC";
The php-mysql interface doesn't support multiple queries in a single operation
so you can forget this approach.
> 2. $tempQuery1 = "
> SELECT @most_recent:=MAX(date) from presenters";
> $tempQuery2 = "
> SELECT @recent_presenter:=presenter FROM presenters WHERE
> date=@most_recent;
> $presenterQuery = "
> SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
> p.presenter,
> c.itemNo, c.composer, c.composition, c.note
> FROM presenters p, compositions c
> WHERE p.date = c.date AND p.presenter = @recent_presenter
> ORDER BY p.date DESC";
You're not doing anything with $tempQuery1 & $tempQuery2 this is complete
nonsense ;-)
> 3. $tempQuery1 = "
> SELECT @most_recent:=MAX(date) from presenters";
> $tempQuery1Result = mysql_db_query($database, $tempQuery1,
> $connection) or die ( mysql_error() );
> $tempQuery2 = "
> SELECT @recent_presenter:=presenter FROM presenters WHERE date =
> \"$tempQuery1Result\"";
> $tempQuery2Result = mysql_db_query($database, $tempQuery2,
> $connection) or die ( mysql_error() );
> $presenterQuery = "
> SELECT date_format(p.date, '%d/%m/%y') AS readable_date, p.theme,
> p.presenter,
> c.itemNo, c.composer, c.composition, c.note
> FROM presenters p, compositions c
> WHERE p.date = c.date AND p.presenter = \"$tempQuery2Result\"
> ORDER BY p.date DESC";
This is getting closer. Unfortunately you haven't been reading the manual.
mysql_query() returns a "resource ID". See examples in manual for details on
how to properly query and return results from a db.
Looking at your queries, it seems that you're doing more steps than is
strictly required.
SELECT @most_recent:=MAX(date)
FROM presenters;
SELECT @recent_presenter:=presenter
FROM presenters
WHERE date = @most_recent;
Couldn't the above be condensed to:
SELECT presenter FROM presenters ORDER BY date DESC LIMIT 1;
Which means you can get by with 2 queries:
$query = "SELECT presenter FROM presenters ORDER BY date DESC LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$presenter = $row['presenter'];
You can now use $presenter in your last query:
$presenterQuery = "SELECT p.date, p.theme, p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date AND p.presenter = $presenter
ORDER BY p.date DESC";
> $presenterResult = mysql_db_query($database, $presenterQuery,
> $connection) or die ( mysql_error() );
All code untested, handle with care.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
If we won't stand together, we don't stand a chance.
*/
--- End Message ---
--- Begin Message ---
> I'm currently developing a PHP/MySQL project, one aspect of which
> involves displaying a default set from the database which picks out
all
> records for whichever individual is associated with the most recent
> date. I know this is a very general description, but I don't think
it's
> necessary to burden list members with further detail, nor to pass on
> details of my table structures.
>
> Suffice it to say that I successfully achieved my goal with MySQL from
> the command line, but I'm not sure how to write this functionality
into
> my PHP code.
>
> In MySQL, the following sequence of commands works the magic:
>
> SELECT @most_recent:=MAX(date)
> FROM presenters;
>
> SELECT @recent_presenter:=presenter
> FROM presenters
> WHERE date = @most_recent;
>
> SELECT p.date, p.theme, p.presenter,
> c.itemNo, c.composer, c.composition, c.note
> FROM presenters p, compositions c
> WHERE p.date = c.date AND p.presenter =
@recent_presenter
> ORDER BY p.date DESC;
>
> So how do I transfer all this to PHP?
Pretty sure you can do all that with one query. Something like:
SELECT p.date, p.theme, p.presenter,
c.itemNo, c.composer, c.composition, c.note
FROM presenters p, compositions c
WHERE p.date = c.date
ORDER BY p.date DESC LIMIT 1
Not sure, though, as I don't have time to test right now.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> > 2. $tempQuery1 = "
> > SELECT @most_recent:=MAX(date) from presenters";
> > $tempQuery2 = "
> > SELECT @recent_presenter:=presenter FROM presenters WHERE
> > date=@most_recent;
> > $presenterQuery = "
> > SELECT date_format(p.date, '%d/%m/%y') AS
> readable_date, p.theme,
> > p.presenter,
> > c.itemNo, c.composer, c.composition, c.note
> > FROM presenters p, compositions c
> > WHERE p.date = c.date AND p.presenter = @recent_presenter
> > ORDER BY p.date DESC";
>
> You're not doing anything with $tempQuery1 & $tempQuery2 this is complete
> nonsense ;-)
Not true - this is using MySQL's variable approach. The '@xxxx' represents a
user variable per connection in MySQL. See
http://www.mysql.com/doc/en/Variables.html for more information.
mark C.
--- End Message ---
--- Begin Message ---
On Sunday, January 26, 2003, at 06:26 pm, Jason Wong wrote:
You're not doing anything with $tempQuery1 & $tempQuery2 this is
complete
nonsense ;-)
Bowing obsequiously, suitably chastened, I read on . . .
This is getting closer. Unfortunately you haven't been reading the
manual.
mysql_query() returns a "resource ID". See examples in manual for
details on
how to properly query and return results from a db.
Knuckles recovering from another knock, I read further . . .
Couldn't the above be condensed to:
SELECT presenter FROM presenters ORDER BY date DESC LIMIT 1;
Much neater indeed. Elegant, even.
Which means you can get by with 2 queries:
$query = "SELECT presenter FROM presenters ORDER BY date DESC LIMIT
1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$presenter = $row['presenter'];
You can now use $presenter in your last query
All code untested, handle with care.
Code successfully incorporated and working as intended. Thanks for the
help.
Jim MacCormaic
Dublin, Ireland
iChat/AIM : [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On Monday 27 January 2003 02:36, Mark Charette wrote:
> > -----Original Message-----
> > From: Jason Wong [mailto:[EMAIL PROTECTED]]
> >
> > > 2. $tempQuery1 = "
> > > SELECT @most_recent:=MAX(date) from presenters";
> > > $tempQuery2 = "
> > > SELECT @recent_presenter:=presenter FROM presenters WHERE
> > > date=@most_recent;
> > > $presenterQuery = "
> > > SELECT date_format(p.date, '%d/%m/%y') AS
> >
> > readable_date, p.theme,
> >
> > > p.presenter,
> > > c.itemNo, c.composer, c.composition, c.note
> > > FROM presenters p, compositions c
> > > WHERE p.date = c.date AND p.presenter = @recent_presenter
> > > ORDER BY p.date DESC";
> >
> > You're not doing anything with $tempQuery1 & $tempQuery2 this is complete
> > nonsense ;-)
>
> Not true - this is using MySQL's variable approach. The '@xxxx' represents
> a user variable per connection in MySQL. See
> http://www.mysql.com/doc/en/Variables.html for more information.
I know. The important point is that although $tempQuery1 & $tempQuery2 are
assigned, they aren't being passed to any mysql_query().
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Music in the soul can be heard by the universe.
-- Lao Tsu
*/
--- End Message ---
--- Begin Message ---
Hey all.
I'm a recent PHP convert (coming from Cold Fusion)..........
Here's the deal:
I've got a table that contains hockey game result info; for each goal
scored I record the goal scorer ID (i.e. their Jersey Number), and assist1
and assist2 IDs if applicable. When I output the game box score I join in
the roster and team tables (to get the team name and player names).
In Cold Fusion I was able to group a goal info set on the time of goal (each
goal returns from 1 to 3 rows depending on the number of players who
contributed to the goal); then, in Cold Fusion I could use it's output
function to display the goal info set as one row.
For example, if three players were in on a goal, the output would look
something like:
Team Name-- goal scorer name (assist1 name, assist2 name) -- Time of goal --
Goal type.
Since each goal can, and usualy does, have more than one participant, the
scoring table will be returning more than one row for each goal scored --
how can I combine these rows into one PHP output row?
If you need more info, let me know.
Thanks for any ideas,
--Noah
--
--- End Message ---
--- Begin Message ---
Thanks a lot for your sugestions guys, and i'll have a look into phpMail
and write a prototype keeping in mind your advice about the size of
chunks and use of sleep. Just let me bother you a little bit more
if i run into trouble Michael ;-)
Thanks again guys !
------------------------------------------------------------------
"Few are those who see with their own eyes and feel with their own
hearts."
Albert Einstein
-----------------------------------------------------------------
Maciek Ruckaber Bielecki
--- End Message ---
--- Begin Message ---
Hello Everyone,
I am a little confused. Why do predefined variables like $PHP_SELF or
$DOCUMENT_ROOT not process within a class, in the methods secifically. For
example:
<?php
class someClass {
function someFunction () {
$root = $DOCUMENT_ROOT;
return $root;
}
function someFunction2 () {
$path = $this->someFunction() . $PHP_SELF;
return $path;
}
}
?>
I just threw this together to give you an example of how I might be using
these two predefined variables in a class. The problem is that
$DOCUMENT_ROOT or $PHP_SELF won't parse or something. It just returns blank.
It is included in another page when needed, say somePage.php. Shouldn't
$PHP_SELF recognize the somePage.php as the current running script file, as
opposed to the class file where these two functions are called? If it
doesn't work that way then how do I do this without sending predefined
variable parameters to these functions?
Please note that register globals is on. I could not find any documentation
on this on php.net. Maybe someone can give me a hint of point it out for me
on the documentation. Thanks.
--- End Message ---
--- Begin Message ---
Read:
http://www.php.net/variables.scope
Also note that $_SERVER is an autoglobal.
Regards,
Philip
On Sun, 26 Jan 2003, @ Nilaab wrote:
> Hello Everyone,
>
> I am a little confused. Why do predefined variables like $PHP_SELF or
> $DOCUMENT_ROOT not process within a class, in the methods secifically. For
> example:
>
> <?php
> class someClass {
>
> function someFunction () {
> $root = $DOCUMENT_ROOT;
> return $root;
> }
>
> function someFunction2 () {
> $path = $this->someFunction() . $PHP_SELF;
> return $path;
> }
> }
> ?>
>
> I just threw this together to give you an example of how I might be using
> these two predefined variables in a class. The problem is that
> $DOCUMENT_ROOT or $PHP_SELF won't parse or something. It just returns blank.
>
> It is included in another page when needed, say somePage.php. Shouldn't
> $PHP_SELF recognize the somePage.php as the current running script file, as
> opposed to the class file where these two functions are called? If it
> doesn't work that way then how do I do this without sending predefined
> variable parameters to these functions?
>
> Please note that register globals is on. I could not find any documentation
> on this on php.net. Maybe someone can give me a hint of point it out for me
> on the documentation. Thanks.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Just in case someone wants to know : I had to uncheck the passing parameters
in the go to detailpage parameter box!
Martin
"Wmb" <[EMAIL PROTECTED]> schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
| Hope Í'm at the right place to ask this question.
|
| Am using DMX and encounter following problem:
|
| Have a connection to a database with plenty of data.
| On a page which shows part of these records (10 max) I have a go to detail
| page action which works fine when called from the 1st 10 records, but when
| called from any other page (not the 1st 10 records any more) it suddenly
| sends the following header:
| quote--
|
http://blabla.com/detailshowpage.php?pageNum_Recordset1=2&totalRows_Recordse
| t1=1130&lidnummer=515
| unquote--
| and now the detailshowpage doesn't work correctly,
|
| while when done from the 1st page with the 1st ten records it only sends:
| quote--
| http://blabla.com/detailshowpage.php?lidnummer=515
| unquote--
|
| on the page I am using the recordset paging functions, and this is pbly
| causing it but just don't know how to solve my little problem here.
|
| Your help is appreciated, thanks,
| Martin
|
|
|
--- End Message ---
--- Begin Message ---
Working on getting Java integration going. I was able to get it to work
with the online example and can create an object of java.lang.System and
print various properties returned from there.
However, if I create my own class, I can instantiate it, but if I call a
method on that class it causes a SIGSEV.
Could anyone provide some insight?
Here's the code and backtrace:
This is with Sun jdk 1.4.1_1, php-4.2.3 on Red Hat 8.0.
<?
$obj = new Java('com.x.reports.Serv');
print $obj->getMsg();
?>
--- java code stored off of class path in com/x/reports ---
package com.x.reports;
class Serv
{
public String msg = "THIS IS A TEST MESSAGE";
Serv()
{
}
public String getMsg()
{
return this.msg;
}
}
------------------ BACKTRACE -------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 9303)]
0x402da2cb in java_call_function_handler (ht=0, return_value=0x8114d14,
this_ptr=0x810d604, return_value_used=1, property_reference=0xbfffdf54)
at java.c:464
464 obj = zend_list_find(Z_LVAL_PP(handle), &type);
(gdb) bt
#0 0x402da2cb in java_call_function_handler (ht=0,
return_value=0x8114d14, this_ptr=0x810d604, return_value_used=1,
property_reference=0xbfffdf54) at java.c:464
#1 0x40191553 in call_overloaded_function (T=0xbfffdf48, arg_count=0,
return_value=0x8114d14) at zend_execute.c:953
#2 0x40194636 in execute (op_array=0x8114b6c) at zend_execute.c:1660
#3 0x401a40a3 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at zend.c:812
#4 0x401b5aaf in php_execute_script (primary_file=0xbffff450) at
main.c:1383
#5 0x401b0aba in apache_php_module_main (r=0x8107004,
display_source_mode=0) at sapi_apache.c:90
#6 0x401b18ea in send_php (r=0x8107004, display_source_mode=0,
filename=0x8107b34 "/opt/apache_1.3.27/htdocs/t.php") at mod_php4.c:575
#7 0x401b1963 in send_parsed_php (r=0x8107004) at mod_php4.c:590
#8 0x08074880 in ap_invoke_handler ()
#9 0x08088c76 in process_request_internal ()
#10 0x08088cd6 in ap_process_request ()
#11 0x0807ff9a in child_main ()
#12 0x0808013a in make_child ()
#13 0x080802a1 in startup_children ()
#14 0x080808ce in standalone_main ()
#15 0x080810ec in main ()
#16 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
--- End Message ---
--- Begin Message ---
Zdravo php-general,
Hi I'm having ptoblem how do I aneble PHP on apache..??
I've read Hot to install but Apche changed httpd.conf on new version
of Apache server.
Help
Thanks
+++++++Info About this E-mail+++++++++
+Poruka je napisana u 12:45:19 +
+Dana Sunday, January 26, 2003 +
+Files in this E-mail massage +
+<none> +
+ +
+Email: [EMAIL PROTECTED] +
++++++++++++++++++++++++++++++++++++++
--- End Message ---