php-general Digest 17 Jan 2010 18:45:07 -0000 Issue 6543

Topics (messages 301155 through 301164):

order by ASC
        301155 by: John Taylor-Johnston
        301156 by: Robert Cummings
        301157 by: John Taylor-Johnston
        301158 by: John Taylor-Johnston
        301159 by: Robert Cummings

304 Not Modified header not working within a class
        301160 by: Camilo Sperberg

Implementation of non-linear business processes in PHP
        301161 by: AmirBehzad Eslami

RSYNC - who knows more?
        301162 by: Jens Geier
        301163 by: Richard

Re: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1
        301164 by: hack988 hack988

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 ---
Ok, I think this is a MySQl question. Take pity on me?

$sql = "SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC";

rollnumber is a varchar(50). I need it to be a text field. ASC does not order the way I want.

1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?

--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
Ok, I think this is a MySQl question. Take pity on me?

$sql = "SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC";

rollnumber is a varchar(50). I need it to be a text field. ASC does not order the way I want.

1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?

CAST it to an integer in the ORDER BY clause.

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

--- End Message ---
--- Begin Message ---
It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST(rollnumber AS int) SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST(`rollnumber` AS int) SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST('rollnumber' AS int)

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 'int) ASC' at line 1

I'll keep trying.

Robert Cummings wrote:
CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:
Ok, I think this is a MySQl question. Take pity on me?

$sql = "SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC";

rollnumber is a varchar(50). I need it to be a text field. ASC does not order the way I want.

1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?

--- End Message ---
--- Begin Message ---
Did some googling. This worked:
ORDER BY CAST(`rollnumber` AS SIGNED)

What is the difference? My problem in the meanwhile must be my version of MySQL?

John Taylor-Johnston wrote:
It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST(rollnumber AS int) SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST(`rollnumber` AS int) SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY CAST('rollnumber' AS int)

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 'int) ASC' at line 1

I'll keep trying.

Robert Cummings wrote:
CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:
Ok, I think this is a MySQl question. Take pity on me?

$sql = "SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC";

rollnumber is a varchar(50). I need it to be a text field. ASC does not order the way I want.

1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?



--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
Did some googling. This worked:
ORDER BY CAST(`rollnumber` AS SIGNED)

What is the difference? My problem in the meanwhile must be my version of MySQL?

You could have skipped quotes altogether. The difference is that you are referencing a field name, not a string value.

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

--- End Message ---
--- Begin Message ---
Hi list, my first message here :)

To the point: I'm programming a class that takes several CSS files, parses,
compresses and saves into a cache file. However, I would like to go a step
further and also use the browser cache, handling the 304 and 200 header
types myself.

Now, what is the problem? If I do it within a function, there is absolutely
no problem, everything works like a charm. However, when I implement that
same concept into my class, there is no way I can send a 304 Not Modified
header, when the data is *over* ~100 bytes.

What is funnier is that it enters the 304 function within the class, but
apparently it doesn't respect that and ends sending a 200 OK header anyway.
Let's take a look at the code:

This is a simple test scenario implemented within a little file just to
proof and make sure it is working before I adapt the code in the class.
Everything is ok here:

define('TIME_BROWSER_CACHE','3600');
$last_modified = filemtime('blabla.css');

if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified) {
  header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified',TRUE,304);
  header('Pragma: public');
  header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).' GMT');
  header('Cache-Control: max-age='.TIME_BROWSER_CACHE.', must-revalidate,
public');
  header('Expires: '.gmdate('D, d M Y H:i:s',time() + TIME_BROWSER_CACHE).'
GMT');
  die();
}
header('Content-type: text/css; charset=UTF-8');
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).' GMT');
header('Cache-Control: max-age='.TIME_BROWSER_CACHE.', must-revalidate,
public');
header('Expires: '.gmdate('D, d M Y H:i:s',time() + TIME_BROWSER_CACHE).'
GMT');

Now the class (simplified):

  public function printme($method = 'file') {
    if($this->qCSS > 0 AND ($method == 'file' OR $method = 'inline')) {
      if ($method == 'file') {
        $last_modified = filemtime(CACHE_LOCATION);
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified AND
$this->valid_cache()) {
          // $this->valid_cache() determines if the internal CSS cache is
still valid. If it is, it returns TRUE, else FALSE
          header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified', TRUE,
304);
          // also tried sending header('HTTP/1.1 304 Not Modified'); but
that didn't do the trick
          header('Pragma: public'); // Useless? Maybe, but the function
works with or without it.
          header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).'
GMT'); // Always good to send this too.
          header('Cache-Control: max-age='.TIME_BROWSER_CACHE); // idem
          header('Expires: '.gmdate('D, d M Y H:i:s',time() +
TIME_BROWSER_CACHE).' GMT'); // idem
          $fp = fopen('cache/hi.txt','a'); // Just to check stuff
          fwrite($fp,'header 304 sended, let\'s die'."\n"); // It logs this
without problem, which means it really enters this function when needed.
          fclose($fp);
          die(); // Terminate script execution or else it would continue to
the bottom, which isn't necessary.
        }
        header('Content-type: text/css; charset='.CHARSET); // From here on,
it applies only if we need to send the CSS.
        if (USE_BROWSER_CACHE) { // Constant [TRUE|FALSE] which defines
whether to use the browser cache or not.
          header('Pragma: public');
          header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).'
GMT');
          header('Cache-Control: max-age='.TIME_BROWSER_CACHE);
          header('Expires: '.gmdate('D, d M Y H:i:s',time() +
TIME_BROWSER_CACHE).' GMT');
        }
        // Rest of the function: get the CSS and echo it, within an
ob_start('ob_gzhandler');
        (....)
        $content_length = filesize(CACHE_LOCATION);
        if (extension_loaded('zlib')) $content_length = ob_get_length();
        header('Content-Length: '.$content_length); // Necesary if we don't
want to send the CSS in chunks.
        if (extension_loaded('zlib')) ob_end_flush();

Other useful information:
- Code #1 returns an 304 when it is needed, even when the CSS size is over
50kb. (Haven't test any CSS over that size yet)
- Code #2 goes into the 304 part but doesn't send the 304, unless the total
CSS size is under 100 bytes.
- Tried also with ETags, didn't worked either.
- Tried increasing or decreasing TIME_BROWSER_CACHE, didn't worked.
- Tried with/without Pragma header, Last-Modified header, Cache-Control
header, Expires header, all the 16 posibilities. None of them worked.
- Tried with getallheaders() and making the proper changes.
- Tried with/without ob_gzhandler.
- Tried with/without ob_start().
- Tried with all options on/off within Last-Modified header and
Cache-Control header (must-revalidate, public, etc). None of them worked.
- Tried searching on Google, reading the comments on php.net and searching
within this list. Nothing like this came up.
- I've been checking everything with Live HTTP Headers, a plugin for
Firefox. Haven't tested it on other browsers yet. However, I don't think
this is a browser issue.
- I've been using PHP 5.2.6 with Suhosin, APC and xDebug installed.
Webserver is Apache 2.2.8. Everything is working fine there. Proof is
everything goes well within the first code.

Any suggestions? What am I doing wrong?

Greetings and thanks in advance :)
If you need to take a look at more code, just ask for it, and sorry for my
bad english, it's not my native language.

-- 
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/

--- End Message ---
--- Begin Message ---
Dear List,
Helllo!!!

I'm trying to write a web application for my own ISP, to simplify the
processing of orders for Internet Accounts,
creating reports of their users, and keeping track of their sales.

A brief history:
This ISP provides ADSL connections over ordinary telephone lines for home
users. The activation of ADSL for these kind of users
is a bit complicated, and its business process is not linear. For example,
some telephone lines do not support separation of
data and voice, because their type is PCM. There are many situations that
they can't provide ADSL.
The ISP company has many resellers on the country, there are many
Administration Groups, etc.

With PHP, I'm trying to simplify this process. I guess there are many
examples out there, but I want to write
the application by myself in PHP.

A short list of requirements are:

1) Ability to add/edit Resellers, which in turn, they can have their own
Admins, Standard Users (ISP Insiders), and
they have different roles. Perhaps one user is allowed to view quotes, the
other is allowed to edit invoices,
and one user is allowed to finalize the orders.
2) Ability to change the order of different processes. For example, in one
situation the payment should occur before
the ADSL connection, in the other scenario the payment is not necessary at
the first place ( a 30-day trial connection ).

Is there any solution to implement non-linear business processes in PHP
(where different tasks could be done by different users,
with different roles, in different order)?

Please let me know what you think.
I appreciate your kindness. Thank you.
-b

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

as sugestet i tried backup by using RSYNC.
It is working fine.

But i have some more Questions for this software.

Is here some one that can help me with it?

Kind Regards
Jens Geier



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

> as sugestet i tried backup by using RSYNC.
> It is working fine.
>
> But i have some more Questions for this software.
>
> Is here some one that can help me with it?

You might get better results with the documentation:

http://samba.anu.edu.au/rsync/documentation.html

At a glance there are links to mailing lists too.

--
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 2nd January)
Lots of PHP and Javascript code - http://www.phpguru.org

--- End Message ---
--- Begin Message ---
I think Vasily Pupkin is right.
http://www.freebsd.org/cgi/cvsweb.cgi/ports/Mk/bsd.port.mk.diff?r1=1.630;r2=1.631;f=h
Found {portsdir}/Mk/bsd.port.mk and make sure the version is higher
than 1.631(2009/12/18)
In another side,your are use "*default tag=." in your supfile or /etc/make.conf?

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html
mybe you need to use "*default tag=RELEASE_6_1_0"

http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/php5/?only_with_tag=RELEASE_6_1_0
php5.x for freebsd 6.1

2010/1/16 Vasily Pupkin <[email protected]>:
> add X11BASE=${LOCALBASE} as it is shown below:
>
> #echo "X11BASE=${LOCALBASE}" >> /etc/make.conf
>
> The problem is in recent changeset for ports/Mk/bsd.port.mk:
> (http://www.freebsd.org/cgi/cvsweb.cgi/ports/Mk/bsd.port.mk.diff?r1=1.630;r2=1.631;f=h)
>
> ..if ${X11BASE} != ${LOCALBASE}
> ..BEGIN:
> @${ECHO_MSG} "X11BASE is now deprecated. Unset X11BASE in make.conf and try 
> again."
> @${FALSE}
> ..endif
>
> The guy commited the revision couldn't imagine that there is no X11BASE on 
> system defined at all while LOCALBASE is defined.
> This bug should be fixed soon because a lot of people will stuck with it 
> after ports upgrade.
>
>> =======================
>> I try a 'make all-depend-list'
>> the error shows up
>> =============================
>> which error show ?
>
> # make
> X11BASE is now deprecated.  Unset X11BASE in make.conf and try again.
> *** Error code 1
>
> Stop.
>
> That's the error... happens every time, no matter what I try to set/unset in
> /etc/make.conf. I looked through the makefiles to see where X11BASE is
> referenced and I can't find any place where it is to just kill it.
>
>> > This is _exactly_ what I did, and as soon as I try a 'make all-
>> depend-list'
>> > the error shows up. I don't even have the X11 system installed (it's
>> a
>> > headless server, with no GUI).
>> >
>> > This is on a CLEAN 6.1 install, without any upgrades/patches, just
>> straight
>> > off the ISO install and after a portsnap install/extract.
>> >
>> > I tried building it _before_ I updated the ports and it would build a
>> 5.1.2
>> > php ok, but I need 5.2.12. Something has changed in the port between
>> 5.1.2
>> > and 5.2.12
>> >
>> >> 1.add
>> >> WITHOUT_X11=yes
>> >> in /etc/make.conf
>> >> 2.remove
>> >> X11BASE=""
>> >> from that file and
>> >>
>> >> 4.make all-depend-list
>> >> 5.make clean all depend soft
>> >> 6.make menuconfig set X11 disable
>> >> 7.make &&make install
>> >>
>> >>
>> >> 2010/1/12 Don O'Neil <[email protected]>:
>> >> > Ok.. just for grins I installed a new instance of 6.1, NO Patches,
>> >> just
>> >> > straight off the ISO...
>> >> >
>> >> > I loaded the ports that came WITH the distro, and was able to make
>> >> php 5.1.2
>> >> > ok...
>> >> >
>> >> > When I did a portsnap fetch, portsnap extract, then went into the
>> >> > /usr/ports/lang/php5 and just typed make I get the same error...
>> >> >
>> >> > SO as it seems, the port is broken, at least for working with
>> FreeBSD
>> >> 6.1.
>> >> >
>> >> > Can anyone give me some hints on how to build this sucker by hand?
>> >> Seems as
>> >> > though there are a bunch of patches that are referenced in the
>> >> distinfo
>> >> > file.
>> >> >
>> >> > I REALLY need to get this taken care of asap, any help is
>> >> appreciated.
>> >> >
>> >> > Thanks!
>> >> >
>> >> >> > > I tried adding WITHOUT_X11=yes to /etc/make.conf as well as
>> >> >> X11BASE=
>> >> >> > and
>> >> >> > > X11BASE="", but I still get the same error.
>> >> >> >
>> >> >> > Remove them. This makes sure they are not defined, not even
>> >> >> > empty (as in "#define BLA -> symbol 'BLA' is defined").
>> >> >> >
>> >> >> > > Where to go from here? Do I have and old version of something
>> >> that
>> >> >> is
>> >> >> > > causing this? I get this error _right away_ before anything
>> is
>> >> even
>> >> >> > built.
>> >> >> >
>> >> >> > It seems to be a check by the Makefile at port's top level.
>> >> >>
>> >> >> Ok... I have no definition for X11BASE anywhere, not in my env,
>> not
>> >> in
>> >> >> my
>> >> >> /etc/make.conf, nowhwere...
>> >> >>
>> >> >> However, it's still complaining about X11BASE being deprecated. I
>> >> tried
>> >> >> just
>> >> >> adding WITHOUT_X11=yes in /etc/make, and without it. I even
>> searched
>> >> >> all the
>> >> >> Makefiles in /usr/ports, and in the /usr/ports/lang/php5 dir to
>> find
>> >> >> any
>> >> >> reference to X11, or X, or X11BASE, but nada... I don't even know
>> >> where
>> >> >> this
>> >> >> error message is being generated from.
>> >> >>
>> >> >> I can't even do a basic make without it immediately spitting out
>> the
>> >> >> error:
>> >> >>
>> >> >> # make
>> >> >> X11BASE is now deprecated.  Unset X11BASE in make.conf and try
>> >> again.
>> >> >> *** Error code 1
>> >> >>
>> >> >> Stop.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to