php-general Digest 27 Jun 2005 18:15:28 -0000 Issue 3536

Topics (messages 217675 through 217703):

Re: including the result of one query in another query
        217675 by: Burhan Khalid

Re: PHP vs. ColdFusion
        217676 by: Anton Kovalenko
        217691 by: Angelo Zanetti
        217703 by: Brad Pauly

status
        217677 by: Bounced mail

Re: array_diff php version
        217678 by: Shaw, Chris - Accenture

Display picture from MySQL
        217679 by: Bagus Nugroho
        217680 by: Greg Donald
        217685 by: Georgi Ivanov
        217686 by: Angelo Zanetti

daemons listen on apache port when run by php
        217681 by: Dusan Smolnikar

Re: Removing nonlatin characters
        217682 by: Kristen G. Thorson

PHP 5.0.4 compilation under Mac
        217683 by: Nicolas Diez

Re: $mydata->StampDate
        217684 by: Kevin L'Huillier

Re: PHP search
        217687 by: Jason Barnett

removing chars from string
        217688 by: Paul Nowosielski
        217689 by: Jay Blanchard
        217690 by: Kevin L'Huillier
        217692 by: Jay Blanchard
        217693 by: Richard Davey
        217694 by: John Nichel
        217695 by: Jay Blanchard
        217696 by: Josh Olson
        217697 by: Jay Blanchard
        217698 by: Richard Davey
        217699 by: John Nichel
        217700 by: John Nichel
        217701 by: Stut
        217702 by: Richard Davey

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 ---
Pedro Quaresma de Almeida wrote:
Hi

I have two databases, on for aeromodelistas (aeromodelling) and
another for Códigos Postais (Postal Codes). I whant to do the
following query

SELECT CódigoPostal FROM Aeromodelistas WHERE CódigoPostal IN (SELECT distinct(CP4) FROM codigopostal.LOCART,codigopostal.DISTRITO WHERE codigopostal.LOCART.DD=codigopostal.DISTRITO.DD AND codigopostal.DISTRITO.DESIG='Coimbra');
This query is not working, and I do not know why. If I try the two
queries individualy they work, togheter they don't!?

Firstly, this is not PHP related. If you are using MySQL, you should know that sub-selects are only supported in versions 4.1 and above.
--- End Message ---
--- Begin Message ---
PHP is open source. It's highly supported by lots of developers.
It's free. There are many different libraries such as PEAR, for instance.
There many free frameworks for creating convinient modular and easyly
managebale applications both web and command line.
I can name mojavi.org as a brilliant MVC pattern implementation for PHP5,
propel (propel.phpdb.org)
and metastorage (http://www.meta-language.net/metastorage.html)  as
OOtoR transformation frameworks.

As to ColdFusion, It seems to me that this technology is dead already.


Rick Emery wrote:
> My employer has (finally) decided to take full advantage of our
> intranet, and wants to move from client-server applications to web-based
> applications. To that end, we're trying to determine the best platform
> for our applications. We're a Microsoft shop, with Microsoft SQL Server
> 2000 for all of our databases (that won't change any time soon, if
> ever). Due to past experience that I won't get into, we (the Development
> group) have all agreed that ASP.Net is out (at least for the short term).
> 
> We had the opportunity to visit a local enterprise that has deployed
> ColdFusion, and they couldn't stop singing its praises. I'm partial to
> PHP, even after sampling Coldfusion, so what I would like is some
> "ammunition" that I can take into a meeting to "sell" management on PHP
> instead of ColdFusion. I've already been harping on the difference in
> cost, so I'm looking for other points to go with. Besides, we'll
> probably invest in Zend products if we choose PHP, and Macromedia has
> government rates available; I don't have any numbers (yet), but the cost
> difference may not be that great in the end.
> 
> Any input would be greatly appreciated. Opinions are welcome (especially
> from programmers with experience in both), but I have to "sell" it to
> management (I'm already on the PHP side), so links to data or articles
> comparing the two are best.
> 
> Thanks in advance,
> Rick

--- End Message ---
--- Begin Message ---
as well as  a great templating engine: smarty (there are others as well)

Please let us know what the outcome is!!
thanks
Angelo

Anton Kovalenko wrote:

>PHP is open source. It's highly supported by lots of developers.
>It's free. There are many different libraries such as PEAR, for instance.
>There many free frameworks for creating convinient modular and easyly
>managebale applications both web and command line.
>I can name mojavi.org as a brilliant MVC pattern implementation for PHP5,
>propel (propel.phpdb.org)
>and metastorage (http://www.meta-language.net/metastorage.html)  as
>OOtoR transformation frameworks.
>
>As to ColdFusion, It seems to me that this technology is dead already.
>
>
>Rick Emery wrote:
>  
>
>>My employer has (finally) decided to take full advantage of our
>>intranet, and wants to move from client-server applications to web-based
>>applications. To that end, we're trying to determine the best platform
>>for our applications. We're a Microsoft shop, with Microsoft SQL Server
>>2000 for all of our databases (that won't change any time soon, if
>>ever). Due to past experience that I won't get into, we (the Development
>>group) have all agreed that ASP.Net is out (at least for the short term).
>>
>>We had the opportunity to visit a local enterprise that has deployed
>>ColdFusion, and they couldn't stop singing its praises. I'm partial to
>>PHP, even after sampling Coldfusion, so what I would like is some
>>"ammunition" that I can take into a meeting to "sell" management on PHP
>>instead of ColdFusion. I've already been harping on the difference in
>>cost, so I'm looking for other points to go with. Besides, we'll
>>probably invest in Zend products if we choose PHP, and Macromedia has
>>government rates available; I don't have any numbers (yet), but the cost
>>difference may not be that great in the end.
>>
>>Any input would be greatly appreciated. Opinions are welcome (especially
>>from programmers with experience in both), but I have to "sell" it to
>>management (I'm already on the PHP side), so links to data or articles
>>comparing the two are best.
>>
>>Thanks in advance,
>>Rick
>>    
>>
>
>  
>

--- End Message ---
--- Begin Message ---
On 6/26/05, Rick Emery <[EMAIL PROTECTED]> wrote:
> My employer has (finally) decided to take full advantage of our
> intranet, and wants to move from client-server applications to
> web-based applications. To that end, we're trying to determine the best
> platform for our applications. We're a Microsoft shop, with Microsoft
> SQL Server 2000 for all of our databases (that won't change any time
> soon, if ever). Due to past experience that I won't get into, we (the
> Development group) have all agreed that ASP.Net is out (at least for
> the short term).
> 
> We had the opportunity to visit a local enterprise that has deployed
> ColdFusion, and they couldn't stop singing its praises. I'm partial to
> PHP, even after sampling Coldfusion, so what I would like is some
> "ammunition" that I can take into a meeting to "sell" management on PHP
> instead of ColdFusion. I've already been harping on the difference in
> cost, so I'm looking for other points to go with. Besides, we'll
> probably invest in Zend products if we choose PHP, and Macromedia has
> government rates available; I don't have any numbers (yet), but the
> cost difference may not be that great in the end.
> 
> Any input would be greatly appreciated. Opinions are welcome
> (especially from programmers with experience in both), but I have to
> "sell" it to management (I'm already on the PHP side), so links to data
> or articles comparing the two are best.

It might not be easy to put a number on, but consider your (and
possibly the other developers') enthusiasm about PHP. I would guess
that you will be more productive with something that you are excited
about.

I have done a lot of work in both ColdFusion and PHP and I much prefer
PHP. There are some technical reasons (i.e., I like "shared nothing"),
but some of it is also personal preference. I just like it. CF is fine
and I don't think it's dead, but it just isn't as fun to work with. My
biggest problem with CF is probably that I have to use it on Windows
and, well, I really don't like that. ;) You mention being in a Windows
environment so maybe you don't have a choice with that aspect.

If management can see that you are stoked to use PHP that might help your cause.

- Brad

--- End Message ---
--- Begin Message ---
The original message was received at Mon, 27 Jun 2005 13:10:24 +0200
from [127.20.163.238]

----- The following addresses had permanent fatal errors -----
php-general@lists.php.net




--- End Message ---
--- Begin Message ---
As far as I can see in the Help File, Array_Diff was introduced in 4.0.1 and
should be in the version you are using.

Does it not work?


-----Original Message-----
From: André Le Tissier [mailto:[EMAIL PROTECTED]
Sent: 26 June 2005 10:20
To: php-general@lists.php.net
Subject: [PHP] array_diff php version


Help! Array_diff is the perfect function for what I am try to do but I have
a php version 4.1.5. Is there any replacement I can use to achieve the same
result



Many thanks,



André Le Tissier






************************

This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*************************

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

I'm looking for tutorial/template/code, how to display a picture on web pages 
which the picture is stored on MySQl database.


Thanks in advance,
regards

--- End Message ---
--- Begin Message ---
On 6/27/05, Bagus Nugroho <[EMAIL PROTECTED]> wrote:
> I'm looking for tutorial/template/code, how to display a picture on web
> pages which the picture is stored on MySQl database.

You can download a copy of my image rating script and have a look at
the image.php.

http://destiney.com/Scripts


-- 
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

--- End Message ---
--- Begin Message ---
/*Fetch the image :*/
$res=mysql_query("select picture from pics_table where id=1") or die("err");
$line=mysql_fecth_array($res);
/*Send headers*/
header("content-type: image/png");
echo $line[picture];


On Monday 27 June 2005 15:38, Bagus Nugroho wrote:
> Hi All,
>
> I'm looking for tutorial/template/code, how to display a picture on web
> pages which the picture is stored on MySQl database.
>
>
> Thanks in advance,
> regards

--- End Message ---
--- Begin Message ---
or you could just store the path to where the directory is in the
database and go find the file according to the path and filename.

HTH

Georgi Ivanov wrote:

>/*Fetch the image :*/
>$res=mysql_query("select picture from pics_table where id=1") or die("err");
>$line=mysql_fecth_array($res);
>/*Send headers*/
>header("content-type: image/png");
>echo $line[picture];
>
>
>On Monday 27 June 2005 15:38, Bagus Nugroho wrote:
>  
>
>>Hi All,
>>
>>I'm looking for tutorial/template/code, how to display a picture on web
>>pages which the picture is stored on MySQl database.
>>
>>
>>Thanks in advance,
>>regards
>>    
>>
>
>  
>

--- End Message ---
--- Begin Message --- I am trying to run a daemon via php4 & apache2 (on debian sarge). I am using the command "exec('sh script.sh');". All works fine, my daemon (which I run with script.sh) is running. But when I stop apache, I can see that the daemon I ran previously is listening on port 80 (apache port). This does not happen if I run the script from a shell. How can I prevent these daemons from taking over port
80?

This happens with amule and giftd (haven't tried any others though).

this is my script:
#!/bin/bash
HOME=/var/www

case "$1" in
        start)
                /usr/bin/giftd -dq --home-dir '/var/www'
                ;;
        stop)
                killall giftd
                ;;
        restart | force-reload)
                $0 stop
                sleep 2
                $0 start
                ;;
        *)
echo "Usage: gift.sh {start|stop|restart|force- reload}" exit 1
esac

exit 0


the command used in php:
exec('./gift.sh start');

what I get when I stop apache, after I ran the script:
[router:/var/www/.giFT] racer% sudo netstat -np --ip --listen | grep 80
tcp   0   0 0.0.0.0:80   0.0.0.0:*   LISTEN   2522/giftd




Dusan Smolnikar

--- End Message ---
--- Begin Message ---
Have you seen:

http://us2.php.net/manual/en/function.recode-string.php


kgt



Dotan Cohen wrote:

I thought that this was another old STFA but marc and google are quiet.

I as parsing a bunch of submitted works and some of them have
non-latin characters. I know that I once saw in the user-submitted
notes in the docs a function for replacing them with o,a,i,e,u but I
can't find it. I think that it may have been purged. Can anyone help?

Dotan
http://lyricslist.com/lyrics/artist_albums/109/carlisle_belinda.php
Belinda Carlisle Lyrics


--- End Message ---
--- Begin Message ---
Hello, I've search the archive but doesn't find anything about what I
will expose to you.

There is my problem : 
I've followed the following tutorial :
http://www.phpmac.com/articles.php?view=221
, in order to compile apache 2.0.54 and php 5.0.4 under MacOSX Tiger
10.4.1. XCode is installed on the box in version 2.1.

I only change the configure command line for php by doing this : 
./configure --prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs --with-openssl --with-zlib
--enable-bcmath --with-bz2 --enable-calendar --enable-sigchild 
--enable-ftp --with-gd --with-jpeg-dir=/sw --with-png-dir=/sw
--with-mime-magic --with-mysql=/usr/local/mysql --with-ncurses
--enable-sockets --with-unixODBC=/usr --with-pdflib --with-tiff-dir
--enable-sysvmsg --enable-sysvshm --enable-sysvsem --with-xslt
--with-xsl --with-curl -with-ming=/sw --with-libxml-dir
--enable-zend-multibyte --with-crypt --with-mime-magic --with-crack
--enable-mbstring --with-dom && make clean && make

But I little problem. The compilation fails with these error messages : 
/usr/bin/ld: warning multiple definitions of symbol _pcre_free
ext/pcre/pcrelib/pcre.o definition of _pcre_free in section (__DATA,__data)
/usr/local/apache/bin/httpd definition of _pcre_free
/usr/bin/ld: warning multiple definitions of symbol _pcre_malloc
ext/pcre/pcrelib/pcre.o definition of _pcre_malloc in section (__DATA,__data)
/usr/local/apache/bin/httpd definition of _pcre_malloc
/usr/bin/ld: warning multiple definitions of symbol _regcomp
/usr/local/apache/bin/httpd definition of _regcomp
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib(regcomp.So)
definition of _regcomp
/usr/bin/ld: warning multiple definitions of symbol _regexec
/usr/local/apache/bin/httpd definition of _regexec
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib(regexec.So)
definition of _regexec
/usr/bin/ld: warning multiple definitions of symbol _regfree
/usr/local/apache/bin/httpd definition of _regfree
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libpthread.dylib(regfree.So)
definition of _regfree
/usr/bin/ld: Undefined symbols:
_SQLGetPrivateProfileString
_SQLSetConfigMode
_SQLGetConfigMode
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1

I don't know what to do. I doesn't want to disable PEAR which will
allow me to disable PCRE in php because I will need PCRE and I don't
know if I will not use a PEAR package during the developement of the
website.

Has someone a workaround for this problem ?

--- End Message ---
--- Begin Message ---
On 27/06/05, Jasper Bryant-Greene <[EMAIL PROTECTED]> wrote:
> John Taylor-Johnston wrote:
> > I could just change the field type. But how do you calculate it? I don't
> > see much to inspire a start. I'm not a full-time coder either. More of a
> > tinkerer. I don't want someone to do it for me, but need to get my head
> > around how to do it.
> > http://ca3.php.net/manual/en/function.strtotime.php
> 
> As I said, though, you should be using a MySQL date field. Have a look
> at the MySQL manual for the corresponding functions to the above --
> there's probably a quicker way with MySQL too.

Dates should almost always be stored as dates in a database, not
varchars.  This allows for more and/or faster date functions, sorting
that works (it only works with yyyy-mm-dd format in varchars), and you
can select the data into a unix timestamp instead of needing to
strtotime() first.

The calculation in mysql couldn't be much simpler.

select datediff(StampDate, '2003-08-23') as StampDateDiff


>From the manual:

DATEDIFF() returns the number of days between the start date expr and
the end date expr2. expr  and expr2 are date or date-and-time
expressions. Only the date parts of the values are used in the
calculation.

mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
 -> 1

http://mysql.org/doc/mysql/en/date-and-time-functions.html

--- End Message ---
--- Begin Message ---
Bruce Gilbert wrote:
Hello,

I am fairly new to PHP, and I am looking to create a search
functionality on a website using php. Can anyone point me to a good
tutorial that can walk me through this?

Between Google / Codewalkers / PHPFreaks you should be able to find something.

--
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php

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

If a have a string thats 11 characters long how can I strip off the last
two characters?

TIA!
 
Paul  

--- End Message ---
--- Begin Message ---
[snip]
If a have a string thats 11 characters long how can I strip off the last
two characters?
[/snip]

$newString = substr($oldString, 0, 8);
echo $newString;

--- End Message ---
--- Begin Message ---
Paul Nowosielski <[EMAIL PROTECTED]> wrote:
> If a have a string thats 11 characters long how can I strip off the last
> two characters?

Jay Blanchard <[EMAIL PROTECTED]> wrote:
> $newString = substr($oldString, 0, 8);
> echo $newString;

substr's third argument is length, not position.  It also accepts
negative values which makes it go from the end, allowing you to do
absolute lengths or relative.

To make a string no more than 9 characters:
  substr($string, 0, 9);

To always remove the last two characters of a string:
  substr($string, 0, -2);

http://php.net/substr

--- End Message ---
--- Begin Message ---
[snip]
Paul Nowosielski <[EMAIL PROTECTED]> wrote:
> If a have a string thats 11 characters long how can I strip off the
last
> two characters?

Jay Blanchard <[EMAIL PROTECTED]> wrote:
> $newString = substr($oldString, 0, 8);
> echo $newString;

substr's third argument is length, not position.  It also accepts
negative values which makes it go from the end, allowing you to do
absolute lengths or relative.

To make a string no more than 9 characters:
  substr($string, 0, 9);

To always remove the last two characters of a string:
  substr($string, 0, -2);

http://php.net/substr
[/snip]

I know that it is length, and I gave the correct length for an 11
character string minus two characters. But as always, there is more than
one way to skin a mule.

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

Monday, June 27, 2005, 4:33:35 PM, you wrote:

PN> If a have a string thats 11 characters long how can I strip off
PN> the last two characters?

$newstring = substr($string, 0, -2);

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
<snip>
I know that it is length, and I gave the correct length for an 11
character string minus two characters. But as always, there is more than
one way to skin a mule.
</snip>

Did you take Math in Mississippi?  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
[snip]
Jay Blanchard wrote:
<snip>
> I know that it is length, and I gave the correct length for an 11
> character string minus two characters. But as always, there is more
than
> one way to skin a mule.
</snip>

Did you take Math in Mississippi?  ;)
[/snip]

As a matter of fact.... ;)

0-8 is nine characters, which is two less than eleven, IIRC

--- End Message ---
--- Begin Message ---
> I know that it is length, and I gave the correct length for an 11 character 
> string minus two characters. But as always, there is more than
> one way to skin a mule.


$string = '12345678901';

$jayString = substr($string, 0, 9);
$kevinString = substr($string, 0, 8);

echo $jayString; // echos 123456789
echo '<br />'; // echos 12345678
echo $kevinString;

It turns out to "skin" a mule is to outsmart him. Because mules aren't
actually stubborn, they're just smarter than most of us.

--- End Message ---
--- Begin Message ---
[snip]
$string = '12345678901';

$jayString = substr($string, 0, 9);
$kevinString = substr($string, 0, 8);

echo $jayString; // echos 123456789
echo '<br />'; // echos 12345678
echo $kevinString;

It turns out to "skin" a mule is to outsmart him. Because mules aren't
actually stubborn, they're just smarter than most of us.
[/snip]

Drat! Foiled again! My mind is absent. If you only knew....


My apologies for getting the math wrong...damn....I need a vacation.

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

Monday, June 27, 2005, 4:46:36 PM, you wrote:

JB> I know that it is length, and I gave the correct length for an 11
JB> character string minus two characters. But as always, there is
JB> more than one way to skin a mule.

Would that be a three-legged mule? :-) (you're one short : 0,8)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
Jay Blanchard wrote:
<snip>

I know that it is length, and I gave the correct length for an 11
character string minus two characters. But as always, there is more

than

one way to skin a mule.

</snip>

Did you take Math in Mississippi?  ;)
[/snip]

As a matter of fact.... ;)

0-8 is nine characters, which is two less than eleven, IIRC

Yeah, but that new math doesn't work with PHP.  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Stut wrote:
Jay Blanchard wrote:

0-8 is nine characters, which is two less than eleven, IIRC


So the length should be 9 not 8 no? Or should I go back to school?


Forgive us, it's Monday.

$newstring = substr ( $oldstring, 0, 9 );

Will knock the last two characters off of an eleven character string. 0 is the starting point, and 9 is the length you want returned....

$newstring = substr ( $oldstring, 1, 9 );

Will knock off the first and last character of an eleven character string (giving you the 'middle' 9 characters).

$newstring = substr ( $oldstring, 0, -2 );

Will knock the last two characters off a string of any length.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
0-8 is nine characters, which is two less than eleven, IIRC

So the length should be 9 not 8 no? Or should I go back to school?

-Stuart

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

Monday, June 27, 2005, 4:59:17 PM, you wrote:

>> 0-8 is nine characters, which is two less than eleven, IIRC
S> So the length should be 9 not 8 no? Or should I go back to school?

It should be 9 if you want 9 characters.

Lots of PHP functions are zero-based, but the 3rd parameter to substr
is asking for the number of characters to return, not the actual
character location in the string to stop at - if it did, then it would
have been 8 (0 being the 1st character, etc), but in this case it's 9.

It's an easy one to slip-up on imho.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

--- End Message ---

Reply via email to