php-general Digest 16 Jan 2005 22:48:32 -0000 Issue 3231

Topics (messages 206465 through 206489):

PHP date returns wrong value ??
        206465 by: Michael Gale
        206479 by: Jason Wong

Re: Adding up query results
        206466 by: Chris

which is best php editor?
        206467 by: QT
        206469 by: Ville Mattila
        206471 by: Michelle Konzack
        206472 by: trobi
        206480 by: QT

Re: Protected Mail System
        206468 by: allan.lodestone.co.za

Re: SMTP Server
        206470 by: eriksson.php.net

printer_open() command in redhatlinux 9, php 4.3.9
        206473 by: Muditha Fernando

Any idea when 4.3.11 will be released?
        206474 by: Gal
        206475 by: Jeffery Fernandez
        206478 by: Gal
        206485 by: DvDmanDT

Only variables can be passed by reference -  Preg_match Fatal error
        206476 by: Chandana Bandara
        206477 by: Adrian

Re: Comman line vs. phpinfo()
        206481 by: Joseph E. Maxwell
        206484 by: DvDmanDT
        206487 by: Marek Kilimajer

Problem with foreatch()
        206482 by: Ben Edwards (lists)
        206483 by: DvDmanDT
        206486 by: James Kaufman

Re: Persistent PHP web application?
        206488 by: Zouari Fourat

socket_connect giving me weird error
        206489 by: Adam Hubscher

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hello,

I have a web page that loads php code from another file using include, the second file calls a function from a third file after doing a include on it.

I am running php 4.3.7

Below is the snip of code that gets called to update the database. The problem is with the tentry_time value.

The part of the code:
$query .= " tentry_time = '" . date("H:j:s") . "',";

For some reason ... the value for seconds is always off, if I do a update, then another one right way, the value that gets stored in the database for the second entry will occure before the first according to the number of seconds.

Here is some data from the DB after a select statement, you can see that the times do not follow the auto-increment value (first field).
26 | 15 | 2005-01-15 | 23:15:27 | 1 | 90 | Testing updates |

27 | 15 | 2005-01-15 | 23:15:33 | 1 | 90 | Another update ... |

28 | 15 | 2005-01-15 | 23:15:07 | 1 | 90 | Testing a 4 entry


--snip--
if (($_POST) AND (isset($_POST['newentry']))) {
$check=0;
if ($_POST['ticket_id'] != $ticket) {
$check=1;
$status="<li class=error>ERROR -- YOU DO NOT HAVE ACCESS TO THIS TICKET !!!!!</li>\n";
}

if ($check==0) {
$query="INSERT INTO tentry_table SET ticket_id = '" . $ticket . "',";
$query .= " tentry_date = '" . date("Y-m-d") . "',";
$query .= " tentry_time = '" . date("H:j:s") . "',";
$query .= " tentry_rep = '" . $_SESSION['userid'] . "',";
if ((isset($_POST['tentry_ctime'])) AND $_POST['tentry_ctime'] > 5 and $_POST['tentry_ctime'] < 90) {
$query .= " tentry_ctime = '" . mysql_real_escape_string($_POST['tentry_ctime']) . "',";
} else {
$query .= " tentry_ctime = '90',";
}
if ((isset($_POST['tentry_body'])) AND strlen($_POST['tentry_body']) > 5) {
$query .= " tentry_body = '" . mysql_real_escape_string($_POST['tentry_body']) . "'";
} else {
$status="<li class=error>ERROR with entry -- appears to be empty !!!!!</li>\n";
$check=1;
}
--snip--


Anyone have any ideas ??

Michael.
--- End Message ---
--- Begin Message ---
On Sunday 16 January 2005 15:22, Michael Gale wrote:

Not a direct answer to your problem ...

>   $query="INSERT INTO tentry_table SET ticket_id = '" . $ticket . "',";
>   $query .= " tentry_date = '" . date("Y-m-d") . "',";
>   $query .= " tentry_time = '" . date("H:j:s") . "',";

1) When doing something involving date/time it is best practice to assign 
date/time *once* to a variable then work off of that variable. This ensures 
that your date/time is consistent withing that block of code.

2) If there is no particular reason why you are storing the date and the time 
separately why not just use a DATETIME field? Then you can just use the 
builtin db function NOW(). Or, if that datetime never changes once assigned, 
you could even use a TIMESTAMP field.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

--- End Message ---
--- Begin Message ---
You should be able to do this:

select sum(quantity*price) from sale where dvd_id=1

Chris


Nathan Mealey wrote:

I hope someone can help with this frustratingly simple (I assume!) question I have.

I run this mysql query: "select sum(quantity)*price,price from sale where dvd_id=1 group by price";

I get this result:
sum(quantity)*price     price
        450.00        15.00
         29.99         29.99

I want to display the sum of the values in the first column (450.00+29.99), but I cannot figure out how to do this! Can someone clue me in?

Thanks a million,
Nathan
--
Nathan Mealey
Website Manager & Administrative Director
Cycle-Smart, Inc.
P.O. Box 1482
Northampton, MA
01061-1482
[EMAIL PROTECTED]
(413) 210-7984
(512) 681-7043 Fax


--- End Message ---
--- Begin Message ---
dear Sirs,

I try to use a couple of php editor, but I am not satisfied with them.

Any suggestion for good php editor.

best regards

--- End Message ---
--- Begin Message --- QT wrote:
Any suggestion for good php editor.

My favourite PHP editor is jEdit, one of the best applications ever created. =) http://www.jedit.org/

Ville
--- End Message ---
--- Begin Message ---
Am 2005-01-16 11:29:50, schrieb QT:
> dear Sirs,
> 
> I try to use a couple of php editor, but I am not satisfied with them.
> 
> Any suggestion for good php editor.

notepad.exe :-)

But I prefer mc/mcedit.

> best regards

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/ 
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

Attachment: signature.pgp
Description: Digital signature


--- End Message ---
--- Begin Message ---
Michelle Konzack  wrote / napísal (a):

Am 2005-01-16 11:29:50, schrieb QT:


dear Sirs,

I try to use a couple of php editor, but I am not satisfied with them.

Any suggestion for good php editor.



notepad.exe :-)

But I prefer mc/mcedit.



best regards



Greetings Michelle



kwrite or vi

trobi
--- End Message ---
--- Begin Message ---
hi Ville,

I just download jedit to my windows 2000. Wth my experience, jar contents
are working slow on windows. Same jedit works much slower than editplus on
my computer.

Are you using jedit with windows? can I increase performance?

Best regards

"Ville Mattila" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> QT wrote:
> > Any suggestion for good php editor.
>
> My favourite PHP editor is jEdit, one of the best applications ever
> created. =) http://www.jedit.org/
>
> Ville
>

--- End Message ---
--- Begin Message ---
Protected Mail System Test.


+++ Attachment: No Virus found
+++ MC-Afee AntiVirus - www.mcafee.com


--- End Message ---
--- Begin Message ---
Protected message is attached.


+++ Attachment: No Virus found
+++ Kaspersky AntiVirus - www.kaspersky.com


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

Can printer_open() command be used in redhatlinux 9, php 4.3.9.
It works fine under win2000.

Pls help.

Regards
Muditha Fernando

--- End Message ---
--- Begin Message ---
Hello,

I'm Working in organization which also using php on the Windows platform.
Because of the security holes in the older version and a COM bug at PHP 4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a problematic version.

Does anyone here knows - what is the status of the release of 4.3.11 ?

Regards,
Gal

--- End Message ---
--- Begin Message ---
Gal wrote:

Hello,

I'm Working in organization which also using php on the Windows platform.
Because of the security holes in the older version and a COM bug at PHP 4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a problematic version.

Does anyone here knows - what is the status of the release of 4.3.11 ?

Regards,
Gal

*[23 Dec 2004 2:43am CET] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

cheers,
JefferyFernandez
http://melbourne.ug.php.net

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

Thanks for the info.

I'm happy to read that the problem has been fixed. but i don't intend to use a CVS version on a production machine.

This is the reason i asked for info on the official 4.3.11 release date.
Do you have any idea when it is planned ?

Thanks,
Gal


Jeffery Fernandez wrote:
Gal wrote:

Hello,

I'm Working in organization which also using php on the Windows platform.
Because of the security holes in the older version and a COM bug at PHP 4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a problematic version.

Does anyone here knows - what is the status of the release of 4.3.11 ?

Regards,
Gal

*[23 Dec 2004 2:43am CET] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

cheers,
JefferyFernandez
http://melbourne.ug.php.net

--- End Message ---
--- Begin Message ---
They aren't talking about it on internals.. Not much on QA neither.. So..
Don't expect a release tomorrow.. :p CVS version might be the best option if
that bug is a problem..:p

-- 
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
"Gal" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Hi Jeffery,
>
> Thanks for the info.
>
> I'm happy to read that the problem has been fixed. but i don't intend to
> use a CVS version on a production machine.
>
> This is the reason i asked for info on the official 4.3.11 release date.
> Do you have any idea when it is planned ?
>
> Thanks,
> Gal
>
>
> Jeffery Fernandez wrote:
> > Gal wrote:
> >
> >> Hello,
> >>
> >> I'm Working in organization which also using php on the Windows
platform.
> >> Because of the security holes in the older version and a COM bug at
> >> PHP 4.3.10 (http://bugs.php.net/bug.php?id=31159) we are using a
> >> problematic version.
> >>
> >> Does anyone here knows - what is the status of the release of 4.3.11 ?
> >>
> >> Regards,
> >> Gal
> >>
> > *[23 Dec 2004 2:43am CET] [EMAIL PROTECTED]
> >
> > This bug has been fixed in CVS.
> >
> > Snapshots of the sources are packaged every three hours; this change
> > will be in the next snapshot. You can grab the snapshot at
> > http://snaps.php.net/.
> >
> > cheers,
> > JefferyFernandez
> > http://melbourne.ug.php.net

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

When i try to compile this code it gives following error.....
<b>Fatal error</b>:  Only variables can be passed by reference in 
<b>/var/www/html/hello/test.php</b> on line <b>16</b><br />

I have defined variable for to match some string patterns / symbols.
when i execute that code for   preg_match , gives this fatal error .

<?php

$user="root";
$pass="pass";
$db="database";
$pattern="[ _  :< ] >";
       
         $dblink = mysql_connect("localhost:3306", "$user", "$pass")or 
die("Could not connect to db");
         mysql_select_db($db) or die ("can't select the db");
        
         $result = mysql_query ("select ServiceNo,Reply from Acknowledgement 
order by ServiceNo") or die ("Invalid query");
         while ( $rset= mysql_fetch_array($result)) {
                /* Lets check the reply with the database*/
                $chk_msg= $rset["Reply"];
                //echo "checking $chk_msg in $msg<br>";
                if ( preg_match("$pattern","/$chk_msg/","$msg", $match) ) {
                        // match found
                        $SQL="update ServiceStatus set Status = 'UP' where 
ServiceNo=".$rset["ServiceNo"];
                        mysql_query ("$SQL") or die ("Invalid 2nd query");
                }else{
                        
                }

        }
        mysql_close($dblink);

?>

how can i prevent this problem ???


Thanx in advance
chandana

--- End Message ---
--- Begin Message ---
check your preg_match() call...

things like "$pattern" and "$msg" are the spawn of satan btw.
there is ABSOLUTELY NO REASON to put variables in quotation marks
except that php has to parse the string which is slower than php just
seeing the variable.
and when a functions expects a reference, "$variable" will cause a
fatal error like it happens in your script.

--- End Message ---
--- Begin Message ---
Just upgraded to php 4.3.10
phpinfo() apparently stuck on


PHP Version 4.3.5


System FreeBSD xxxxxxx.com 4.9-STABLE FreeBSD 4.9-STABLE #0: Wed Nov i386 Build Date Apr 11 2004 20:01:52



Command line  ==>
  php -v
  PHP 4.3.10 (cli) (built: Jan 15 2005 12:54:11)
  Copyright (c) 1997-2004 The PHP Group
  Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


Is this a php or an Apache problem. I did do an Apache restart !

Thanks
--- End Message ---
--- Begin Message ---
My guess is that something went wrong when you upgraded your PHP
installation.. Maybe you didn't recompile Apache with the new PHP version or
something..

-- 
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
"Joseph E. Maxwell" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Just upgraded to php 4.3.10
> phpinfo() apparently stuck on
>
>
>   PHP Version 4.3.5
>
>
> System FreeBSD xxxxxxx.com 4.9-STABLE FreeBSD 4.9-STABLE #0: Wed Nov i386
> Build Date Apr 11 2004 20:01:52
>
>
>
> Command line  ==>
>    php -v
>    PHP 4.3.10 (cli) (built: Jan 15 2005 12:54:11)
>    Copyright (c) 1997-2004 The PHP Group
>    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
>
>
> Is this a php or an Apache problem. I did do an Apache restart !
>
> Thanks
>

--- End Message ---
--- Begin Message --- Joseph E. Maxwell wrote:
Just upgraded to php 4.3.10
phpinfo() apparently stuck on


PHP Version 4.3.5


System FreeBSD xxxxxxx.com 4.9-STABLE FreeBSD 4.9-STABLE #0: Wed Nov i386
Build Date Apr 11 2004 20:01:52



Command line  ==>
  php -v
  PHP 4.3.10 (cli) (built: Jan 15 2005 12:54:11)
  Copyright (c) 1997-2004 The PHP Group
  Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


Is this a php or an Apache problem. I did do an Apache restart !

Thanks



Where is apache looking for the php module?
--- End Message ---
--- Begin Message ---
I have the following Code:

  foreatch( $_POST["mtype"] as $akey => $avalue ) {
    echo "$akey, $avalue<br>";
  }

When I run it I get:

  Parse error: parse error, unexpected T_AS   
  in /var/www/mb/mb_estab_update.php on line 58

58 is the line with the foreatch on it.  However if I replace it with:

  print_r( $_POST["mtype"] );    

I get:

  Array ( [1] => RESTAURANT [2] => BEVERAGEWINE [3] => MAIN )

so the array is populated, what am I doing Wrong?

Regards,
Ben
-- 
Ben Edwards - Poole, UK, England
If you have a problem sending me email use this link
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---
--- Begin Message ---
Well, it's spelled foreach, not foreatch, that's why you get the error..

-- 
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
"Ben Edwards" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
On Sun, Jan 16, 2005 at 03:20:26PM +0000, Ben Edwards (lists) wrote:
> I have the following Code:
> 
>   foreatch( $_POST["mtype"] as $akey => $avalue ) {
>     echo "$akey, $avalue<br>";
>   }
> 
> When I run it I get:
> 
>   Parse error: parse error, unexpected T_AS   
>   in /var/www/mb/mb_estab_update.php on line 58
> 
> 58 is the line with the foreatch on it.  However if I replace it with:
> 
>   print_r( $_POST["mtype"] );    
> 
> I get:
> 
>   Array ( [1] => RESTAURANT [2] => BEVERAGEWINE [3] => MAIN )
> 
> so the array is populated, what am I doing Wrong?
> 
> Regards,
> Ben

You could try:

foreach( $_POST["mtype"] as $akey => $avalue ) {
    echo "$akey, $avalue<br>";
}

--- End Message ---
--- Begin Message ---
but u dont need to reinitialise your variables every time the script
loads, u need just to init them once and u get what you want wherever
you want in your files


On Sun, 16 Jan 2005 11:38:48 +0800, Xuefer Tinys <[EMAIL PROTECTED]> wrote:
> $_SESSION is same as it use serialize/unserialize, alghough there're
> some difference
> 
> 
> On Sat, 15 Jan 2005 10:06:58 +0100, Zouari Fourat <[EMAIL PROTECTED]> wrote:
> > what about using $_SESSION arrays ?
> >
> >
> > On Fri, 14 Jan 2005 19:28:24 -0500, Al <[EMAIL PROTECTED]> wrote:
> > > George Schlossnagle addresses exactly your requirement in his book 
> > > "Advanced PHP
> > > Programming".
> > >
> > > Josh Whiting wrote:
> > > > Dear list,
> > > >
> > > > My web application (an online classifieds server) requires a set of
> > > > fairly large global arrays which contain vital information that most all
> > > > the page scripts rely upon for information such as the category list,
> > > > which fields belong to each category, and so on. Additionally, there are
> > > > a large number of function definitions (more than 13,000 lines of code
> > > > in all just for these global definitions).
> > > >
> > > > These global arrays and functions never change between requests.
> > > > However, the PHP engine destroys and recreates them every time. After
> > > > having spent some serious time doing benchmarking (using Apache Bench),
> > > > I have found that this code takes at least 7ms to parse per request on
> > > > my dual Xeon 2.4ghz server (Zend Accelerator in use*). This seriously
> > > > cuts into my server's peak capacity, reducing it by more than half.
> > > >
> > > > My question is: is there a way to define a global set of variables and
> > > > functions ONCE per Apache process, allowing each incoming hit to run a
> > > > handler function that runs within a persistent namespace? OR, is it
> > > > possible to create some form of shared variable and function namespace
> > > > that each script can tap?
> > > >
> > > > AFAIK, mod_python, mod_perl, Java, etc. all allow you to create a
> > > > persistent, long-running application with hooks/handlers for individual
> > > > Apache requests. I'm surprised I haven't found a similar solution for
> > > > PHP.
> > > >
> > > > In fact, according to my work in the past few days, if an application
> > > > has a large set of global functions and variable definitions, mod_python
> > > > FAR exceeds the performance of mod_php, even though Python code runs
> > > > significantly slower than PHP code (because in mod_python you can put
> > > > all these definitions in a module that is loaded only once per Apache
> > > > process).
> > > >
> > > > The most promising prospect I've come across is FastCGI, which for Perl
> > > > and other languages, allows you to run a while loop that sits and
> > > > receives incoming requests (e.g. "while(FCGI::accept() >= 0) {..}").
> > > > However, the PHP/FastCGI modality seems to basically compare to mod_php:
> > > > every request still creates and destroys the entire application
> > > > (although the PHP interpreter itself does persist).
> > > >
> > > > Essentially I want to go beyond a persistent PHP *interpreter* (mod_php,
> > > > PHP/FastCGI) and create a persistent PHP *application*... any
> > > > suggestions?
> > > >
> > > > Thanks in advance for any help!
> > > > Regards,
> > > > J. Whiting
> > > >
> > > > * - Please note that I am using the Zend Accelerator (on Redhat
> > > > Enterprise with Apache 1.3) to cache the intermediate compiled PHP code.
> > > > My benchmarks (7ms+) are after the dramatic speedup provided by the
> > > > accelerator. I wouldn't even bother benchmarking this without the
> > > > compiler cache, but it is clear that a compiler cache does not prevent
> > > > PHP from still having to run the (ableit precompiled) array and function
> > > > definition code itself.
> > >
> > > --
> > > 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
> >
> >
>

--- End Message ---
--- Begin Message --- Warning: socket_connect() expects parameter 3 to be long, string given in testing.php on line 21
Couldn't Create Socket: Success

It actually spits that across for every socket I'm trying to connect.

I'm doing an online status for multiple servers, which I have tested to work when I simply do a socket_connect($sock,$url,$port); on the port numbers of the various servers. The servers all reside on the same IP address.

The script actually works manually, ie if i put the actual port in to the socket_connect function call. However, as soon as I put the variable in - it wont work.

The code looks like so:

foreach ($servers as $key => $value){

$currport = $servers[$key]['Port']; // was attempting this to see if it would work - it did not either. Normally tried $servers[$key]['Port'] directly.
if(!socket_connect($sock, 'rmoff.ath.cx', $currport)){
print("Couldn't Create Socket: " . socket_strerror(socket_last_error()). "\n"); // Debugging purposes
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~ Offline <br />";
}
else{
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~ Online <br />";
}
}

I cant quite find anything that is... actually wrong with the code. I dont understand the error all that much either, as it says "Success" in it. Needless to say - I'm thoroughly confused!

Anyone help me out?

Thanks!
--- End Message ---

Reply via email to