Re: [PHP] Guestbook

2008-01-13 Thread Børge Holen
On Sunday 13 January 2008 01:32:53 Andrés Robinet wrote:
> Hi Guys,
>
> Anybody knows of a free and decent PHP Multilanguage guestbook (or at least
> supporting German and English)? I don't care if it is db-driven or uses
> flat files.
> I know how to write one, but it's for a website we didn't develop (but will
> now host) and I'm feeling a bit lazy... maybe someone has a hint.
> I don't care of how it looks, I can customize that, just want to write as
> less code as possible and avoid any security headaches as well (yeah... the
> good old lazy days :)).

jup feeling lazy alright. Good thing google works


>
> Thanks in advance,
>
> Rob
>
> ndrés Robinet | Lead Developer | BESTPLACE CORPORATION
> 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL
> 33308
>
> | TEL 954-607-4207 | FAX 954-337-2695
>
> Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
> bestplace |  Web: http://www.bestplace.biz | Web: http://www.seo-diy.com



-- 
---
Børge Holen
http://www.arivene.net

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Jochem Maas

Sancar Saran schreef:

Well,

ADODB and TYPO3 are  successfull oss procjecs which uses PHP and they utilizes 
globals at large.


windows is a successful OS but most people would agree it's built on a 
foundation
of cruft.

success != built with good code != globals are good practice.



Regards.

Sancar



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session_start problems with FireFox on Mac

2008-01-13 Thread Jochem Maas

Terry Calie schreef:

...



To illustrate my php goes like this:

index.php
=


index2.php





...

to avoid this in future never add the closing php bracket to the end of
the php file (unless you explicitly want to output something after the
code in question - which is almost never the case), it is not required.

e.g.

- >8 info.php 
8 info.php 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problem with sessions.

2008-01-13 Thread Balasubramanyam A
Could someone help with this code? It is a search and delete program. I'm
executing bunch of code within if-else statement. After searching the
records in else block the code is redirecting to if block. I'm not able
delete the records in else block. How do avoid the control move to if block?


 IIA, Kodaikanal  Observatory
 KODAIKANAL - 624 103";
$hosakote = "Scientist in-charge  CREST Campus  HOSAKOTE - 562
114";
$leh_ladakh = "Engineer in-charge  IAO-HANLE Fort Road.SKARA P.O.Box No.100LEH-LADAKH - 194 101  (J & K)";
$kavalur = "Resident Scientist  Vainu Bappu Observatory  KAVALUR
- 635 701";

$_SESSION['voucher_value'] =  $_POST['voucher_to'];
if($_SESSION['voucher_value'] == k1)
{
$add_val =  $kodaikanal;
}
elseif($_SESSION['voucher_value'] == h1)
{
$add_val =  $hosakote;
}
elseif($_SESSION['voucher_value'] == l1)
{
$add_val =  $leh_ladakh;
}
elseif($_SESSION['voucher_value'] == k2)
{
$add_val =  $kavalur;
}

if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}


}
$sql="SELECT * FROM $tbl_name where name='$search_temp' &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

if ($count == 0)
{
include('header.php');
print "";
print "";
print "Search does not find any such records";
print "";
exit();
include('footer.php');
}
include('ser_mis.php');
}




else
{

$tbl_name = "voucherb";
if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}
if(!(mysql_affected_rows() == 1))
{
include('header.php');
print "";
print "";
print "Records has not been deleted. Please contact administrator";
include('footer.php');
exit();
}else
{
include('header.php');
print "";
print "";
print "The record(s) has been successfully deleted from database";
print "";
exit();
include('footer.php');
}
}
$sql="SELECT * FROM $tbl_name where name='$search_temp'";// &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

/*if ($count == 0)
{
include('header.php');
print "";
print "";
print "Search does not find any such records";
print "";
exit();
include('footer.php');
}*/
include('ser_misb.php');
}

?>


Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Naz Gassiep



While "global variables are good" in quotes did not return any results
from Google, "global variables are evil" in quotes only returned a result
set of 4:

Results *1* - *4* of *4* for *" 
global
variableare
evil
"*
**
Hardly an overwhelming argument by using search results as a measure.

David




Nevermind. I forgot the 's'.

Once again:

Personalized Results *1* - *8* of *8* for
*"global
variablesare
good
"*. (*0.17* seconds)

Personalized Results *1* - *10* of about *136* for
*"global
variablesare
evil
"*. (*0.07* seconds

Ok. So those of us who use globals are 17 time more likely to end up in
hell.

I can live with those odds.

David


God, I'm glad you're not in charge of decision-making on any issues that 
affect me :P

- Naz.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session_start problems with FireFox on Mac

2008-01-13 Thread Europus

Jochem Maas wrote:


?>


...
to avoid this in future never add the closing php bracket to the end of
the php file (unless you explicitly want to output something after the
code in question - which is almost never the case), it is not required.

e.g.
- >8 info.php 
8 info.php 


I didn't know that. Does the underlying engine in PHP provide the
otherwise missing tag? Does the described problem only happen with
FF on Mac or does it affect other browsers on other OSes?

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread David Giragosian
On 1/13/08, Naz Gassiep <[EMAIL PROTECTED]> wrote:
>
>
> >> While "global variables are good" in quotes did not return any results
> >> from Google, "global variables are evil" in quotes only returned a
> result
> >> set of 4:
> >>
> >> Results *1* - *4* of *4* for *" global<
> http://www.google.com/url?sa=X&oi=dict&ei=-nyGR539MKjIgQT1hKC7Bg&sig2=Gorx1ErPpjplcNDVa0qb6g&q=http://www.answers.com/global%26r%3D67&usg=AFQjCNFszs4YfNg7ok3-m08IgyrhO5EAsQ
> >
> >> variable<
> http://www.google.com/url?sa=X&oi=dict&ei=-nyGR539MKjIgQT1hKC7Bg&sig2=vCOY79teeScIcrxuvb6k3g&q=http://www.answers.com/variable%26r%3D67&usg=AFQjCNEzQBZwfNnJ4pr1pnYOXYttJJNkvg
> >are
> >> evil<
> http://www.google.com/url?sa=X&oi=dict&ei=-nyGR539MKjIgQT1hKC7Bg&sig2=eh8-cXxXIwGuHRJhXG2REQ&q=http://www.answers.com/evil%26r%3D67&usg=AFQjCNHcgNJwcVKoYcSB_Ks5OMr4LnAXWw
> >
> >> "*
> >> **
> >> Hardly an overwhelming argument by using search results as a measure.
> >>
> >> David
> >>
> >>
> >
> > Nevermind. I forgot the 's'.
> >
> > Once again:
> >
> > Personalized Results *1* - *8* of *8* for
> > *"global<
> http://www.google.com/url?sa=X&oi=dict&ei=joCGR9SjMp2wgATIv4HWBg&sig2=RNnAskxl87Jpwe85XDzyvg&q=http://www.answers.com/global%26r%3D67&usg=AFQjCNFkKRqMEPNyoEfdOeatXZo5_51d5Q
> >
> > variables<
> http://www.google.com/url?sa=X&oi=dict&ei=joCGR9SjMp2wgATIv4HWBg&sig2=b_YKTOej3C0R3RD0QrZUwA&q=http://www.answers.com/variables%26r%3D67&usg=AFQjCNGXzEwYW9a5HoADskUH1aTT5OIvsg
> >are
> > good<
> http://www.google.com/url?sa=X&oi=dict&ei=joCGR9SjMp2wgATIv4HWBg&sig2=L-Je5IAp1doAPCeTovvqwA&q=http://www.answers.com/good%26r%3D67&usg=AFQjCNG9Bm-38XQxaR5w7aHA_cDvLT1nSw
> >
> > "*. (*0.17* seconds)
> >
> > Personalized Results *1* - *10* of about *136* for
> > *"global<
> http://www.google.com/url?sa=X&oi=dict&ei=xYCGR-TiK4fcgASYpOi2Bg&sig2=ntdSUwxo_P-rplOA3PKNrw&q=http://www.answers.com/global%26r%3D67&usg=AFQjCNE2teAhA638GVYsBxeBxb9z0iYi5A
> >
> > variables<
> http://www.google.com/url?sa=X&oi=dict&ei=xYCGR-TiK4fcgASYpOi2Bg&sig2=zCmKFYtnVoOQlWKrXcLqdw&q=http://www.answers.com/variables%26r%3D67&usg=AFQjCNEEdMRqxKMgkWXftVCWfE4kZr98jg
> >are
> > evil<
> http://www.google.com/url?sa=X&oi=dict&ei=xYCGR-TiK4fcgASYpOi2Bg&sig2=HxVB1-BREdrmjuSHo6E9jQ&q=http://www.answers.com/evil%26r%3D67&usg=AFQjCNErEUXMUFMcXbjo95hRT2t8pzkISg
> >
> > "*. (*0.07* seconds
> >
> > Ok. So those of us who use globals are 17 time more likely to end up in
> > hell.
> >
> > I can live with those odds.
> >
> > David
>
> God, I'm glad you're not in charge of decision-making on any issues that
> affect me :P
> - Naz.
>

How kind of you to clarify your position, Naz. ;~)

David


Re: [PHP] Problem with sessions.

2008-01-13 Thread Jochem Maas

Balasubramanyam A schreef:

Could someone help with this code? It is a search and delete program. I'm
executing bunch of code within if-else statement. After searching the
records in else block the code is redirecting to if block. I'm not able
delete the records in else block. How do avoid the control move to if block?


1. your problem description is pretty useless - apart form being seemingly
incoherent you also mention an 'if block' and an 'else block' in such a way as
to imply that there is only one of each (there are plenty of each in the code 
provided).

2. your code is not properly indented at all which makes reading it
and trying to figure out what it does (and what it is supposed to do)
too much bother.

3. your doing alsorts of things wrong aside from any flawed logic that
the script apparently contains.

e.g.

1. why set the following session value unconditionally each time?
why not just use the POST value?

$_SESSION['voucher_value'] =  $_POST['voucher_to'];


2. I assume that k1 is not a constant you have defined elsewhere...

if($_SESSION['voucher_value'] == k1)


3. you have big SQL injection holes in the script, also you make blind
assumptions about incoming request data:

$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";




 IIA, Kodaikanal  Observatory
 KODAIKANAL - 624 103";
$hosakote = "Scientist in-charge  CREST Campus  HOSAKOTE - 562
114";
$leh_ladakh = "Engineer in-charge  IAO-HANLE Fort Road.SKARA P.O.Box No.100LEH-LADAKH - 194 101  (J & K)";
$kavalur = "Resident Scientist  Vainu Bappu Observatory  KAVALUR
- 635 701";

$_SESSION['voucher_value'] =  $_POST['voucher_to'];
if($_SESSION['voucher_value'] == k1)
{
$add_val =  $kodaikanal;
}
elseif($_SESSION['voucher_value'] == h1)
{
$add_val =  $hosakote;
}
elseif($_SESSION['voucher_value'] == l1)
{
$add_val =  $leh_ladakh;
}
elseif($_SESSION['voucher_value'] == k2)
{
$add_val =  $kavalur;
}

if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}


}
$sql="SELECT * FROM $tbl_name where name='$search_temp' &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

if ($count == 0)
{
include('header.php');
print "";
print "";
print "Search does not find any such records";
print "";
exit();
include('footer.php');
}
include('ser_mis.php');
}




else
{

$tbl_name = "voucherb";
if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}
if(!(mysql_affected_rows() == 1))
{
include('header.php');
print "";
print "";
print "Records has not been deleted. Please contact administrator";
include('footer.php');
exit();
}else
{
include('header.php');
print "";
print "";
print "The record(s) has been successfully deleted from database";
print "";
exit();
include('footer.php');
}
}
$sql="SELECT * FROM $tbl_name where name='$search_temp'";// &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

/*if ($count == 0)
{
include('header.php');
print "";
print "";
print "Search does not find any such records";
print "";
exit();
include('footer.php');
}*/
include('ser_misb.php');
}

?>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session_start problems with FireFox on Mac

2008-01-13 Thread Jochem Maas

Europus schreef:

Jochem Maas wrote:


?>


...
to avoid this in future never add the closing php bracket to the end of
the php file (unless you explicitly want to output something after the
code in question - which is almost never the case), it is not required.

e.g.
- >8 info.php 
8 info.php 


I didn't know that. Does the underlying engine in PHP provide the
otherwise missing tag? 


the tag is not missing as such - the tag denotes the end of string that
php parses - it's quite logical to assume that the end of a file means the same
thing (especially when you consider that any file you include/require
must specify '
Does the described problem only happen with
FF on Mac or does it affect other browsers on other OSes?


I have never seen this problem effect just one browser on on platform -
afaic it's a general problem that effects all browsers - you can't send
out HTTP headers after HTTP content ... now it maybe that some browsers
these days see fit to ignore white space before the headers (or maybe
just ignore a "\n") but I doubt it ... honestly I can't see how php
would even send the headers after the "\n" had been output ... either
you error logging level is too low, your not reading the error log or you
have error suppression on the header() function (.e.g @header()). all
of these would give you the incorrect notion that the header function
was working, all of these are bad practice.

you also mentioned you changed the code when trying to test it on another
machine - don't do that, test one thing at a time.

anyway problem solved, preventative knowledge aquired, onto the next hurdle :-)



Ulex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Nathan Nobbe
the 2 problems that globals introduce are

   1. namespace collisions
   2. point of origin problem

where a  namespace collision is the inconsistent use of a global
variable within an application
eg.
// one point in the application
$GLOBALS['curUser'] = array('username' => 'bob', 'userId' => 5);

// another point in the application
$GLOBALS['curUser'] = new stdClass();
$GLOBALS['curUser']->username = 'bob';
$GLOBALS['curUser']->userId = 5;

and what im calling the 'point of origin' problem, is the ambiguity
introduced by global variables.  when reading through the code of an
application and you encounter the use of a global variable, where was
that variable set?  if not in the same file, then youll have to start
looking.  you may not even be able to determine where the value is
getting set by looking through the code, that is, you might have to analyze
the runtime behavior of the application.  and with the $GLOBALS array, this
can be cumbersome because there is no way (that i know of) to add implicit
logging to setting of values within.

now, whether you or your team or business or w/e will have to deal with
these
problems depends on what sort of conventions, if any, are used to work with
globals (or whether theyre used at all ;)).

to make them work in a team environment you should have some external
documentation
that establishes clear usage guidelines and outlines the purpose (or
declares 'namespaces')
within the $GLOBALS array.  so you might say "$GLOBALS['user'] is designated
to contain
user data, which will be a record from the users table in our database".  it
will be an array.
at that point if someone uses $GLOBALS['user'] for something else, or
changes its data type
or something, you can say, well youve violated our convention here so youll
have to clean that up.

there is the issue of working with code from other parties and this is where
things
can still get messy.  say that you have your conventions and everything is
hunky-dory; then you
decide to use some third party code, and it uses one of your global
'namespaces'.
so for example you get some third party code and within it, for whatever
reason $GLOBALS['user']
(referenced earlier) is being read or set.  well if you want to use that
code, youll have to refactor
either yours, or theirs.

object oriented development helps with some of these problems, but it is not
by itself a silver bullet.
for example with singleton
http://www.phppatterns.com/doku.php/design/singleton_pattern
problems 1, and 2 above are still relevant.  php is introducing namespaces
soon enough, but prior
to those class name collisions are generally resolved in php by prefixing a
class name
eg.
class User {}
becomes
class MyBiz__User {}

problem 2 though is relevant depending on what the singleton is used for.
suppose it only contains
2 values, a reference to itself and one datum, which is set in the private
constructor (or another private
method invoked as part of the constructor).  this is the most trivial case
and it is not really subject to
the problem.  however, if a singleton were to have getter and setter methods
problem number 2 above
can occur.  the good news here is that since singleton is a class you write,
adding logging is trivial
so you should be able to track down those spurious cases where a value is
set in one portion of the
application and read in another.

i happen to know that facebook uses globals, and i just thought i would
mention it as a 'successful'
yet perhaps 'code not so great' example of a large application using
globals.

if you are to use globals, then establish conventions.
the worst stuff i have ever seen is use of other superglobal arrays for the
same purpose as what the
$GLOBALS array is intended to be.
eg.
// one part of the application
// NOTE: this value did not orginate from the request
$_POST['someVal'] = 5;

// later in the application
$myVar = $_POST['someVal'];

that is just plain bad if you ask me (and they didnt even put the note!).

-nathan


Re: [PHP] session_start problems with FireFox on Mac

2008-01-13 Thread Europus

 Jochem Maas wrote:


you also mentioned you changed the code when trying to test it on another
machine - don't do that, test one thing at a time.


I'm not the original poster, that wasn't me.

anyway problem solved, preventative knowledge aquired, onto the next 
hurdle :-)


I'm having some trouble with a for() loop and echoing array results
to screen to see if I'm getting the data I'm after, I may post about
it later.

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread David Giragosian
On 1/13/08, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> the 2 problems that globals introduce are
>
>1. namespace collisions
>2. point of origin problem
>
> where a  namespace collision is the inconsistent use of a global
> variable within an application
> eg.
> // one point in the application
> $GLOBALS['curUser'] = array('username' => 'bob', 'userId' => 5);
>
> // another point in the application
> $GLOBALS['curUser'] = new stdClass();
> $GLOBALS['curUser']->username = 'bob';
> $GLOBALS['curUser']->userId = 5;
>
> and what im calling the 'point of origin' problem, is the ambiguity
> introduced by global variables.  when reading through the code of an
> application and you encounter the use of a global variable, where was
> that variable set?  if not in the same file, then youll have to start
> looking.  you may not even be able to determine where the value is
> getting set by looking through the code, that is, you might have to
> analyze
> the runtime behavior of the application.  and with the $GLOBALS array,
> this
> can be cumbersome because there is no way (that i know of) to add implicit
> logging to setting of values within.
>
> now, whether you or your team or business or w/e will have to deal with
> these
> problems depends on what sort of conventions, if any, are used to work
> with
> globals (or whether theyre used at all ;)).
>
> to make them work in a team environment you should have some external
> documentation
> that establishes clear usage guidelines and outlines the purpose (or
> declares 'namespaces')
> within the $GLOBALS array.  so you might say "$GLOBALS['user'] is
> designated to contain
> user data, which will be a record from the users table in our database".
> it will be an array.
> at that point if someone uses $GLOBALS['user'] for something else, or
> changes its data type
> or something, you can say, well youve violated our convention here so
> youll have to clean that up.
>
> there is the issue of working with code from other parties and this is
> where things
> can still get messy.  say that you have your conventions and everything is
> hunky-dory; then you
> decide to use some third party code, and it uses one of your global
> 'namespaces'.
> so for example you get some third party code and within it, for whatever
> reason $GLOBALS['user']
> (referenced earlier) is being read or set.  well if you want to use that
> code, youll have to refactor
> either yours, or theirs.
>
> object oriented development helps with some of these problems, but it is
> not by itself a silver bullet.
> for example with singleton
> http://www.phppatterns.com/doku.php/design/singleton_pattern
>
> problems 1, and 2 above are still relevant.  php is introducing namespaces
> soon enough, but prior
> to those class name collisions are generally resolved in php by prefixing
> a class name
> eg.
> class User {}
> becomes
> class MyBiz__User {}
>
> problem 2 though is relevant depending on what the singleton is used for.
> suppose it only contains
> 2 values, a reference to itself and one datum, which is set in the private
> constructor (or another private
> method invoked as part of the constructor).  this is the most trivial case
> and it is not really subject to
> the problem.  however, if a singleton were to have getter and setter
> methods problem number 2 above
> can occur.  the good news here is that since singleton is a class you
> write, adding logging is trivial
> so you should be able to track down those spurious cases where a value is
> set in one portion of the
> application and read in another.
>
> i happen to know that facebook uses globals, and i just thought i would
> mention it as a 'successful'
> yet perhaps 'code not so great' example of a large application using
> globals.
>
> if you are to use globals, then establish conventions.
> the worst stuff i have ever seen is use of other superglobal arrays for
> the same purpose as what the
> $GLOBALS array is intended to be.
> eg.
> // one part of the application
> // NOTE: this value did not orginate from the request
> $_POST['someVal'] = 5;
>
> // later in the application
> $myVar = $_POST['someVal'];
>
> that is just plain bad if you ask me (and they didnt even put the note!).
>
> -nathan
>


A very cogent and detailed assessment of the issues, Nathan, and I
appreciate the time and thoughtfulness involved in writing your response.

My stance concerning globals is that, on PHP projects anyway, I work alone,
use longish and very descriptive variable names, and most always only use
globals for static data needed for calculations of some kind. But I
certainly appreciate that in a team environment and when working on very
large projects, the odds of globals usage, especially without documentation
and adherence to a standard, can lead to the problems described above.

In general, I agree with Stut's response delineated earlier in this thread,
that a careful and circumscribed use of globals has a place in PHP
programming.

David


Re: [PHP] session_start problems with FireFox on Mac

2008-01-13 Thread Jochem Maas

Europus schreef:

 Jochem Maas wrote:


you also mentioned you changed the code when trying to test it on another
machine - don't do that, test one thing at a time.


I'm not the original poster, that wasn't me.

anyway problem solved, preventative knowledge aquired, onto the next 
hurdle :-)


I'm having some trouble with a for() loop and echoing array results
to screen to see if I'm getting the data I'm after, I may post about
it later.


use var_dump() rather than echo.



Ulex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Nathan Nobbe
On Jan 13, 2008 12:14 PM, David Giragosian <[EMAIL PROTECTED]> wrote:

> In general, I agree with Stut's response delineated earlier in this
> thread,
> that a careful and circumscribed use of globals has a place in PHP
> programming.


agreed.

-nathan


[PHP] var_dump() results

2008-01-13 Thread Europus

It's pretty much the same. With var_dump(), values from the first row
of the table are iterated twice, the script is not looping through and
reporting all 2100 rows. Grossly similar behavior was observed with
print_r() and echo: while different data was reported by each, the
loop wouldn't loop. The first row was reported once (or twice) and
that was the end of that. I've tried foreach() also, same-same. It
doesn't loop, it just reports the first row.

Here's my code:

";
?>

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Sancar Saran
On Sunday 13 January 2008 16:53:42 Jochem Maas wrote:
> Sancar Saran schreef:
> > Well,
> >
> > ADODB and TYPO3 are  successfull oss procjecs which uses PHP and they
> > utilizes globals at large.
>
> windows is a successful OS but most people would agree it's built on a
> foundation of cruft.
>
> success != built with good code != globals are good practice.
>
> > Regards.
> >
> > Sancar

Hello there, 

After some research, I found source of the "Globals are evil".

This was coming from common c and c++ practice. In this enviroments using 
globals leding to race conditions which was very hard to resolve.

and uh oh, that php thing was using share nothing perspective. No race 
condtions. except variable crashing.

From my point of view. After 8 years of php programming only one time face the 
variable crashing. And that was a local variable called $i.

Of course your millage was vary...

Regards

Sancar.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread T.Lensselink

Europus wrote:

It's pretty much the same. With var_dump(), values from the first row
of the table are iterated twice, the script is not looping through and
reporting all 2100 rows. Grossly similar behavior was observed with
print_r() and echo: while different data was reported by each, the
loop wouldn't loop. The first row was reported once (or twice) and
that was the end of that. I've tried foreach() also, same-same. It
doesn't loop, it just reports the first row.


It doesn't loop through all rows because you use mysql_fetch_row. Wich 
does exactly
what it's name tells you. It fetches one single row. So instead of 
looping through the
whole result set. You are looping through every cell off the result set. 
You're probably

better of using mysql_fetch_array().


Here's my code:

";
?>

Ulex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread T.Lensselink

Europus wrote:

T.Lensselink wrote:

It doesn't loop through all rows because you use mysql_fetch_row. 
Wich does exactly what it's name tells you. It fetches one single row.


Doh! Yes I'm brand new at PHP, though I've been doing HTML/CSS forever.
That doesn't seem to mean much to a PHP/MySQL installation.

Everybody has to start somewhere :)



So instead of looping through the
whole result set. You are looping through every cell off the result 
set. You're probably better of using mysql_fetch_array().


I made that change, now it reports the 1st row 4 times and never
gets on to the 2nd or subsequent rows. What the ???

Can you show some code?


Ulex





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Jochem Maas

Europus schreef:

It's pretty much the same. With var_dump(), values from the first row
of the table are iterated twice, the script is not looping through and
reporting all 2100 rows. Grossly similar behavior was observed with
print_r() and echo: while different data was reported by each, the
loop wouldn't loop. The first row was reported once (or twice) and
that was the end of that. I've tried foreach() also, same-same. It
doesn't loop, it just reports the first row.

Here's my code:


side note: where does $table come from?





if (!$result) {
echo "query failed.\n";
} else {
while ($row = mysql_fetch_array($result))
var_dump($row);
}   



$row = mysql_fetch_row($result);

//loop through to display results
for($i=0; $i < count($row); $i++){
var_dump($row);
echo "";
?>

Ulex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Europus

T.Lensselink wrote:


Can you show some code?


Apparently I sent replies to T.Lensselink only, here's the meat of
the 2nd one:

--

Actually, it doesn't exactly iterate the 1st row 4 times, it's a bit
more convoluted.

The table fas 4 columns (Fields):
1 - int, primary, auto-incrementer
2 - varchar() values
3 - varchar() values
4 - varchar() values

and 2100 rows. I'm after the data in the 2nd and 3rd columns. The
return is 4 rows of this:

array(4) {
[0]=>  string(11) "col_2_row_1_data" ["col_2"]=>  string(11) 
"col_2_row_1_data"
[1]=>  string(13) "col_3_row_1_data" ["col_3"]=>  string(13) 
"col_3_row_1_data" }


This is way beyond my ken, but I want to learn so I'll keep plugging
at it. Tips & suggestions are welcome

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Steve Edberg

At 12:32 PM -0500 1/13/08, Europus wrote:

It's pretty much the same. With var_dump(), values from the first row
of the table are iterated twice, the script is not looping through and
reporting all 2100 rows. Grossly similar behavior was observed with
print_r() and echo: while different data was reported by each, the
loop wouldn't loop. The first row was reported once (or twice) and
that was the end of that. I've tried foreach() also, same-same. It
doesn't loop, it just reports the first row.

Here's my code:

";
?>

Ulex



As far as displaying only the first row, that's because you're only 
fetching the first row; count($row) in your for loop will always 
evaluate to 0 (if there are no results) or 1. You need to move the 
mysql_fetch_row() call into your loop; something like


$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
var_dump($row);
...
}

or you could do

$result = mysql_query($sql);
$count = mysql_num_rows($result);
for ($i=0; $i<$count; $i++) {
var_dump($row);
...
}

As far as displaying the results twice, I'm not sure; that resembles 
the behavior of mysql_fetch_array() -


http://us.php.net/manual/en/function.mysql-fetch-array.php

- where the default is to return data as both an associative and 
numerically-indexed array. I'm guessing that the above code isn't an 
exact cut-and-paste, as using single quotes (eg, 
mysql_pconnect('$host', '$login', '$passwd') does not interpolate 
variables, so that line will not work unless your username is 
actually '$login', etc. Which it probably isn't. Are you sure the 
real code isn't using mysql_fetch_array() instead of 
mysql_fetch_row()?


steve


--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread T.Lensselink

Europus wrote:

Actually, it doesn't exactly iterate the 1st row 4 times, it's a bit
more convoluted.

The table as 4 columns:
1 - int, primary, auto-incrementer
2 - varchar() values
3 - varchar() values
4 - varchar() values

and 2100 rows. The return is 4 rows of this:

array(4) {
[0]=>  string(11) "col_1_row_1_data" ["col_1"]=>  string(11) 
"col_1_row_1_data"
[1]=>  string(13) "col_2_row_1_data" ["col_2"]=>  string(13) 
"col_2_row_1_data" }


This is way beyond my ken, but I want to learn so I'll keep plugging
at it. Tips & suggestions are welcome

Ulex

Yes well looking at the starting code i realise i forgot something. 
Sorry for that.

When doing mysql_fetch_array or mysql_fetch_row you get only one row.
So what you want to do is loop through the result set:

$result = mysql_query($sql);

//loop through to display results
while ($row = mysql_fetch_array($result)) {
   var_dump($row);
   echo "";
}

P.s. Please reply to the list also :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Europus

Jochem Maas wrote:


side note: where does $table come from?


I didn't want to reveal the real names of my server/host, table,
login or password to the list, so I tried setting $host, $login,
$passwd, and $table variables at the top of the script. That way
it's 4 lines to omit when posting code, instead of parsing through
to edit each instance. That didn't work so I've since restored the
initial values, probably I stepped on a reserved word. I'll check
on that, I like the idea of setting those to variables elsewhere.


//get column data
$sql= "SELECT column2, column3 FROM $table";
$result = mysql_query($sql);


if (!$result) {
echo "query failed.\n";
} else {
while ($row = mysql_fetch_array($result))
var_dump($row);
}   




$row = mysql_fetch_row($result);


Now that, that change makes what looks to be 2100 rows of data flood
the screen, thank you. Now I can move on to processing that data
in the next step of my script.

It looks like, my take-away lesson is that I was invoking var_dump()
too late, I should have been performing that check right after running
mysql_fetch_array(), because later operations step on the data and
that's why I was getting unexpected returns.

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Europus

Steve Edberg wrote:

As far as displaying only the first row, that's because you're only 
fetching the first row; count($row) in your for loop will always 
evaluate to 0 (if there are no results) or 1. You need to move the 
mysql_fetch_row() call into your loop; something like


$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
var_dump($row);
...
}

or you could do

$result = mysql_query($sql);
$count = mysql_num_rows($result);
for ($i=0; $i<$count; $i++) {
var_dump($row);
...
}


Noted, thank you. I'll play with these too, to see what I think of them.

As far as displaying the results twice, I'm not sure; that resembles the 
behavior of mysql_fetch_array() -


The script had ~fetch_array() initially, I couldn't get it to work as
expected so I changed it to ~fetch_row(). Now it's back to ~fetch_array()

Both as a learning exercise and as an end-goal, I'm rewriting some
code so that it does what I want it to, not what it imperfectly does
according to the original programmers intent. That original intent
bears only passing resemblance to what was requested of that programmer,
it's become a sore subject.


http://us.php.net/manual/en/function.mysql-fetch-array.php

- where the default is to return data as both an associative and 
numerically-indexed array. 


That explains some things. And I have some reading and experimenting
to do before I move on to the next step in the script.

I'm guessing that the above code isn't an 
exact cut-and-paste, as using single quotes (eg, mysql_pconnect('$host', 
'$login', '$passwd') does not interpolate variables, so that line will 
not work unless your username is actually '$login', etc. Which it 
probably isn't. 


Correct. That was my attempt to obfuscate some of my real data, the
username and password especially. See my other post on this.

Ulex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] DESC order results

2008-01-13 Thread Danny Brow
Just wondering if anyone could tell me how reliable the DESC order
option is going to be when I am parsing thousands of records where they
are multiple ChartNo's for the same clientNo. Or is there a better way
to grab the most recent ChartNo.

$link = mysql_connect('localhost', 'myuser', 'mypassword') or die('Could
not connect: ' . mysql());

mysql_select_db('mydatabase') or die('Could not select database');

$query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo
DESC';

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

$line = mysql_fetch_array($result, MYSQL_ASSOC);


// Just for testing
print mysql_num_rows($result);



Thanks,
Dan




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DESC order results

2008-01-13 Thread Jochem Maas

Danny Brow schreef:

Just wondering if anyone could tell me how reliable the DESC order
option is going to be when I am parsing thousands of records where they
are multiple ChartNo's for the same clientNo. Or is there a better way
to grab the most recent ChartNo.


this is a mysql question not a php question, please try to ask questions
in the appropriate forum.

the reliability of 'ORDER BY' is not tied to the ammount of
records returned.

given that you only want the 'most recent'
(by which I assume you mean the 'highest value') ChartNo for
a given clientNo you should be performing a query that returns a
single row of data.

also you shouldn't be quoting values pertaining to numeric fields
(I assume clientNo is an integer)

1. assuming ChartNo is numeric:

SELECT MAX(ChartNo) as chartno FROM eChart WHERE clientNo=2

2. assuming ChartNo is a varchar (or similar):

SELECT ChartNo FROM eChart WHERE clientNo=2 ORDER BY ChartNo DESC LIMIT 0,1



$link = mysql_connect('localhost', 'myuser', 'mypassword') or die('Could
not connect: ' . mysql());

mysql_select_db('mydatabase') or die('Could not select database');

$query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo
DESC';

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

$line = mysql_fetch_array($result, MYSQL_ASSOC);


// Just for testing
print mysql_num_rows($result);



Thanks,
Dan






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DESC order results

2008-01-13 Thread Danny Brow

Thanks for the answer, didn't think of asking this in a MySQL forum,
sorry.

Dan

On Sun, 2008-01-13 at 20:28 +0100, Jochem Maas wrote:
> Danny Brow schreef:
> > Just wondering if anyone could tell me how reliable the DESC order
> > option is going to be when I am parsing thousands of records where they
> > are multiple ChartNo's for the same clientNo. Or is there a better way
> > to grab the most recent ChartNo.
> 
> this is a mysql question not a php question, please try to ask questions
> in the appropriate forum.
> 
> the reliability of 'ORDER BY' is not tied to the ammount of
> records returned.
> 
> given that you only want the 'most recent'
> (by which I assume you mean the 'highest value') ChartNo for
> a given clientNo you should be performing a query that returns a
> single row of data.
> 
> also you shouldn't be quoting values pertaining to numeric fields
> (I assume clientNo is an integer)
> 
> 1. assuming ChartNo is numeric:
> 
> SELECT MAX(ChartNo) as chartno FROM eChart WHERE clientNo=2
> 
> 2. assuming ChartNo is a varchar (or similar):
> 
> SELECT ChartNo FROM eChart WHERE clientNo=2 ORDER BY ChartNo DESC LIMIT 0,1
> 
> > 
> > $link = mysql_connect('localhost', 'myuser', 'mypassword') or die('Could
> > not connect: ' . mysql());
> > 
> > mysql_select_db('mydatabase') or die('Could not select database');
> > 
> > $query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo
> > DESC';
> > 
> > $result = mysql_query($query) or die('Query failed: ' . mysql_error());
> > 
> > $line = mysql_fetch_array($result, MYSQL_ASSOC);
> > 
> > 
> > // Just for testing
> > print mysql_num_rows($result);
> > 
> > 
> > 
> > Thanks,
> > Dan
> > 
> > 
> > 
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DESC order results

2008-01-13 Thread Larry Garfield
This is a MySQL question, not a PHP question.  That said, what you want is the 
LIMIT keyword.  

On Sunday 13 January 2008, Danny Brow wrote:
> Just wondering if anyone could tell me how reliable the DESC order
> option is going to be when I am parsing thousands of records where they
> are multiple ChartNo's for the same clientNo. Or is there a better way
> to grab the most recent ChartNo.
>
> $link = mysql_connect('localhost', 'myuser', 'mypassword') or die('Could
> not connect: ' . mysql());
>
> mysql_select_db('mydatabase') or die('Could not select database');
>
> $query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo
> DESC';
>
> $result = mysql_query($query) or die('Query failed: ' . mysql_error());
>
> $line = mysql_fetch_array($result, MYSQL_ASSOC);
>
>
> // Just for testing
> print mysql_num_rows($result);
>
>
>
> Thanks,
> Dan
>
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Jochem Maas

Sancar Saran schreef:

On Sunday 13 January 2008 16:53:42 Jochem Maas wrote:

Sancar Saran schreef:

Well,

ADODB and TYPO3 are  successfull oss procjecs which uses PHP and they
utilizes globals at large.

windows is a successful OS but most people would agree it's built on a
foundation of cruft.

success != built with good code != globals are good practice.


Regards.

Sancar


Hello there, 


After some research, I found source of the "Globals are evil".

This was coming from common c and c++ practice. In this enviroments using 
globals leding to race conditions which was very hard to resolve.


so? this has nothing to do with the reasoning about php globals being evil.



and uh oh, that php thing was using share nothing perspective. No race 
condtions.


no race conditions occur in code written in php? true that there is
no direct race conditions that can occur as a direct result of running code
but obviously you've never dealt with multi-user systems using a databse 
backend,
or file-writing based tools used in a web-environment (e.g. template output 
caching)
or anything that uses shared memory or trying to guanrantee that a command-line 
script
runs as a singleton. to name but a few examples that can most definitely be 
prone
to race-conditions.

oh and I believe you meant 'share nothing architecture'


except variable crashing.


I think you just made up 'variable crashing' - at any rate it not a concept
I understand to mean anything specific to the issue we are talking about.



From my point of view. After 8 years of php programming only one time face the 
variable crashing. And that was a local variable called $i.


well that seals it then - obviously globals are fantastic?!?

not to mention that this does not include any number of globals related
errors lurking in code[pathes] that is yet to be run or tested or errors that 
other
people have encountered in your code but that you know nothing about.



Of course your millage was vary...


it does, depending on how early or late I decide to change gear, the ammount of
traffic on the road, road-surface temperature, humidity, altitude, 
tyre-pressure,
octane number of the fuel I'm using and any number of other variables.

which is another way of saying - your mileage will vary.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DESC order results

2008-01-13 Thread Silvio Porcellana


$query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo
DESC';



If you want just one record:

$query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo 
DESC LIMIT 0, 1';



BTW, you'd better ask the MySQL mlist: http://lists.mysql.com/

HTH, cheers
Silvio

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] anaylyze email

2008-01-13 Thread Yui Hiroaki
Thank you for your response.

I try to write a code.

I actualy want to do;

1) some body send email to me; for example; to [EMAIL PROTECTED] from [EMAIL 
PROTECTED]
2)read it's email
3)return to [EMAIL PROTECTED]

so I can not do this 2)

I try to read pop3. I can not find any example!

Regards,
Yui


[PHP] Re: anaylyze email

2008-01-13 Thread Manuel Lemos
Hello,

on 01/13/2008 07:46 PM Yui Hiroaki said the following:
> Thank you for your response.
> 
> I try to write a code.
> 
> I actualy want to do;
> 
> 1) some body send email to me; for example; to [EMAIL PROTECTED] from [EMAIL 
> PROTECTED]
> 2)read it's email
> 3)return to [EMAIL PROTECTED]
> 
> so I can not do this 2)
> 
> I try to read pop3. I can not find any example!

You can use the MIME parser package. It can be used to parse whole
messages including extracting e-mail addresses from the headers.

But if you have already the From address header value, you can use the
RFC822 address parser class which can extract the e-mail addresses and
any names associated to the names.

It also has some tolerance to malformed addresses, so it can parse
addresses in messages that are not correctly formatted according to the
e-mail standards.

Take a look in particular at the test_message_decoder.php and
test_parse_addresses.php example scripts.

http://www.phpclasses.org/mimeparser


-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Guestbook

2008-01-13 Thread Andrés Robinet
> -Original Message-
> From: Børge Holen [mailto:[EMAIL PROTECTED]
> Sent: Sunday, January 13, 2008 7:48 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Guestbook
> 
> On Sunday 13 January 2008 01:32:53 Andrés Robinet wrote:
> > Hi Guys,
> >
> > Anybody knows of a free and decent PHP Multilanguage guestbook (or at
> least
> > supporting German and English)? I don't care if it is db-driven or
> uses
> > flat files.
> > I know how to write one, but it's for a website we didn't develop
> (but will
> > now host) and I'm feeling a bit lazy... maybe someone has a hint.
> > I don't care of how it looks, I can customize that, just want to
> write as
> > less code as possible and avoid any security headaches as well
> (yeah... the
> > good old lazy days :)).
> 
> jup feeling lazy alright. Good thing google works

Good... that will be my answer next time I don't have anything to say on a
thread.

And yeah... you can search for "Free PHP " and you'll get some
Ad-Oriented websites if you know what I mean... sometimes Google just sucks.

And sometimes "Yes, once I used  which is reliable, simple and supports
German..." is not that hard to answer. If for every issue you come across
you have to use Google alone, then get rid of the list... there were so many
jerky questions that got answered here... Anyway, I'll just have to write my
own and save it on our library, there's a German speaking woman in the
company which will give me a hand. I personally hate guestbooks, but I
prefer to have some reusable piece of our own, than to have to deal with
some dirty code for which I don't have a recommendation.

Pity, it is the first time I ask something to the list, I expected just a
bit more (like a couple of names to research).
Well... seems that I'll change my policy a bit next time someone needs a
hand.

Rob

> 
> 
> >
> > Thanks in advance,
> >
> > Rob
> >
> > ndrés Robinet | Lead Developer | BESTPLACE CORPORATION
> > 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale,
> FL
> > 33308
> >
> > | TEL 954-607-4207 | FAX 954-337-2695
> >
> > Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
> > bestplace |  Web: http://www.bestplace.biz | Web: http://www.seo-
> diy.com
> 
> 
> 
> --
> ---
> Børge Holen
> http://www.arivene.net

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Guestbook

2008-01-13 Thread Børge Holen
On Monday 14 January 2008 00:07:30 Andrés Robinet wrote:
> > -Original Message-
> > From: Børge Holen [mailto:[EMAIL PROTECTED]
> > Sent: Sunday, January 13, 2008 7:48 AM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] Guestbook
> >
> > On Sunday 13 January 2008 01:32:53 Andrés Robinet wrote:
> > > Hi Guys,
> > >
> > > Anybody knows of a free and decent PHP Multilanguage guestbook (or at
> >
> > least
> >
> > > supporting German and English)? I don't care if it is db-driven or
> >
> > uses
> >
> > > flat files.
> > > I know how to write one, but it's for a website we didn't develop
> >
> > (but will
> >
> > > now host) and I'm feeling a bit lazy... maybe someone has a hint.
> > > I don't care of how it looks, I can customize that, just want to
> >
> > write as
> >
> > > less code as possible and avoid any security headaches as well
> >
> > (yeah... the
> >
> > > good old lazy days :)).
> >
> > jup feeling lazy alright. Good thing google works
>
> Good... that will be my answer next time I don't have anything to say on a
> thread.

ok, THAT was informative.

>
> And yeah... you can search for "Free PHP " and you'll get some
> Ad-Oriented websites if you know what I mean... sometimes Google just
> sucks.

I don't care, don't use google.

>
> And sometimes "Yes, once I used  which is reliable, simple and supports
> German..." is not that hard to answer.

You don't even have a suggestion, and still complain

> If for every issue you come across 
> you have to use Google alone, then get rid of the list... there were so
> many jerky questions that got answered here... 

This list is "about" php, ie what you build ... lets say guestbooks of. Jerky 
or not, this is where you come when you hit a brickwall, with no lazyness

> Anyway, I'll just have to 
> write my own and save it on our library, there's a German speaking woman in
> the company which will give me a hand.

See there you go... and with some help you should be down on 30min each.

> I personally hate guestbooks, 

me to, especially those with captcha

> but I  
> prefer to have some reusable piece of our own, than to have to deal with
> some dirty code for which I don't have a recommendation.

Join the club

>
> Pity, it is the first time I ask something to the list, I expected just a
> bit more (like a couple of names to research).

Did you do any research before askin' for help? sure didn't sound like it.
Remember that some (most?) of these guys (and gals?) do php for a living, and 
take it out of their own pocket trying to help one'another, and it's a rude 
practice demanding without showing you'd done some forehand homework.
Me? I'm just rude enought to point that out.

> Well... seems that I'll change my policy a bit next time someone needs a
> hand.

I hope you catch on to both my irony and what I try to tell you, if so you'd 
be doin' just fine

>
> Rob
>
> > > Thanks in advance,
> > >
> > > Rob
> > >
> > > ndrés Robinet | Lead Developer | BESTPLACE CORPORATION
> > > 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale,
> >
> > FL
> >
> > > 33308
> > >
> > > | TEL 954-607-4207 | FAX 954-337-2695
> > >
> > > Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
> > > bestplace |  Web: http://www.bestplace.biz | Web: http://www.seo-
> >
> > diy.com
> >
> >
> >
> > --
> > ---
> > Børge Holen
> > http://www.arivene.net



-- 
---
Børge Holen
http://www.arivene.net

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] $_GET and multiple spaces.

2008-01-13 Thread Churchill, Craig
Hello,

One of the values I'm passing in a URL string contains multiple spaces.

...
(The multiple spaces are between Argononemertes and australiensis)

However when I retrieve the value using $_GET[DarScientificName]
there is only a single space between the two names which I understand is the 
intended behaviour?

Is there a way to preserve the multiple spaces?

Thanks
Craig.



Craig Churchill
Collection Systems Specialist
Museum Victoria
GPO Box 666
Melbourne VIC 3001
Australia
Telephone   +61 3 8341 7743
Email [EMAIL PROTECTED]
 

museumvictoria.com.au
This e-mail is solely for the named addressee and may be confidential.You 
should only read, disclose, transmit, copy, distribute, act in relianceon or 
commercialise the contents if you are authorised to do so. If you are not the 
intended recipient of this e-mail, please notify [EMAIL PROTECTED] by e-mail 
immediately, or notify the sender and then destroy any copy of this message. 
Views expressed in this e-mailare those of the individual sender, except where 
specifically stated to be those of an officer of Museum Victoria. Museum 
Victoria does not represent,warrant or guarantee that the integrity of this 
communication has been maintained nor that it is free from errors, virus or 
interference.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A good book for a perspective programer.

2008-01-13 Thread Sean-Michael
Very nice link kingzones, I did not come across this one yet!

As I mentioned I was looking for some text books that I could keep on
hand... I can print some from the link you provided.  I was looking for a
bit more feed back :( maybe this is all I need :)  I do have the chm manual,
I use it a lot!

Thanks again!
Sean-Michael.

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I have learned PHP using PHP manual available at the www.php.net in chm
> format...
> You can also try.. my php free books collection here
> http://www.kingzones.org/bookszone/php.php
>
> But still I go with PHP manual...
>
>
> On Jan 11, 2008 11:42 PM, Sean-Michael <[EMAIL PROTECTED]> wrote:
>
>> I've been searching the web for all the tutorials I can on the subject of
>> php programming, I don't think there is a limit on what is really
>> available
>> to learn.
>>
>> What I want to ask is if anyone can recommend a good/best text book to
>> learn
>> from, I like to have a good book on hand!  I was going to purchase the 
>> Zen
>> Study Guide but after some research I cam to the conclusion that this is
>> not
>> a good book to buy, or perhaps it is a good companion to my online
>> studies?
>>
>> It's my understanding that this book would be best for me?
>>
>> PHP Objects, Patterns, and Practice, Second Edition
>>
>> http://www.amazon.com/PHP-Objects-Patterns-Practice-Second/dp/1590599098/ref=sr_1_2?ie=UTF8&s=books&qid=1200074884&sr=1-2
>>
>> Thanks in advance for advice with this!
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> -- 
> Visit: http://www.kingzones.org/
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: A good book for a perspective programer.

2008-01-13 Thread David Powers

Sean-Michael wrote:
What I want to ask is if anyone can recommend a good/best text book to learn 
from, I like to have a good book on hand!


It's very difficult to recommend "the best" book to learn from (although 
I'm tempted to suggest my own). Different people learn in different 
ways. Also, people want to use PHP in different ways, not to mention the 
fact that you don't say what your current skill level is.


My advice would be to go to Amazon, and browse the books on PHP. Read 
the reviews. See which are the best sellers.


I have a lot of PHP books on my shelf. The two that are the most 
well-thumbed as "PHP Programming" by Rasmus Lerdorf and Kevin Tatroe, 
and "Upgrading to PHP 5" by Adam Trachtenberg.


The book by Matt Zandstra that you mention is very good, but it's very 
specialized. If you're already at an intermediate-advanced level, and 
want to learn about design patterns with PHP, it might be a good choice. 
If you're at a less advanced level, maybe not.


--
David Powers

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: $_GET and multiple spaces.

2008-01-13 Thread Al

Try "%20" for each space. Better yet, use underscores "_"

Churchill, Craig wrote:

Hello,

One of the values I'm passing in a URL string contains multiple spaces.

...
(The multiple spaces are between Argononemertes and australiensis)

However when I retrieve the value using $_GET[DarScientificName]
there is only a single space between the two names which I understand is the 
intended behaviour?

Is there a way to preserve the multiple spaces?

Thanks
Craig.



Craig Churchill
Collection Systems Specialist
Museum Victoria
GPO Box 666
Melbourne VIC 3001
Australia
Telephone   +61 3 8341 7743
Email [EMAIL PROTECTED]
 


museumvictoria.com.au
This e-mail is solely for the named addressee and may be confidential.You 
should only read, disclose, transmit, copy, distribute, act in relianceon or 
commercialise the contents if you are authorised to do so. If you are not the 
intended recipient of this e-mail, please notify [EMAIL PROTECTED] by e-mail 
immediately, or notify the sender and then destroy any copy of this message. 
Views expressed in this e-mailare those of the individual sender, except where 
specifically stated to be those of an officer of Museum Victoria. Museum 
Victoria does not represent,warrant or guarantee that the integrity of this 
communication has been maintained nor that it is free from errors, virus or 
interference.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] uh oh, I defined a resoruce

2008-01-13 Thread Sancar Saran
On Sunday 13 January 2008 21:42:28 Jochem Maas wrote:
>
> no race conditions occur in code written in php? true that there is
> no direct race conditions that can occur as a direct result of running code
> but obviously you've never dealt with multi-user systems using a databse
> backend, or file-writing based tools used in a web-environment (e.g.
> template output caching) or anything that uses shared memory or trying to
> guanrantee that a command-line script runs as a singleton. to name but a
> few examples that can most definitely be prone to race-conditions.
>

Hmmm interesting so you mean 

$GLOBALS['language'] = memcached->get('language');

race condition prone  than

function hede() {
global $language

$language = memcached->get('language');

}

Regards

Sancar

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Chris





or you could do

$result = mysql_query($sql);
$count = mysql_num_rows($result);
for ($i=0; $i<$count; $i++) {
var_dump($row);
...
}


Not unless you have a

$row = mysql_fetch_assoc($result);

before doing the var_dump of $row because $row isn't being set :)



--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var_dump() results

2008-01-13 Thread Jim Lucas

Europus wrote:

Jochem Maas wrote:


side note: where does $table come from?


I didn't want to reveal the real names of my server/host, table,
login or password to the list, so I tried setting $host, $login,
$passwd, and $table variables at the top of the script. That way
it's 4 lines to omit when posting code, instead of parsing through
to edit each instance. That didn't work so I've since restored the
initial values, probably I stepped on a reserved word. I'll check
on that, I like the idea of setting those to variables elsewhere.


The reason your variables didn't work was that you had them enclosed in 
single quotes.  Within single quotes, no variables are parsed.  Two 
options to fix this.  Use double quotes, or get rid of the quotes 
completely since you are using variables.  The latter suggestion is 
probably the most preferred way of working with variables.


here is the code from your original email.  I have modified it to work 
like one would expect it too.


'.print_r($row, 1);
}

?>

Give this a try and see what happens.  Should do everything you want it 
to do and maybe more.


Jim




//get column data
$sql= "SELECT column2, column3 FROM $table";
$result = mysql_query($sql);


if (!$result) {
echo "query failed.\n";
} else {
while ($row = mysql_fetch_array($result))
var_dump($row);
}  


$row = mysql_fetch_row($result);


Now that, that change makes what looks to be 2100 rows of data flood
the screen, thank you. Now I can move on to processing that data
in the next step of my script.

It looks like, my take-away lesson is that I was invoking var_dump()
too late, I should have been performing that check right after running
mysql_fetch_array(), because later operations step on the data and
that's why I was getting unexpected returns.

Ulex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php