php-general Digest 18 Nov 2001 21:21:48 -0000 Issue 1002

Topics (messages 75024 through 75038):

Re: What's wrong with this date ?
        75024 by: Andrew Forgue
        75026 by: Fred

Changing var value from int to string
        75025 by: phantom
        75033 by: Shane Wright

Re: Form's : making me sick!
        75027 by: Papp Gyozo

Re: [PHP-DEV] ldap_search sort extension, patch included
        75028 by: Stig Venaas
        75030 by: Andre Oppermann
        75035 by: Stig Venaas
        75037 by: Andre Oppermann

Re: Difference of queries in PHP/mySQL?
        75029 by: Jason G.

Quiz questions on PHP
        75031 by: Srinivasan Ramakrishnan
        75032 by: Shane Wright

Re: Standalone PHP Application
        75034 by: Shane Wright

Error running ./configure (c++ error)
        75036 by: Roy Sigurd Karlsbakk

extract() question
        75038 by: David Bernier

Administrivia:

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

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

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


----------------------------------------------------------------------
--- Begin Message ---
Well it should be '$date',

Also.. If the column type is date and you are entering it for a form,
check to make sure you are typing it in ok and you trim() the variable

if It still doest work... do a <? print $query ?> before the mysql_query()
and see exactly what its inserting...





-----Original Message-----
From: trongduc [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 17, 2001 8:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP] What's wrong with this date ?


hi there,
I try to save a record (in the "date" type in MySQL) from the <INPUT
type=text> by :

$query = "INSERT INTO $table VALUES  ($post_id, 0, '$topic', '$uname',
'$body', $date, '$newdate', 0) ";

But it couldn't work (I used $date or '$date' on above, but they got the
same results) !

It showed me the wrong value, as : 1970-0-0 (always this, although I try to
input different values in the text box with the date format is YYYY-MM-DD)
I don't understand the way MySQL saves my date field in his data (is it
YYYY-MM-DD ?)

Can anyone help me in this case ?
Thanks much...

ps : I used the $date field in "varchar(20) type" instead. BWT, what's
different beween the Varchar(length) type with the Char(length) type ?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
Do yourself a favor and read the mysql manual.  It explicitly answers your
questions and many more you are likely to have.  Furthermore, there is a
searchable manual online at mysql.com that makes it rather easy to find
answers about mysql.

To get you started, here is a link to a description of all of the column
types includeing date, varchar and char.

Good Luck
Fred

Trongduc <[EMAIL PROTECTED]> wrote in message
000201c16ff6$ff36e470$1b0b10ac@d">news:000201c16ff6$ff36e470$1b0b10ac@d...
> hi there,
> I try to save a record (in the "date" type in MySQL) from the <INPUT
> type=text> by :
>
> $query = "INSERT INTO $table VALUES  ($post_id, 0, '$topic', '$uname',
> '$body', $date, '$newdate', 0) ";
>
> But it couldn't work (I used $date or '$date' on above, but they got the
> same results) !
>
> It showed me the wrong value, as : 1970-0-0 (always this, although I try
to
> input different values in the text box with the date format is YYYY-MM-DD)
> I don't understand the way MySQL saves my date field in his data (is it
> YYYY-MM-DD ?)
>
> Can anyone help me in this case ?
> Thanks much...
>
> ps : I used the $date field in "varchar(20) type" instead. BWT, what's
> different beween the Varchar(length) type with the Char(length) type ?
>


--- End Message ---
--- Begin Message ---
Is there any inherit danger or taboos against changing the value of a
variable from an integer to a string?

example:

if ($Msg==1) $Msg = "You have foobar'ed your entire server.";

Thanks.



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

Hi

Nope, this is fine

[not necessarily good programming practise mind, but thats a different 
story...]

--
Shane

On Sunday 18 Nov 2001 6:13 am, phantom wrote:
> Is there any inherit danger or taboos against changing the value of a
> variable from an integer to a string?
>
> example:
>
> if ($Msg==1) $Msg = "You have foobar'ed your entire server.";
>
> Thanks.
--- End Message ---
--- Begin Message ---
 > I just want to know how to make a <form> inside a <form> get to respond or
 > dont make any browser errors?

This is prohibited by either SGML DTDs if HTML 
4.01(http://www.w3.org/TR/html4/interact/forms.html#h-17.3):

<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->

and XML DTDs of XHTML 1.0 (http://www.w3.org/TR/xhtml1/#prohibitions)
"form 
    cannot contain other form elements."

So, it is a good reason why browsers don't like it.

Respect to your original problem, value of element <select> can be changed by 
JavaScript
without submitting the whole form.

Here is a little example (this behaves like a combobox ,common input + select with 
history list):

<input type="text" name="combo_input" style="width:5em" 
    onKeypress="combo_select.value=''; return true;"><br>
 <select name="combo_select" style="width:5em" tabindex=-1
    onChange="combo_input.value=combo_select.value; return true;" 
    onFocus="this.blur; return true;">
  <option value="one">one</option>
  <option value="two">two</option>
  <option value="three">three</option>
 </select>

----- Original Message ----- 
From: "Steve Maroney" <[EMAIL PROTECTED]>
To: "George Pitcher" <[EMAIL PROTECTED]>
Cc: "De Necker Henri" <[EMAIL PROTECTED]>; "PHP-General (E-mail)" 
<[EMAIL PROTECTED]>
Sent: Saturday, November 17, 2001 8:18 PM
Subject: Re: [PHP] Form's : making me sick!


> Thats sounds right becasuse anything between <form> ... </form> can only
> will be passeed only to one script.
> 
> Steve
> 
> On Tue, 13 Nov 2001, George Pitcher wrote:
> 
> > I don't think that you can nest forms.
> >
> > George
> >
> > ----- Original Message -----
> > From: "De Necker Henri" <[EMAIL PROTECTED]>
> > To: "PHP-General (E-mail)" <[EMAIL PROTECTED]>
> > Sent: Tuesday, November 13, 2001 1:09 PM
> > Subject: [PHP] Form's : making me sick!
> >
> >
> > > I just want to know how to make a <form> inside a <form> get to respond or
> > > dont make any browser errors?
> > >
> > > It looks someting like this :
> > >
> > > <form>
> > > <input type = "text">
> > > <input type = "text">
> > > <form>
> > > <select onchange = "this.form.submit();">   //This must
> > > change the next <select> values !
> > > </select>
> > > </form>
> > > <select>
> > > //this values must be cahnge
> > > </select>
> > > </form>
> > >
> > > Everthing is working fine but i just cant get the two forms to work
> > > together.If i only can get some ideas on what action,or onchange values to
> > > change it will be greatfull!
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> 
> 
> 
> 
> 
> 
> Thank you,
> Steve Maroney
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
--- End Message ---
--- Begin Message ---
On Sat, Nov 17, 2001 at 11:22:21PM +0100, Andre Oppermann wrote:
> Stig Venaas wrote:
> > In what LDAP APIs are ldap_sort_entries defined? What lib/API are you
> > using? I wonder how well this works, sorting all kinds of Unicode is
> > more or less impossible, but if some APIs have this function...
> 
> This function is supported by OpenLDAP 1.x/2.x, UMICH and Netscape
> SDK as well.

Ah, okay, didn't know, maybe because it isn't mentioned in the specs.
I'm much more positive then.

> Unicode is no problem because you can specify your own comparsion
> function callback (the last parameter "strcmpncase").

Yes, I realized after my post. But isn't this a problem for us? We might
have to allow for people to define their own PHP callback function. I
could fix that, if that's what we want. We could add that as an optional
parameter later perhaps. The way UTF-8 behaves, I guess sorting order is
the same before and after decoding, if not, this function doesn't make
much sense (except when ascii-only being used). You have experiences with
German umlauts perhaps? But for simple things like Norwegian (and I know
others), the special character values are not in alphabetical order, so
this function isn't going to do the job perfectly, a userdefined function
might.

> > I was also thinking of adding support for server side sorting. I'm
> The problem with server side sorting is that it is a LDAPv3 only
> function and there is no requirement that LDAP server implements
> this.

Yes, and if you want all entries, it makes more sense to do it in the
client.
> 
> > thinking of a different PHP API, so that we don't need to add even
> > more parameters to ldap_search(). Adding parameters to ldap_search()
> 
> I added it only to ldap_search() because only there I have access to
> the full LDAPMessage chain. The function needs **ldap_res, not just
> the *ldap_res that is delivered by that internal function in PHP.
> 
> > that only are valid with some APIs is bad I think. What I have in
> > mind is something like:
> 
> ldap_search is valid with basically every ldap lib out there.

I meant parameters that are only valid in some APIs, of course
ldap_search is.

> > ldap_sort($ld, $sortfilter);
> > ldap_search($ld,...); (as usual)
> > 
> > where the filter is used for all following searches, until a new filter
> > is defined. Empty filter could turn it off.
> 
> Until now the right thing to do (see ldapsearch tool in OpenLDAP/UMICH)
> to do this:
> 
>  ldap_search($ld,...);
>  ldap_sort($ld, $res, $sortlist, [OPT_UNICODE | WHATEVER]);

What I wrote with ldap_sort() and ldap_search() was PHP code. I suggest
we write a separate ldap_sort() that works this way. ldap_sort() can
then store stuff in the PHP link structure. Inside PHP's ldap_search()
function, we then check for this after we've done the search. So it
will be very much like your code, except that instead of an extra
parameter for PHP's ldap_search(), we use a separate ldap_sort() to set
it. We can then also add advanced features like user defined callback
more easily.

> Well, there no problem in providing both API. The ldap_sort() call is
> useable today with all ldap libs and with any LDAP server. Server side
> sorting is nice if you have LDAPv3 and your server supports it.

Of course server side sorting also has the ordering issues I mentioned
above. It's mostly impossible to write server side sorting that always
sorts things the right way. Language tags might help. Well, forget this.

I'll add some code for this in a few days, then you can comment on what
I've done. Not that I mind discussing this (:

Stig
--- End Message ---
--- Begin Message ---
Stig Venaas wrote:
> 
> On Sat, Nov 17, 2001 at 11:22:21PM +0100, Andre Oppermann wrote:
> > Stig Venaas wrote:
> > > In what LDAP APIs are ldap_sort_entries defined? What lib/API are you
> > > using? I wonder how well this works, sorting all kinds of Unicode is
> > > more or less impossible, but if some APIs have this function...
> >
> > This function is supported by OpenLDAP 1.x/2.x, UMICH and Netscape
> > SDK as well.
> 
> Ah, okay, didn't know, maybe because it isn't mentioned in the specs.
> I'm much more positive then.

It's not in the LDAP API RFC but universally supported.

> > Unicode is no problem because you can specify your own comparsion
> > function callback (the last parameter "strcmpncase").
> 
> Yes, I realized after my post. But isn't this a problem for us? We might
> have to allow for people to define their own PHP callback function. I
> could fix that, if that's what we want. We could add that as an optional
> parameter later perhaps. The way UTF-8 behaves, I guess sorting order is
> the same before and after decoding, if not, this function doesn't make
> much sense (except when ascii-only being used). You have experiences with
> German umlauts perhaps? But for simple things like Norwegian (and I know
> others), the special character values are not in alphabetical order, so
> this function isn't going to do the job perfectly, a userdefined function
> might.

Defining a PHP callback funtion is probably too complex. But having
different options for sort algorithms would useful:

 LDAP_SORT_ASCII, strncasecmp, default
 LDAP_SORT_ASCII_CASE, strcmp
 LDAP_SORT_UTF8, ???
 LDAP_SORT_UNICODE, ???
 ...

The function would look like this:

 (PHP_)ldap_search($ld, $res, "c, city", LDAP_SORT_ASCII);

> > > I was also thinking of adding support for server side sorting. I'm
> > The problem with server side sorting is that it is a LDAPv3 only
> > function and there is no requirement that LDAP server implements
> > this.
> 
> Yes, and if you want all entries, it makes more sense to do it in the
> client.

Yes.

> > > thinking of a different PHP API, so that we don't need to add even
> > > more parameters to ldap_search(). Adding parameters to ldap_search()
> >
> > I added it only to ldap_search() because only there I have access to
> > the full LDAPMessage chain. The function needs **ldap_res, not just
> > the *ldap_res that is delivered by that internal function in PHP.
> >
> > > that only are valid with some APIs is bad I think. What I have in
> > > mind is something like:
> >
> > ldap_search is valid with basically every ldap lib out there.
> 
> I meant parameters that are only valid in some APIs, of course
> ldap_search is.

Sorry, braino, should have been ldap_sort is valid with basically every
ldap lib out there.

> > > ldap_sort($ld, $sortfilter);
> > > ldap_search($ld,...); (as usual)
> > >
> > > where the filter is used for all following searches, until a new filter
> > > is defined. Empty filter could turn it off.
> >
> > Until now the right thing to do (see ldapsearch tool in OpenLDAP/UMICH)
> > to do this:
> >
> >  ldap_search($ld,...);
> >  ldap_sort($ld, $res, $sortlist, [OPT_UNICODE | WHATEVER]);
> 
> What I wrote with ldap_sort() and ldap_search() was PHP code. I suggest

I wrote PHP code as well ;)

> we write a separate ldap_sort() that works this way. ldap_sort() can
> then store stuff in the PHP link structure. Inside PHP's ldap_search()
> function, we then check for this after we've done the search. So it
> will be very much like your code, except that instead of an extra
> parameter for PHP's ldap_search(), we use a separate ldap_sort() to set
> it. We can then also add advanced features like user defined callback
> more easily.
> 
> > Well, there no problem in providing both API. The ldap_sort() call is
> > useable today with all ldap libs and with any LDAP server. Server side
> > sorting is nice if you have LDAPv3 and your server supports it.
> 
> Of course server side sorting also has the ordering issues I mentioned
> above. It's mostly impossible to write server side sorting that always
> sorts things the right way. Language tags might help. Well, forget this.
> 
> I'll add some code for this in a few days, then you can comment on what
> I've done. Not that I mind discussing this (:

Ok, lets see what you come up with. :)

-- 
Andre
--- End Message ---
--- Begin Message ---
On Sun, Nov 18, 2001 at 01:27:18PM +0100, Andre Oppermann wrote:
> Stig Venaas wrote:
> > 
> > On Sat, Nov 17, 2001 at 11:22:21PM +0100, Andre Oppermann wrote:
> > > Stig Venaas wrote:
> 
> Defining a PHP callback funtion is probably too complex. But having
> different options for sort algorithms would useful:
> 
>  LDAP_SORT_ASCII, strncasecmp, default
>  LDAP_SORT_ASCII_CASE, strcmp
>  LDAP_SORT_UTF8, ???
>  LDAP_SORT_UNICODE, ???
>  ...
> 
> The function would look like this:
> 
>  (PHP_)ldap_search($ld, $res, "c, city", LDAP_SORT_ASCII);

Right (except that I want it to be (PHP_)ldap_sort (maybe
(PHP_)ldap_sort_entries). Think I'll implement it without that last
parameter, at least at first. I still think callback could be useful,
but that's also we can add later if necessary. Have you seen
ldap_sort_entries() implementations that allow multiple attributes? I
haven't seen that yet. I also see that at least OpenLDAP and Netscape
allow sorting on DN if attribute is NULL, I guess we could let empty
string do that.

> > > Until now the right thing to do (see ldapsearch tool in OpenLDAP/UMICH)
> > > to do this:
> > >
> > >  ldap_search($ld,...);
> > >  ldap_sort($ld, $res, $sortlist, [OPT_UNICODE | WHATEVER]);
> > 
> > What I wrote with ldap_sort() and ldap_search() was PHP code. I suggest
> 
> I wrote PHP code as well ;)

Oops, too early in the morning. I'll try to implement it this way, it's
the best PHP API I think (except that I drop the 4th parameter, at least
for now).

Stig
--- End Message ---
--- Begin Message ---
Stig Venaas wrote:
> 
> On Sun, Nov 18, 2001 at 01:27:18PM +0100, Andre Oppermann wrote:
> > Stig Venaas wrote:
> > >
> > > On Sat, Nov 17, 2001 at 11:22:21PM +0100, Andre Oppermann wrote:
> > > > Stig Venaas wrote:
> >
> > Defining a PHP callback funtion is probably too complex. But having
> > different options for sort algorithms would useful:
> >
> >  LDAP_SORT_ASCII, strncasecmp, default
> >  LDAP_SORT_ASCII_CASE, strcmp
> >  LDAP_SORT_UTF8, ???
> >  LDAP_SORT_UNICODE, ???
> >  ...
> >
> > The function would look like this:
> >
> >  (PHP_)ldap_search($ld, $res, "c, city", LDAP_SORT_ASCII);
> 
> Right (except that I want it to be (PHP_)ldap_sort (maybe
> (PHP_)ldap_sort_entries). Think I'll implement it without that last

Ugh... I meant ldap_sort of course. I'm always automagically writing
it wrong... :(

> parameter, at least at first. I still think callback could be useful,
> but that's also we can add later if necessary. Have you seen
> ldap_sort_entries() implementations that allow multiple attributes? I
> haven't seen that yet. I also see that at least OpenLDAP and Netscape
> allow sorting on DN if attribute is NULL, I guess we could let empty
> string do that.

You can specify many attributes to sort for. Simply put them into a
comma separated list.

> > > > Until now the right thing to do (see ldapsearch tool in OpenLDAP/UMICH)
> > > > to do this:
> > > >
> > > >  ldap_search($ld,...);
> > > >  ldap_sort($ld, $res, $sortlist, [OPT_UNICODE | WHATEVER]);
> > >
> > > What I wrote with ldap_sort() and ldap_search() was PHP code. I suggest
> >
> > I wrote PHP code as well ;)
> 
> Oops, too early in the morning. I'll try to implement it this way, it's
> the best PHP API I think (except that I drop the 4th parameter, at least
> for now).

Ok.

-- 
Andre
--- End Message ---
--- Begin Message ---
Check the return value of mysql_query().  It should either evaluate to 
false, or true.  If false, then output some error messages using 
mysql_error() and mysql_errno().

-JasonGarber
IonZoftDotCom

At 01:29 PM 11/17/2001 -0500, Jeff Lewis wrote:
>I am wondering if there are any difference between using PHP and using the
>command line for mySQL.  Entering this at the comman line returns all the
>membergroups properly.  When I use this in my PHP program, it doesn't
>continue past this line:
>
>$request = mysql_query("SELECT membergroup FROM membergroups WHERE 1 ORDER
>BY ID_GROUP");
>
>
>Jeff
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

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

I'm preparing a quiz on PHP for some programmers. I was wondering if there
are good questions that I can use instead of inventing my own.

I'm also evaluating any quizzing software out there that will allow me to
conduct it. Actually I'm in the process of throwing together a script to do
that, but I'm guessing any prefab script will be more feature packed. Do you
know of any?

Cheers,
-Srini
--
http://www.symonds.net/~sriniram

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

Hi

Have a look at the PHP tests on Brainbench.com - they're of a different ilk 
but may be useful (I think they're still free)...

[dunno about the copyright though - but it should say on the site, if nothign 
else it might help with some pointers]

--
Shane

On Sunday 18 Nov 2001 12:43 pm, Srinivasan Ramakrishnan wrote:
> Hi,
>
> I'm preparing a quiz on PHP for some programmers. I was wondering if there
> are good questions that I can use instead of inventing my own.
>
> I'm also evaluating any quizzing software out there that will allow me to
> conduct it. Actually I'm in the process of throwing together a script to do
> that, but I'm guessing any prefab script will be more feature packed. Do
> you know of any?
>
> Cheers,
> -Srini
--- End Message ---
--- Begin Message ---

Hi

You could have a look at the GTK+ bindings for PHP - AFAIK they let you write 
standalone apps.

There's info on the PHP web site ( www.php.net ).

--
Shane

>
>  I'm looking for information on using PHP for standalone applications.
>  Specifically, I need to create a PHP-based application that can be runned
>  from a CD-ROM. Have any of you done this?
>
>  Any suggestions?
>
>  On another note:
>  I need to develop a CD-ROM based Survey, where the result will be saved
>  in an external file. What software, would you recommend, to use for this?
>  I'm currently using Multimedia Builder, and was wondering if
>  there is something better.
>
>  I need something that allows customization(via scripting) and more
>  interaction with external files/commands.
>  Any help would be appreciated.
>
>  Thanks!
>
>  -John
>
>
>
> __________John Monfort_________________
> _+-----------------------------------+_
>      P E P I E  D E S I G N S
>        www.pepiedesigns.com
> "The world is waiting, are you ready?"
> -+___________________________________+-
--- End Message ---
--- Begin Message ---
Hi all

I try to ./configure php to run on a just-upgraded rh72 box, but it tells
me c++ cannot create executables.

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-msql \
        --enable-inline-optimization --enable-ftp
check...
check...
check...
checking for c++... c++
checking whether the C++ compiler (c++   -Wl,-rpath,/usr/local/Hughes/lib 
-L/usr/local/Hughes/lib) works... no
configure: error: installation or configuration problem: C++ compiler cannot create 
executables.

The following c++-like stuff is installed

# rpm -qa | grep ++
libstdc++-2.96-98
gcc-c++-2.96-98
libstdc++3-devel-3.0.1-3
libsigc++-1.0.3-5
compat-libstdc++-6.2-2.9.0.16
libstdc++-devel-2.96-98
libstdc++3-3.0.1-3
gcc3-c++-3.0.1-3
compat-egcs-c++-6.2-1.1.2.16
libsigc++-devel-1.0.3-5

Thanks a lot

roy
--
Roy Sigurd Karlsbakk, MCSE, MCNE, CLS, LCA

Computers are like air conditioners.
They stop working when you open Windows.


--- End Message ---
--- Begin Message ---
There is this array which I would like to convert into a series variables using the 
extract function: 

<?
$oz = array(
 "lion" => "courage", 
 "dorothy" => "kansas", 
 "scarecrow" => "brain"
 "tin man" => "heart"); 

extract($oz);
?>

now, I would like to access my new variables. it is obviously easy for $lion, 
$dorothy, and $scarecrow but it isn't for "tin man".

from this, I have 3 or 4 questions:
1) has $oz["tin man"] been passed into a variable?
2) if yes, how do I access the variable that came out of $oz["tin man"]?
3) let's pretend that I have no control over the names of the keys for $oz, how should 
I have called extract() to tell it to replace the space between "tin" and "man" by a 
underscore character?
4)  finally, is there a way to access and retrieve that values of the symbol table 
without knowing their names?

David

--- End Message ---

Reply via email to