|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 11 Nov 2004 04:41:51 -0000 Issue 3105
php-general-digest-help
lists.php.net
Date: Wed Nov 10 2004 - 22:41:51 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 11 Nov 2004 04:41:51 -0000 Issue 3105
Topics (messages 201667 through 201733):
Question on functions
201667 by: Jason
201668 by: John Holmes
201669 by: Jason
201671 by: elixon
201691 by: Jason
201697 by: Sebastian Mendel
201702 by: Jason
201706 by: Greg Donald
201707 by: Jason
Re: Shell Script error
201670 by: Rui Francisco
201673 by: Matthew Weier O'Phinney
Re: Database Search
201672 by: Stuart Felenstein
201675 by: Jon Hill
201676 by: Stuart Felenstein
201679 by: Jason Wong
201680 by: Graham Cossey
201681 by: Sebastian Mendel
201683 by: Stuart Felenstein
201687 by: Jason Wong
[PHP-WIN] Re: [PHP] Shell Script error
201674 by: Angelo Zanetti
Re: php mail() error
201677 by: Jason Wong
201678 by: Greg Donald
201694 by: Manuel Lemos
201703 by: Manuel Lemos
201721 by: John Holmes
201733 by: Zareef Ahmed
Multiple session_start()s / Is it a problem??
201682 by: Al
201685 by: Klaus Reimer
201686 by: Greg Donald
201692 by: elixon
201693 by: elixon
Error logging problem
201684 by: Al
201689 by: Greg Donald
201695 by: Al
Re: newbie: string to char array
201688 by: Ford, Mike
201690 by: raditha dissanayake
201701 by: Ford, Mike
Array to $_GET variable
201696 by: Mike Smith
201698 by: Sebastian Mendel
201700 by: Marek Kilimajer
XML Parser doesn't work when moved....
201699 by: Jay Blanchard
201705 by: Jay Blanchard
201718 by: Jay Blanchard
Callback function as parameter
201704 by: Francisco M. Marzoa Alonso
201713 by: Matthew Weier O'Phinney
displaying repetitive results
201708 by: Chris Lott
201719 by: Brent Baisley
201724 by: Greg Donald
Load testing for PHP Applications
201709 by: Pablo Gosse
201711 by: Greg Donald
should basic data validation go outside a function or inside?
201710 by: Chris W. Parker
201720 by: Greg Donald
201725 by: Brad Pauly
Copyright law, how to protect your investment, how to protect your work... Was - RE: [PHP-DB] Please point me in the right direction.......
201712 by: Gryffyn, Trevor
LINUX: Problem with php installation
201714 by: abhilash kumar
201726 by: Greg Donald
chmod difficulties...
201715 by: Scott Fletcher
201716 by: M. Sokolewicz
201717 by: Scott Fletcher
201728 by: Scott Fletcher
Programmatic Browser Rendering Engine?
201722 by: Richard Lynch
201723 by: Jay Blanchard
201727 by: Jennifer Goodie
201730 by: Rick Fletcher
header variable ?
201729 by: Jerry Swanson
201731 by: Tom Rogers
201732 by: Ligaya Turmelle
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
My question is in regard to passing global variables to a function.
Here is my code, any idea why it is not working? I suppose my
understanding of a global variable being able to be used within a
function is off?
global $array = array( "0" => "hostname", "1" => "username", "2" =>
"password" );
function database()
{
$dbase = mysql_pconnect( $array[0], $array[1], $array[2] )or die(
mysql_error());
if( connection_status() != 1 ) {
echo "connection failed";
}
}
call_user_func( "database" );
--
Jason Gerfen
jason.gerfen
scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show
attached mail follows:
Jason wrote:
> My question is in regard to passing global variables to a function. Here
> is my code, any idea why it is not working? I suppose my understanding
> of a global variable being able to be used within a function is off?
>
> global $array = array( "0" => "hostname", "1" => "username", "2" =>
> "password" );
>
> function database()
> {
You need to declare it global within the function...
function database()
{
global $array;
...
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
attached mail follows:
John Holmes wrote:
> Jason wrote:
>
>> My question is in regard to passing global variables to a function.
>> Here is my code, any idea why it is not working? I suppose my
>> understanding of a global variable being able to be used within a
>> function is off?
>>
>> global $array = array( "0" => "hostname", "1" => "username", "2" =>
>> "password" );
>>
>> function database()
>> {
>
>
> You need to declare it global within the function...
>
> function database()
> {
> global $array;
> ...
>
thanks, it figures it is something easy like that... =)
--
Jason Gerfen
jason.gerfen
scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show
attached mail follows:
Or you can use superglobal variable $GLOBALS that is array containing
all GLOBAL variables. This variable is superglobal thus does not need to
be declared global using 'global $GLOBALS;' statement. Works anywhere.
function database() {
... $GLOBALS['array'][0], $GLOBALS['array'][1] ...
}
elixon
Tip: I recommend to not use GLOBALS for this type of data. Better use
function parameters -> function database($host, $user, $pwd, $db) {...}
It will save you time when your application grows and starts clashing
with other global variables or third party pieces of code ;-)
Jason Gerfen wrote:
> John Holmes wrote:
>
>> Jason wrote:
>>
>>> My question is in regard to passing global variables to a function.
>>> Here is my code, any idea why it is not working? I suppose my
>>> understanding of a global variable being able to be used within a
>>> function is off?
>>>
>>> global $array = array( "0" => "hostname", "1" => "username", "2" =>
>>> "password" );
>>>
>>> function database()
>>> {
>>
>>
>>
>> You need to declare it global within the function...
>>
>> function database()
>> {
>> global $array;
>> ...
>>
> thanks, it figures it is something easy like that... =)
>
attached mail follows:
Could you give me a good example of the tip you recommend or point me to
a good tutorial on it?
Elixon wrote:
> Or you can use superglobal variable $GLOBALS that is array containing
> all GLOBAL variables. This variable is superglobal thus does not need to
> be declared global using 'global $GLOBALS;' statement. Works anywhere.
>
>
> function database() {
> ... $GLOBALS['array'][0], $GLOBALS['array'][1] ...
> }
>
> elixon
>
> Tip: I recommend to not use GLOBALS for this type of data. Better use
> function parameters -> function database($host, $user, $pwd, $db) {...}
> It will save you time when your application grows and starts clashing
> with other global variables or third party pieces of code ;-)
>
> Jason Gerfen wrote:
>
>> John Holmes wrote:
>>
>>> Jason wrote:
>>>
>>>> My question is in regard to passing global variables to a function.
>>>> Here is my code, any idea why it is not working? I suppose my
>>>> understanding of a global variable being able to be used within a
>>>> function is off?
>>>>
>>>> global $array = array( "0" => "hostname", "1" => "username", "2" =>
>>>> "password" );
>>>>
>>>> function database()
>>>> {
>>>
>>>
>>>
>>>
>>> You need to declare it global within the function...
>>>
>>> function database()
>>> {
>>> global $array;
>>> ...
>>>
>> thanks, it figures it is something easy like that... =)
>>
--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
jason.gerfen
scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show
attached mail follows:
Jason wrote:
> Could you give me a good example of the tip you recommend or point me to
> a good tutorial on it?
$GLOBALS holds all variables defined in main(), main() meaning outside
any function or class
//main()
$my_var = 'test';
function myFunction()
{
echo $GLOBALS['my_var'];
// is the same as:
global $my_var
echo $my_var;
// 'global' just creates a local reference to the global variable
// global $my_var; is the same as:
$my_var =& $GLOBALS['my_var'];
echo $my_var;
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
attached mail follows:
Yeah the global stuff I understand and can use fine. What I would like
more information about is the use of arguments to functions i.e.
function( $user, $pass, $db ) {
$db =
mysql_connect( $user, $pass, $db );
}
I understand parts but googling for the proper use of functions in php
hasn't gotten me anywhere...
Sebastian Mendel wrote:
> Jason wrote:
>
>> Could you give me a good example of the tip you recommend or point me
>> to a good tutorial on it?
>
>
> $GLOBALS holds all variables defined in main(), main() meaning outside
> any function or class
>
> //main()
> $my_var = 'test';
>
> function myFunction()
> {
> echo $GLOBALS['my_var'];
>
> // is the same as:
> global $my_var
> echo $my_var;
>
> // 'global' just creates a local reference to the global variable
> // global $my_var; is the same as:
> $my_var =& $GLOBALS['my_var'];
> echo $my_var;
> }
>
>
>
--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
jason.gerfen
scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show
attached mail follows:
On Wed, 10 Nov 2004 10:10:37 -0700, Jason <jason.gerfen
scl.utah.edu> wrote:
> Yeah the global stuff I understand and can use fine. What I would like
> more information about is the use of arguments to functions i.e.
> function( $user, $pass, $db ) {
> $db =
mysql_connect( $user, $pass, $db );
> }
>
> I understand parts but googling for the proper use of functions in php
> hasn't gotten me anywhere...
Looks like you understand already. Did you have some broken code you
wanted help with?
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Greg Donald wrote:
> On Wed, 10 Nov 2004 10:10:37 -0700, Jason <jason.gerfen
scl.utah.edu> wrote:
>
>>Yeah the global stuff I understand and can use fine. What I would like
>>more information about is the use of arguments to functions i.e.
>>function( $user, $pass, $db ) {
>> $db =
mysql_connect( $user, $pass, $db );
>>}
>>
>>I understand parts but googling for the proper use of functions in php
>>hasn't gotten me anywhere...
>
>
> Looks like you understand already. Did you have some broken code you
> wanted help with?
>
>
yeah.. I should have posted it first. Here it is:
/* User Defined Variables */
$defined = array( "0" => "localhost",
"1" => "user",
"2" => "password" );
/* Database connection */
function db() {
global $defined;
if( connection_status() != 0 ) {
$db =
mysql_pconnect( $defined[9], $defined[1], $defined[2] )or die(
"<font face=\"arial\"><b>phpDHCPAdmin currently not active, is under
repair or is not configured correctly.</b><br><br>Error Number: " .
mysql_errno( $db ) . <br>Error Message: " . mysql_error( $db ) .
"<br>Email Administrator: <a
href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
mysql_select_db( $defined[3] )or die( "<font face=\"arial\"><b>Could
not connect to database: $defined[3]</b><br>Error Me\
ssage: " .
mysql_error( $db ) . "<br>" . "Error Number: " .
mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailt\
o:$defined[5]\">$defined[5]</a></font>" );
}
}
/* Logging function */
function logs() {
global $defined;
call_user_func( "db" );
$pagecount = "1";
$tble = "logs";
$sql =
mysql_query( "SELECT * FROM $tble WHERE session =
\"$_SESSION[hash]\"", $db )or die( "<font face=\"arial\"><b>Error\
occured when searching logs for session id:</b>
$_SESSION[hash]<br>Error Message: " .
mysql_error( $db ) . "<br>" . "Error\
Number: " .
mysql_errno( $db ) . "<br>Email Administrator: <a
href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
while( $row =
mysql_fetch_array( $sql ) ) {
$id = $row["session"]; }
if(
mysql_num_rows( $sql ) == 0 ) {
$insert =
mysql_query( "INSERT INTO $tble VALUES
(\"\",\"$_SESSION[date]\",\"$_SESSION[hour]\",\"$_SESSION[ipaddy]\",\\
"$_SESSION[host]\",\"$_SESSION[ref]\",\"$_SERVER[HTTP_USER_AGENT]\",\"$_SERVER[PHP_SELF]\",\"$pagecount\",\"$_SESSION[msg]\"\
,\"$_SESSION[hash]\")", $db )or die( "<font face=\"arial\"><b>Error
occured creating logs for $_SESSION[hash]</b><br>Error M\
essage: " .
mysql_error( $db ) . "<br>" . "Error Number: " .
mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mail\
to:$defined[5]\">$defined[5]</a></font>" );
} elseif(
mysql_num_rows( $sql ) != 0 ) {
if( ( $_SESSION['hash'] == $id ) || ( empty( $pagecount ) ) ) {
$pagecount++;
$update =
mysql_query( "UPDATE $tble SET
date=\"$_SESSION[date]\", time=\"$_SESSION[hour]\",
ip=\"$_SESSION[ipaddy]\"\
, host=\"$_SESSION[host]\", referer=\"$_SESSION[ref]\",
agent=\"$_SERVER[HTTP_USER_AGENT]\", page=CONCAT(page,\".:||:.$_SERV\
ER[PHP_SELF]\"), pagecount=\"$pagecount\", message=\"$_SESSION[msg]\",
session=\"$_SESSION[hash]\" WHERE session=\"$id\"", $\
db )or die( "<font face=\"arial\"><b>Error occured while updating logs
for $_SESSION[hash]</b><br>Error Message: " .
mysql_\
error( $db ) . "<br>" . "Error Number: " .
mysql_errno( $db ) .
"<br>Email Administrator: <a href=\"mailto:$defined[5]\">$d\
efined[5]</a></font>" );
} else {
call_user_func( "exit_app" ); }
} else {
call_user_func( "exit_app" ); }
}
the result is that trying to call a function from within a function
seems to be giving me problems. I get no error message or code. Any
help is appreciated
--
Jason Gerfen
jason.gerfen
scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show
attached mail follows:
Its a simple script
$_SERVER['utilizador']='user';
$_SERVER['pass']='pass';
$_SERVER['host']='localhost or IP address';
$_SERVER['db_name']='c:/path/dbname.fdb';
include_once('DB.php');
$dsn="ibase://".$_SERVER['utilizador'].":".$_SERVER['pass']."
".$_SERVER['host']."/".$_SERVER['db_name'];
$ligacaoBD=DB::connect($dsn);
if (DB::isError($ligacaoBD)) {
die($ligacaoBD->getMessage());
}
The user has admin right on the database, and the database doesn't
implement security measures like Mysql for access from other hosts.
The problem is that if i run the script on the browser it works, but on
the command line on Windows machine it doesn't work
Thanks in advance
Rui Francisco
Angelo Zanetti wrote:
>well maybe you are trying to connect to localhost which could be fine
>for the server but not from commandline... send more info.
>
>
>
>>>>Rui Francisco <rui.francisco
fccn.pt> 11/10/2004 2:06:09 PM >>>
>>>>
>>>>
>Hi,
>
>I have a small problem with a PHP script with Pear DB
>
>The problem is the following: I'm creating a shell script in PHP that
>access one interbase database.
>
>The problem is that if i run it on a webserver the script run
>correctly
>but if i runit in the command line it reports one error (DB Error:
>connect failed).
>
>Does anybody know what is the problem ?
>
>Thanks in advance
>Rui Francisco
>
>
>
--
Rui Francisco - rui.francisco
fccn.pt
FCCN - Fundação para a Computação Científica Nacional
Av. Brasil, 101 1700-066 Lisboa - Portugal
Tel: +351 218440100 Fax: +351 218472167
-----------------------------------------------------
attached mail follows:
* Rui Francisco <rui.francisco
fccn.pt>:
>
> Its a simple script
>
> $_SERVER['utilizador']='user';
> $_SERVER['pass']='pass';
> $_SERVER['host']='localhost or IP address';
> $_SERVER['db_name']='c:/path/dbname.fdb';
Why are you using the $_SERVER array? This is supposed to provide
information regarding the web server environment, such as headers,
script and path locations, and other items in the CGI specifications; it
shouldn't be used for storing application data.
In addition, it may or may not be available on the command line, which
could be causing the issue you're seeing.
If you simply need a global array... set up an array and then initialize
it in your functions/classes using the global keyword. Alternately,
$_ENV might be a better place to store this information.
>
> include_once('DB.php');
>
> $dsn="ibase://".$_SERVER['utilizador'].":".$_SERVER['pass']."
".$_SERVER['host']."/".$_SERVER['db_name'];
>
> $ligacaoBD=DB::connect($dsn);
> if (DB::isError($ligacaoBD)) {
> die($ligacaoBD->getMessage());
> }
>
> The user has admin right on the database, and the database doesn't
> implement security measures like Mysql for access from other hosts.
>
> The problem is that if i run the script on the browser it works, but on
> the command line on Windows machine it doesn't work
> > well maybe you are trying to connect to localhost which could be fine
> > for the server but not from commandline... send more info.
> >
> > Rui Francisco <rui.francisco
fccn.pt> 11/10/2004 2:06:09 PM >>>
> > > Hi,
> > >
> > > I have a small problem with a PHP script with Pear DB
> > >
> > > The problem is the following: I'm creating a shell script in PHP that
> > > access one interbase database.
> > >
> > > The problem is that if i run it on a webserver the script run
> > > correctly
> > > but if i runit in the command line it reports one error (DB Error:
> > > connect failed).
--
Matthew Weier O'Phinney | mailto:matthew
garden.org
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
attached mail follows:
I am creating a database search form and results.
Running into a problem though.
I have two form elements, both that are fed by tables
that have int values (1, 2 , etc)
my sql statement is such:
SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
vendorjobs.Industry, vendorjobs.VendorID,
vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
Date_Sub(Curdate(), interval '$Days' day) <= PostStart
"
But if the user decides to only use one of the
elements, then I don't want the query to return
nothing because of the "And" in the where clause so I
have these 2 statements that set a default value
(shown here as 0 in the event one of the two elements
aren't selected: (Having no luck as the form still
only works correctly if I've set both elements)
$Ind = "0";
if (isset($_POST['Ind'])) {
$Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
addslashes($_POST['Ind']);
}
$Days = "0";
if (isset($_POST['Days'])) {
$Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
addslashes($_POST['Days']);
Thank you ,
Stuart
attached mail follows:
You might want to try looking up the syntax for left join queries.
I think this might be what you are after.
http://dev.mysql.com/doc/mysql/en/JOIN.html
On Wednesday 10 November 2004 14:37, Stuart Felenstein wrote:
> I am creating a database search form and results.
> Running into a problem though.
> I have two form elements, both that are fed by tables
> that have int values (1, 2 , etc)
>
> my sql statement is such:
>
> SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
> vendorjobs.Industry, vendorjobs.VendorID,
> vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
> vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
> Date_Sub(Curdate(), interval '$Days' day) <= PostStart
> "
>
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected: (Having no luck as the form still
> only works correctly if I've set both elements)
>
> $Ind = "0";
> if (isset($_POST['Ind'])) {
> $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
> addslashes($_POST['Ind']);
> }
> $Days = "0";
> if (isset($_POST['Days'])) {
> $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
> addslashes($_POST['Days']);
>
> Thank you ,
> Stuart
attached mail follows:
--- Jon Hill <jon
foneport.com> wrote:
> You might want to try looking up the syntax for left
> join queries.
> I think this might be what you are after.
>
> http://dev.mysql.com/doc/mysql/en/JOIN.html
>
It has nothing to do with left joins. It works fine
provided I do one of two things, make selections on
both form elements, or change the where statement to
"or" instead of and.
Stuart
attached mail follows:
On Wednesday 10 November 2004 14:37, Stuart Felenstein wrote:
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected: (Having no luck as the form still
> only works correctly if I've set both elements)
Why not build your sql query according to whether or not whatever you want is
selected or not. That way debugging is easier as you won't be looking at
queries that contain redundant "... AND 0 ...".
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
This system will self-destruct in five minutes.
*/
attached mail follows:
What about doing something like:
$sql = "SELECT * FROM my_table WHERE col1=$var1";
if (isset($var2))
$sql .= " AND col2='$var2'";
HTH
Graham
> -----Original Message-----
> From: Stuart Felenstein [mailto:stuart4m
yahoo.com]
> Sent: 10 November 2004 14:37
> To: php-general
lists.php.net
> Subject: [PHP] Help: Database Search
>
>
> I am creating a database search form and results.
> Running into a problem though.
> I have two form elements, both that are fed by tables
> that have int values (1, 2 , etc)
>
> my sql statement is such:
>
> SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
> vendorjobs.Industry, vendorjobs.VendorID,
> vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
> vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
> Date_Sub(Curdate(), interval '$Days' day) <= PostStart
> "
>
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected: (Having no luck as the form still
> only works correctly if I've set both elements)
>
> $Ind = "0";
> if (isset($_POST['Ind'])) {
> $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
> addslashes($_POST['Ind']);
> }
> $Days = "0";
> if (isset($_POST['Days'])) {
> $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
> addslashes($_POST['Days']);
>
> Thank you ,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Stuart Felenstein wrote:
> I am creating a database search form and results.
> Running into a problem though.
> I have two form elements, both that are fed by tables
> that have int values (1, 2 , etc)
>
> my sql statement is such:
>
> SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
> vendorjobs.Industry, vendorjobs.VendorID,
> vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
> vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
> Date_Sub(Curdate(), interval '$Days' day) <= PostStart
> "
>
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected: (Having no luck as the form still
> only works correctly if I've set both elements)
>
> $Ind = "0";
> if (isset($_POST['Ind'])) {
> $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
> addslashes($_POST['Ind']);
> }
> $Days = "0";
> if (isset($_POST['Days'])) {
> $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
> addslashes($_POST['Days']);
$where = array();
if ( isset($_POST['Ind']) ) {
$where[] = 'vendorjobs.Industry = ' . (int) $_POST['Ind'];
}
if ( isset($_POST['Days']) ) {
$where[] = 'Date_Sub(Curdate(), interval ' . (int) $_POST['Days'] .
' day) <= PostStart';
}
$sql = '
SELECT ...
FROM vendorjobs
WHERE ' . implode( ' AND ', $where );
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
attached mail follows:
--- Jason Wong <php-general
gremlins.biz> wrote:
> Why not build your sql query according to whether or
> not whatever you want is
> selected or not. That way debugging is easier as
> you won't be looking at
> queries that contain redundant "... AND 0 ...".
>
Jason, How would I do that ? Care to share a short
exmaple ?
Thank you
Stuart
attached mail follows:
On Wednesday 10 November 2004 15:37, Stuart Felenstein wrote:
> --- Jason Wong <php-general
gremlins.biz> wrote:
> > Why not build your sql query according to whether or
> > not whatever you want is
> > selected or not. That way debugging is easier as
> > you won't be looking at
> > queries that contain redundant "... AND 0 ...".
>
> Jason, How would I do that ? Care to share a short
> exmaple ?
A simplistic pseudo-code version:
$sql = "SELECT <blah> WHERE 1";
if ($something = "selected") {
$sql .= "AND something";
}
...
...
$sql .= "... rest of query";
Anyway, someone has already posted a more detailed example.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Hmm... Which would do a better job at driving physicists crazy? Travel
faster than light, or a floating-point boolean value?
-- Michael Mol
*/
attached mail follows:
not too sure but can your database name be a path??
>>> Rui Francisco <rui.francisco
fccn.pt> 11/10/2004 4:28:21 PM >>>
Its a simple script
$_SERVER['utilizador']='user';
$_SERVER['pass']='pass';
$_SERVER['host']='localhost or IP address';
$_SERVER['db_name']='c:/path/dbname.fdb';
include_once('DB.php');
$dsn="ibase://".$_SERVER['utilizador'].":".$_SERVER['pass']."
".$_SERVER['host']."/".$_SERVER['db_name'];
$ligacaoBD=DB::connect($dsn);
if (DB::isError($ligacaoBD)) {
die($ligacaoBD->getMessage());
}
The user has admin right on the database, and the database doesn't
implement security measures like Mysql for access from other hosts.
The problem is that if i run the script on the browser it works, but on
the command line on Windows machine it doesn't work
Thanks in advance
Rui Francisco
Angelo Zanetti wrote:
>well maybe you are trying to connect to localhost which could be fine
>for the server but not from commandline... send more info.
>
>
>
>>>>Rui Francisco <rui.francisco
fccn.pt> 11/10/2004 2:06:09 PM >>>
>>>>
>>>>
>Hi,
>
>I have a small problem with a PHP script with Pear DB
>
>The problem is the following: I'm creating a shell script in PHP that
>access one interbase database.
>
>The problem is that if i run it on a webserver the script run
>correctly
>but if i runit in the command line it reports one error (DB Error:
>connect failed).
>
>Does anybody know what is the problem ?
>
>Thanks in advance
>Rui Francisco
>
>
>
--
Rui Francisco - rui.francisco
fccn.pt
FCCN - Fundação para a Computação Científica Nacional
Av. Brasil, 101 1700-066 Lisboa - Portugal
Tel: +351 218440100 Fax: +351 218472167
-----------------------------------------------------
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
attached mail follows:
On Wednesday 10 November 2004 12:36, Garth Hapgood - Strickland wrote:
> Im using the php mail() function to try send an email to a user that has
> just registered.
>
> mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website Registration' ,
> 'Welcome');
>
> But when I get the following error back.:
> Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
> garth
redpoint.co.za
>
> Can someone help me out, by telling me what it means or what Im doing
> wrong?
This is a VERY FAQ.
googling the error message will tell you what it means. Searching the archives
will give you some solutions.
Or you can wait for Manuel Lemos' reply :)
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
He who is content with his lot probably has a lot.
*/
attached mail follows:
On Wed, 10 Nov 2004 23:14:43 +0000, Jason Wong <php-general
gremlins.biz> wrote:
> Or you can wait for Manuel Lemos' reply :)
Good one. :)
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Hello,
On 11/10/2004 10:36 AM, Garth Hapgood - Strickland wrote:
> Im using the php mail() function to try send an email to a user that has
> just registered.
>
> mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website Registration' ,
> 'Welcome');
>
> But when I get the following error back.:
> Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
> garth
redpoint.co.za
>
> Can someone help me out, by telling me what it means or what Im doing wrong?
(Thank you Jason for the introduction! :-)
That means your SMTP server requires authentication to relay messages.
The mail function does not support SMTP authentication.
Alternatively, you may want to try this class that comes with a wrapper
function named smtp_mail(). It works like the mail() function but lets
you specify the authentication user name and password.
http://www.phpclasses.org/mimemessage
You also need these two:
http://www.phpclasses.org/smtpclass
http://www.phpclasses.org/sasl
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
attached mail follows:
Hello,
On 11/10/2004 10:36 AM, Garth Hapgood - Strickland wrote:
> Im using the php mail() function to try send an email to a user that has
> just registered.
>
> mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website Registration' ,
> 'Welcome');
>
> But when I get the following error back.:
> Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
> garth
redpoint.co.za
>
> Can someone help me out, by telling me what it means or what Im doing wrong?
(Thank you Jason for the introduction! :-)
That means your SMTP server requires authentication to relay messages.
The mail function does not support SMTP authentication.
Alternatively, you may want to try this class that comes with a wrapper
function named smtp_mail(). It works like the mail() function but lets
you specify the authentication user name and password.
http://www.phpclasses.org/mimemessage
You also need these two:
http://www.phpclasses.org/smtpclass
http://www.phpclasses.org/sasl
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
attached mail follows:
Garth Hapgood - Strickland wrote:
> But when I get the following error back.:
> Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
> garth
redpoint.co.za
>
> Can someone help me out, by telling me what it means or what Im doing wrong?
Your mail server is not set up to send mail from (or relay) for
"redpoint.co.za". Consult your mail server documentation for help (i.e.
not a PHP issue).
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
attached mail follows:
Hi,
Problem is realted to your smtp server.
Make sure it allowed outgoing mail without authenctication.
You must also set a header in fourth parameter of mail function, it is
good practice and can save you from some basic indentification problems.
In windows you can set default send mail from in php.ini
Try
Mail("you
yourdomain.com","test subject","test
body","from:your_email
youranotherdomain.com\r\r");
If it fails contact your ISP.
Additionally read
http://www.chilkatsoft.com/faq/Smtp550.html
Zareef ahmed
-----Original Message-----
From: Garth Hapgood - Strickland [mailto:garth
redpoint.co.za]
Sent: Wednesday, November 10, 2004 6:06 PM
To: php-general
lists.php.net
Subject: [PHP] php mail() error
Im using the php mail() function to try send an email to a user that has
just registered.
mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website
Registration' , 'Welcome');
But when I get the following error back.:
Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
garth
redpoint.co.za
Can someone help me out, by telling me what it means or what Im doing
wrong?
Thanx
Garth
------------------------------------------------------------------------
--
Zareef Ahmed :: A PHP develoepr in Delhi ( India )
Homepage :: http://www.zasaifi.com
attached mail follows:
Is there a problem issuing multiple session_start()s for a given script?
I can't find anything in the manual that says one way or the other.
I have some scripts that call more than one functions include file and for
convenience put a session_start() on each one.
This gives me a "Notice" error.
Of course I can simply use "
session_start()" to negate the Notice; but, I want
to be certain this is good practice.
Al.........
attached mail follows:
Al wrote:
> Is there a problem issuing multiple session_start()s for a given script?
> I can't find anything in the manual that says one way or the other.
Then you have not looked good enough ;-)
> I have some scripts that call more than one functions include file and
> for convenience put a session_start() on each one.
> This gives me a "Notice" error.
You'll find this in the documentation of session_start(): "Note: As of
PHP 4.3.3, calling session_start() while the session has already been
started will result in an error of level E_NOTICE. Also, the second
session start will simply be ignored."
So there is no problem with multiple calls to session_start(). You can
safely ignore the notice.
attached mail follows:
On Wed, 10 Nov 2004 10:40:17 -0500, Al <news
ridersite.org> wrote:
> Of course I can simply use "
session_start()" to negate the Notice; but, I want
> to be certain this is good practice.
I haven't tried it but you might try wrapping session_start() that
with if ( !isset ($_SESSION) ) if you don't like using the
error
suppression. I usually have a single common file like config.php or
something that I do session_start() in, so I've never actually ran
across this issue.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
I guess that session_id() method will return null if session is not
started (not tested) so theoreticaly you can use:
if (!session_id()) session_start();
elixon
Al wrote:
> Is there a problem issuing multiple session_start()s for a given script?
>
> I can't find anything in the manual that says one way or the other.
>
> I have some scripts that call more than one functions include file and
> for convenience put a session_start() on each one.
>
> This gives me a "Notice" error.
>
> Of course I can simply use "
session_start()" to negate the Notice; but,
> I want to be certain this is good practice.
>
> Al.........
attached mail follows:
And I think that $_SESSION does not exist unless session is started =>
if (!is_array($_SESSION)) session_start();
might do the job as well.
elixon
Al wrote:
> Is there a problem issuing multiple session_start()s for a given script?
>
> I can't find anything in the manual that says one way or the other.
>
> I have some scripts that call more than one functions include file and
> for convenience put a session_start() on each one.
>
> This gives me a "Notice" error.
>
> Of course I can simply use "
session_start()" to negate the Notice; but,
> I want to be certain this is good practice.
>
> Al.........
attached mail follows:
My site is on a virtual host and I'd like to log errors to a file while I'm
debugging. Can't get it to work.
Here is the code at the top of my script:
> ini_set("display_errors", "on"); //also tried "Off"
>
> ini_set("error_log", "/AutoSch/error.log");
>
> $ini_array= ini_get_all();
>
> error_reporting(E_ALL ^ E_WARNING ); //On for debuging only
>
> print_r($ini_array);
Printing $ini_array shows my ini_set() statements are working; but, the errors
are not being appended to error.log.
I put a error.log in the folder, assuming the error handler needed one to append
to.
I don't want to turn on error logging for the whole site; just the folder I'm
working on.
Thanks....
attached mail follows:
On Wed, 10 Nov 2004 10:49:29 -0500, Al <news
ridersite.org> wrote:
> > ini_set("error_log", "/AutoSch/error.log");
Looks like this might be a path relative to your domain or your vhost
definition? I'd go with a full system path if that's the case.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Greg Donald wrote:
> On Wed, 10 Nov 2004 10:49:29 -0500, Al <news
ridersite.org> wrote:
>
>>> ini_set("error_log", "/AutoSch/error.log");
>
>
> Looks like this might be a path relative to your domain or your vhost
> definition? I'd go with a full system path if that's the case.
>
>
Hey Greg, that did it.
It's obvious now.
Thanks....
attached mail follows:
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 10 November 2004 13:37, Horst Jäger wrote:
(Please keep this on list -- others may be able to help better/faster than
me!)
> > > mySplit('example') == array('e', 'x', 'a', 'm', 'p' 'l' 'e') ?
> >
> > Do you absolutely need it as an array? If indexing by character
> > would suffice, just use PHP's {} syntax:
> >
> > $s = 'example';
> > echo $s{0}; // e
> > echo $s{1}; // x
> > // etc.
>
> I am thinking about complexity.
> How is a string implemented in PHP? A deque<char> or a char* ?
Pass -- this looks like a question for PHP's developers, not the denizens of
php-general who are mostly just humble users. But I would expect a char*.
> How does $s{n} acces the n-th char?
>
> 1. Does it go to the beginning of the string and then jump
> from one char to
> the next, counting the instances and return when the n-th ionstance
> is reached?
>
> 2. Or does it jump to the n-th char directly?
Given the nature of PHP, I'd be astonished if it did 1. But again, this
looks more like a question for the PHP developers, not php-general.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
Ford, Mike wrote:
>To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
>
>
>
>
are you in a position to impose any terms (not that i have visited your
link) on an email that get's distributed to thousands of readers, get's
archived on hundreds of sites and possibly ends up in the inbox of bots
designed to harvest email addresses?
>
>
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
attached mail follows:
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 10 November 2004 16:19, raditha dissanayake wrote:
> Ford, Mike wrote:
>
> > To view the terms under which this email is distributed,
> please go to http://disclaimer.leedsmet.ac.uk/email.htm
> >
> are you in a position to impose any terms (not that i have
> visited your
> link) on an email that get's distributed to thousands of
> readers, get's
> archived on hundreds of sites and possibly ends up in the
> inbox of bots
> designed to harvest email addresses?
No. But I'm also not in a position to prevent this ludicrosity from being
prefixed to all outgoing mail from where I work. I would suppress it if I
could, but I can't. Sorry. You'll just have to judge whether the general
standard of my replies warrants putting up with the noise factor, but I
would understand entirely if you filtered me to /dev/null.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
I am trying to cache a database recordset so users can sort, etc
without hitting the database everytime. I'm using ADODB to access a
MSSQL database.
$s = "SELECT id, part, description FROM parts\n";
$r = $db->Execute($s);
$parts = array(id=>array(),part=>array(),desc=>array())
while(!$r->EOF){
array_push($parts['id'],$r->fields[0]);
array_push($parts['part'],$r->fields[0]);
array_push($parts['desc'],$r->fields[0]);
$r->MoveNext();
}
// print_r($parts) displays array data.
Here's what I'm doing:
$v = serialize($parts);
echo "<a href=\"{$_SERVER['PHP_SELF']}?getvar=$v\">Link</a>\n";
If($_GET['getvar']){
$newvar = unserialize($_GET['getvar']);
//This does nothing
echo $newvar;
print_r($newvar);
}
Am i missing something very simple? Should I make the array a
$_SESSION variable, or how do others "cache" a recordset?
attached mail follows:
Mike Smith wrote:
> I am trying to cache a database recordset so users can sort, etc
> without hitting the database everytime. I'm using ADODB to access a
> MSSQL database.
>
>
> $s = "SELECT id, part, description FROM parts\n";
> $r = $db->Execute($s);
>
> $parts = array(id=>array(),part=>array(),desc=>array())
>
> while(!$r->EOF){
> array_push($parts['id'],$r->fields[0]);
> array_push($parts['part'],$r->fields[0]);
> array_push($parts['desc'],$r->fields[0]);
> $r->MoveNext();
> }
>
> // print_r($parts) displays array data.
> Here's what I'm doing:
>
> $v = serialize($parts);
>
>
> echo "<a href=\"{$_SERVER['PHP_SELF']}?getvar=$v\">Link</a>\n";
>
> If($_GET['getvar']){
> $newvar = unserialize($_GET['getvar']);
>
> //This does nothing
> echo $newvar;
> print_r($newvar);
>
> }
>
> Am i missing something very simple? Should I make the array a
> $_SESSION variable, or how do others "cache" a recordset?
i would prefer $_SESSION!
btw.
- do you see the ...?getvar=... in the URL ?
- what does var_dump( $_GET['getvar'] );
- do you tried urlencode();
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
attached mail follows:
Mike Smith wrote:
> I am trying to cache a database recordset so users can sort, etc
> without hitting the database everytime. I'm using ADODB to access a
> MSSQL database.
>
>
> $s = "SELECT id, part, description FROM parts\n";
> $r = $db->Execute($s);
>
> $parts = array(id=>array(),part=>array(),desc=>array())
>
> while(!$r->EOF){
> array_push($parts['id'],$r->fields[0]);
> array_push($parts['part'],$r->fields[0]);
> array_push($parts['desc'],$r->fields[0]);
> $r->MoveNext();
> }
>
> // print_r($parts) displays array data.
> Here's what I'm doing:
>
> $v = serialize($parts);
>
>
> echo "<a href=\"{$_SERVER['PHP_SELF']}?getvar=$v\">Link</a>\n";
>
> If($_GET['getvar']){
> $newvar = unserialize($_GET['getvar']);
>
> //This does nothing
> echo $newvar;
> print_r($newvar);
>
> }
>
> Am i missing something very simple?
You did not tell what is the problem, so I only guess - urlencode? Or
the recordset exceeds allowed size for query string? (But I've once seen
3 or 4 EULAs in one link on microsofts site :))
> Should I make the array a
> $_SESSION variable, or how do others "cache" a recordset?
I don't as it gives more trouble than help.
attached mail follows:
Below is the code that work on a PHP 4.2.1 test server. For some reason
it is not working and not throwing errors(set to E_ALL) on 4.3.7 server.
Has anyone experienced this kind of error? Or can someone point me in
the right direction? TVMIA!
/* create a parser */
if(!($covadParser = xml_parser_create())){
echo "Failed to create parser<br>\n";
exit();
}
/* set handlers for parser */
xml_set_element_handler($covadParser, "StartTag", "EndTag");
xml_set_character_data_handler($covadParser, "DataHandler");
/* let's parse! */
if($readXML = fopen(XMLDIR."testRecp.xml", "r")){
while($lineXML = fread($readXML, 4096)){
//echo $lineXML . "<br>\n";
xml_parse($covadParser, $lineXML, feof($readXML));
}
} else {
echo "COULD NOT READ XML FILE\n";
}
/* clear the parser */
xml_parser_free($covadParser);
attached mail follows:
[snip]
/* let's parse! */
if($readXML = fopen(XMLDIR."testRecp.xml", "r")){
while($lineXML = fread($readXML, 4096)){
//echo $lineXML . "<br>\n";
xml_parse($covadParser, $lineXML, feof($readXML));
}
} else {
echo "COULD NOT READ XML FILE\n";
}
/* clear the parser */
xml_parser_free($covadParser);
[/snip]
Having added the following line
echo "XML Error " . xml_error_string(xml_get_error_code($covadParser)) .
"<br>\n";
just after the xml_parse PHP is reporting "not well-formed (invalid
token)" so I will have to explore. Seems that one server is not as
strict as the other. Is there a way to reduced strictness of xml
validation?
attached mail follows:
[snip]
Having added the following line
echo "XML Error " . xml_error_string(xml_get_error_code($covadParser)) .
"<br>\n";
just after the xml_parse PHP is reporting "not well-formed (invalid
token)" so I will have to explore.
[/snip]
Having beaten my head against the wall for severqal hours now, I am
thouroughly stumped and have a major headache. I have turned over all of
the rocks that I can and cannot even come up with a clean explanation of
the error itself. Does anyone have anything that can help me clean this
up? Unfortunately I have no control over the XML as it is a received
document that I am trying to parse.
attached mail follows:
Hi everybody,
I want to wrote a function that receives another function as parameter
that will be used as a Callback. Well, better a bit of code than
thousand words:
class TreeNode {
...
function Traverse ( CallBack ) {
$rtn = CallBack ($this);
foreach ($this->Sons as $Son) {
$Son->Traverse ( CallBack );
}
return $rtn;
}
...
}
And later I'll do something as:
function CallBack ( $Node ) {
echo $Node->Name;
}
$MyTreeNode->Traverse ( CallBack );
...
Hope you understand what I'm trying to do. Can it be done as is or am I
on the wrong way?
Thx. a million in advance,
attached mail follows:
* Francisco M. Marzoa Alonso <fmmarzoa
gmx.net>:
> I want to wrote a function that receives another function as parameter
> that will be used as a Callback. Well, better a bit of code than
> thousand words:
>
> class TreeNode {
> ...
> function Traverse ( CallBack ) {
> $rtn = CallBack ($this);
> foreach ($this->Sons as $Son) {
> $Son->Traverse ( CallBack );
> }
> return $rtn;
> }
> ...
> }
>
> And later I'll do something as:
>
> function CallBack ( $Node ) {
> echo $Node->Name;
> }
>
> $MyTreeNode->Traverse ( CallBack );
>
> ...
>
> Hope you understand what I'm trying to do. Can it be done as is or am I
> on the wrong way?
Two ways to do it:
1) Pass a string that is the callback function's name; then call it a
dynamic variable function:
function Traverse($callback)
{
$rtn = $callback($this);
...
}
2) Use a PHP callback pseudotype (http://php.net/pseudo-types):
function Traverse($callback)
{
// Calls the callback with $this as its argument:
$rtn = call_use_func($callback, $this);
...
}
Callbacks can be either a string containing a function name or an array
with the first element either a class name or object reference and the
second argument a method name (the first does a static method call, the
second an object method call).
--
Matthew Weier O'Phinney | mailto:matthew
garden.org
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
attached mail follows:
Given a database query thats returns results from a linking (or xref)
table which includes repetition because of the joins:
+----+--------------------------+----------+
| id | title | subject |
+----+--------------------------+----------+
| 1 | Collected Poems of Keats | poetry |
| 2 | Spy High | suspense |
| 3 | Sci Fi Spies | suspense |
| 3 | Sci Fi Spies | sci-fi |
+----+--------------------------+----------+
What is the best way to go about displaying this for the user so that
the record looks "complete":
ID: 3
title: Sci Fi Spies
Subjects: suspense, scifi
or something similar? Or is there some better way to query? It's also
a problem in terms of limiting the query because if I limit the query
to 10 records I might be chopping off some subjects for the last book?
The query and tables are simple:
select books.id, books.title, subjects.subject
from books, subjects, books_subjects
where books_subjects.bid = books.id
and books_subjects.sid = subjects.id
BOOKS
1. collected poems of keats
2. spy high
3. sci-fi spies
SUBJECTS:
1. poetry
2. suspense
3. sci-fi
4. horror
5. mystery
BOOKS_SUBJECTS
bid sid
1 1
2 2
3 2
3 3
c
attached mail follows:
Don't know what version of MySQL you are using, but I upgraded to 4.1
so that I could use the GROUP_CONCAT function, which does what you are
looking for.
http://dev.mysql.com/doc/mysql/en/GROUP-BY-Functions.html
Otherwise, your front-end will need to do the rolling up of the records.
On Nov 10, 2004, at 1:04 PM, Chris Lott wrote:
> Given a database query thats returns results from a linking (or xref)
> table which includes repetition because of the joins:
>
> +----+--------------------------+----------+
> | id | title | subject |
> +----+--------------------------+----------+
> | 1 | Collected Poems of Keats | poetry |
> | 2 | Spy High | suspense |
> | 3 | Sci Fi Spies | suspense |
> | 3 | Sci Fi Spies | sci-fi |
> +----+--------------------------+----------+
>
> What is the best way to go about displaying this for the user so that
> the record looks "complete":
>
> ID: 3
> title: Sci Fi Spies
> Subjects: suspense, scifi
>
> or something similar? Or is there some better way to query? It's also
> a problem in terms of limiting the query because if I limit the query
> to 10 records I might be chopping off some subjects for the last book?
>
> The query and tables are simple:
>
> select books.id, books.title, subjects.subject
> from books, subjects, books_subjects
> where books_subjects.bid = books.id
> and books_subjects.sid = subjects.id
>
> BOOKS
> 1. collected poems of keats
> 2. spy high
> 3. sci-fi spies
>
> SUBJECTS:
> 1. poetry
> 2. suspense
> 3. sci-fi
> 4. horror
> 5. mystery
>
> BOOKS_SUBJECTS
> bid sid
> 1 1
> 2 2
> 3 2
> 3 3
>
> c
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
attached mail follows:
On Wed, 10 Nov 2004 09:04:27 -0900, Chris Lott <chris.lott
gmail.com> wrote:
> Given a database query thats returns results from a linking (or xref)
> table which includes repetition because of the joins:
>
> +----+--------------------------+----------+
> | id | title | subject |
> +----+--------------------------+----------+
> | 1 | Collected Poems of Keats | poetry |
> | 2 | Spy High | suspense |
> | 3 | Sci Fi Spies | suspense |
> | 3 | Sci Fi Spies | sci-fi |
> +----+--------------------------+----------+
>
> What is the best way to go about displaying this for the user so that
> the record looks "complete":
>
> ID: 3
> title: Sci Fi Spies
> Subjects: suspense, scifi
You might normalize the data a bit.
I'd go with three tables: books, subjects, and a books_subjects_xref
table. The subjects table would contain the subject_id and the
subject. The books table would contain the book_id and book_title.
The books_subjects_xref table will contain the book_id and subject_id,
with a two-field unique constraint on book_id and subject_id. You
would have an entry for each subject a book is in.
As far as the sql, I'd suggest something but you didn't say what db
you're using. Looks like MySQL output but I could be wrong.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Hi folks. I'm wondering if anyone out there can recommend a good tool
for load testing a large php application? Ideally it would be something
fairly intelligent, that would follow links, remember what links it has
followed and where any problems occurred, etc.
Can anyone provide any recommendations?
Cheers and TIA,
Pablo
attached mail follows:
On Wed, 10 Nov 2004 10:15:33 -0800, Pablo Gosse <gossep
unbc.ca> wrote:
> Hi folks. I'm wondering if anyone out there can recommend a good tool
> for load testing a large php application? Ideally it would be something
> fairly intelligent, that would follow links, remember what links it has
> followed and where any problems occurred, etc.
>
> Can anyone provide any recommendations?
If you use Apache, you can use the Apache benchmark tool `ab`.
If you just want to slam a site with requests, you could use htdig to
index it or maybe something like:
while(true); do wget -m -np http://yahoo.com/; done
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
hi.
call me stupid but i can't decide which option is better (actually don't
call me stupid because it will hurt my feelings and i might cry). and
having said that, maybe neither option is better than the other?
whatever the answer, i just want some outside input on this because for
some reason my brain is getting caught up on it and it's bothering me.
should basic data validation come before a function call or be performed
within the function?
example of validation outside the function:
<?php
if(is_numeric($this->id) && !empty($this->id))
{
$new_number = my_function($this->id);
}
else
{
$new_number = false;
}
?>
example of validation inside the function:
<?php
function my_function($number)
{
if(is_numeric($number) && !empty($number))
{
// perform some calculations
}
else
{
return false;
}
}
$new_number = my_function($this->id)
?>
thanks,
chris.
attached mail follows:
On Wed, 10 Nov 2004 11:00:12 -0800, Chris W. Parker
<cparker
swatgear.com> wrote:
> should basic data validation come before a function call or be performed
> within the function?
<advice type="record" status="b0rken" value="Benchmark them both and
see which way is faster. then post back and tell us. :)" />
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
On Wed, 10 Nov 2004 11:00:12 -0800, Chris W. Parker
<cparker
swatgear.com> wrote:
> hi.
>
> call me stupid but i can't decide which option is better (actually don't
> call me stupid because it will hurt my feelings and i might cry). and
> having said that, maybe neither option is better than the other?
> whatever the answer, i just want some outside input on this because for
> some reason my brain is getting caught up on it and it's bothering me.
>
> should basic data validation come before a function call or be performed
> within the function?
I would do the validation inside the function. This avoids repeating
the validation everywhere the function is called. It also makes the
function more self-contained. It expects a certain input and
complains, or returns false, if it doesn't get it.
Brad
attached mail follows:
I'm surprised I havn't seen this question come up before (might have
just missed it) but it's an excellent question so forgive the
crossposting as it's extremely relevant to coders and those purchasing
services of coders.
Anyone who's gotten married and hired a wedding photographer is probably
familiar with the idea of "You can't make your own reprints, the photos
are owned by the photographer". What kind of BS is that eh? It was
your wedding! You paid the guy, right?
I read a really interesting article talking about this a while ago and
found out that they key words you want to use (if you want to own what
you pay for) are the words "work for hire". Usually this would be put
in the contract or even on the check you use to pay for the services..
"Signing this check constitutes the payee's acknowledgement that the
services performed and the final output/art/photos/etc is considered a
Work for Hire" or something like that. It's not good enough to say "All
copy rights transfer to the client" apparently.
How I understand it is this... Any artist (musician, coder, author,
painter, etc) has an implicit copyright on whatever they make as soon as
they make it. While in the process of making something, it's
considered a "Work in progress" and has additional rights under certain
laws (see the Steve Jackson case with the Secret Service about them
seizing electronic copies of a game manual that was "in progress" as a
suspected guide to hacking. The electronic copies weren't protected
back then whereas a printed copy would have been.. But they may be
protected from seizure in legal cases these days... Not sure).
Anyway... So you write this code and you own it. Regardless of whether
someone paid you to write it. Unless of course you have an
"intellectual property" thing with the company you work for (like I do..
It says whatever I create for the company... On company time... Is
theirs).
So all those websites and PHP scripts that you set up for people...
They're yours. Unless the client specifies that it's a "work for hire"
in your contract or on the check you gotta sign to get your bucks.
Now from the client's side of things.. Because we don't always write our
own stuff.. It's important to know about this as well so you can
protect your investment. I don't know that a coder can legally demand
that you stop using their code, but it means that if you want to re-sell
what you had developed, you need to clear it with the coder first. A
lot of people don't know this stuff and it's hard to find out when
someone's pirating code that technically belongs to you.. But it's good
to know what rights you do have.
Doing a quick search on Yahoo for "work for hire" and "copyright", I
found a TON of sites that seem to cover the subject. I don't have time
to read them, but at a glance, some of these sounded like good things to
check up on:
http://www.weblawresources.com/Work-For-Hire-Clause.htm
http://www.gigalaw.com/articles/2000/loc-2000-02.html
http://www.copylaw.com/new_articles/wfh.html
http://repositories.cdlib.org/boaltwp/55/
http://www.keytlaw.com/Copyrights/wfhire.htm
http://www.copyright.gov/circs/circ1.html
http://www.music-law.com/workforhire.html
Hope this helps and maybe informs a few people. You can ask me
questions if you want, but this is literally all I know about the
subject. You're better off reading up on the sites above (and Googling
for others) and talking to a copyright lawyer about the matter if you
want more details.
Good luck everyone!
-TG
> -----Original Message-----
> From: Michael Cortes [mailto:cortesm
fortleboeuf.net]
> Sent: Wednesday, November 10, 2004 2:12 PM
> To: php-db
lists.php.net
> Subject: [PHP-DB] Please point me in the right direction.......
>
> I have a question about contracts or agreements.
>
> I am considering hiring a local company to do some coding for
> us in LAMP to
> augment what we have done already. I have a problem with the
> standard "we
> own the code and copyright" clause in thier service agreement.
>
> Can someone point me to the correct mailing list as I don't
> wish to start an
> inapropriate thread.
>
>
> Thank you.
> --
>
> Michael Cortes
> Fort LeBoeuf School District
> 34 East Ninth Street
> PO Box 810
> Waterford PA 16441-0810
> 814.796.4795
attached mail follows:
I installed latest version of PHP from the source on a
AMD ATHELON64 system with REDHAT 9.0 installed with
apache server 2. There were no error upon running
"configure" or "make" or "make install" I have checked
the instalation procedures many times now but I get a
blank screen on the mozilla browser.
Upon viewing the source it shows the source of a blank
html page. The server works well with html pages. Only
the problem is with any php page. I have made the
mentioned additions to be done in the httpd.conf file
namely LoadModule and AddType.
The error log file is showing "Segmentation fault".
___________________________________________________________
Moving house? Beach bar in Thailand? New Wardrobe? Win 10k with Yahoo! Mail to make your dream a reality.
Get Yahoo! Mail http://uk.mail.yahoo.com
attached mail follows:
On Wed, 10 Nov 2004 20:34:46 +0000 (GMT), abhilash kumar
<warrierabhilash
yahoo.co.uk> wrote:
> The error log file is showing "Segmentation fault".
Did you happen to try display_startup_errors = On in your php.ini..
I'm not sure but it might provide a more informative error message.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Hi, I'm using the AIX or UNIX system... When I tried the ...
--snip--
passthru('chmod -R a+rw ../WebHelp/* 2>&1');
--snip--
I get an error message, "Operation Is Not Permitted".. So, I tried other
option...
--snip--
chmod("../WebHelp/", 0755);
--snip--
I get an error message, "Warning: chmod(): Not owner in <<filepath>> on line
13"..
Problem here is that Apache use hte account, "nobody" and is used as "other"
when it come to file permission. (Not the "file owner" or "group")... The
rest of the website files are in a different user account and have different
ownership:group...
Does anyone encountered this situation and does anyone every have a
workaround to it to your knowledge??
Thanks,
Scott
attached mail follows:
you can have apache SU to a user with enough permissions to do what you
are trying :)
(passthru('SU ...'))
Scott Fletcher wrote:
> Hi, I'm using the AIX or UNIX system... When I tried the ...
>
> --snip--
> passthru('chmod -R a+rw ../WebHelp/* 2>&1');
> --snip--
>
> I get an error message, "Operation Is Not Permitted".. So, I tried other
> option...
>
> --snip--
> chmod("../WebHelp/", 0755);
> --snip--
>
> I get an error message, "Warning: chmod(): Not owner in <<filepath>> on line
> 13"..
>
> Problem here is that Apache use hte account, "nobody" and is used as "other"
> when it come to file permission. (Not the "file owner" or "group")... The
> rest of the website files are in a different user account and have different
> ownership:group...
>
> Does anyone encountered this situation and does anyone every have a
> workaround to it to your knowledge??
>
> Thanks,
> Scott
attached mail follows:
I tried that before and it doesn't work... Here's the response..
--snip--
3004-501 Cannot su to "webacct" : Authentication is denied.
--snip--
Scott
"M. Sokolewicz" <tularis
php.net> wrote in message
news:20041110210603.38034.qmail
pb1.pair.com...
> you can have apache SU to a user with enough permissions to do what you
> are trying :)
>
> (passthru('SU ...'))
>
> Scott Fletcher wrote:
> > Hi, I'm using the AIX or UNIX system... When I tried the ...
> >
> > --snip--
> > passthru('chmod -R a+rw ../WebHelp/* 2>&1');
> > --snip--
> >
> > I get an error message, "Operation Is Not Permitted".. So, I tried
other
> > option...
> >
> > --snip--
> > chmod("../WebHelp/", 0755);
> > --snip--
> >
> > I get an error message, "Warning: chmod(): Not owner in <<filepath>> on
line
> > 13"..
> >
> > Problem here is that Apache use hte account, "nobody" and is used as
"other"
> > when it come to file permission. (Not the "file owner" or "group")...
The
> > rest of the website files are in a different user account and have
different
> > ownership:group...
> >
> > Does anyone encountered this situation and does anyone every have a
> > workaround to it to your knowledge??
> >
> > Thanks,
> > Scott
attached mail follows:
Oh I see. I tried a different experiment through the telnet and I noticed I
get this error if I use the wrong password. So, I get the impression that
it is a timing issues or something because I may be sending out the password
too early or too late... Sigh!! More work for me.... Boy!!
Scott
"Scott Fletcher" <scott
abcoa.com> wrote in message
news:20041110211017.56338.qmail
pb1.pair.com...
> I tried that before and it doesn't work... Here's the response..
>
> --snip--
> 3004-501 Cannot su to "webacct" : Authentication is denied.
> --snip--
>
> Scott
>
> "M. Sokolewicz" <tularis
php.net> wrote in message
> news:20041110210603.38034.qmail
pb1.pair.com...
> > you can have apache SU to a user with enough permissions to do what you
> > are trying :)
> >
> > (passthru('SU ...'))
> >
> > Scott Fletcher wrote:
> > > Hi, I'm using the AIX or UNIX system... When I tried the ...
> > >
> > > --snip--
> > > passthru('chmod -R a+rw ../WebHelp/* 2>&1');
> > > --snip--
> > >
> > > I get an error message, "Operation Is Not Permitted".. So, I tried
> other
> > > option...
> > >
> > > --snip--
> > > chmod("../WebHelp/", 0755);
> > > --snip--
> > >
> > > I get an error message, "Warning: chmod(): Not owner in <<filepath>>
on
> line
> > > 13"..
> > >
> > > Problem here is that Apache use hte account, "nobody" and is used as
> "other"
> > > when it come to file permission. (Not the "file owner" or "group")...
> The
> > > rest of the website files are in a different user account and have
> different
> > > ownership:group...
> > >
> > > Does anyone encountered this situation and does anyone every have a
> > > workaround to it to your knowledge??
> > >
> > > Thanks,
> > > Scott
attached mail follows:
Please Cc: me, as it's been quite some time since I posted 50 emails per
day to this list... :-^
I'm interested in anybody's experience, good or bad, in what I am naively
coining as a "Programmatic Browser Rendering Engine":
In an ideal world, it would be a PHP function definition not unlike this:
------------------------
bool imagesurfto(resource image, string url, [int width, int height]);
This function surfs to the given URL, as if a browser window the
dimensions (imagesx, imagesy) of image were opened to that URL, and places
in image a representation of what the user would see if they surfed to
that site.
If width and height are provided, the surfing is done as if the browser
window were the provided width and height, and the result is then scaled
to fit into image.
Example:
<?php
$image = imagecreatetruecolor(800, 600);
imagesurfto($image, 'http://php.net');
header("Content-type: image/jpeg");
imagejpeg($image);
?>
This displays what a user would see surfing to the PHP home page, if their
browser window was open to 800x600.
<?php
$image = imagecreatetruecolor(400, 300);
imagesurfto($image, 'http://php.net');
header("Content-type: image/jpeg");
imagejpeg($image);
?>
This displays the same image as the first example, only scaled down to
half-size.
------------------------
In my case, I have a GUI to admin a web-site by adding links, and I want
to give the user some Interface Feedback that the URL they have typed as a
destination for their link looks like what they expect.
If this is all known technology and everybody is already doing it, please
tell me what everybody else has decided is the correct term for this, as
I've got No Clue. :-)
I'm also very very very open to other ideas how to achieve my goal:
The user should see an image of what the link goes to, so they will notice
if it's not the right URL, as they edit/review their link choices.
This could be useful in sites that allow administrators maintain a "Links
Page" semi-automatically.
It could be particularly useful these days now that domain squatters and
speculators are taking over every expired domain and throwing a bunch of
advertisement/pay-per-click links on them. Just checking that a link is
valid is no longer "Good Enough" to know that you are linking to what you
want to link to. But that's only one portion of the problem I want to
address, so keeping an eye on domain expiration records would solve this
case, but not the more general issue.
And, of course, if you somehow magically allowed another optional argument
of which browser to use... Wow! I could visually compare side-by-side the
images of what my layout looks like on all the browsers? Sign me up!
Okay, so this is probably NOT do-able. But the rest doesn't seem like it
should be that tricky...
Hmmmmm. Does a frame allow a "scaling" factor? Might actually make me
want to use frames [shudder] if they do.
PS If somebody familiar with, say, Mozilla, were to create a PHP function
such as I described above, you'd have instant fame and glory. Hint, hint.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
[snip]
This function surfs to the given URL, as if a browser window the
dimensions (imagesx, imagesy) of image were opened to that URL, and
places
in image a representation of what the user would see if they surfed to
that site.
If width and height are provided, the surfing is done as if the browser
window were the provided width and height, and the result is then scaled
to fit into image.
Example:
<?php
$image = imagecreatetruecolor(800, 600);
imagesurfto($image, 'http://php.net');
header("Content-type: image/jpeg");
imagejpeg($image);
?>
[/snip]
Perhaps an iframe?
The problem here is that you would have to be able to get an image of a
remote site without having a 'printscreen' available. You could
dynamically control an iframe, but the remote would not stretch or
shrink to fit.
attached mail follows:
-------------- Original message ----------------------
From: "Richard Lynch" <ceo
l-i-e.com>
> Please Cc: me, as it's been quite some time since I posted 50 emails per
> day to this list... :-^
>
>
> I'm interested in anybody's experience, good or bad, in what I am naively
> coining as a "Programmatic Browser Rendering Engine":
>
> In an ideal world, it would be a PHP function definition not unlike this:
>
> ------------------------
> bool imagesurfto(resource image, string url, [int width, int height]);
>
> This function surfs to the given URL, as if a browser window the
> dimensions (imagesx, imagesy) of image were opened to that URL, and places
> in image a representation of what the user would see if they surfed to
> that site.
>
You might want to look at webthumb http://www.boutell.com/webthumb/
It is a linux command line utility that creates thumbnails of webpages.
attached mail follows:
> You might want to look at webthumb http://www.boutell.com/webthumb/
> It is a linux command line utility that creates thumbnails of webpages.
or khtml2png: http://www.babysimon.co.uk/khtml2png/
attached mail follows:
What variable "header" use? If I send something in header, what GLOBAL
variable header use?
attached mail follows:
Hi,
Thursday, November 11, 2004, 8:51:49 AM, you wrote:
JS> What variable "header" use? If I send something in header, what GLOBAL
JS> variable header use?
If you are talking about redirection....
You have to use the GET method then look in $_GET or $_REQUEST
$url = 'http://somewhere.com/test.php?variable=hello';
header("Location: $url");
exit;
//test.php
if(isset($_GET['variable'])) echo 'Variable = '.$_GET['variable'].'<br>';
--
regards,
Tom
attached mail follows:
Don't understand what you are asking.
Respectfully,
Ligaya Turmelle
Jerry Swanson wrote:
> What variable "header" use? If I send something in header, what GLOBAL
> variable header use?
>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]