Re: [PHP] What's wrong the __autoload()?

2008-03-14 Thread Aschwin Wesselius

Robert Cummings wrote:

It works like follows...

- $z asserts $a or claims $b
- $y disagrees with $a or $b or both and responds with rebuttal $h
  and makes claims $c, $d, sometimes $e
- $z responds with rebuttal $i and often asserts a few other things
  that well call $f, $g
- $x throws in $Q
- $w throws in $wtf
- $foo, $fee, and $fii join in
- $someone mentions $TLC
- $o calls us all immature
- $SJHSKJ mentions Nazis
- $x invokes Godwin's Law
- $y asserts Quirk's Exception
- $G_Zus resurrects point $d
- $nobody wins
- $r, $u, $stillWithMe
  


Aaah. so we're just six points before the end of this thread? ;-)
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] Last Friday of every month

2008-03-14 Thread Aschwin Wesselius

VamVan wrote:

Can you tell me how to do this ?

suppose I have a date variable = '02/23/2008'

i need to know if this is the last friday of february

let me know.


   $month = 3;
   $year = 2008;

   for ($day = 31; $day >= 21; $day--) { // maximum of 7 days, but 
february starts at 28
  
   $tmp_time = mktime(0, 0, 0, $month, $day, $year);


   if (date('w', $tmp_time) === '5') { // 5 = friday
  
   return date('d-m-Y', $tmp_time);
   // return $day.'-'.$month.'-'.$year; // without the function 
it is faster off course

   // echo 'Yeah, friday!';
   }
   }

Something similar worked for me to find out when daylight saving time is.
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


[PHP] Sending multiple values from a form having same field names.

2008-03-14 Thread Suamya Srivastava

Hi,

How can I send multiple values from a form to be stored in a database, as
name of the fields is the same?

For example:





";
 }
 elseif ($datatype=="textarea") {
  echo "";
  }
  echo "";
}
?>

This creates a form with field names and text box or textarea box next to
each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value entered
in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a solution for
this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.



 
-
DISCLAIMER:- 
  "The information in this e-mail is confidential, and is intended 
solely for the addressee or addressees. If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. Any 
unauthorised use or disclosure of the contents of the mail is not permitted 
and may be unlawful."
-

 "Scanned By MailScanner"


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



Re: [PHP] Last Friday of every month

2008-03-14 Thread Richard Heyes

VamVan wrote:

Can you tell me how to do this ?

suppose I have a date variable = '02/23/2008'

i need to know if this is the last friday of february


Work backwards from the 28th subtracting 86400 from your Unix timestamp 
until you get to a Friday. Compare this with your variable.


--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

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



Re: [PHP] What's wrong the __autoload()?

2008-03-14 Thread Zoltán Németh
2008. 03. 14, péntek keltezéssel 08.52-kor Aschwin Wesselius ezt írta:
> Robert Cummings wrote:
> > It works like follows...
> >
> > - $z asserts $a or claims $b
> > - $y disagrees with $a or $b or both and responds with rebuttal $h
> >   and makes claims $c, $d, sometimes $e
> > - $z responds with rebuttal $i and often asserts a few other things
> >   that well call $f, $g
> > - $x throws in $Q
> > - $w throws in $wtf
> > - $foo, $fee, and $fii join in
> > - $someone mentions $TLC
> > - $o calls us all immature
> > - $SJHSKJ mentions Nazis
> > - $x invokes Godwin's Law
> > - $y asserts Quirk's Exception
> > - $G_Zus resurrects point $d
> > - $nobody wins
> > - $r, $u, $stillWithMe
> >   
> 
> Aaah. so we're just six points before the end of this thread? ;-)

threads like this live forever. after we all finish with it, sooner or
later someone will say something which will trigger its resurrection

greets,
Zoltán Németh


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



Re: [PHP] Sending multiple values from a form having same field names.

2008-03-14 Thread Zoltán Németh
2008. 03. 14, péntek keltezéssel 14.08-kor Suamya Srivastava ezt írta:
> Hi,
> 
> How can I send multiple values from a form to be stored in a database, as
> name of the fields is the same?
> 
> For example:
> 
>  foreach ($field_data as $field) {
> 
>  $field_name=$field["field_name"];
>  $field_id=$field["field_id"];
>  $datatype=$field["datatype_name"];
> 
> ?>
> 
> 
> 
>   if ($datatype=="text" || $datatype=="integer") {
> echo "";

make field_data an array indexed by field_id

  }
>  elseif ($datatype=="textarea") {
>   echo " name=\"field_data\">";
>   }
>   echo "";
> }
> ?>
> 
> This creates a form with field names and text box or textarea box next to
> each field name depending on the datatype. After the user enters the
> values in the text or textarea and clicks submit, the values should get
> stored in a database. But what is happening is that only the value entered
> in the last field of the form is getting entered into the database.
> This code is embedded in an application which is having an inbuilt
> structure of taking the values from a form in a hash. Since key is the
> same (i.e. field_id) everytime, the value gets overwritten and only the
> last value gets stored in db. But I am not able to work out a solution for
> this.
> I hope I am able to make my problem clear enough.
> 
> Thanks,
> Suamya.
> 
> 
> 
>  
> -
> DISCLAIMER:- 
>   "The information in this e-mail is confidential, and is intended 
> solely for the addressee or addressees. If you are not the intended recipient,
>  please delete the mail and kindly notify the sender of misdelivery. Any 
> unauthorised use or disclosure of the contents of the mail is not permitted 
> and may be unlawful."
> -
> 
>  "Scanned By MailScanner"
> 
> 


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



Re: [PHP] Last Friday of every month

2008-03-14 Thread Eric Butera
On Thu, Mar 13, 2008 at 9:39 PM, Andrés Robinet <[EMAIL PROTECTED]> wrote:
> > -Original Message-
>  > From: VamVan [mailto:[EMAIL PROTECTED]
>  > Sent: Thursday, March 13, 2008 9:13 PM
>  > To: php-general@lists.php.net
>  > Subject: [PHP] Last Friday of every month
>  >
>  > Can you tell me how to do this ?
>  >
>  > suppose I have a date variable = '02/23/2008'
>  >
>  > i need to know if this is the last friday of february
>  >
>  > let me know.
>
>  My view...
>
>  $strDate = '02/23/2008';
>  //
>  $intDate = strtotime($strDate);
>  $numDaysInMonth = date('t', $intDate);
>  $dayOfWeek = date('w', $intDate);
>  $dayOfMonth = date('j', $intDate);
>  If ($dayOfWeek == 5 && $numDaysInMonth - $dayOfMonth < 7) {
> echo "Friday Party!";
>  } else {
> echo "Sorry dude, you missed it";
>  }
>
>  Btw, read the manual (and don't think to be so lucky to not found any bugs 
> in my
>  code).
>
>  Regards,
>
>  Rob(inet)
>
>
>  Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
>  5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 
> |
>  TEL 954-607-4296 | FAX 954-337-2695 |
>  Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace 
> |
>   Web: bestplace.biz  | Web: seo-diy.com
>
>
>
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just FYI you can use the word "last friday" in strtotime.  So really
you could check and see if the max day in a month is a friday and if
not fall back on last friday.  I didn't test it but I just thought I'd
throw that out there.

erics:~ eric$ php -r "echo date('n/j/Y', strtotime('last friday'));"
3/7/2008


Re: [PHP] Sending multiple values from a form having same field names.

2008-03-14 Thread Eric Butera
On Fri, Mar 14, 2008 at 6:02 AM, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> 2008. 03. 14, péntek keltezéssel 14.08-kor Suamya Srivastava ezt írta:
>
> > Hi,
>  >
>  > How can I send multiple values from a form to be stored in a database, as
>  > name of the fields is the same?
>  >
>  > For example:
>  >
>  >   > foreach ($field_data as $field) {
>  >
>  >  $field_name=$field["field_name"];
>  >  $field_id=$field["field_id"];
>  >  $datatype=$field["datatype_name"];
>  >
>  > ?>
>  > 
>  > 
>  > 
>  >   >  if ($datatype=="text" || $datatype=="integer") {
>  > echo "";
>
>  make field_data an array indexed by field_id
>
>  
>  greets,
>  Zoltán Németh
>
>
>
>  >  }
>  >  elseif ($datatype=="textarea") {
>  >   echo "  > name=\"field_data\">";
>  >   }
>  >   echo "";
>  > }
>  > ?>
>  >
>  > This creates a form with field names and text box or textarea box next to
>  > each field name depending on the datatype. After the user enters the
>  > values in the text or textarea and clicks submit, the values should get
>  > stored in a database. But what is happening is that only the value entered
>  > in the last field of the form is getting entered into the database.
>  > This code is embedded in an application which is having an inbuilt
>  > structure of taking the values from a form in a hash. Since key is the
>  > same (i.e. field_id) everytime, the value gets overwritten and only the
>  > last value gets stored in db. But I am not able to work out a solution for
>  > this.
>  > I hope I am able to make my problem clear enough.
>  >
>  > Thanks,
>  > Suamya.
>  >
>  >
>  >
>  >
>  > 
> -
>  > DISCLAIMER:-
>  >   "The information in this e-mail is confidential, and is intended
>  > solely for the addressee or addressees. If you are not the intended 
> recipient,
>  >  please delete the mail and kindly notify the sender of misdelivery. Any
>  > unauthorised use or disclosure of the contents of the mail is not permitted
>  > and may be unlawful."
>  > 
> -
>  >
>  >  "Scanned By MailScanner"
>  >
>  >
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Since Zoltán give you the answer I might give you another fish.  Which
one is more readable:




";
}
elseif ($datatype=="textarea") {
 echo "";
 }
 echo "";
}
?>













 




Re: [PHP] Web host with SOAP

2008-03-14 Thread Daniel Brown
On Thu, Mar 13, 2008 at 10:53 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote:
>  >>
>  > Ooo...  I want SUDO!
>
>  ALL = NOPASSWD: ALL
>
>  please!

Which is exactly why you get the following FANTASTIC package!

* No shell access
* No databases
* No scripting support
* No FTP access
* 500K shared web space (additional 500K blocks are just $7.99)
* A free @gmail.com address
* No tech support
* No crons
* No SSI
* No SSL
* 5MB transfer per month (additional 1MB blocks are only $4.99)

All for the exclusive Internet price created just for you: $99.99
per month with a $99 one-time setup fee and $7/mo. account maintenance
fee. ;-P

All kidding aside, it's rather reminiscent of the pioneering days
of the web hosting industry.  Check it out on the Internet Archive.

-- 

Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
Hi,

I maid the modifications you suggested. For the error
context when i display it, it gives a lot of
information, but not easy to understand how the array
is structured. If somebody knows about a site
explaining how to access the context it would be
great.
I also modified the error reporting to E_ALL as you
suggested. Now an other question arise: For the
connection to the database if i put a wrong username
or password the error is reported automatically to the
function that i defined as the error handling
function, but for the next statement (see code below)
if i put a wrong database name the error is not
reported automatically, i have to trigger it using
triger_error. So i'm wondering if there are some rules
that can help me know if an error will be reported
automatically or not. here is my code after
modification:

";

switch($errno) {
case E_USER_ERROR: $type = 
"E_USER_ERROR";break;
case E_USER_WARNING: $type =
"E_USER_WARNING";break; 
case E_USER_NOTICE: $type = 
"E_USER_NOTICE";break;
case E_ERROR: $type = "E_ERROR";break;
case E_WARNING: $type = "E_WARNING";break;
case E_PARSE: $type = "E_PARSE";break;
case E_NOTICE: $type = "E_NOTICE";break;
case E_CORE_ERROR: $type = "E_CORE_ERROR";break;
case E_CORE_WARNING: $type =
"E_CORE_WARNING";break; 
case E_COMPILE_ERROR: $type =
"E_COMPILE_ERROR";break;
case E_STRICT: $type = "E_STRICT";break;
case E_COMPILE_WARNING: $type =
"E_COMPILE_WARNING";break;  
case E_RECOVERABLE_ERROR: $type =
"E_RECOVERABLE_ERROR";break;
default: echo "This is an error not listed";

}
$str = "";
$str .= "ERROR TYPE: ". $type;
$str .= "ERROR Number: ". $errno;
$str .= "ERROR MESSAGE: ". $errstr;
$str.= "File: ". $filename;
$str.= "Line number: ". $lineno;
echo $str;
echo "Context: ";
print_r($errcontext);
}





echo "Testing set_error_handler";

error_reporting(E_ALL);  
set_error_handler('error_handler'); 
mysql_connect("localhost", "admin", "admin"); 
mysql_select_db("wrongdb") or trigger_error("wrong
database");

?>
--- Jim Lucas <[EMAIL PROTECTED]> wrote:

> It Maq wrote:
> > Hi,
> > 
> > i need help because I'm unable to retrieve error's
> context. Below is the code that is working perfectly
> except the context that is not displayed:
> > 
> >  > function error_handler($errno, $errstr,
> $filename, $lineno, $errcontext)
> > {
> > 
> 
> try doing a print_r($errcontext) here and see what
> you get?
> 
> maybe the zero index does not exist.
> 
> >   
> > $str = "";
> > $str .= "ERROR Number: ". $errno;
> > $str .= "ERROR MESSAGE: ". $errstr;
> > $str.= "File: ". $filename;
> > $str.= "Line number: ". $lineno;
> > $str.= "Context: ". $errcontext[0];
> > echo $str;
> > 
> > 
> > }
> > 
> > echo "Testing set_error_handler";
> > 
> 
> I have always used
> error_reporting(E_ALL);
> instead of this.
> > error_reporting(0);  
> > set_error_handler('error_handler'); 
> > ini_set('error_reporting', 0);
> 
> I have never seen the above line before.  This and
> the error_reporting(0) would 
> probably suppress all error messages generated by
> PHP.  Double check these 
> settings and make sure the you can still trigger an
> error with trigger_error() 
> if you have error_reporting() turned off.
> 
> > 
> > //trigger_error("The string for testing the
> error", E_USER_WARNING);
> > $ourFileName = "testFile.txt";
> > $fh = fopen($ourFileName, 'X');// or die("Can't
> open file");
> > fclose($fh);
> > 
> > 
> > ?>



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



Re: [PHP] How to get error context

2008-03-14 Thread Zoltán Németh
2008. 03. 14, péntek keltezéssel 07.20-kor It Maq ezt írta:
> So i'm wondering if there are some rules
> that can help me know if an error will be reported
> automatically or not. 

there is no general rule for that. you have to check the manual for each
function, some of them just returns false on error, others throw
warnings/notices/errors...

greets,
Zoltán Németh


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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
For example "mysql_connect" reprted automatically the
error but in the manual
http://us3.php.net/manual/en/function.mysql-connect.php
 all they give as information is the return: "Returns
a MySQL link identifier on success, or FALSE on
failure.", where can i see if it throws an error, and
when you say throwing do you mean that i can catch the
error without throwing it myself?
 
--- Zoltán Németh <[EMAIL PROTECTED]> wrote:

> 2008. 03. 14, péntek keltezéssel 07.20-kor It Maq
> ezt írta:
> > So i'm wondering if there are some rules
> > that can help me know if an error will be reported
> > automatically or not. 
> 
> there is no general rule for that. you have to check
> the manual for each
> function, some of them just returns false on error,
> others throw
> warnings/notices/errors...
> 
> greets,
> Zoltán Németh
> 
> 



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



[PHP] storing / processing login info (newbie stuff not in tutorials)

2008-03-14 Thread good_times

1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
can i save this info in a file and have my php script either include or call
it when it needs to make a db connection? what would that look like? i may
want to point my app to a test db at some point & it would be nice to only
change it in one place.

2. i see an example where a form in a login.html submits to "authcheck.php"
but authcheck.php just prints ('User not found in LDAP' or 'error occured'
or 'success'). how can authcheck.php redirect the user to... say.. BACK to
the login.html and tell it "yes or no" and then have login.html either
direct the user to a different data entry page (if the login was good), or
display "sorry, try again" - all from the 1 form's "submit"

thanx in advance, 
mike.
-- 
View this message in context: 
http://www.nabble.com/storing---processing-login-info-%28newbie-stuff-not-in-tutorials%29-tp16048165p16048165.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] storing / processing login info (newbie stuff not in tutorials)

2008-03-14 Thread tedd

At 8:01 AM -0700 3/14/08, good_times wrote:

1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
can i save this info in a file and have my php script either include or call
it when it needs to make a db connection? what would that look like? i may
want to point my app to a test db at some point & it would be nice to only
change it in one place.


Use:

include('config.php');

Where:

$usrname = 'username';
$passwrd = 'password';
$db = 'mydB';

In your script

include('config.php');
$conn=ocilogon($usrname,$passwrd,$db);




2. i see an example where a form in a login.html submits to "authcheck.php"
but authcheck.php just prints ('User not found in LDAP' or 'error occured'
or 'success'). how can authcheck.php redirect the user to... say.. BACK to
the login.html and tell it "yes or no" and then have login.html either
direct the user to a different data entry page (if the login was good), or
display "sorry, try again" - all from the 1 form's "submit"


If ($auth != true)
  {
  header('Location: http://www.example.com/login.html');
  }

It's all in the manuals.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] storing / processing login info (newbie stuff not intutorials)

2008-03-14 Thread Shawn McKenzie
good_times wrote:
> 1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
> can i save this info in a file and have my php script either include or call
> it when it needs to make a db connection? what would that look like? i may
> want to point my app to a test db at some point & it would be nice to only
> change it in one place.
> 
> 2. i see an example where a form in a login.html submits to "authcheck.php"
> but authcheck.php just prints ('User not found in LDAP' or 'error occured'
> or 'success'). how can authcheck.php redirect the user to... say.. BACK to
> the login.html and tell it "yes or no" and then have login.html either
> direct the user to a different data entry page (if the login was good), or
> display "sorry, try again" - all from the 1 form's "submit"
> 
> thanx in advance, 
> mike.

1. Normally you would have a file that is included in every file or most
files that does certain things like setup the db connection, etc...
This file can also include other files based upon some other logic that
you define, but a simple example would be to include('db_config.php');
in your pages:

db_config.php

$db_username = 'myusername';
$db_password = 'somepassword';
$db_name = 'mydb';

Then you can use those vars in your code.

2. Just have the login.html form submit to itself.  At the top of the
file check to see if it is a POST request and if so check the user
credentials, set a session var that shows that they are loggedin and use
header() to redirect to the correct page.

-Shawn

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



Re: [PHP] What's wrong the __autoload()?

2008-03-14 Thread Aschwin Wesselius

tedd wrote:

At 9:19 PM -0400 3/13/08, Robert Cummings wrote:

- $z asserts $a or claims $b
- $y disagrees with $a or $b or both and responds with rebuttal $h
  and makes claims $c, $d, sometimes $e
- $z responds with rebuttal $i and often asserts a few other things
  that well call $f, $g
- $x throws in $Q
- $w throws in $wtf
- $foo, $fee, and $fii join in
- $someone mentions $TLC
- $o calls us all immature
- $SJHSKJ mentions Nazis
- $x invokes Godwin's Law
- $y asserts Quirk's Exception
- $G_Zus resurrects point $d
- $nobody wins
- $r, $u, $stillWithMe

Cheers,
Rob.


Aha, you lose. You were the first to mention Nazis.  :-)


Hey, at least I've learned something today. I thought he was joking 
about Godwin's Law and whatever. But it really exists! Nice to know.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] What's wrong the __autoload()?

2008-03-14 Thread tedd

At 9:19 PM -0400 3/13/08, Robert Cummings wrote:

- $z asserts $a or claims $b
- $y disagrees with $a or $b or both and responds with rebuttal $h
  and makes claims $c, $d, sometimes $e
- $z responds with rebuttal $i and often asserts a few other things
  that well call $f, $g
- $x throws in $Q
- $w throws in $wtf
- $foo, $fee, and $fii join in
- $someone mentions $TLC
- $o calls us all immature
- $SJHSKJ mentions Nazis
- $x invokes Godwin's Law
- $y asserts Quirk's Exception
- $G_Zus resurrects point $d
- $nobody wins
- $r, $u, $stillWithMe

Cheers,
Rob.


Aha, you lose. You were the first to mention Nazis.  :-)

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] How to get error context

2008-03-14 Thread Zoltán Németh
2008. 03. 14, péntek keltezéssel 07.40-kor It Maq ezt írta:
> For example "mysql_connect" reprted automatically the
> error but in the manual
> http://us3.php.net/manual/en/function.mysql-connect.php
>  all they give as information is the return: "Returns
> a MySQL link identifier on success, or FALSE on
> failure.", where can i see if it throws an error, and
> when you say throwing do you mean that i can catch the
> error without throwing it myself?

hmm actually what error did mysql_connect throw?
because if it just fails connecting, it returns false. on the other
hand, if you provide it wrong arguments (e.g. less arguments, or wrong
data type, or whatever) that raises a php error and the function does
not even run.
this is true for most functions which return false on error. the
returning false means there was some error with the action itself, while
php errors are raised when the action can not be executed because of
some error in the code itself.

greets,
Zoltán Németh

>  
> --- Zoltán Németh <[EMAIL PROTECTED]> wrote:
> 
> > 2008. 03. 14, péntek keltezéssel 07.20-kor It Maq
> > ezt írta:
> > > So i'm wondering if there are some rules
> > > that can help me know if an error will be reported
> > > automatically or not. 
> > 
> > there is no general rule for that. you have to check
> > the manual for each
> > function, some of them just returns false on error,
> > others throw
> > warnings/notices/errors...
> > 
> > greets,
> > Zoltán Németh
> > 
> > 
> 
> 
> 
>   
> 
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 
> 


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



Re: [PHP] Last Friday of every month

2008-03-14 Thread tedd

At 8:17 AM -0400 3/14/08, Eric Butera wrote:


Just FYI you can use the word "last friday" in strtotime.  So really
you could check and see if the max day in a month is a friday and if
not fall back on last friday.  I didn't test it but I just thought I'd
throw that out there.

erics:~ eric$ php -r "echo date('n/j/Y', strtotime('last friday'));"
3/7/2008


Eric:

When I read that, I went "Na, that can't be right" -- so I checked it.

You were right -- here it is:

http://webbytedd.com/b1/last-friday/

Thanks for the suggestion.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Sendmail question

2008-03-14 Thread nihilism machine
I have a link that i want to use as the  body of an html email. here  
is the code i use:


// Notify about comments
public function emailComment($Link, $ID) {
$mail = new SendMail();
$mail->SetCharSet("ISO-8859-1");
$mail->from("someone", "[EMAIL PROTECTED]");
$mail->to("[EMAIL PROTECTED]");
$mail->subject("New Comment!");
	$str = 'http://www.mysite.com/permalink.php?ID='. 
$Link.'">Comment ID #'.$ID.'';

$mail->text($str);
//$mail->attachment($fileName);
$mail->send();

Where link = a number.

the email that i get is:

So the email should be a link to: http://www.mysite.com/permalink.php?ID=120
but instead links to: http://www.mysite.com/permalink.php?ID%120

Here is the php sendmail library =

textboundary = uniqid(time());
$this->emailboundary = uniqid(time());
$this->charset = "ISO-8859-1";
}

public function SetCharSet($char) {
$this->charset = $char;
}

public function Validate_Email($emailAddress) {
	if(!preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a- 
z-]*[0-9a-z]\.)+([a-z]{2,4})/i", $emailAddress)) {

die('Invalid Email Address: '.$emailAddress);
}
return $emailAddress;
}

public function from($name, $email) {
$this->emailheader .= 'From: '.$name.'<'.$email.'>'."\r\n";
}

public function to($to) {
$this->empfaenger = $this->Validate_Email($to);
}

public function cc($cc) {
$this->cc[] = $cc;
}

public function bcc($cc) {
$this->bcc[] = $cc;
}

public function makeMimeMail() {
if(count($this->cc) > 0) {
$this->emailheader .= 'Cc: ';
for($i=0; $icc); $i++) {
if($i > 0) $this->emailheader .= ',';
$this->emailheader .= 
$this->Validate_Email($this->cc[$i]);
}
$this->emailheader .= "\r\n";
}
if(count($this->bcc) > 0) {
$this->emailheader .= 'Bcc: ';
for($j=0;$jbcc);$j++) {
if($j > 0) $this->emailheader .= ',';
$this->emailheader .= 
$this->Validate_Email($this->bcc[$j]);
}
$this->emailheader .= "\r\n";
}
$this->emailheader .= 'MIME-Version: 1.0'."\r\n";
}

public function subject($subject) {
$this->subject = $subject;
}

public function text($text) {
	$this->textheader .= 'Content-Type: multipart/alternative;  
boundary="'.$this->textboundary.'"'."\r\n\r\n";

$this->textheader .= '--'.$this->textboundary."\r\n";
	$this->textheader .= 'Content-Type: text/plain; charset="'.$this- 
>charset.'"'."\r\n";
	$this->textheader .= 'Content-Transfer-Encoding: quoted- 
printable'."\r\n\r\n";

$this->textheader .= strip_tags($text)."\r\n\r\n";
$this->textheader .= '--'.$this->textboundary."\r\n";
	$this->textheader .= 'Content-Type: text/html; charset="'.$this- 
>charset.'"'."\r\n";
	$this->textheader .= 'Content-Transfer-Encoding: quoted- 
printable'."\r\n\r\n";
	$this->textheader .= ''.$text.''."\r\n 
\r\n";

$this->textheader .= '--'.$this->textboundary.'--'."\r\n\r\n";
}

public function attachment($fileName) {
if(is_file($fileName)) {
$attachment_header = '--'.$this->emailboundary."\r\n" ;
			$attachment_header .= 'Content-Type: application/octet-stream;  
name="'.basename($fileName).'"'."\r\n";

$attachment_header .= 'Content-Transfer-Encoding: 
base64'."\r\n";
			$attachment_header .= 'Content-Disposition: attachment;  
filename="'.basename($fileName).'"'."\r\n\r\n";

$file['inhalt'] = 
fread(fopen($fileName,"rb"),filesize($fileName));
$file['inhalt'] = base64_encode($file['inhalt']);
$file['inhalt'] = chunk_split($file['inhalt'],72);
$this->attachment[] = 
$attachment_header.$file['inhalt']."\r\n";
} else {
die('ERROR - Invalid Filename: "' . $fileName . "\r\n");
}
}

public function send() {
$this->makeMimeMail();
$header = $this->emailheader;

if(count($this->attachment)>0) {
			$header .= 'Content-Type: multipart/mixed; boundary="'.$this- 
>emailboundary.'"'."\r\n\r\n";

$header .= '--'.$this->emailboundary."\r\n";
$header .= $this->textheader;
			if(count($this->attachment) > 0) $header .= implode("",$this- 
>attachment);

$header .= '--'.$this->emailboundary.'--';
} else {
$header .= $this->textheader;
}
mail("$this->

Re: [PHP] What's wrong the __autoload()?

2008-03-14 Thread tedd

At 4:24 PM +0100 3/14/08, Aschwin Wesselius wrote:

tedd wrote:
At 9:19 PM -0400 3/13/08, Robert Cummings wrote:


- $SJHSKJ mentions Nazis

Aha, you lose. You were the first to mention Nazis.  :-)

Hey, at least I've learned something today. I thought he was joking 
about Godwin's Law and whatever. But it really exists! Nice to know.


Once you lose a valid argument, because you happen to use Hitler as a 
bad example, you learn to never use it again. It's a stupid "Law", 
but too many use it.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Is this the best way?

2008-03-14 Thread Jason Pruim

Hi everyone,

I am attempting to add a little error checking for a very simple login  
system. The info is stored in a MySQL database, and I am using mysqli  
to connect to it. I have it working with the solution provided below,  
but I am wondering if this is the right way to do it or if there is a  
better way?


My thinking with this is if more then 1 record is returned from the  
database, then there is a issue... If only  is returned then the  
username/password matched and I can safely show them the info...


$rowcnt = mysqli_num_rows($loginResult);
if($rowcnt !="1"){
echo "Auth failed";
die("Auth failed... Sorry");



}else{
while($row1 = mysqli_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";
$table = $row1['tableName'];
$adminLevel = $row1['adminLevel'];
$authenticated = "TRUE";
echo "authentication complete";
}
return Array($table, $authenticated, $adminLevel);


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





Re: [PHP] storing / processing login info (newbie stuff not in tutorials)

2008-03-14 Thread Philip Thompson

On Mar 14, 2008, at 10:15 AM, tedd wrote:


At 8:01 AM -0700 3/14/08, good_times wrote:

1. instead of typing: $conn=ocilogon("usrname","passwrd","db");
can i save this info in a file and have my php script either  
include or call
it when it needs to make a db connection? what would that look  
like? i may
want to point my app to a test db at some point & it would be nice  
to only

change it in one place.


Use:

include('config.php');

Where:

$usrname = 'username';
$passwrd = 'password';
$db = 'mydB';

In your script

include('config.php');
$conn=ocilogon($usrname,$passwrd,$db);



2. i see an example where a form in a login.html submits to  
"authcheck.php"
but authcheck.php just prints ('User not found in LDAP' or 'error  
occured'
or 'success'). how can authcheck.php redirect the user to... say..  
BACK to
the login.html and tell it "yes or no" and then have login.html  
either
direct the user to a different data entry page (if the login was  
good), or

display "sorry, try again" - all from the 1 form's "submit"


If ($auth != true)
 {
 header('Location: http://www.example.com/login.html');


exit;

This will potentially save you some headaches Read more at:

http://php.net/header



 }

It's all in the manuals.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com



HTH,
~Philip

"Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me..." ~S. Johnson


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



Re: [PHP] Last Friday of every month

2008-03-14 Thread Philip Thompson

On Mar 13, 2008, at 8:12 PM, VamVan wrote:


Can you tell me how to do this ?

suppose I have a date variable = '02/23/2008'

i need to know if this is the last friday of february

let me know.


There are plenty of ways. Here's a couple:

OS X:
1. Finder > Applications > iCal (or Command-space for Spotlight, and  
then type 'ical')

2. Click on Month (if not already selected)
3. Scroll to February
4. Look

Windows:
1. Double-click the clock in the task bar
2. Scroll to February
3. Look

HTH,
~Philip

PS... For a programmatic way, consult the PHP date functions...

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



Re: [PHP] Is this the best way?

2008-03-14 Thread Dan Joseph
>
> I am attempting to add a little error checking for a very simple login
> system. The info is stored in a MySQL database, and I am using mysqli
> to connect to it. I have it working with the solution provided below,
> but I am wondering if this is the right way to do it or if there is a
> better way?
>
>
>
I don't see anything wrong with that method.  One thing I would suggest is
that you make username unique in your database if you want to avoid
duplicate results.  But your way of checking is just fine as it is.

-- 
-Dan Joseph

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] Last Friday of every month

2008-03-14 Thread Philip Thompson

On Mar 14, 2008, at 11:44 AM, Philip Thompson wrote:


On Mar 13, 2008, at 8:12 PM, VamVan wrote:


Can you tell me how to do this ?

suppose I have a date variable = '02/23/2008'

i need to know if this is the last friday of february

let me know.


There are plenty of ways. Here's a couple:

OS X:
1. Finder > Applications > iCal (or Command-space for Spotlight, and  
then type 'ical')

2. Click on Month (if not already selected)
3. Scroll to February
4. Look

Windows:
1. Double-click the clock in the task bar
2. Scroll to February
3. Look


Can't forget *nix:

1. Open a terminal and type the following
%> cal 2 2008



HTH,
~Philip

PS... For a programmatic way, consult the PHP date functions...



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



Re: [PHP] Is this the best way?

2008-03-14 Thread TG

I think the first thing I'd check is why you'd have more than one row being 
returned.   Is this a problem with some other part of the system?  Bad data 
import?   Not checking for unique users when creating them?   Something 
like that.

If you do everything you can to prevent the possibility of multiple users, 
then you can still check for multiple results if you want, maybe send an 
email to yourself, but for the sake of not frustrating your users, just 
take the first result and compare the login to that.   The worst that'll 
happen is they won't match and the user won't get logged in.   Best case is 
they get logged in and you won't get an annoyed user calling you.

-TG

- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: PHP General List 
Date: Fri, 14 Mar 2008 12:12:56 -0400
Subject: [PHP] Is this the best way?

> Hi everyone,
> 
> I am attempting to add a little error checking for a very simple login  
> system. The info is stored in a MySQL database, and I am using mysqli  
> to connect to it. I have it working with the solution provided below,  
> but I am wondering if this is the right way to do it or if there is a  
> better way?
> 
> My thinking with this is if more then 1 record is returned from the  
> database, then there is a issue... If only  is returned then the  
> username/password matched and I can safely show them the info...
> 
> $rowcnt = mysqli_num_rows($loginResult);
> if($rowcnt !="1"){
>   echo "Auth failed";
>   die("Auth failed... Sorry");
>   
>   
>   
>   }else{
>   while($row1 = mysqli_fetch_array($loginResult)) {
>   $_SESSION['user'] = $row1['loginName'];
>   $_SESSION['loggedin'] = "YES";
>   $table = $row1['tableName'];
>   $adminLevel = $row1['adminLevel'];
>   $authenticated = "TRUE";
>   echo "authentication complete";
>   }
>   return Array($table, $authenticated, $adminLevel);


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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 12:45 PM, Dan Joseph wrote:


I am attempting to add a little error checking for a very simple login
system. The info is stored in a MySQL database, and I am using mysqli
to connect to it. I have it working with the solution provided below,
but I am wondering if this is the right way to do it or if there is a
better way?



I don't see anything wrong with that method.  One thing I would  
suggest is that you make username unique in your database if you  
want to avoid duplicate results.  But your way of checking is just  
fine as it is.



Hey Dan,

Thanks for the reply! I couldn't find any reason why it wouldn't work,  
but just wanted someone else to look at it as well... I'm not the best  
programmer yet... Or at all.. But I'm getting there!


Thanks for the tip about the username being unique I'll make that  
change as well...



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 12:51 PM, TG wrote:



I think the first thing I'd check is why you'd have more than one  
row being
returned.   Is this a problem with some other part of the system?   
Bad data
import?   Not checking for unique users when creating them?
Something

like that.


The username's will be unique... Still need to make that change to the  
DB but they will be.


The main reason I'm doing it this way, is if I don't put in some kind  
of a check on the authentication then it pops up a mysql error saying  
that there is a problem with my syntax...  instead of NOT logging them  
in... So I thought if I checked to make sure that the query only  
returned 1 row, it would match up and I could do some error checking  
based on that...








If you do everything you can to prevent the possibility of multiple  
users,
then you can still check for multiple results if you want, maybe  
send an
email to yourself, but for the sake of not frustrating your users,  
just
take the first result and compare the login to that.   The worst  
that'll
happen is they won't match and the user won't get logged in.   Best  
case is

they get logged in and you won't get an annoyed user calling you.






-TG

- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: PHP General List 
Date: Fri, 14 Mar 2008 12:12:56 -0400
Subject: [PHP] Is this the best way?


Hi everyone,

I am attempting to add a little error checking for a very simple  
login

system. The info is stored in a MySQL database, and I am using mysqli
to connect to it. I have it working with the solution provided below,
but I am wondering if this is the right way to do it or if there is a
better way?

My thinking with this is if more then 1 record is returned from the
database, then there is a issue... If only  is returned then the
username/password matched and I can safely show them the info...

$rowcnt = mysqli_num_rows($loginResult);
if($rowcnt !="1"){
echo "Auth failed";
die("Auth failed... Sorry");



}else{
while($row1 = mysqli_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";
$table = $row1['tableName'];
$adminLevel = $row1['adminLevel'];
$authenticated = "TRUE";
echo "authentication complete";
}
return Array($table, $authenticated, $adminLevel);





--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Is this the best way?

2008-03-14 Thread Richard Heyes

$rowcnt = mysqli_num_rows($loginResult);
if($rowcnt !="1"){
echo "Auth failed";
die("Auth failed... Sorry");

   
   
}else{

while($row1 = mysqli_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";


Eww. Use booleans:

$_SESSION['loggedin'] = true;


$table = $row1['tableName'];
$adminLevel = $row1['adminLevel'];
$authenticated = "TRUE";


Like above, I would advise using booleans (true/false) and not strings 
(text):


$authenticated = true; // Note the lack of quote marks

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

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



Re: [PHP] Last Friday of every month

2008-03-14 Thread Eric Butera
On Fri, Mar 14, 2008 at 11:57 AM, tedd <[EMAIL PROTECTED]> wrote:
> At 8:17 AM -0400 3/14/08, Eric Butera wrote:
>  >
>  >Just FYI you can use the word "last friday" in strtotime.  So really
>  >you could check and see if the max day in a month is a friday and if
>  >not fall back on last friday.  I didn't test it but I just thought I'd
>  >throw that out there.
>  >
>  >erics:~ eric$ php -r "echo date('n/j/Y', strtotime('last friday'));"
>  >3/7/2008
>
>  Eric:
>
>  When I read that, I went "Na, that can't be right" -- so I checked it.
>
>  You were right -- here it is:
>
>  http://webbytedd.com/b1/last-friday/
>
>  Thanks for the suggestion.
>
>  Cheers,
>
>  tedd
>  --
>  ---
>  http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hi Tedd,

Thanks for the writeup!  You could streamline that a bit by using
getdate() and using the returned array values.

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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
Here is the error message captured by my error
handling function:

mysql_connect() [function.mysql-connect]: Access
denied for user 'admin'@'localhost' (using password:
YES)

i put a wrong password and username
--- Zoltán Németh <[EMAIL PROTECTED]> wrote:

> 2008. 03. 14, péntek keltezéssel 07.40-kor It Maq
> ezt írta:
> > For example "mysql_connect" reprted automatically
> the
> > error but in the manual
> >
>
http://us3.php.net/manual/en/function.mysql-connect.php
> >  all they give as information is the return:
> "Returns
> > a MySQL link identifier on success, or FALSE on
> > failure.", where can i see if it throws an error,
> and
> > when you say throwing do you mean that i can catch
> the
> > error without throwing it myself?
> 
> hmm actually what error did mysql_connect throw?
> because if it just fails connecting, it returns
> false. on the other
> hand, if you provide it wrong arguments (e.g. less
> arguments, or wrong
> data type, or whatever) that raises a php error and
> the function does
> not even run.
> this is true for most functions which return false
> on error. the
> returning false means there was some error with the
> action itself, while
> php errors are raised when the action can not be
> executed because of
> some error in the code itself.
> 
> greets,
> Zoltán Németh
> 
> >  
> > --- Zoltán Németh <[EMAIL PROTECTED]> wrote:
> > 
> > > 2008. 03. 14, péntek keltezéssel 07.20-kor It
> Maq
> > > ezt írta:
> > > > So i'm wondering if there are some rules
> > > > that can help me know if an error will be
> reported
> > > > automatically or not. 
> > > 
> > > there is no general rule for that. you have to
> check
> > > the manual for each
> > > function, some of them just returns false on
> error,
> > > others throw
> > > warnings/notices/errors...
> > > 
> > > greets,
> > > Zoltán Németh
> > > 
> > > 
> > 
> > 
> > 
> >  
>

> > Never miss a thing.  Make Yahoo your home page. 
> > http://www.yahoo.com/r/hs
> > 
> > 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping


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



Re: [PHP] Is this the best way?

2008-03-14 Thread Eric Butera
On Fri, Mar 14, 2008 at 1:02 PM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> > $rowcnt = mysqli_num_rows($loginResult);
>  > if($rowcnt !="1"){
>  > echo "Auth failed";
>  > die("Auth failed... Sorry");
>  >
>  >
>  >
>  > }else{
>  > while($row1 = mysqli_fetch_array($loginResult)) {
>  > $_SESSION['user'] = $row1['loginName'];
>  > $_SESSION['loggedin'] = "YES";
>
>  Eww. Use booleans:
>
>  $_SESSION['loggedin'] = true;
>
>
>  > $table = $row1['tableName'];
>  > $adminLevel = $row1['adminLevel'];
>  > $authenticated = "TRUE";
>
>  Like above, I would advise using booleans (true/false) and not strings
>  (text):
>
>  $authenticated = true; // Note the lack of quote marks
>
>  --
>  Richard Heyes
>  Employ me:
>  http://www.phpguru.org/cv
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Yes, if it is a lack of being able to see your value using print_r or
echo, then use var_dump().

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



Re: [PHP] Is this the best way?

2008-03-14 Thread Shawn McKenzie
Dan Joseph wrote:
>> I am attempting to add a little error checking for a very simple login
>> system. The info is stored in a MySQL database, and I am using mysqli
>> to connect to it. I have it working with the solution provided below,
>> but I am wondering if this is the right way to do it or if there is a
>> better way?
>>
>>
>>
> I don't see anything wrong with that method.  One thing I would suggest is
> that you make username unique in your database if you want to avoid
> duplicate results.  But your way of checking is just fine as it is.
> 
To go along with this and making sure that usernames are unique, I would
LIMIT 1 on the query.  With no LIMIT, if you have 300,000 users, then
the query will not stop if it matches the first user, it searches all
300,000.  With LIMIT 1 it will stop on the first match.

-Shawn

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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 1:05 PM, Eric Butera wrote:

On Fri, Mar 14, 2008 at 1:02 PM, Richard Heyes  
<[EMAIL PROTECTED]> wrote:






Yes, if it is a lack of being able to see your value using print_r or
echo, then use var_dump().

Seeing the value's and printing them arn't a problem... Just a hold  
over from an old program I am rewriting now that I know more about  
what I'm doing. Hopefully stream lining the entire thing!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 1:15 PM, Shawn McKenzie wrote:


Dan Joseph wrote:
I am attempting to add a little error checking for a very simple  
login
system. The info is stored in a MySQL database, and I am using  
mysqli
to connect to it. I have it working with the solution provided  
below,
but I am wondering if this is the right way to do it or if there  
is a

better way?



I don't see anything wrong with that method.  One thing I would  
suggest is

that you make username unique in your database if you want to avoid
duplicate results.  But your way of checking is just fine as it is.

To go along with this and making sure that usernames are unique, I  
would

LIMIT 1 on the query.  With no LIMIT, if you have 300,000 users, then
the query will not stop if it matches the first user, it searches all
300,000.  With LIMIT 1 it will stop on the first match.


Hi Shawn,

I do have a LIMIT 0,1 that didn't make it into the actual copy/paste.  
Thanks though for the tip!






-Shawn

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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Is this the best way?

2008-03-14 Thread TG

What error are you getting?  Maybe there's some way to fix that too.

Just remember that errors and notices are like pain.  It usually means 
there's something wrong.  If you're getting an error, there may be a better 
way of doing waht you're doing.

Ideally, you should get zero results if there's no match in the user database.

Typically for a user lookup, you might do something like this:

SELECT  FROM usertable WHERE username = '' AND password = 
''

If you get zero results, then they don't exist OR they entered the wrong 
password.

If you get more than one result, then you have a duplicate account.

If you have duplicate usernames, then you won't get multiple matches unless 
the passwords are also duplicated.

Say, for example, you have a duplicated username but different passwords:

user: me
pass: pass1

user: me
pass: pass2


Then login will succeed if they use me/pass1 OR me/pass2  but each way, 
you'll still only get one result from your db query.


btw.. before someone rails me for not mentioning security... typically you'd 
store the passwords encrypted or hashed (one-way md5 or something) then you 
encrypt or hash the password the same when the user is logging in and 
compare them to the DB.  That way, you don't store the password in 
plaintext and you can still check to see if the right password is entered.


example:

user: me
pass: pass1
md5(pass1): laksro2i3(fake md5.. lazy :)

user logs in with:

user: me
pass: pass1

system runs md5(pass1) and gets laksro2i3 again.  it matches what's in the 
DB, so therefore is the correct password.


Anyway..  main point is.. if you're getting errors, try to fix them.   If 
you're getting multiple results on your user check, you may have bad 
input/uniqueness checking or you may be implementing your user system not 
as logically as you could.

-TG


- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: "TG" <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 13:00:11 -0400

> On Mar 14, 2008, at 12:51 PM, TG wrote:
> 
> The username's will be unique... Still need to make that change to the  
> DB but they will be.
> 
> The main reason I'm doing it this way, is if I don't put in some kind  
> of a check on the authentication then it pops up a mysql error saying  
> that there is a problem with my syntax...  instead of NOT logging them  
> in... So I thought if I checked to make sure that the query only  
> returned 1 row, it would match up and I could do some error checking  
> based on that...


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



Re: [PHP] Last Friday of every month

2008-03-14 Thread tedd

At 1:03 PM -0400 3/14/08, Eric Butera wrote:

On Fri, Mar 14, 2008 at 11:57 AM, tedd <[EMAIL PROTECTED]> wrote:

 >

  You were right -- here it is:


 >  http://webbytedd.com/b1/last-friday/





Hi Tedd,

Thanks for the writeup!  You could streamline that a bit by using
getdate() and using the returned array values.


Streamline?

Anyway that does the job that I can understand works for me.  :-)

Cheers,

tedd

PS: As they say in Perl "More than one way to do it." or something to 
that affect -- it's been a long time since I programmed in Perl.

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] storing / processing login info (newbie stuff not in tutorials)

2008-03-14 Thread tedd

At 11:38 AM -0500 3/14/08, Philip Thompson wrote:

On Mar 14, 2008, at 10:15 AM, tedd wrote:

At 8:01 AM -0700 3/14/08, good_times wrote:

2. i see an example where a form in a login.html submits to "authcheck.php"
but authcheck.php just prints ('User not found in LDAP' or 'error occured'
or 'success'). how can authcheck.php redirect the user to... say.. BACK to
the login.html and tell it "yes or no" and then have login.html either
direct the user to a different data entry page (if the login was good), or
display "sorry, try again" - all from the 1 form's "submit"


If ($auth != true)
 {
 header('Location: http://www.example.com/login.html');


exit;

This will potentially save you some headaches Read more at:

http://php.net/header



Yeah, you're right. But I didn't see headaches = OFF in the OP's question.  :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] email issue

2008-03-14 Thread nihilism machine

here is my simple email lib: http://pastebin.com/m4d107c01

any idea why in the body i have a link with an = sign that gets  
replaced with a % sign?


-e

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



Re: [PHP] email issue

2008-03-14 Thread Børge Holen
On Friday 14 March 2008 18:33:13 nihilism machine wrote:
> here is my simple email lib: http://pastebin.com/m4d107c01
>
> any idea why in the body i have a link with an = sign that gets
> replaced with a % sign?
>
> -e

read up on urlencode

-- 
---
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] PHP and #if

2008-03-14 Thread Eric Gorr
In C, etc. one can place #if's around code to determine whether or not  
the compiler should pay any attention to the code.


Is there a similar technique for PHP?

I've not seen anything like this before and a brief search hasn't  
turned up anything either...just thought I would ask to make sure.



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



Re: [PHP] PHP and #if

2008-03-14 Thread Børge Holen
On Friday 14 March 2008 19:19:30 Eric Gorr wrote:
> In C, etc. one can place #if's around code to determine whether or not
> the compiler should pay any attention to the code.
>
> Is there a similar technique for PHP?
>
> I've not seen anything like this before and a brief search hasn't
> turned up anything either...just thought I would ask to make sure.

# Notin' here
// here neither
*/
Nor there
/*

-- 
---
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] PHP and #if

2008-03-14 Thread Eric Gorr
If you are talking about simply commenting code out, yes, I am aware  
of this...however, the #if technique is far more capable in certain  
situations.


There are reasons why C, etc. has included the ability to comment out  
lines of code and also provide #if's.


But based on your reply, I have to assume that PHP does not current  
provide such a technique...as I suspected.



On Mar 14, 2008, at 2:22 PM, Børge Holen wrote:


On Friday 14 March 2008 19:19:30 Eric Gorr wrote:
In C, etc. one can place #if's around code to determine whether or  
not

the compiler should pay any attention to the code.

Is there a similar technique for PHP?

I've not seen anything like this before and a brief search hasn't
turned up anything either...just thought I would ask to make sure.


# Notin' here
// here neither
*/
Nor there
/*

--
---
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP and #if

2008-03-14 Thread Dave Goodchild
in php you have a number of constructs that can be used to execute code (or
not) based on certain conditions ie is_defined(). Not sure if
the comparison with C holds true as C is compiled and PHP is interpreted.

On Fri, Mar 14, 2008 at 6:34 PM, Eric Gorr <[EMAIL PROTECTED]> wrote:

> If you are talking about simply commenting code out, yes, I am aware
> of this...however, the #if technique is far more capable in certain
> situations.
>
> There are reasons why C, etc. has included the ability to comment out
> lines of code and also provide #if's.
>
> But based on your reply, I have to assume that PHP does not current
> provide such a technique...as I suspected.
>
>
> On Mar 14, 2008, at 2:22 PM, Børge Holen wrote:
>
> > On Friday 14 March 2008 19:19:30 Eric Gorr wrote:
> >> In C, etc. one can place #if's around code to determine whether or
> >> not
> >> the compiler should pay any attention to the code.
> >>
> >> Is there a similar technique for PHP?
> >>
> >> I've not seen anything like this before and a brief search hasn't
> >> turned up anything either...just thought I would ask to make sure.
> >
> > # Notin' here
> > // here neither
> > */
> > Nor there
> > /*
> >
> > --
> > ---
> > 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 General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] PHP and #if

2008-03-14 Thread Stut

On 14 Mar 2008, at 18:34, Eric Gorr wrote:
If you are talking about simply commenting code out, yes, I am aware  
of this...however, the #if technique is far more capable in certain  
situations.


There are reasons why C, etc. has included the ability to comment  
out lines of code and also provide #if's.


But based on your reply, I have to assume that PHP does not current  
provide such a technique...as I suspected.


PHP has no built-in macro language. I started to write a pre-processor  
a while ago but didn't get very far before the real world forced me to  
shelve it, but such a beast is pretty simple to write but obviously is  
not evaluated at runtime.


IIRC there was a project a while ago to build a macro language into  
PHP but I have no idea how far it got. I think it was being done under  
the GSoC initiative. Google should have more on that.


-Stut

--
http://stut.net/

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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 1:44 PM, TG wrote:



What error are you getting?  Maybe there's some way to fix that too.


The error I get without checking the row count is this:

You have an error in your SQL syntax; check the manual that  
corresponds to your MySQL server version for the right syntax to use  
near 'order by LName' at line 1



Just remember that errors and notices are like pain.  It usually means
there's something wrong.  If you're getting an error, there may be a  
better

way of doing waht you're doing.

Ideally, you should get zero results if there's no match in the user  
database.


Typically for a user lookup, you might do something like this:

SELECT  FROM usertable WHERE username = '' AND  
password =

''


Which is very simular to what I have:

$loginQuery = "SELECT * FROM current WHERE loginName='".$user."' AND  
loginPassword='".$password."' LIMIT 0,1;";
			$loginResult = mysqli_query($link1, $loginQuery) or die("Wrong data  
supplied or database error"  .mysqli_error($link1));





If you get zero results, then they don't exist OR they entered the  
wrong

password.

If you get more than one result, then you have a duplicate account.

If you have duplicate usernames, then you won't get multiple matches  
unless

the passwords are also duplicated.

Say, for example, you have a duplicated username but different  
passwords:


user: me
pass: pass1

user: me
pass: pass2


Then login will succeed if they use me/pass1 OR me/pass2  but each  
way,

you'll still only get one result from your db query.


btw.. before someone rails me for not mentioning security...  
typically you'd
store the passwords encrypted or hashed (one-way md5 or something)  
then you

encrypt or hash the password the same when the user is logging in and
compare them to the DB.  That way, you don't store the password in
plaintext and you can still check to see if the right password is  
entered.


Which I have complete with some $salt added :)




example:

user: me
pass: pass1
md5(pass1): laksro2i3(fake md5.. lazy :)

user logs in with:

user: me
pass: pass1

system runs md5(pass1) and gets laksro2i3 again.  it matches what's  
in the

DB, so therefore is the correct password.


Anyway..  main point is.. if you're getting errors, try to fix  
them.   If

you're getting multiple results on your user check, you may have bad
input/uniqueness checking or you may be implementing your user  
system not

as logically as you could.


It was the error, rather then multiple accounts that I'm checking for.  
I'm not advanced enough in my programming ability to implement a true  
multi user envriomnent where user1/pass1 is different from user1/ 
pass2 :)






-TG


- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: "TG" <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 13:00:11 -0400


On Mar 14, 2008, at 12:51 PM, TG wrote:

The username's will be unique... Still need to make that change to  
the

DB but they will be.

The main reason I'm doing it this way, is if I don't put in some kind
of a check on the authentication then it pops up a mysql error saying
that there is a problem with my syntax...  instead of NOT logging  
them

in... So I thought if I checked to make sure that the query only
returned 1 row, it would match up and I could do some error checking
based on that...



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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] PHP and #if

2008-03-14 Thread Eric Gorr

Unfortunately, such things cannot be used to wrap functions.



On Mar 14, 2008, at 2:38 PM, Dave Goodchild wrote:

in php you have a number of constructs that can be used to execute  
code (or not) based on certain conditions ie is_defined(). Not sure if
the comparison with C holds true as C is compiled and PHP is  
interpreted.


On Fri, Mar 14, 2008 at 6:34 PM, Eric Gorr <[EMAIL PROTECTED]>  
wrote:

If you are talking about simply commenting code out, yes, I am aware
of this...however, the #if technique is far more capable in certain
situations.

There are reasons why C, etc. has included the ability to comment out
lines of code and also provide #if's.

But based on your reply, I have to assume that PHP does not current
provide such a technique...as I suspected.


On Mar 14, 2008, at 2:22 PM, Børge Holen wrote:

> On Friday 14 March 2008 19:19:30 Eric Gorr wrote:
>> In C, etc. one can place #if's around code to determine whether or
>> not
>> the compiler should pay any attention to the code.
>>
>> Is there a similar technique for PHP?
>>
>> I've not seen anything like this before and a brief search hasn't
>> turned up anything either...just thought I would ask to make sure.
>
> # Notin' here
> // here neither
> */
> Nor there
> /*
>
> --
> ---
> 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





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



Re: [PHP] PHP and #if

2008-03-14 Thread Shawn McKenzie
Eric Gorr wrote:
> Unfortunately, such things cannot be used to wrap functions.
> 
> 
> 
> On Mar 14, 2008, at 2:38 PM, Dave Goodchild wrote:
> 
>> in php you have a number of constructs that can be used to execute
>> code (or not) based on certain conditions ie is_defined(). Not sure if
>> the comparison with C holds true as C is compiled and PHP is interpreted.
>>
>> On Fri, Mar 14, 2008 at 6:34 PM, Eric Gorr <[EMAIL PROTECTED]> wrote:
>> If you are talking about simply commenting code out, yes, I am aware
>> of this...however, the #if technique is far more capable in certain
>> situations.
>>
>> There are reasons why C, etc. has included the ability to comment out
>> lines of code and also provide #if's.
>>
>> But based on your reply, I have to assume that PHP does not current
>> provide such a technique...as I suspected.
>>
>>
>> On Mar 14, 2008, at 2:22 PM, Børge Holen wrote:
>>
>> > On Friday 14 March 2008 19:19:30 Eric Gorr wrote:
>> >> In C, etc. one can place #if's around code to determine whether or
>> >> not
>> >> the compiler should pay any attention to the code.
>> >>
>> >> Is there a similar technique for PHP?
>> >>
>> >> I've not seen anything like this before and a brief search hasn't
>> >> turned up anything either...just thought I would ask to make sure.
>> >
>> > # Notin' here
>> > // here neither
>> > */
>> > Nor there
>> > /*
>> >
>> > --
>> > ---
>> > 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 General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
Surrounding a bit of code/function in an if statement in PHP does the
same thing as the #if in C because PHP is interpreted.

In C, if the #if is true then the compiler compiles the code and when
you execute the binary the code is executed, if the #if is false then
the code is not compiled so it can't execute because it isn't there.

In PHP, if you execute the script and the if is true then the code
executes, if the if is false then the code doesn't execute.

Same same...

-Shawn

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



Re: [PHP] PHP and #if

2008-03-14 Thread Stut

On 14 Mar 2008, at 19:03, Eric Gorr wrote:

Unfortunately, such things cannot be used to wrap functions.


Erm, yes they can. Try it.



Oh, and top-posting is evil, please don't do it.

-Stut

--
http://stut.net/

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



Re: [PHP] PHP and #if

2008-03-14 Thread Eric Gorr


On Mar 14, 2008, at 3:10 PM, Stut wrote:


On 14 Mar 2008, at 19:03, Eric Gorr wrote:

Unfortunately, such things cannot be used to wrap functions.


Erm, yes they can. Try it.





Gives:

Parse error: syntax error, unexpected T_STRING in /Users/Eric/Sites/ 
ifWrapping.php on line 3




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



Re: [PHP] PHP and #if

2008-03-14 Thread Eric Gorr


On Mar 14, 2008, at 3:15 PM, Eric Gorr wrote:



On Mar 14, 2008, at 3:10 PM, Stut wrote:


On 14 Mar 2008, at 19:03, Eric Gorr wrote:

Unfortunately, such things cannot be used to wrap functions.


Erm, yes they can. Try it.





Gives:

Parse error: syntax error, unexpected T_STRING in /Users/Eric/Sites/ 
ifWrapping.php on line 3


Oh, sorry, apparently there are some invisible characters in the text  
you pasted which I had to zap first. Yes, this does work as expected.


However, try wrapping the arse function in a class.

arse();
?>


That fails with:


Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in / 
Users/Eric/Sites/ifWrapping.php on line 4




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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jim Lucas

Jason Pruim wrote:


On Mar 14, 2008, at 1:15 PM, Shawn McKenzie wrote:


Dan Joseph wrote:

I am attempting to add a little error checking for a very simple login
system. The info is stored in a MySQL database, and I am using mysqli
to connect to it. I have it working with the solution provided below,
but I am wondering if this is the right way to do it or if there is a
better way?



I don't see anything wrong with that method.  One thing I would 
suggest is

that you make username unique in your database if you want to avoid
duplicate results.  But your way of checking is just fine as it is.


To go along with this and making sure that usernames are unique, I would
LIMIT 1 on the query.  With no LIMIT, if you have 300,000 users, then
the query will not stop if it matches the first user, it searches all
300,000.  With LIMIT 1 it will stop on the first match.


Hi Shawn,

I do have a LIMIT 0,1 that didn't make it into the actual copy/paste. 
Thanks though for the tip!




If this is the case, then you will never have a situation where your result set 
will be larger then 1.  It will be either 1 or 0 (zero).


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] PHP and #if

2008-03-14 Thread Shawn McKenzie
Eric Gorr wrote:
> 
> On Mar 14, 2008, at 3:15 PM, Eric Gorr wrote:
> 
>>
>> On Mar 14, 2008, at 3:10 PM, Stut wrote:
>>
>>> On 14 Mar 2008, at 19:03, Eric Gorr wrote:
 Unfortunately, such things cannot be used to wrap functions.
>>>
>>> Erm, yes they can. Try it.
>>>
>>> >>   if (rand(0,1) == 0)
>>>   {
>>>   function arse()
>>>   {
>>>   echo "arse 1\n";
>>>   }
>>>   }
>>>   else
>>>   {
>>>   function arse()
>>>   {
>>>   echo "arse 2\n";
>>>   }
>>>   }
>>>
>>>   arse();
>>> ?>
>>>
>>
>> Gives:
>>
>> Parse error: syntax error, unexpected T_STRING in
>> /Users/Eric/Sites/ifWrapping.php on line 3
> 
> Oh, sorry, apparently there are some invisible characters in the text
> you pasted which I had to zap first. Yes, this does work as expected.
> 
> However, try wrapping the arse function in a class.
> 
>  class TestClass
> {
> if ( rand(0,1) == 0 )
> {
> function arse()
> {
> echo "arse 1\n";
> }
> }
> else
> {
> function arse()
> {
> echo "arse 2\n";
> }
> }
> 
> }
> 
> $myVar = new TestClass;
> 
> $myVar->arse();
> ?>
> 
> 
> That fails with:
> 
> 
> Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in
> /Users/Eric/Sites/ifWrapping.php on line 4
> 
> 
Never tried it in a class.  There is probably a way to hack and get it
to work.  However, unless you're doing something so much more
sophisticated than most people, what's wrong with this?

arse();
?>

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



Re: [PHP] PHP and #if

2008-03-14 Thread André Medeiros
OK, here's how it goes:



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



Re: [PHP] PHP and #if

2008-03-14 Thread Stut

On 14 Mar 2008, at 19:21, Eric Gorr wrote:

On Mar 14, 2008, at 3:15 PM, Eric Gorr wrote:

On Mar 14, 2008, at 3:10 PM, Stut wrote:

On 14 Mar 2008, at 19:03, Eric Gorr wrote:

Unfortunately, such things cannot be used to wrap functions.


Erm, yes they can. Try it.





Gives:

Parse error: syntax error, unexpected T_STRING in /Users/Eric/Sites/ 
ifWrapping.php on line 3


Oh, sorry, apparently there are some invisible characters in the  
text you pasted which I had to zap first. Yes, this does work as  
expected.


However, try wrapping the arse function in a class.

arse();
?>


In my experience there are very few valid reasons for conditionally  
defining functions, and even fewer for conditionally defining methods  
in a class. Maybe if you explain what you're trying to achieve we can  
help you find a better way.


-Stut

--
http://stut.net/

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



[PHP] Posting Summary for Week Ending 14 March, 2008: php-general@lists.php.net

2008-03-14 Thread PostTrack [Dan Brown]

Posting Summary for PHP-General List
Week Ending: Friday, 14 March, 2008

Messages| Bytes  | Sender
++--
480 (100%)  799678 (100%)   EVERYONE
39 (8.1%)  36359   (4.5%)  Daniel Brown 
30 (6.3%)  36149   (4.5%)  tedd 
29 (6%)27607   (3.5%)  Greg Donald 
18 (3.8%)  26766   (3.3%)  Robert Cummings 
16 (3.3%)  19915   (2.5%)  Aschwin Wesselius 
16 (3.3%)  10147   (1.3%)  Richard Heyes 
15 (3.1%)  28839   (3.6%)  Shawn McKenzie 
14 (2.9%)  18288   (2.3%)  Stut 
14 (2.9%)  24748   (3.1%)  Jason Pruim 
13 (2.7%)  16242   (2%)Thijs Lensselink 
13 (2.7%)  24267   (3%)It Maq 
12 (2.5%)  8291(1%)Per Jessen 
12 (2.5%)  22543   (2.8%)  Zoltán Németh 
11 (2.3%)  21755   (2.7%)  Eric Butera 
11 (2.3%)  17774   (2.2%)  Alain Roger 
10 (2.1%)  20007   (2.5%)  Ray Hauge 
9  (1.9%)  31225   (3.9%)  Andrés Robinet 
9  (1.9%)  10301   (1.3%)  Wolf 
8  (1.7%)  18532   (2.3%)  TG 
8  (1.7%)  10605   (1.3%)  Philip Thompson 
8  (1.7%)  5096(0.6%)  Bill 
7  (1.5%)  4871(0.6%)  Chris 
6  (1.3%)  9135(1.1%)  Nathan Nobbe 
5  (1%)8546(1.1%)  Jim Lucas 
5  (1%)5191(0.6%)  Eric Gorr 
5  (1%)5025(0.6%)  Børge Holen 
5  (1%)3873(0.5%)  Murat BEŞER 
4  (0.8%)  7319(0.9%)  Larry Garfield 
4  (0.8%)  6834(0.9%)  Adil Drissi 
4  (0.8%)  11467   (1.4%)  Lamonte 
4  (0.8%)  1985(0.2%)  Anup Shukla 
4  (0.8%)  2192(0.3%)  Lamonte H 
3  (0.6%)  4440(0.6%)  Lamp Lists 
3  (0.6%)  9173(1.1%)  Andrés Robinet 
3  (0.6%)  3532(0.4%)  Dave Goodchild 
3  (0.6%)  3389(0.4%)  Al 
3  (0.6%)  6984(0.9%)  Stephane Ulysse 
3  (0.6%)  4300(0.5%)  Angelo Zanetti 
2  (0.4%)  1060(0.1%)  Steven Macintyre 
2  (0.4%)  3596(0.4%)  Willian Schubert Baldasso 

2  (0.4%)  2023(0.3%)  dev at lenss dot nl
2  (0.4%)  2604(0.3%)  Børge Holen 
2  (0.4%)  1876(0.2%)  David Giragosian 
2  (0.4%)  2829(0.4%)  Matty Sarro 
2  (0.4%)  2087(0.3%)  H u g o H i r a m 
2  (0.4%)  878 (0.1%)  Tim Daff 
2  (0.4%)  1917(0.2%)  John Comerford 
2  (0.4%)  1739(0.2%)  sinseven at aol dot com
2  (0.4%)  1897(0.2%)  mathieu leddet 
2  (0.4%)  5329(0.7%)  Edward Kay 
2  (0.4%)  1684(0.2%)  jeffry s 
2  (0.4%)  522 (0.1%)  VamVan 
2  (0.4%)  50180   (6.3%)  Evone Wong
2  (0.4%)  50180   (6.3%)  Evone Wong
2  (0.4%)  623 (0.1%)  John Taylor-Johnston 
2  (0.4%)  5304(0.7%)  nihilism machine 

2  (0.4%)  2170(0.3%)  Danny Brow 
2  (0.4%)  50180   (6.3%)  Evone Wong
2  (0.4%)  993 (0.1%)  Ian M dot  Evans 
2  (0.4%)  797 (0.1%)  John Taylor-Johnston 
2  (0.4%)  2141(0.3%)  Ken Kixmoeller 
2  (0.4%)  1759(0.2%)  Shelley 
1  (0.2%)  862 (0.1%)  Dan Joseph 
1  (0.2%)  289 (0%)André Medeiros 
1  (0.2%)  730 (0.1%)  Steve Finkelstein 
1  (0.2%)  1883(0.2%)  Wolf 
1  (0.2%)  311 (0%)Colin Guthrie 
1  (0.2%)  567 (0.1%)  Sn!per 
1  (0.2%)  1960(0.2%)  Virgil Hilts 
1  (0.2%)  1222(0.2%)  Julio César García Vizcaíno 

1  (0.2%)  2328(0.3%)  Martin Jerga 
1  (0.2%)  1345(0.2%)  Wolf 
1  (0.2%)  2603(0.3%)  Roland Häder 
1  (0.2%)  862 (0.1%)  Gustavo Narea 
1  (0.2%)  1203(0.2%)  Manuel Lemos 
1  (0.2%)  1922(0.2%)  Steve Edberg 
1  (0.2%)  2112(0.3%)  Suamya Srivastava 
1  (0.2%)  869 

RE: [PHP] PHP and #if

2008-03-14 Thread Andrés Robinet
> -Original Message-
> From: Eric Gorr [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 14, 2008 3:22 PM
> To: PHP General
> Subject: Re: [PHP] PHP and #if
> 
> 
> On Mar 14, 2008, at 3:15 PM, Eric Gorr wrote:
> 
> >
> > On Mar 14, 2008, at 3:10 PM, Stut wrote:
> >
> >> On 14 Mar 2008, at 19:03, Eric Gorr wrote:
> >>> Unfortunately, such things cannot be used to wrap functions.
> >>
> >> Erm, yes they can. Try it.
> >>
> >>  >>   if (rand(0,1) == 0)
> >>   {
> >>   function arse()
> >>   {
> >>   echo "arse 1\n";
> >>   }
> >>   }
> >>   else
> >>   {
> >>   function arse()
> >>   {
> >>   echo "arse 2\n";
> >>   }
> >>   }
> >>
> >>   arse();
> >> ?>
> >>
> >
> > Gives:
> >
> > Parse error: syntax error, unexpected T_STRING in /Users/Eric/Sites/
> > ifWrapping.php on line 3
> 
> Oh, sorry, apparently there are some invisible characters in the text
> you pasted which I had to zap first. Yes, this does work as expected.
> 
> However, try wrapping the arse function in a class.
> 
>  class TestClass
> {
>   if ( rand(0,1) == 0 )
>   {
>   function arse()
>   {
>   echo "arse 1\n";
>   }
>   }
>   else
>   {
>   function arse()
>   {
>   echo "arse 2\n";
>   }
>   }
> 
> }
> 
> $myVar = new TestClass;
> 
> $myVar->arse();
> ?>
> 
> 
> That fails with:
> 
> 
> Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in /
> Users/Eric/Sites/ifWrapping.php on line 4
> 
> 
> 

Mmmm... why would you want to use a different class definition on some
conditions? Yes, there might be reasons, but it's usually just a matter of
realizing that you can use inheritance, containment or some design patterns
(say, the Adapter pattern).
There are other ways to solve the problem which are not yet available in PHP.
Some of them are being discussed nowadays
(http://wiki.php.net/rfc/nonbreakabletraits).
Now, if you want something weird... I believe this would work:


 class TestClass
 {

function arse()
{
echo "arse 1\n";
}

function arse()
{
echo "arse 2\n";
}

 
 }
arse();
?>

I didn't test this, but it should work I think... I remember nuSoap doing
something similar for soap proxys (though not using output buffering). There are
alternatives that are way better (and smarter about performance) than this,
but... you see... everything can be done in PHP.

If you look for "build-like" tools, that is, generate code at "deployment-time",
you may try phing http://phing.info.

Regards,

Rob

Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4296 | FAX 954-337-2695 | 
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |
 Web: bestplace.biz  | Web: seo-diy.com




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



Re: [PHP] Posting Summary for Week Ending 14 March, 2008: php-general@lists.php.net

2008-03-14 Thread Jason Pruim
So... After this post gets sent... Does Dan have some code in here to  
kill all traffic on the list for a minimum amount of time? :)


Happy Friday everyone!


On Mar 14, 2008, at 4:00 PM, PostTrack [Dan Brown] wrote:



Posting Summary for PHP-General List
Week Ending: Friday, 14 March, 2008

Messages| Bytes  | Sender
++--
480 (100%)  799678 (100%)   EVERYONE
	39 (8.1%)  36359   (4.5%)  Daniel Brown gmail dot com>
	30 (6.3%)  36149   (4.5%)  tedd gmail dot com>
	29 (6%)27607   (3.5%)  Greg Donald gmail dot com>
	18 (3.8%)  26766   (3.3%)  Robert Cummings interjinn dot com>
	16 (3.3%)  19915   (2.5%)  Aschwin Wesselius at illuminated dot nl>
	16 (3.3%)  10147   (1.3%)  Richard Heyes phpguru dot org>
	15 (3.1%)  28839   (3.6%)  Shawn McKenzie mckenzies dot net>
	14 (2.9%)  18288   (2.3%)  Stut com>
	14 (2.9%)  24748   (3.1%)  Jason Pruim raoset dot com>
	13 (2.7%)  16242   (2%)Thijs Lensselink lenss dot nl>
	13 (2.7%)  24267   (3%)It Maq dot com>
	12 (2.5%)  8291(1%)Per Jessen dot org>
	12 (2.5%)  22543   (2.8%)  Zoltán Németh alterationx dot hu>
	11 (2.3%)  21755   (2.7%)  Eric Butera at gmail dot com>
	11 (2.3%)  17774   (2.2%)  Alain Roger gmail dot com>
	10 (2.1%)  20007   (2.5%)  Ray Hauge lists at gmail dot com>
	9  (1.9%)  31225   (3.9%)  Andrés Robinet bestplace dot biz>
	9  (1.9%)  10301   (1.3%)  Wolf dot com>
	8  (1.7%)  18532   (2.3%)  TG gryffyndevelopment dot com>
	8  (1.7%)  10605   (1.3%)  Philip Thompson  

	8  (1.7%)  5096(0.6%)  Bill dot com>
	7  (1.5%)  4871(0.6%)  Chris com>
	6  (1.3%)  9135(1.1%)  Nathan Nobbe at gmail dot com>
	5  (1%)8546(1.1%)  Jim Lucas dot com>
	5  (1%)5191(0.6%)  Eric Gorr ericgorr dot net>
	5  (1%)5025(0.6%)  Børge Holen arivene dot net>
	5  (1%)3873(0.5%)  Murat BEŞER beser dot com>
	4  (0.8%)  7319(0.9%)  Larry Garfield garfieldtech dot com>
	4  (0.8%)  6834(0.9%)  Adil Drissi at yahoo dot com>
	4  (0.8%)  11467   (1.4%)  Lamonte dot com>
	4  (0.8%)  1985(0.2%)  Anup Shukla at gmail dot com>
	4  (0.8%)  2192(0.3%)  Lamonte H dot com>
	3  (0.6%)  4440(0.6%)  Lamp Lists at yahoo dot com>
	3  (0.6%)  9173(1.1%)  Andrés Robinet bestplace dot biz>
	3  (0.6%)  3532(0.4%)  Dave Goodchild at gmail dot com>

3  (0.6%)  3389(0.4%)  Al 
	3  (0.6%)  6984(0.9%)  Stephane Ulysse bachrachgroup dot com>
	3  (0.6%)  4300(0.5%)  Angelo Zanetti elemental dot co dot za>
	2  (0.4%)  1060(0.1%)  Steven Macintyre steven dot macintyre dot name>
	2  (0.4%)  3596(0.4%)  Willian Schubert Baldasso  


2  (0.4%)  2023(0.3%)  dev at lenss dot nl
	2  (0.4%)  2604(0.3%)  Børge Holen arivene dot net>
	2  (0.4%)  1876(0.2%)  David Giragosian  

	2  (0.4%)  2829(0.4%)  Matty Sarro dot com>
	2  (0.4%)  2087(0.3%)  H u g o H i r a m hugohiram dot com>
	2  (0.4%)  878 (0.1%)  Tim Daff dot com>
	2  (0.4%)  1917(0.2%)  John Comerford optionsystems dot com dot au>

2  (0.4%)  1739(0.2%)  sinseven at aol dot com
	2  (0.4%)  1897(0.2%)  mathieu leddet leddet at mobilescope dot com>
	2  (0.4%)  5329(0.7%)  Edward Kay dot com>
	2  (0.4%)  1684(0.2%)  jeffry s dot com>
	2  (0.4%)  522 (0.1%)  VamVan dot com>
	2  (0.4%)  50180   (6.3%)  Evone Wongstreamyx dot com>
	2  (0.4%)  50180   (6.3%)  Evone Wongdot com dot my>
	2  (0.4%)  623 (0.1%)  John Taylor-Johnston johnston at USherbrooke dot ca>
	2  (0.4%)  5304(0.7%)  nihilism machine  

	2  (0.4%)  2170(0.3%)  Danny Brow fullmotions dot com>
	2  (0.4%)  50180   (6.3%)  Evone Wongdot com>
	2  (0.4%)  993 (0.1%)  Ian M dot  Evans at digitalhit dot com>
	2  (0.4%)  797 (0.1%)  John Taylor-Johnston dot Taylor-Johnston at cegepsherbrooke dot qc dot ca>
	2  (0.4%)  2141(0.3%)  Ken Kixmoeller comcast dot net>
	2  (0.4%)  1759(0.2%)  Shelley dot com>
	1  (0.2%)  862 (0.1%)  Dan Joseph gmail dot com>
	1  (0.2%)  289 (0%)André Medeiros caum at gmail dot com>
	1  (0.2%)  730 (0.1%)  Steve Finkelstein stevefink dot net>
	1  (0.2%)  1883(0

[PHP] Unable to create selectable TCP socket

2008-03-14 Thread ros

Hi! I have a simple PHP script:

$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "[EMAIL PROTECTED]",
"123");
if(!$mbox) {
echo 'Error: '.imap_last_error().'';
}

Script works fine from local PC, but results to error when executed at web
hoster site. 
The error is: "Error: Unable to create selectable TCP socket (2090 >= 1024)"

What could cause this error?

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Unable-to-create-selectable-TCP-socket-tp16055595p16055595.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Is this the best way?

2008-03-14 Thread TG



- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: TG <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 14:56:32 -0400
Subject: Re: [PHP] Is this the best way?

> 
> On Mar 14, 2008, at 1:44 PM, TG wrote:
> 
> >
> > What error are you getting?  Maybe there's some way to fix that too.
> 
> The error I get without checking the row count is this:
> 
> You have an error in your SQL syntax; check the manual that  
> corresponds to your MySQL server version for the right syntax to use  
> near 'order by LName' at line 1

Ok so the next thing to check is your query.  Maybe echo it out so you can 
see what's actually attempting to execute.

I don't see an "ORDER BY" in the SQL listed below.

Usually when I get errors like this, it's because a variable I expect to be 
populated isn't and it messes up the SQL by leaving a blank where it 
expects something.

SELECT * FROM users WHERE username = 'tg' ORDER BY LName

If I had:

$user = "'tg'"

with the single-quotes inside the variable.. if I typo'd on $user and did 
something like:

$query = "SELECT * FROM users WHERE username = $usr ORDER BY LName";

Then I'd get:

SELECT * FROM users WHERE username = ORDER BY LName



> >
> >
> > Just remember that errors and notices are like pain.  It usually means
> > there's something wrong.  If you're getting an error, there may be a  
> > better
> > way of doing waht you're doing.
> >
> > Ideally, you should get zero results if there's no match in the user  
> > database.
> >
> > Typically for a user lookup, you might do something like this:
> >
> > SELECT  FROM usertable WHERE username = '' AND  
> > password =
> > ''
> 
> Which is very simular to what I have:
> 
> $loginQuery = "SELECT * FROM current WHERE loginName='".$user."' AND  
> loginPassword='".$password."' LIMIT 0,1;";
>   $loginResult = mysqli_query($link1, $loginQuery) or 
> die("Wrong data  
> supplied or database error"  .mysqli_error($link1));




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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 5:03 PM, TG wrote:





- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: TG <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 14:56:32 -0400
Subject: Re: [PHP] Is this the best way?



On Mar 14, 2008, at 1:44 PM, TG wrote:



What error are you getting?  Maybe there's some way to fix that too.


The error I get without checking the row count is this:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'order by LName' at line 1


Ok so the next thing to check is your query.  Maybe echo it out so  
you can

see what's actually attempting to execute.


echo from my actual query
SELECT * FROM current WHERE loginName='japruim' AND  
loginPassword='mybadpassword' LIMIT 0,1;



I don't see an "ORDER BY" in the SQL listed below.


The ORDER BY actually comes from a different query that should ONLY be  
done AFTER successful login... It's actually related to the sorting of  
the records that should be retrieved.



Usually when I get errors like this, it's because a variable I  
expect to be

populated isn't and it messes up the SQL by leaving a blank where it
expects something.

SELECT * FROM users WHERE username = 'tg' ORDER BY LName

If I had:

$user = "'tg'"

with the single-quotes inside the variable.. if I typo'd on $user  
and did

something like:

$query = "SELECT * FROM users WHERE username = $usr ORDER BY LName";

Then I'd get:

SELECT * FROM users WHERE username = ORDER BY LName


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Posting Summary for Week Ending 14 March, 2008: php-general@lists.php.net

2008-03-14 Thread Børge Holen
On Friday 14 March 2008 21:24:30 Jason Pruim wrote:
> So... After this post gets sent... Does Dan have some code in here to
> kill all traffic on the list for a minimum amount of time? :)

no but he does some time travel.
merry christmas everyone! ;D

>
> Happy Friday everyone!
>
> On Mar 14, 2008, at 4:00 PM, PostTrack [Dan Brown] wrote:
> > Posting Summary for PHP-General List
> > Week Ending: Friday, 14 March, 2008
> >
> > Messages| Bytes  | Sender
> > ++--
> > 480 (100%)  799678 (100%)   EVERYONE
> > 39 (8.1%)  36359   (4.5%)  Daniel Brown  > gmail dot com>
> > 30 (6.3%)  36149   (4.5%)  tedd  > gmail dot com>
> > 29 (6%)27607   (3.5%)  Greg Donald  > gmail dot com>
> > 18 (3.8%)  26766   (3.3%)  Robert Cummings  > interjinn dot com>
> > 16 (3.3%)  19915   (2.5%)  Aschwin Wesselius  > at illuminated dot nl>
> > 16 (3.3%)  10147   (1.3%)  Richard Heyes  > phpguru dot org>
> > 15 (3.1%)  28839   (3.6%)  Shawn McKenzie  > mckenzies dot net>
> > 14 (2.9%)  18288   (2.3%)  Stut  > com>
> > 14 (2.9%)  24748   (3.1%)  Jason Pruim  > raoset dot com>
> > 13 (2.7%)  16242   (2%)Thijs Lensselink  > lenss dot nl>
> > 13 (2.7%)  24267   (3%)It Maq  > dot com>
> > 12 (2.5%)  8291(1%)Per Jessen  > dot org>
> > 12 (2.5%)  22543   (2.8%)  Zoltán Németh  > alterationx dot hu>
> > 11 (2.3%)  21755   (2.7%)  Eric Butera  > at gmail dot com>
> > 11 (2.3%)  17774   (2.2%)  Alain Roger  > gmail dot com>
> > 10 (2.1%)  20007   (2.5%)  Ray Hauge  > lists at gmail dot com>
> > 9  (1.9%)  31225   (3.9%)  Andrés Robinet  > bestplace dot biz>
> > 9  (1.9%)  10301   (1.3%)  Wolf  > dot com>
> > 8  (1.7%)  18532   (2.3%)  TG  > gryffyndevelopment dot com>
> > 8  (1.7%)  10605   (1.3%)  Philip Thompson
> > 
> > 8  (1.7%)  5096(0.6%)  Bill  > dot com>
> > 7  (1.5%)  4871(0.6%)  Chris  > com>
> > 6  (1.3%)  9135(1.1%)  Nathan Nobbe  > at gmail dot com>
> > 5  (1%)8546(1.1%)  Jim Lucas  > dot com>
> > 5  (1%)5191(0.6%)  Eric Gorr  > ericgorr dot net>
> > 5  (1%)5025(0.6%)  Børge Holen  > arivene dot net>
> > 5  (1%)3873(0.5%)  Murat BEŞER  > beser dot com>
> > 4  (0.8%)  7319(0.9%)  Larry Garfield  > garfieldtech dot com>
> > 4  (0.8%)  6834(0.9%)  Adil Drissi  > at yahoo dot com>
> > 4  (0.8%)  11467   (1.4%)  Lamonte  > dot com>
> > 4  (0.8%)  1985(0.2%)  Anup Shukla  > at gmail dot com>
> > 4  (0.8%)  2192(0.3%)  Lamonte H  > dot com>
> > 3  (0.6%)  4440(0.6%)  Lamp Lists  > at yahoo dot com>
> > 3  (0.6%)  9173(1.1%)  Andrés Robinet  > bestplace dot biz>
> > 3  (0.6%)  3532(0.4%)  Dave Goodchild  > at gmail dot com>
> > 3  (0.6%)  3389(0.4%)  Al 
> > 3  (0.6%)  6984(0.9%)  Stephane Ulysse  > bachrachgroup dot com>
> > 3  (0.6%)  4300(0.5%)  Angelo Zanetti  > elemental dot co dot za>
> > 2  (0.4%)  1060(0.1%)  Steven Macintyre  > steven dot macintyre dot name>
> > 2  (0.4%)  3596(0.4%)  Willian Schubert Baldasso
> > 
> > 2  (0.4%)  2023(0.3%)  dev at lenss dot nl
> > 2  (0.4%)  2604(0.3%)  Børge Holen  > arivene dot net>
> > 2  (0.4%)  1876(0.2%)  David Giragosian
> > 
> > 2  (0.4%)  2829(0.4%)  Matty Sarro  > dot com>
> > 2  (0.4%)  2087(0.3%)  H u g o H i r a m  > hugohiram dot com>
> > 2  (0.4%)  878 (0.1%)  Tim Daff  > dot com>
> > 2  (0.4%)  1917(0.2%)  John Comerford  > optionsystems dot com dot au>
> > 2  (0.4%)  1739(0.2%)  sinseven at aol dot com
> > 2  (0.4%)  1897(0.2%)  mathieu leddet  > leddet at mobilescope dot com>
> > 2  (0.4%)  5329(0.7%)  Edward Kay  > dot com>
> > 2  (0.4%)  1684(0.2%)  jeffry s  > dot com>
> > 2  (0.4%)  522 (0.1%)  VamVan  > dot com>
> > 2  (0.4%)  50180   (6.3%)  Evone Wong > streamyx dot com>
> > 2  (0.4%)  50180   (6.3%)  Evone Wong > dot com dot my>
> > 2  (0.4%)  623 (0.1%)  John Taylor-Johnston  > johnston at USherbrooke dot ca>
> > 2  (0.4%)  5304(0.7%)  nihilism machine
> > 
> > 2  (0.4%)  2170(0.3%)  Danny Brow  > 

Re: [PHP] Is this the best way?

2008-03-14 Thread TG

Then it's the other query (with the ORDER BY) that you want to look at to fix 
the SQL error.

Don't forget to use (assuming MySQL) mysql_real_escape_string() on all 
variables being used in the SQL query.  That'll help prevent a problem with 
single quotes or other bad characters showing up in your variables and 
breaking your SQL.  Not to mention the security benefits.

-TG

- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: "TG" <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 17:11:40 -0400

> > Ok so the next thing to check is your query.  Maybe echo it out so  
> > you can
> > see what's actually attempting to execute.
> 
> echo from my actual query
> SELECT * FROM current WHERE loginName='japruim' AND  
> loginPassword='mybadpassword' LIMIT 0,1;
> >
> >
> > I don't see an "ORDER BY" in the SQL listed below.
> 
> The ORDER BY actually comes from a different query that should ONLY be  
> done AFTER successful login... It's actually related to the sorting of  
> the records that should be retrieved.


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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jason Pruim


On Mar 14, 2008, at 5:40 PM, TG wrote:



Then it's the other query (with the ORDER BY) that you want to look  
at to fix

the SQL error.

Don't forget to use (assuming MySQL) mysql_real_escape_string() on all
variables being used in the SQL query.  That'll help prevent a  
problem with

single quotes or other bad characters showing up in your variables and
breaking your SQL.  Not to mention the security benefits.


All that's taken care of... The issue is though, that that query is  
getting run even when the login wasn't successful... When you log in  
with the proper username/password that query runs just fine...





-TG

- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: "TG" <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 17:11:40 -0400


Ok so the next thing to check is your query.  Maybe echo it out so
you can
see what's actually attempting to execute.


echo from my actual query
SELECT * FROM current WHERE loginName='japruim' AND
loginPassword='mybadpassword' LIMIT 0,1;



I don't see an "ORDER BY" in the SQL listed below.


The ORDER BY actually comes from a different query that should ONLY  
be
done AFTER successful login... It's actually related to the sorting  
of

the records that should be retrieved.






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



Re: [PHP] Is this the best way?

2008-03-14 Thread Jim Lucas

Jason Pruim wrote:


On Mar 14, 2008, at 5:03 PM, TG wrote:





- Original Message -
From: Jason Pruim <[EMAIL PROTECTED]>
To: TG <[EMAIL PROTECTED]>
Cc: "PHP General List" 
Date: Fri, 14 Mar 2008 14:56:32 -0400
Subject: Re: [PHP] Is this the best way?



On Mar 14, 2008, at 1:44 PM, TG wrote:



What error are you getting?  Maybe there's some way to fix that too.


The error I get without checking the row count is this:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'order by LName' at line 1


Ok so the next thing to check is your query.  Maybe echo it out so you 
can

see what's actually attempting to execute.


echo from my actual query
SELECT * FROM current WHERE loginName='japruim' AND 
loginPassword='mybadpassword' LIMIT 0,1;


obviously it isn't this SQL statement that is causing the problem, it doesn't 
have the ORDER BY piece that is failing.





I don't see an "ORDER BY" in the SQL listed below.


The ORDER BY actually comes from a different query that should ONLY be 
done AFTER successful login... It's actually related to the sorting of 
the records that should be retrieved.


Somehow it is getting to this statement and the variable that you are using just 
before the ORDER BY part is empty,  Why don't you show us that statement.




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] Newbie ' If Statement' Question

2008-03-14 Thread [EMAIL PROTECTED]
Hello Folks,

I would like to be able to wrap a 'form' inside a php 'if statement' -  so
that the form will appear if the 'if condition' is met.

-  most likely I cannot have a getField('testfield') !="") {
print "






";}else {print "Non Print";} ?>



--
Thanks - RevDave
Cool7 @ hosting4days . com
[db-lists]




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



Re: [PHP] Newbie ' If Statement' Question

2008-03-14 Thread Nathan Nobbe
On Fri, Mar 14, 2008 at 7:56 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' -  so
> that the form will appear if the 'if condition' is met.
>
> -  most likely I cannot have a  I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING
> in...
>
> Q:  What is the best way to accomplish this goal?
>
> ---
>
> getField('testfield') !="") {
>print "
> 
> 
> 
> 
> 
>
> ";}else {print "Non Print";} ?>
>

something like this,

getField('testfield') != '') { ?>

  
  
  



// warning: typed directly into browser w/ no testing ;)

-nathan


Re: [PHP] Newbie ' If Statement' Question

2008-03-14 Thread Benjamin Darwin
On Fri, Mar 14, 2008 at 7:56 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' -  so
> that the form will appear if the 'if condition' is met.
>
> -  most likely I cannot have a  I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING
> in...
>
> Q:  What is the best way to accomplish this goal?
>
>
> ---
>
> getField('testfield') !="") {
>print "
> 
> 
> 
> 
> 
>
> ";}else {print "Non Print";} ?>
>
>
>
> --
> Thanks - RevDave
> Cool7 @ hosting4days . com
> [db-lists]
>

Your first mistake I'm finding is the use of quotes. You started the print
with a ", which means the print ends at name=", and it's expecting more PHP
code, rather than a HTML string. The first fix would be to either escape all
quotes in the HTML with a slash (\) before it, or to change your opening and
closing quotes on the print to a single quote (').
Second, yes, you cannot enclose PHP tags inside PHP tags.  To do this,
change that portion to end the print, attach the two portions with a period
(.) and start up with the php function, then a period, and back to the
print.

Here's a fix that should work. I haven't tested it though, so I may have
missed one or two quotes.

getField('testfield') !="") {
   print "


getRecordId()."\">



";}else {print "Non Print";} ?>


Re: [PHP] Sending multiple values from a form having same field names.

2008-03-14 Thread Jim Lucas

Eric Butera wrote:

On Fri, Mar 14, 2008 at 6:02 AM, Zoltán Németh <[EMAIL PROTECTED]> wrote:

2008. 03. 14, péntek keltezéssel 14.08-kor Suamya Srivastava ezt írta:


Hi,

 >
 > How can I send multiple values from a form to be stored in a database, as
 > name of the fields is the same?
 >
 > For example:
 >
 >  foreach ($field_data as $field) {
 >
 >  $field_name=$field["field_name"];
 >  $field_id=$field["field_id"];
 >  $datatype=$field["datatype_name"];
 >
 > ?>
 > 
 > 
 > 
 >   if ($datatype=="text" || $datatype=="integer") {
 > echo "";

 make field_data an array indexed by field_id

   }
 >  elseif ($datatype=="textarea") {
 >   echo " name=\"field_data\">";
 >   }
 >   echo "";
 > }
 > ?>
 >
 > This creates a form with field names and text box or textarea box next to
 > each field name depending on the datatype. After the user enters the
 > values in the text or textarea and clicks submit, the values should get
 > stored in a database. But what is happening is that only the value entered
 > in the last field of the form is getting entered into the database.
 > This code is embedded in an application which is having an inbuilt
 > structure of taking the values from a form in a hash. Since key is the
 > same (i.e. field_id) everytime, the value gets overwritten and only the
 > last value gets stored in db. But I am not able to work out a solution for
 > this.
 > I hope I am able to make my problem clear enough.
 >
 > Thanks,
 > Suamya.
 >
 >
 >
 >
 > -
 > DISCLAIMER:-
 >   "The information in this e-mail is confidential, and is intended
 > solely for the addressee or addressees. If you are not the intended 
recipient,
 >  please delete the mail and kindly notify the sender of misdelivery. Any
 > unauthorised use or disclosure of the contents of the mail is not permitted
 > and may be unlawful."
 > -
 >
 >  "Scanned By MailScanner"
 >
 >


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




Since Zoltán give you the answer I might give you another fish.  Which
one is more readable:




";
}
elseif ($datatype=="textarea") {
 echo "";
 }
 echo "";
}
?>













 




This is more readable

';

  # Check to see if it requires a text area
  } elseif ( $datatype == "textarea" ) {

# Create Text Area
$field = ''.
 '';

  }
  # Display it all
  echo <<
  {$field_name}
  {$field}

ROW;
}
?>


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Sending multiple values from a form having same field names.

2008-03-14 Thread Eric Butera
On Fri, Mar 14, 2008 at 8:12 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:
>
> Eric Butera wrote:
>  > On Fri, Mar 14, 2008 at 6:02 AM, Zoltán Németh <[EMAIL PROTECTED]> wrote:
>  >> 2008. 03. 14, péntek keltezéssel 14.08-kor Suamya Srivastava ezt írta:
>  >>
>  >>> Hi,
>  >>  >
>  >>  > How can I send multiple values from a form to be stored in a database, 
> as
>  >>  > name of the fields is the same?
>  >>  >
>  >>  > For example:
>  >>  >
>  >>  >   >>  > foreach ($field_data as $field) {
>  >>  >
>  >>  >  $field_name=$field["field_name"];
>  >>  >  $field_id=$field["field_id"];
>  >>  >  $datatype=$field["datatype_name"];
>  >>  >
>  >>  > ?>
>  >>  > 
>  >>  > 
>  >>  > 
>  >>  >   >>  >  if ($datatype=="text" || $datatype=="integer") {
>  >>  > echo "";
>  >>
>  >>  make field_data an array indexed by field_id
>  >>
>  >>>>
>  >>  greets,
>  >>  Zoltán Németh
>  >>
>  >>
>  >>
>  >>  >  }
>  >>  >  elseif ($datatype=="textarea") {
>  >>  >   echo "  >>  > name=\"field_data\">";
>  >>  >   }
>  >>  >   echo "";
>  >>  > }
>  >>  > ?>
>  >>  >
>  >>  > This creates a form with field names and text box or textarea box next 
> to
>  >>  > each field name depending on the datatype. After the user enters the
>  >>  > values in the text or textarea and clicks submit, the values should get
>  >>  > stored in a database. But what is happening is that only the value 
> entered
>  >>  > in the last field of the form is getting entered into the database.
>  >>  > This code is embedded in an application which is having an inbuilt
>  >>  > structure of taking the values from a form in a hash. Since key is the
>  >>  > same (i.e. field_id) everytime, the value gets overwritten and only the
>  >>  > last value gets stored in db. But I am not able to work out a solution 
> for
>  >>  > this.
>  >>  > I hope I am able to make my problem clear enough.
>  >>  >
>  >>  > Thanks,
>  >>  > Suamya.
>  >>  >
>  >>  >
>  >>  >
>  >>  >
>  >>  > 
> -
>  >>  > DISCLAIMER:-
>  >>  >   "The information in this e-mail is confidential, and is 
> intended
>  >>  > solely for the addressee or addressees. If you are not the intended 
> recipient,
>  >>  >  please delete the mail and kindly notify the sender of misdelivery. 
> Any
>  >>  > unauthorised use or disclosure of the contents of the mail is not 
> permitted
>  >>  > and may be unlawful."
>  >>  > 
> -
>  >>  >
>  >>  >  "Scanned By MailScanner"
>  >>  >
>  >>  >
>  >>
>  >>
>  >>  --
>  >>  PHP General Mailing List (http://www.php.net/)
>  >>  To unsubscribe, visit: http://www.php.net/unsub.php
>  >>
>  >>
>  >
>  > Since Zoltán give you the answer I might give you another fish.  Which
>  > one is more readable:
>  >
>  > 
>  > 
>  > 
>  >   > if ($datatype=="text" || $datatype=="integer") {
>  >echo "";
>  > }
>  > elseif ($datatype=="textarea") {
>  >  echo "  > name=\"field_data\">";
>  >  }
>  >  echo "";
>  > }
>  > ?>
>  >
>  >
>  > 
>  > 
>  >   
>  >
>  >   
>  >   
>  > 
>  >   
>  >name="field_data">
>  >   
>  >   
>  >  
>  >
>  > 
>
>  This is more readable
>
>while ( $row = mysql_fetch_row($result_set) ) {
>
># Extract all data fields from result set
>list($datatype,$field_id,$field_name,etc...) = $row;
>
># Initialize or clear variable
>$field = '';
>
># Check to see if it requires a text field
>
>if ( $datatype == "text" || $datatype == "integer" ) {
>
>  # Create Text field
>  $field = '';
>
># Check to see if it requires a text area
>} elseif ( $datatype == "textarea" ) {
>
>  # Create Text Area
>  $field = ' name="field_data[{$field_id}]">'.
>   '';
>
>}
># Display it all
>echo <<  
>{$field_name}
>{$field}
>  
>  ROW;
>  }
>  ?>
>
>
>  --
>  Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
>  Twelfth Night, Act II, Scene V
>  by William Shakespeare
>

Not really.  Also you aren't escaping your output.


[PHP]

2008-03-14 Thread John Taylor-Johnston
Am coding something. Cannot quite clear my head. I know what my SQL 
looks like. I just cannot see clearly to input it.
What is $_POST["checkregion"] going to look like? Is it going to have 
all the convenient commas I will need in my SQL? Or do I have to parse 
God knows how many checkboxes?

John


A
A



$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', 'Knowlton,Thetford Mines') ';


CREATE TABLE IF NOT EXISTS `GLApplications` (
 `Name` varchar(200) NOT NULL,
set(''Knowlton','Thetford Mines','Clarenceville','Sawyerville','Laval') 
NOT NULL,

 `dummy` int(10) NOT NULL auto_increment,
 PRIMARY KEY  (`dummy`)
)

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



[PHP] Re:

2008-03-14 Thread John Taylor-Johnston

http://www.glquebec.org/English/test.php
When I check "Knowlton" and "Thetford Mines" or others, only "Thetford 
Mines" shows up in phpinfo(). $_POST["checkregion"] only sees "Thetford 
Mines".
What am I doing wrong? How do I parse value checkregion? Or set this up 
differently?




A
A



CREATE TABLE IF NOT EXISTS `GLApplications` (
 `Name` varchar(200) NOT NULL,
set(''Knowlton','Thetford Mines','Clarenceville','Sawyerville','Laval') 
NOT NULL,

 `dummy` int(10) NOT NULL auto_increment,
 PRIMARY KEY  (`dummy`)
)



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



[PHP] Re:

2008-03-14 Thread John Taylor-Johnston

$_POST["checkregion"] is supposed to be an array, no?

John Taylor-Johnston wrote:

http://www.glquebec.org/English/test.php
When I check "Knowlton" and "Thetford Mines" or others, only "Thetford 
Mines" shows up in phpinfo(). $_POST["checkregion"] only sees 
"Thetford Mines".
What am I doing wrong? How do I parse value checkregion? Or set this 
up differently?




value="Knowlton">A
A



CREATE TABLE IF NOT EXISTS `GLApplications` (
 `Name` varchar(200) NOT NULL,
set(''Knowlton','Thetford 
Mines','Clarenceville','Sawyerville','Laval') NOT NULL,

 `dummy` int(10) NOT NULL auto_increment,
 PRIMARY KEY  (`dummy`)
)





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



Re: [PHP] Re:

2008-03-14 Thread Robert Cummings

On Fri, 2008-03-14 at 23:14 -0400, John Taylor-Johnston wrote:
> $_POST["checkregion"] is supposed to be an array, no?

You want the following (otherwise each checked entry overwrites the
previous):




Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Re:

2008-03-14 Thread John Taylor-Johnston

Ah! ok,

Array
(
[0] => Hemmingford
[1] => Huntingdon
)

How do I set up my $sql?

$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', '".implode(',', $_POST['myvalues']."') ';


... Hey!! What is this?

Diagnostic-Code: smtp; 550-5.7.1 mail rejected by policy.  SURBL hit 
550-Spammy
URLs in your message 550 See 
http://master.php.net/mail/why.php?why=SURBL



Robert Cummings wrote:

On Fri, 2008-03-14 at 23:14 -0400, John Taylor-Johnston wrote:

$_POST["checkregion"] is supposed to be an array, no?


You want the following (otherwise each checked entry overwrites the
previous):




Cheers,
Rob.


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



Re: [PHP] Re:

2008-03-14 Thread John Taylor-Johnston

Will this do it?

> $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> values ('John', '".implode(',', serialise($_POST['checkregion'])."') ';

http://ca.php.net/manual/en/function.serialize.php



Array
(
[0] => Hemmingford
[1] => Huntingdon
)






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



Re: [PHP] Re:

2008-03-14 Thread John Taylor-Johnston

Sorry, will this work?

$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', '".serialise($_POST['checkregion'])."') ';


John Taylor-Johnston wrote:

Will this do it?

 > $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
 > values ('John', '".implode(',', serialise($_POST['checkregion'])."') ';

http://ca.php.net/manual/en/function.serialize.php



Array
(
[0] => Hemmingford
[1] => Huntingdon
)






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



Re: [PHP] Re:

2008-03-14 Thread Robert Cummings

On Sat, 2008-03-15 at 00:18 -0400, John Taylor-Johnston wrote:
> Sorry, will this work?
> 
> $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> values ('John', '".serialise($_POST['checkregion'])."') ';

Depends on what you want to do with the data. But you've certainly
spelled serialize() wrong as it regards usage in PHP.

Cheers,
Rob.



> 
> 
> John Taylor-Johnston wrote:
> > Will this do it?
> > 
> >  > $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> >  > values ('John', '".implode(',', serialise($_POST['checkregion'])."') ';
> > 
> > http://ca.php.net/manual/en/function.serialize.php
> > 
> > 
> >> Array
> >> (
> >> [0] => Hemmingford
> >> [1] => Huntingdon
> >> )
> >>
> >>> 
> >>> 
> 
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Re:

2008-03-14 Thread John Taylor-Johnston

Robert,


Array
(
[0] => Hemmingford
[1] => Huntingdon
)

You want the following (otherwise each checked entry overwrites the
previous):




How would you proceed?

$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', '". ?? ."') ';

I'm just guessing.


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



Re: [PHP] Re:

2008-03-14 Thread Robert Cummings

On Sat, 2008-03-15 at 00:33 -0400, John Taylor-Johnston wrote:
> Robert,
> 
>  Array
>  (
>  [0] => Hemmingford
>  [1] => Huntingdon
>  )
> > You want the following (otherwise each checked entry overwrites the
> > previous):
> > 
> > 
> 
> How would you proceed?
> 
> $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> values ('John', '". ?? ."') ';
> 
> I'm just guessing.

It depend son what you want to do with the data. It may be that you want
a row for every selected entry or it may be that you can just serialize
the data. Do you want to just have a snapshot of what the user chose? Or
do you want to be able to query the database about who selected
"Knowlton"? If the former, then you can get away with just serializing
the data, but if you want to be able to do queries, then you need to
store each entry in its own row.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Re:

2008-03-14 Thread John Taylor-Johnston

Robert Cummings wrote:

On Sat, 2008-03-15 at 00:33 -0400, John Taylor-Johnston wrote:

Robert,


Array
(
[0] => Hemmingford
[1] => Huntingdon
)

You want the following (otherwise each checked entry overwrites the
previous):



How would you proceed?

$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', '". ?? ."') ';

I'm just guessing.


It depend son what you want to do with the data. It may be that you want
a row for every selected entry or it may be that you can just serialize
the data. Do you want to just have a snapshot of what the user chose? Or
do you want to be able to query the database about who selected
"Knowlton"? If the former, then you can get away with just serializing
the data, but if you want to be able to do queries, then you need to
store each entry in its own row.

Cheers,
Rob.


It would look like:

$sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
values ('John', 'Montreal,Knowlton,anything') ';

checkregion[5] = "Montreal";
checkregion[7] = "Knowlton";
checkregion[55] = "anything";

I need to unarray checkregion[] and break it up into separate words and 
then separate them by commas.


Hmm?

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



Re: [PHP] Re:

2008-03-14 Thread Robert Cummings

On Sat, 2008-03-15 at 01:00 -0400, John Taylor-Johnston wrote:
> Robert Cummings wrote:
> > On Sat, 2008-03-15 at 00:33 -0400, John Taylor-Johnston wrote:
> >> Robert,
> >>
> >> Array
> >> (
> >> [0] => Hemmingford
> >> [1] => Huntingdon
> >> )
> >>> You want the following (otherwise each checked entry overwrites the
> >>> previous):
> >>> 
> >>> 
> >> How would you proceed?
> >>
> >> $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> >> values ('John', '". ?? ."') ';
> >>
> >> I'm just guessing.
> > 
> > It depend son what you want to do with the data. It may be that you want
> > a row for every selected entry or it may be that you can just serialize
> > the data. Do you want to just have a snapshot of what the user chose? Or
> > do you want to be able to query the database about who selected
> > "Knowlton"? If the former, then you can get away with just serializing
> > the data, but if you want to be able to do queries, then you need to
> > store each entry in its own row.
> > 
> > Cheers,
> > Rob.
> 
> It would look like:
> 
> $sql ='insert into `database`.`table` (`Nom` ,`checkregion`)
> values ('John', 'Montreal,Knowlton,anything') ';
> 
> checkregion[5] = "Montreal";
> checkregion[7] = "Knowlton";
> checkregion[55] = "anything";
> 
> I need to unarray checkregion[] and break it up into separate words and 
> then separate them by commas.

$regions = implode( ',', $checkregion );

$sql =
"INSERT INTO `database`.`table` "
   ."( "
   ."`Nom`, "
   ."`checkregion` "
   .") "
   ."VALUES "
   ."( "
   ."'".mysql_real_escape_string( $nom, $conn )."', "
   ."'".mysql_real_escape_string( $regions, $conn )."' "
   .") ";

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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