[PHP] XSLT and DocBook

2007-06-06 Thread Larry Garfield
Hi all.  I have a DocBook source[1] that I am processing into XHTML using the 
DocBook XSL[2] toolchain.  That is, XSLT.  I'm not doing a huge amount of 
customization on top of the default setup, either.  Right now, I'm using the 
standard XSLT Java toolchain; Xalan, Xerces, XIncluder, and all of the 
various other Apache projects[3].  The problem is, well, it's Java, which 
means the classpaths and build environment and such break if I so much as 
sneeze at the wrong time.  I'd love to be able to replace it with PHP's XSL 
parser[4], since I actually know PHP and its chances of breaking on every 
other Tuesday are slimmer, but I don't know if it has all of the 
functionality I'd need.  

Specifically, I need multi-file output and support for  
directives.  Right now I'm using the Xalan multi-file output extensions, but 
I'm happy to switch to something else if it means eliminating the huge gobs 
of touchy Javascript I have.  

Does anyone know if that's doable with PHP's XSLT support (circa PHP 5.2, I 
run the server so can install whatever I need)?  Has anyone tried doing this 
before?  It's all offline processing, so performance isn't a huge issue.  
Thanks.

[1] http://www.docbook.org/tdg/en/html/docbook.html
[2] http://www.sagehill.net/docbookxsl/
[3] http://xml.apache.org/
[4] http://us.php.net/manual/en/ref.xsl.php

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] Re: More include issues

2007-06-06 Thread Jared Farrish

On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:


On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > I feel ya brotha! I think Stut might be having a bad day...
> >
> > Bad day?? Did you read the same posts I read?
>
> Sure I did. Let's not take this too seriously, ok?

You forgot a winkie ;) :)

Cheers,
Rob.



Ach! YOU ARE S RIGHT!

Now I need a twinkie... ;)


--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


[PHP] register_globals and magic_quotes_gpc (again)

2007-06-06 Thread Afan Pasalic

hi,
this question is already posted thousand times. but, after I tried for 2 
hours to figure it out, I gave up and posted the question here.

I'm rebuilding one site. php 4.4.4
as usual, register_globals on, as well as magic_quotes.
I tried to turn it off using .htaccess but what ever I change in the 
(already existing) file, I would get 500 Internal Server Error


this is content of the .htaccess file:

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*


order deny,allow
deny from all
allow from all


order deny,allow
deny from all

AuthName mkl1332
AuthUserFile /u/web/afan/_vti_pvt/service.pwd
AuthGroupFile /u/web/afan/_vti_pvt/service.grp

and I tried to add
php_flag register_globals Off
and it doesn't work (500 internal server error)

I tried with register_global 0 - same thing.

could you please point me where to look after?

thanks for any help.

-afan

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



Re: [PHP] Re: More include issues

2007-06-06 Thread Robert Cummings
On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > I feel ya brotha! I think Stut might be having a bad day...
> >
> > Bad day?? Did you read the same posts I read?
> 
> Sure I did. Let's not take this too seriously, ok?

You forgot a winkie ;) :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: More include issues

2007-06-06 Thread Jared Farrish

On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:


On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> I feel ya brotha! I think Stut might be having a bad day...

Bad day?? Did you read the same posts I read?

Cheers,
Rob.



Sure I did. Let's not take this too seriously, ok?

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


Re: [PHP] Re: More include issues

2007-06-06 Thread Robert Cummings
On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> >
> > I try not to bother the list and figure things out by myself as much as I
> > can, but it's hard when I was "volunteered" to become the guinea pig to
> > convert some of our apps from ColdFusion to PHP...especially when nobody I
> > work with has ever touched PHP before.  I have nobody to turn to except
> > google/forums/this list.
> 
> 
> I feel ya brotha! I think Stut might be having a bad day...

Bad day?? Did you read the same posts I read?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] Parse domain from URL

2007-06-06 Thread Stefan Wixfort

> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 06, 2007 5:44 PM
> Subject: [PHP] Parse domain from URL
> 
> Hey guys,
> 
> I'm faced with an interesting problem, and wondering if there's an easy
> solution.
> 
> I need to strip out a domain name from a URL, and ignore subdomains (like
> www)
> 
> I can use parse_url to get the hostname. And my first thought was to take
> the last 2 segments of the hostname to get the domain.  So if the URL is
> http://www.example.com/
> Then the domain is "example.com."   If the URL is http://example.org/ then
> the domain is "example.org."
> 
> This seemed to work perfectly until I come across a URL like
> http://www.example.co.uk/
> My script thinks the domain is "co.uk."
> 
> So I added a bit of code to account for this, basically if the 2nd to last
> segment of the hostname is "co" then take the last 3 segments.
> 
> Then I stumbled across a URL like http://www.example.com.au/
> 
> So it occurred to me that this is not the best solution, unless I have a
> definitive list of all exceptions to go off of.
> 
> Does anyone have any suggestions?
> 
> Any advice is much appreciated.
> 
> Thanks,
> Brad
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Maybe use some regexp like this:
$url = http://www.a-domain.co.uk;

$domain = preg_match( "!^(http://)([-a-z0-9]+(?:\.[-a-z0-9]+)*)$!i" ); //
you will get www.a-domain.co.uk // So u can search for "www." In front of
the string to replace it or // you could edit the search for ignoring the
'www.'

Echo $domain[2];


Greetings,

Stefan

Note: this is untested.

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



Re: [PHP] cannot make directory at remote host

2007-06-06 Thread Chris

blueboy wrote:

This work localy but not on my remote host. How can I debug it?

if(!(is_dir('images/$customer_id')))
{
mkdir("images/$customer_id", 0700);

}

The file is in the main public_html folder and there is a images folder. 


First tip - always use full paths instead of local ones so you know 
*exactly* where it's going.


If it goes under the current folder (and I hope you have some basic 
checking here somewhere for customer_id):


$customer_id = (int)$customer_id;
if ($customer_id <= 0) {
  die("Bad customerid!");
}

$dir = dirname(__FILE__) . '/images/' . $customer_id;

if (!is_dir($dir)) {
  mkdir($dir, 0700);
}


What should the permissions be?


Depends on the host (whether they are running php in cgi mode or as an 
apache module).


Check if safe-mode is on or off.

Check the parent folder to make sure that the webserver user has write & 
execute access to be able to get into the base folder.


display errors and turn error reporting up to work out why it's not working.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] php-cli vs python

2007-06-06 Thread Chris

Abdullah Ramazanoglu wrote:

Hello,

I'm already (going to) use php for web based development. Shell scripting
and compiled languages have their own places, but there's also a place for
a high level scripting language. While people usually use python (for
higher level and perl for lower level tasks) for this, I really wonder
whether this would be worthwhile for me.

I have just cursory info about python, and I'm by no means a php expert. So
I can't reliably compare the two, but my rationale so far is simple: If
php5, with its enhanced object oriented features and rich libraries is on
par with python on the command line, then wouldn't it make better sense
for me to use php for both web and cli/gui development?

Nevertheless, I can't ignore the fact that people do use python almost
exclusively for high level CLI/GUI scripting. Where's the catch? What's
the top 3 killer features of python against php (and vice versa)?

Any ideas, pointers, analysis, insights are most welcome. This is a rather
strategical crossroads for me, and I'd very much like to make an informed
decision.


If you want to have any sort of code re-use, then you're going to have 
to use php (or python) for both.


Otherwise you have to start again from scratch in python code (creating 
more places for bugs to hide and making the whole thing more complicated).


While they can access the same database, there's nothing else they can 
share.


Personally I'd stick to one or the other for the whole project, you'll 
save yourself a lot of headaches in the future.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



[PHP] Re: More include issues

2007-06-06 Thread Jared Farrish


I try not to bother the list and figure things out by myself as much as I
can, but it's hard when I was "volunteered" to become the guinea pig to
convert some of our apps from ColdFusion to PHP...especially when nobody I
work with has ever touched PHP before.  I have nobody to turn to except
google/forums/this list.



I feel ya brotha! I think Stut might be having a bad day...

Coldfusion, MSSQL, Informix, PHP, oh my!

So once again, thank you, and thanks to everyone else that is helping this

novice become more familiar with PHP.



Don't let the b*st*rds get you down, man.

A note about include paths: Unless you want to drive yourself totally batty,
always try to use absolute document paths when include/require'ing. I use a
simple constant that I stick at the top of every path I put together:


// The @ kills an error that would be produced
// if already defined
// Leave 'www/' empty if root path
// to current file is not a subdirectory
@define('INCLUDE_PATH_SUBDIRECTORY','www/');
@define('INCLUDE_PATH',
   $_SERVER['DOCUMENT_ROOT'] .
   (strrpos($_SERVER['DOCUMENT_ROOT'],'/') !==
   (strlen($_SERVER['DOCUMENT_ROOT'])-1) ? '/' : '') .
   INCLUDE_PATH_SUBDIRECTORY)
);
// Usage
// I recommend always using
// include_once and require_once
// unless you know for sure you
// need multiple includes for that
// file
include_once INCLUDE_PATH . 'Connections/conn.php';


This might output for INCLUDE_PATH:

"/inetpub/www/virtual/www_example_com/"

for example, which then becomes

"/inetpub/www/virtual/www_example_com/Connections/conn.php"

PHP will always know how to find that.

This works for me, but your usage or results may vary, and may not work on
all servers (IIS, for instance) or some Apache installations (I guess). Try
creating a test page and play around with it using echo and so on to see
what it outputs. You can contact me directly if the forum mungs it up on the
line-wrap.

Also try:


echo '';
print_r($_SERVER);
echo '';


To see what server variables are available. Just remember, webroot (public)
and docroot (private) are different things.

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


[PHP] php-cli vs python

2007-06-06 Thread Abdullah Ramazanoglu
Hello,

I'm already (going to) use php for web based development. Shell scripting
and compiled languages have their own places, but there's also a place for
a high level scripting language. While people usually use python (for
higher level and perl for lower level tasks) for this, I really wonder
whether this would be worthwhile for me.

I have just cursory info about python, and I'm by no means a php expert. So
I can't reliably compare the two, but my rationale so far is simple: If
php5, with its enhanced object oriented features and rich libraries is on
par with python on the command line, then wouldn't it make better sense
for me to use php for both web and cli/gui development?

Nevertheless, I can't ignore the fact that people do use python almost
exclusively for high level CLI/GUI scripting. Where's the catch? What's
the top 3 killer features of python against php (and vice versa)?

Any ideas, pointers, analysis, insights are most welcome. This is a rather
strategical crossroads for me, and I'd very much like to make an informed
decision.

Thank you and kind regards.
-- 
Abdullah Ramazanoglu
aramazan ÄT myrealbox D0T cöm

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



Re: [PHP] ownership and permissions

2007-06-06 Thread Daniel Brown

On 6/6/07, blueboy <[EMAIL PROTECTED]> wrote:


t: 0131 553 3935 | m:07816 996 930 | [EMAIL PROTECTED] |
http://www:blue-fly.co.uk


I cannot delete a couple of folders on the server as the have the owner
'nobody'. All I am doing is making the folders with

mkdir($customer_id, 0755);


Now is there a way to set the ownership when I created the folder. What is
the appropriate folder levels for securoty (755, 640?)

Thanks,

R.

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




   If you search the archives, I wrote out a very long post on file
and folder security a few weeks back.  Also, chances are, you can't
chown() the files with your PHP scripts, but you can do either

> 2>&1',$ret,$xc);
   $xc == 1 ? echo $ret : '';
?>

    or, by far easier



   Since your existing scripts run as user: nobody, the file delete
script will, as well, meaning the files and folders that were created
via the web can be removed via the web.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



[PHP] ownership and permissions

2007-06-06 Thread blueboy

t: 0131 553 3935 | m:07816 996 930 | [EMAIL PROTECTED] | 
http://www:blue-fly.co.uk


I cannot delete a couple of folders on the server as the have the owner 
'nobody'. All I am doing is making the folders with

mkdir($customer_id, 0755);


Now is there a way to set the ownership when I created the folder. What is 
the appropriate folder levels for securoty (755, 640?)

Thanks,

R. 

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



[PHP] help with soapvar and xml list

2007-06-06 Thread Nathan Wheeler
I'm trying to create a request with a list. Here is what the request 
should be:



http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>

 
   http://ws.oag.com";>
 string
 string
 string
 string
* 
   string
   string
 *
 short
 short
 boolean
 short
 short
 string
   
 


So I can get everything except the CarrierCodeFilterList right. How 
would I use SoapVar or something else to create that? Here is an excerpt 
of what I'm using for the rest:


$params->SecurityToken = new SoapVar($sectoken, XSD_STRING, 'string', 
"http://www.w3.org/2001/XMLSchema";);
$params->DepartureDateTime = new SoapVar('2007-06-06', XSD_STRING, 
'string', "http://www.w3.org/2001/XMLSchema";);
$params->DepAirportCode = new SoapVar('BOI', XSD_STRING, 'string', 
"http://www.w3.org/2001/XMLSchema";);

$client = new SoapClient('file.wsdl');
$airresult = $client->OFSByAirportPairPerHour($air);
$airport = $airresult->OFSByAirportPairPerHourResult;

It gives me an error about the specified type was not recognized for the 
CarrierCodeFilterList so I can't even use __getLastRequest.


Thanks!

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

Sorry Stut, I am fairly newb and don't know all the in's and out's of all
the functionality.  I thought I had a good grasp on th edatabase connection
part, but obviously was having a major oversight.  Sorry for the confusion
and THANK YOU for sticking with me to get this issue resolved.

I try not to bother the list and figure things out by myself as much as I
can, but it's hard when I was "volunteered" to become the guinea pig to
convert some of our apps from ColdFusion to PHP...especially when nobody I
work with has ever touched PHP before.  I have nobody to turn to except
google/forums/this list.

So once again, thank you, and thanks to everyone else that is helping this
novice become more familiar with PHP.


On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> It seems that PHP is getting confused unless I post the $database =
> mssql_select_db("database", $connection) or die ('DB selection failed');
> before the query.   This is probably due to the fact that I am pulling
> information from multiple databases (Two MSSQL and One Informix)
>
> So if my query just starts out with $sql = "Select * from..." it doesn't
> really know which connection to use.

OK, that's more than a little annoying. I wish you'd mentioned that
you're using multiple database connection, this would have been so much
easier.

The mssql_query function can take the connection resource as a second
parameter. This also goes for every other database function. If you're
using multiple database connections you *need* to be passing that in. In
fact, even if you're not currently using multiple connections I would
recommend that people always pass the connection resource to the DB
functions - it saves a lot of headaches if you ever need to use a second
connection.

-Stut



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:
It seems that PHP is getting confused unless I post the $database = 
mssql_select_db("database", $connection) or die ('DB selection failed'); 
before the query.   This is probably due to the fact that I am pulling 
information from multiple databases (Two MSSQL and One Informix)
 
So if my query just starts out with $sql = "Select * from..." it doesn't 
really know which connection to use.


OK, that's more than a little annoying. I wish you'd mentioned that 
you're using multiple database connection, this would have been so much 
easier.


The mssql_query function can take the connection resource as a second 
parameter. This also goes for every other database function. If you're 
using multiple database connections you *need* to be passing that in. In 
fact, even if you're not currently using multiple connections I would 
recommend that people always pass the connection resource to the DB 
functions - it saves a lot of headaches if you ever need to use a second 
connection.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Richard Lynch
Use two different $connection variables, say, $mssql and $informix and
pass them in as the optional arg to _query or whatever, and then you
can avoid flip-flopping like that.

On Wed, June 6, 2007 3:53 pm, Dan Shirah wrote:
> It seems that PHP is getting confused unless I post the $database =
> mssql_select_db("database", $connection) or die ('DB selection
> failed');
> before the query.   This is probably due to the fact that I am pulling
> information from multiple databases (Two MSSQL and One Informix)
>
> So if my query just starts out with $sql = "Select * from..." it
> doesn't
> really know which connection to use.
>
>
> On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:
>>
>> Dan Shirah wrote:
>> > I thought that if you made a connection at the beginning of a
>> page, that
>> > you could use that connection throughout the page without having
>> to type
>> > it over again as long as you did not explicitly put in code to
>> close the
>> > connection??  Which is why I only inserted the include fil at the
>> > beginning of the page.
>> >
>> > Instead of having:
>> >
>> > $connection = mssql_pconnect('SERVER','user','password') or die
>> ('server
>> > connection failed');
>> > $database = mssql_select_db("database", $connection) or die ('DB
>> > selection failed');
>> >
>> > in my include file, I should only have $connection instead and
>> then
>> > specify $database before the query to the database.
>> >
>> > Does that sound like the correct solution?
>>
>> The way you have it at the moment should work fine. Might I suggest
>> you
>> try using a non-persistant connection? I've heard things in the past
>> that the persistant connection implementation in the MSSQL extension
>> can
>> be a bit flakey.
>>
>> -Stut
>>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

It seems that PHP is getting confused unless I post the $database =
mssql_select_db("database", $connection) or die ('DB selection failed');
before the query.   This is probably due to the fact that I am pulling
information from multiple databases (Two MSSQL and One Informix)

So if my query just starts out with $sql = "Select * from..." it doesn't
really know which connection to use.


On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> I thought that if you made a connection at the beginning of a page, that
> you could use that connection throughout the page without having to type
> it over again as long as you did not explicitly put in code to close the
> connection??  Which is why I only inserted the include fil at the
> beginning of the page.
>
> Instead of having:
>
> $connection = mssql_pconnect('SERVER','user','password') or die ('server
> connection failed');
> $database = mssql_select_db("database", $connection) or die ('DB
> selection failed');
>
> in my include file, I should only have $connection instead and then
> specify $database before the query to the database.
>
> Does that sound like the correct solution?

The way you have it at the moment should work fine. Might I suggest you
try using a non-persistant connection? I've heard things in the past
that the persistant connection implementation in the MSSQL extension can
be a bit flakey.

-Stut



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:
I thought that if you made a connection at the beginning of a page, that 
you could use that connection throughout the page without having to type 
it over again as long as you did not explicitly put in code to close the 
connection??  Which is why I only inserted the include fil at the 
beginning of the page.
 
Instead of having:
 
$connection = mssql_pconnect('SERVER','user','password') or die ('server 
connection failed');
$database = mssql_select_db("database", $connection) or die ('DB 
selection failed');
 
in my include file, I should only have $connection instead and then 
specify $database before the query to the database.
 
Does that sound like the correct solution?


The way you have it at the moment should work fine. Might I suggest you 
try using a non-persistant connection? I've heard things in the past 
that the persistant connection implementation in the MSSQL extension can 
be a bit flakey.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

I thought that if you made a connection at the beginning of a page, that you
could use that connection throughout the page without having to type it over
again as long as you did not explicitly put in code to close the
connection??  Which is why I only inserted the include fil at the beginning
of the page.

Instead of having:

$connection = mssql_pconnect('SERVER','user','password') or die ('server
connection failed');
$database = mssql_select_db("database", $connection) or die ('DB selection
failed');

in my include file, I should only have $connection instead and then specify
$database before the query to the database.

Does that sound like the correct solution?

On 6/6/07, Richard Lynch <[EMAIL PROTECTED]> wrote:


On Wed, June 6, 2007 3:24 pm, Dan Shirah wrote:
> Yes, I have error_reporting = E_ALL and show_warnings = On.

Use phpinfo to confirm that, because...

> Here's something interesting...if I put the include directly above the
> code
> for the dropdown it workslike below:

> and then the code stops again at the next area of my page where it
> needs to
> connect to the database.

This sounds like a clear indicator that the problem is in your connect
script.

Aside: Having "../../" as part of the include path is a Warning Signal
for all kinds of settings, including open_basedir restirctions, and
also means you aren't leveraging include_path as you probably should.

> Since I have my database connection set as mssql_pconnect(persistent
> connection) I should not have to include the connection file before
> every
> attempt to retrieve something from the database, but that is the only
> way it
> is working right now.

That's NOT what persistent means at all...

PERSISTENT means:
"MySQL keeps my connetion around so it doesn't have to build a whole
new one the next time I connect"

It does NOT mean:
"I don't have to connect again"

PS
I also wouldn't recomment display_errors ON, but, rather, error_log ON
and make sure you can cause an error on purpose and read the error you
expect to see in the log file.

display_errors ON is only going to lead to trouble in the long run,
even on a dev box, with HTML masking errors and JS hiding erros, and
CSS not written to display errors leading to overlaid error output on
top of exected output, which makes both unreadable, and often
un-selectable for copy/paste without using "View Source"...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?




Re: [PHP] More include issues

2007-06-06 Thread Richard Lynch
On Wed, June 6, 2007 3:24 pm, Dan Shirah wrote:
> Yes, I have error_reporting = E_ALL and show_warnings = On.

Use phpinfo to confirm that, because...

> Here's something interesting...if I put the include directly above the
> code
> for the dropdown it workslike below:

> and then the code stops again at the next area of my page where it
> needs to
> connect to the database.

This sounds like a clear indicator that the problem is in your connect
script.

Aside: Having "../../" as part of the include path is a Warning Signal
for all kinds of settings, including open_basedir restirctions, and
also means you aren't leveraging include_path as you probably should.

> Since I have my database connection set as mssql_pconnect(persistent
> connection) I should not have to include the connection file before
> every
> attempt to retrieve something from the database, but that is the only
> way it
> is working right now.

That's NOT what persistent means at all...

PERSISTENT means:
"MySQL keeps my connetion around so it doesn't have to build a whole
new one the next time I connect"

It does NOT mean:
"I don't have to connect again"

PS
I also wouldn't recomment display_errors ON, but, rather, error_log ON
and make sure you can cause an error on purpose and read the error you
expect to see in the log file.

display_errors ON is only going to lead to trouble in the long run,
even on a dev box, with HTML masking errors and JS hiding erros, and
CSS not written to display errors leading to overlaid error output on
top of exected output, which makes both unreadable, and often
un-selectable for copy/paste without using "View Source"...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:

Yes, I have error_reporting = E_ALL and show_warnings = On.
 
Here's something interesting...if I put the include directly above the 
code for the dropdown it workslike below:




and then the code stops again at the next area of my page where it needs 
to connect to the database.
 
Since I have my database connection set as mssql_pconnect(persistent 
connection) I should not have to include the connection file before 
every attempt to retrieve something from the database, but that is the 
only way it is working right now.


Ok, first of all that's not what persistant connections are. Persistent 
connection refers to pooling connections in the server such that each 
page request does not need to create a new connection if an existing 
idle connection exists.


I have no idea what's going on. It's possible that MSSQL is closing the 
connection for some reason, but I really don't know. I suggest you 
consult the MSSQL logs for clues.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

Yes, I have error_reporting = E_ALL and show_warnings = On.

Here's something interesting...if I put the include directly above the code
for the dropdown it workslike below:


'.print_r($credit_card_type_code));

 foreach ($credit_card_type_desc as $c)
 {
   if ($c['credit_card_type_code'] == $_POST['credit_card'])
 echo "{$c['credit_card_type_desc']}\n";
   else
 echo "{$c['credit_card_type_desc']}\n";
 }
?>


and then the code stops again at the next area of my page where it needs to
connect to the database.

Since I have my database connection set as mssql_pconnect(persistent
connection) I should not have to include the connection file before every
attempt to retrieve something from the database, but that is the only way it
is working right now.

On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> I only added those echo's since we have been trying to figure this out,
> so I could see how far it was getting before it stopped.   When I select
> "VIew Source", the last line of code is:
>
> 

Do you have display_errors on and error_reporting to show at least
errors and warnings?

If that's the last line output then there's a fatal error in the code
right after it, and developing without showing errors and warnings can
lead to lengthy and usually pointless discussions on mailing lists.

-Stut



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:
I only added those echo's since we have been trying to figure this out, 
so I could see how far it was getting before it stopped.   When I select 
"VIew Source", the last line of code is:
 



Do you have display_errors on and error_reporting to show at least 
errors and warnings?


If that's the last line output then there's a fatal error in the code 
right after it, and developing without showing errors and warnings can 
lead to lengthy and usually pointless discussions on mailing lists.


-Stut

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



RE: [PHP] customer ids

2007-06-06 Thread WeberSites LTD
Check out some of the Password Generators on the list 

http://www.php-code-search.com/?q=password%20generator

berber 

-Original Message-
From: blueboy [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 06, 2007 4:40 PM
To: php-general@lists.php.net
Subject: [PHP] customer ids

Hi,

I want to create random customer ids. I have an auto incremented coulumn but
I would rather have a 6-8 digit/letter id randomly generated  that can be
used as a unique identifier across 3 tables. Does anyone have a algorithm to
generate such a string and can you give the odds against 2 duplicate stings
being generated?

I know this is a strange ask.


R. 

--
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] More include issues

2007-06-06 Thread Dan Shirah

I only added those echo's since we have been trying to figure this out, so I
could see how far it was getting before it stopped.   When I select "VIew
Source", the last line of code is:




On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> 
>  *  *** This is the query that uses the inlude file database connection
> info that is currently returning no results *
>   // Query the credit_card_type table and load all of the records
>   // into an array.
>   echo "Pre-SQL";   This does not echo out*
>   $sql = "SELECT * FROM credit_card_code_types ORDER BY
> credit_card_type_desc";
>   $res = mssql_query($sql) or die(mssql_error());
>   echo $sql;  This does not echo out*
>   echo $res;  This does not echo out*
>   while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] =
$rec;
>
>   // die(''.print_r($credit_card_type_code));
> * *** No data is returned in the dropdown list*
>   foreach ($credit_card_type_desc as $c)
>   {
> if ($c['credit_card_type_code'] == $_POST['credit_card'])
>   echo " SELECTED>{$c['credit_card_type_desc']}\n";
> else
>   echo "
value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n";
>
>   }
> ?>
> 

Get rid of the echo statements in there - they will really screw up the
output of the select box. Alternatively view the source of the page this
displays - chances are that the options are being output properly, but
the HTML is so messed up that you end up with an empty select box.

-Stut



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:


*  *** This is the query that uses the inlude file database connection 
info that is currently returning no results *

  // Query the credit_card_type table and load all of the records
  // into an array.
  echo "Pre-SQL";   This does not echo out*
  $sql = "SELECT * FROM credit_card_code_types ORDER BY 
credit_card_type_desc";

  $res = mssql_query($sql) or die(mssql_error());
  echo $sql;  This does not echo out*
  echo $res;  This does not echo out*
  while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;
 
  // die(''.print_r($credit_card_type_code));
* *** No data is returned in the dropdown list* 
  foreach ($credit_card_type_desc as $c)

  {
if ($c['credit_card_type_code'] == $_POST['credit_card'])
  echo "SELECTED>{$c['credit_card_type_desc']}\n";

else
  echo "value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n"; 


  }
?>



Get rid of the echo statements in there - they will really screw up the 
output of the select box. Alternatively view the source of the page this 
displays - chances are that the options are being output properly, but 
the HTML is so messed up that you end up with an empty select box.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

If something was being displayed in there, then we wouldn't be getting to
the blank dropdown box.  But just for you I put something in there and it
doesn't get echo'd out.

On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
>  if(!empty($_POST['max_id'])) {   For this test, max_id is empty*
>
> }
> else {
> ?>

For sh*ts and giggles, echo something in there - I'm betting it'll get
displayed.

-Stut



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:




For sh*ts and giggles, echo something in there - I'm betting it'll get 
displayed.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

Okay, here's the entire thing:




Submit a New Payment.







   Credit Card
Information


  
   

 
  
   
 


 
  
   

 

 
   
 Is it a debit card?
   
 Yes 
 No 
   Credit Card Type:
   

'.print_r($credit_card_type_code));
* *** No data is returned in the dropdown list*
 foreach ($credit_card_type_desc as $c)
 {
   if ($c['credit_card_type_code'] == $_POST['credit_card'])
 echo "{$c['credit_card_type_desc']}\n";
   else
 echo "{$c['credit_card_type_desc']}\n";
 }
?>


 
 




On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


You can't rely on everyone seeing the different colours in your text.
Please lay out your replies so they can be read in plain text.

Dan Shirah wrote:
> Ok, I can't see anything wrong with that. Me either Are you absolutely
> sure it
> works when you replace the include line with the contents of the include
> file? Are you sure you're replacing it exactly? Yes, because when I
> originally made the form I had the connection info hard coded.  I "cut"
> the info from the form and pasted it into the newly created include
file.
>
> One minor thing... that include file is not the same path and filename
> you gave in your original post. You are looking at the right piece of
> code yes? Yeah, in my previous post I changed the folder/file name just
> to be safe, but I forgot to do it before posting this one.
>
> One thing I'd suggest you add is a check after the mssql_query to see
> how many rows were returned. Beyond that I'm stumped.

Something must be different. Assuming none of these files are being used
inside a function or class the act of simply moving code out to an
included file should not affect its operation.

-Stut



Re: [PHP] Image Information

2007-06-06 Thread zerof

Stut escreveu:

zerof wrote:

Steve Marquez escreveu:

Greetings,

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?

Thank you,

--
Steve Marquez


array getimagesize ( string file_image_name )

http://www.educar.pro.br/en/a/gdlib/index.php?pn=22&tr=97


Won't work *before* it is uploaded. Please read the question.

-Stut

Sorry... I think this can be useful:

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1272318&enterthread=y

http://us3.php.net/manual/en/features.file-upload.php
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
--
Você deve, sempre, consultar uma segunda opinião!
--
Deixe todos saberem se esta informação foi-lhe útil.
--  
You must hear, always, one second opinion! In all cases.
--
Let the people know if this info was useful for you!
--

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



Re: [PHP] More include issues

2007-06-06 Thread Stut
You can't rely on everyone seeing the different colours in your text. 
Please lay out your replies so they can be read in plain text.


Dan Shirah wrote:
Ok, I can't see anything wrong with that. Me either Are you absolutely 
sure it

works when you replace the include line with the contents of the include
file? Are you sure you're replacing it exactly? Yes, because when I 
originally made the form I had the connection info hard coded.  I "cut" 
the info from the form and pasted it into the newly created include file.


One minor thing... that include file is not the same path and filename
you gave in your original post. You are looking at the right piece of
code yes? Yeah, in my previous post I changed the folder/file name just 
to be safe, but I forgot to do it before posting this one.


One thing I'd suggest you add is a check after the mssql_query to see
how many rows were returned. Beyond that I'm stumped.


Something must be different. Assuming none of these files are being used 
inside a function or class the act of simply moving code out to an 
included file should not affect its operation.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

Using required() it still echoes the text I put in the include file for
testing.

On 6/6/07, Jim Moseby <[EMAIL PROTECTED]> wrote:


>
> I have error_reporting set to E_ALL and display_errors is set to On.
>
> And no errors are displayed


As a troubleshooting step, use require() instead if include().  It will
return an error message if error_reporting() allows it to.

JM



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

../../Conn/prpr_mssql.php

or

../../Connections/connection.php

These are the same file, I was just changing the name to
Connections/connection.php for a little added security of my info being on
the web is all.


On 6/6/07, Jim Lucas <[EMAIL PROTECTED]> wrote:


Stut wrote:
> Dan Shirah wrote:
>> Ask and you shall recieve!! :)
>>
>> // My include statement at the beginning of the body
>> 
>>
>> **Various plain HTML form data here**
>>
>> // My dropdown box that is not getting populated
>> >   // Query the credit_card_type table and load all of the records
>>   // into an array.
>>   $sql = "SELECT * FROM credit_card_code_types ORDER BY
>> credit_card_type_desc";
>>   $res = mssql_query($sql) or die(mssql_error());
>>   while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] =
$rec;
>>
>>   // die(''.print_r($credit_card_type_code));
>>
>>   foreach ($credit_card_type_desc as $c)
>>   {
>> if ($c['credit_card_type_code'] == $_POST['credit_card'])
>>   echo "> SELECTED>{$c['credit_card_type_desc']}\n";
>> else
>>   echo ">
value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n";
>>
>>   }
>> ?>
>
> Ok, I can't see anything wrong with that. Are you absolutely sure it
> works when you replace the include line with the contents of the include
> file? Are you sure you're replacing it exactly?
>
> One minor thing... that include file is not the same path and filename
> you gave in your original post. You are looking at the right piece of
> code yes?

but he said that he echo'ed something from the include file.

Which file was it called from?

>
> One thing I'd suggest you add is a check after the mssql_query to see
> how many rows were returned. Beyond that I'm stumped.
>
> -Stut
>


I'm thinking this is a scope issue

are either of these two pieces of code being called from within a function
or class?

the display code, or the include statement? was it

../../Conn/prpr_mssql.php

or

../../Connections/connection.php

Which file did you have the include statement in?

--
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




RE: [PHP] More include issues

2007-06-06 Thread Jim Moseby
> 
> I have error_reporting set to E_ALL and display_errors is set to On.
> 
> And no errors are displayed


As a troubleshooting step, use require() instead if include().  It will
return an error message if error_reporting() allows it to.

JM

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



Re: [PHP] Image Information

2007-06-06 Thread Jim Lucas

zerof wrote:

Steve Marquez escreveu:

Greetings,

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?

Thank you,

--
Steve Marquez


array getimagesize ( string file_image_name )

http://www.educar.pro.br/en/a/gdlib/index.php?pn=22&tr=97


I think you missed the part where he said "before it is uploaded"

--
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] More include issues

2007-06-06 Thread Dan Shirah

Ok, I can't see anything wrong with that. Me either Are you absolutely sure
it
works when you replace the include line with the contents of the include
file? Are you sure you're replacing it exactly? Yes, because when I
originally made the form I had the connection info hard coded.  I "cut" the
info from the form and pasted it into the newly created include file.

One minor thing... that include file is not the same path and filename
you gave in your original post. You are looking at the right piece of
code yes? Yeah, in my previous post I changed the folder/file name just to
be safe, but I forgot to do it before posting this one.

One thing I'd suggest you add is a check after the mssql_query to see
how many rows were returned. Beyond that I'm stumped.

-Stut


On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> Ask and you shall recieve!! :)
>
> // My include statement at the beginning of the body
> 
>
> **Various plain HTML form data here**
>
> // My dropdown box that is not getting populated
>// Query the credit_card_type table and load all of the records
>   // into an array.
>   $sql = "SELECT * FROM credit_card_code_types ORDER BY
> credit_card_type_desc";
>   $res = mssql_query($sql) or die(mssql_error());
>   while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] =
$rec;
>
>   // die(''.print_r($credit_card_type_code));
>
>   foreach ($credit_card_type_desc as $c)
>   {
> if ($c['credit_card_type_code'] == $_POST['credit_card'])
>   echo " SELECTED>{$c['credit_card_type_desc']}\n";
> else
>   echo "
value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n";
>
>   }
> ?>

Ok, I can't see anything wrong with that. Are you absolutely sure it
works when you replace the include line with the contents of the include
file? Are you sure you're replacing it exactly?

One minor thing... that include file is not the same path and filename
you gave in your original post. You are looking at the right piece of
code yes?

One thing I'd suggest you add is a check after the mssql_query to see
how many rows were returned. Beyond that I'm stumped.

-Stut

> On 6/6/07, *Stut* <[EMAIL PROTECTED] > wrote:
>
> Dan Shirah wrote:
>  > If I put an echo into my included file, the echo displays on the
> screen.
>  >
>  > But no results are returned.
>  >
>  > However, if I copy the data from my include file and paste it
> directly
>  > into my page, I get the results.
>
> Ok, so that's confirmed that the include file is being included
> properly. I think we need to see the code you're using to get the
data
> before we can help any more.
>
> -Stut
>
>  > On 6/6/07, *Stut* <[EMAIL PROTECTED] 
> mailto:[EMAIL PROTECTED]>>> wrote:
>  >
>  > Dan Shirah wrote:
>  >  > I have error_reporting set to E_ALL and display_errors is
> set to On.
>  >  >
>  >  > And no errors are displayed
>  >  >
>  >  > My code run through as it should...passes my include
>  > statement...displays
>  >  > part of the form, but when it gets to a dropdown box that
is
>  > populated by
>  >  > the database (Which the connection is set in the include)
it
>  > returns an
>  >  > empty drop down and none of the rest of my form is
displayed.
>  >
>  > Try outputting something in the include file. If that gets
> displayed
>  > then the problem is most likely that the code you have to get
the
>  > dropdown contents is not returning anything.
>  >
>  > -Stut
>  >
>  >  > On 6/6/07, Jim Lucas < [EMAIL PROTECTED]
>   >>
>  > wrote:
>  >  >>
>  >  >> Dan Shirah wrote:
>  >  >> > Okay, I'm stumped!!!
>  >  >> >
>  >  >> > I have all of my database connection info in a file:
>  > connection.php
>  >  >> > This info is stored in a folder: Connections
>  >  >> > Example of connection.php:
>  >  >> >   >  >> > $connection =
> mssql_pconnect('SERVER','user','password') or die
>  >  >> ('server
>  >  >> > connection failed');
>  >  >> > $database = mssql_select_db("my_database", $connection)
> or die
>  > ('DB
>  >  >> > selection failed');
>  >  >> > ?>
>  >  >> >
>  >  >> > I am trying to include the connection.php file in all
of my
>  > pages so I
>  >  >> > don't
>  >  >> > have to hard code the info into every page.
>  >  >> > But, my data never returns because the include
> apparently is not
>  >  >> working.
>  >  >> > If I remove the include and hard code the info, it
works.
>  >  >> >
>  >  >> > Here is an example of the include sta

RE: [PHP] customer ids using UUID, MD5, reverse logic, error 1062

2007-06-06 Thread Daevid Vincent
Have you thought of using a UUID:
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#func
tion_uuid

While not real pretty, it would save you the extra "SELECT".
You could also just MD5(UUID()) to make it a bit 'smaller', or some
other mechanizm.

Even something as simple as MD5(UNIX_TIME()) might be fine enough
resolution/granularity for your needs, depending on how many
simultaneous "INSERT"s you expect. 

Honestly, I would use a little reverse logic, and not do the select
first (which is a wasted query as you have more chance of success if
your 'random' pool is big/unique enough), but rather _assume_ it will
INSERT, and then handle the case you get a "DUPLICATE KEY" issue (i.e. a
failure. "ERROR 1062 (23000): Duplicate entry '1' for key 1", so you can
check:

This is rough pseudo code, but you get the idea...

$key = UUID();
While (!success)
{
 $sth = mysql_query("insert into () values ()");
 if (!$sth || mysql_error() == '1062')
 {
//pick a new key and loop around.
  continue;
 }
 $success = true;
}

> -Original Message-
> From: blueboy [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 06, 2007 7:40 AM
> To: php-general@lists.php.net
> Subject: [PHP] customer ids
> 
> Hi,
> 
> I want to create random customer ids. I have an auto 
> incremented coulumn but 
> I would rather have a 6-8 digit/letter id randomly generated  
> that can be 
> used as a unique identifier across 3 tables. Does anyone have 
> a algorithm to 
> generate such a string and can you give the odds against 2 
> duplicate stings 
> being generated?
> 
> I know this is a strange ask.
> 
> 
> R. 
> 
> -- 
> 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] More include issues

2007-06-06 Thread Jim Lucas

Stut wrote:

Dan Shirah wrote:

Ask and you shall recieve!! :)
 
// My include statement at the beginning of the body


 
**Various plain HTML form data here**
 
// My dropdown box that is not getting populated

  $sql = "SELECT * FROM credit_card_code_types ORDER BY 
credit_card_type_desc";

  $res = mssql_query($sql) or die(mssql_error());
  while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;
 
  // die(''.print_r($credit_card_type_code));
 
  foreach ($credit_card_type_desc as $c)

  {
if ($c['credit_card_type_code'] == $_POST['credit_card'])
  echo "SELECTED>{$c['credit_card_type_desc']}\n";

else
  echo "value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n"; 


  }
?>


Ok, I can't see anything wrong with that. Are you absolutely sure it 
works when you replace the include line with the contents of the include 
file? Are you sure you're replacing it exactly?


One minor thing... that include file is not the same path and filename 
you gave in your original post. You are looking at the right piece of 
code yes?


but he said that he echo'ed something from the include file.

Which file was it called from?



One thing I'd suggest you add is a check after the mssql_query to see 
how many rows were returned. Beyond that I'm stumped.


-Stut




I'm thinking this is a scope issue

are either of these two pieces of code being called from within a function or 
class?

the display code, or the include statement? was it

../../Conn/prpr_mssql.php

or

../../Connections/connection.php

Which file did you have the include statement in?

--
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] Image Information

2007-06-06 Thread Stut

zerof wrote:

Steve Marquez escreveu:

Greetings,

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?

Thank you,

--
Steve Marquez


array getimagesize ( string file_image_name )

http://www.educar.pro.br/en/a/gdlib/index.php?pn=22&tr=97


Won't work *before* it is uploaded. Please read the question.

-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:

Ask and you shall recieve!! :)
 
// My include statement at the beginning of the body


 
**Various plain HTML form data here**
 
// My dropdown box that is not getting populated

  $sql = "SELECT * FROM credit_card_code_types ORDER BY 
credit_card_type_desc";

  $res = mssql_query($sql) or die(mssql_error());
  while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;
 
  // die(''.print_r($credit_card_type_code));
 
  foreach ($credit_card_type_desc as $c)

  {
if ($c['credit_card_type_code'] == $_POST['credit_card'])
  echo "SELECTED>{$c['credit_card_type_desc']}\n";

else
  echo "value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}\n"; 


  }
?>


Ok, I can't see anything wrong with that. Are you absolutely sure it 
works when you replace the include line with the contents of the include 
file? Are you sure you're replacing it exactly?


One minor thing... that include file is not the same path and filename 
you gave in your original post. You are looking at the right piece of 
code yes?


One thing I'd suggest you add is a check after the mssql_query to see 
how many rows were returned. Beyond that I'm stumped.


-Stut


On 6/6/07, *Stut* <[EMAIL PROTECTED] > wrote:

Dan Shirah wrote:
 > If I put an echo into my included file, the echo displays on the
screen.
 >
 > But no results are returned.
 >
 > However, if I copy the data from my include file and paste it
directly
 > into my page, I get the results.

Ok, so that's confirmed that the include file is being included
properly. I think we need to see the code you're using to get the data
before we can help any more.

-Stut

 > On 6/6/07, *Stut* <[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]>>> wrote:
 >
 > Dan Shirah wrote:
 >  > I have error_reporting set to E_ALL and display_errors is
set to On.
 >  >
 >  > And no errors are displayed
 >  >
 >  > My code run through as it should...passes my include
 > statement...displays
 >  > part of the form, but when it gets to a dropdown box that is
 > populated by
 >  > the database (Which the connection is set in the include) it
 > returns an
 >  > empty drop down and none of the rest of my form is displayed.
 >
 > Try outputting something in the include file. If that gets
displayed
 > then the problem is most likely that the code you have to get the
 > dropdown contents is not returning anything.
 >
 > -Stut
 >
 >  > On 6/6/07, Jim Lucas < [EMAIL PROTECTED]
 >>
 > wrote:
 >  >>
 >  >> Dan Shirah wrote:
 >  >> > Okay, I'm stumped!!!
 >  >> >
 >  >> > I have all of my database connection info in a file:
 > connection.php
 >  >> > This info is stored in a folder: Connections
 >  >> > Example of connection.php:
 >  >> >   >> > $connection =
mssql_pconnect('SERVER','user','password') or die
 >  >> ('server
 >  >> > connection failed');
 >  >> > $database = mssql_select_db("my_database", $connection)
or die
 > ('DB
 >  >> > selection failed');
 >  >> > ?>
 >  >> >
 >  >> > I am trying to include the connection.php file in all of my
 > pages so I
 >  >> > don't
 >  >> > have to hard code the info into every page.
 >  >> > But, my data never returns because the include
apparently is not
 >  >> working.
 >  >> > If I remove the include and hard code the info, it works.
 >  >> >
 >  >> > Here is an example of the include statement I am using
on my
 > pages.
 >  >> >
 >  >> > 
 >  >> >
 >  >> > The Connections folder is two level above my form
 > page.  Example file
 >  >> > structure below.
 >  >> >
 >  >> > ROOT
 >  >> >Connections
 >  >> > connection.php
 >  >> >Submit
 >  >> >Current_Forms
 >  >> > My_Form.php
 >  >> >
 >  >> > I've tried ../../../Connections/connection.php,
 >  >> > ../../Connections/connection.php,
 > ../Connections/connection.php but
 >  >> nothing
 >  >> > works.
 >  >> >
 >  >> > Any ideas what I am doing wrong???
 >  >> >
 >  >> Set your error_reporting to E_ALL.
 >  >> and set display_errors to On
 >  >>
 >  >> Then you should be able to see all the errors.
 >  >>
 >  >> Because, without the error messages, we are not going to
be able
 > to help
 >  >> you.
 >  >

Re: [PHP] Image Information

2007-06-06 Thread zerof

Steve Marquez escreveu:

Greetings,

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?

Thank you,

--
Steve Marquez


array getimagesize ( string file_image_name )

http://www.educar.pro.br/en/a/gdlib/index.php?pn=22&tr=97
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
--
Você deve, sempre, consultar uma segunda opinião!
--
Deixe todos saberem se esta informação foi-lhe útil.
--  
You must hear, always, one second opinion! In all cases.
--
Let the people know if this info was useful for you!
--

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



Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

Ask and you shall recieve!! :)

// My include statement at the beginning of the body


**Various plain HTML form data here**

// My dropdown box that is not getting populated
'.print_r($credit_card_type_code));

 foreach ($credit_card_type_desc as $c)
 {
   if ($c['credit_card_type_code'] == $_POST['credit_card'])
 echo "{$c['credit_card_type_desc']}\n";
   else
 echo "{$c['credit_card_type_desc']}\n";
 }
?>


On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> If I put an echo into my included file, the echo displays on the screen.
>
> But no results are returned.
>
> However, if I copy the data from my include file and paste it directly
> into my page, I get the results.

Ok, so that's confirmed that the include file is being included
properly. I think we need to see the code you're using to get the data
before we can help any more.

-Stut

> On 6/6/07, *Stut* <[EMAIL PROTECTED] > wrote:
>
> Dan Shirah wrote:
>  > I have error_reporting set to E_ALL and display_errors is set to
On.
>  >
>  > And no errors are displayed
>  >
>  > My code run through as it should...passes my include
> statement...displays
>  > part of the form, but when it gets to a dropdown box that is
> populated by
>  > the database (Which the connection is set in the include) it
> returns an
>  > empty drop down and none of the rest of my form is displayed.
>
> Try outputting something in the include file. If that gets displayed
> then the problem is most likely that the code you have to get the
> dropdown contents is not returning anything.
>
> -Stut
>
>  > On 6/6/07, Jim Lucas <[EMAIL PROTECTED] >
> wrote:
>  >>
>  >> Dan Shirah wrote:
>  >> > Okay, I'm stumped!!!
>  >> >
>  >> > I have all of my database connection info in a file:
> connection.php
>  >> > This info is stored in a folder: Connections
>  >> > Example of connection.php:
>  >> >   >> > $connection = mssql_pconnect('SERVER','user','password') or
die
>  >> ('server
>  >> > connection failed');
>  >> > $database = mssql_select_db("my_database", $connection) or die
> ('DB
>  >> > selection failed');
>  >> > ?>
>  >> >
>  >> > I am trying to include the connection.php file in all of my
> pages so I
>  >> > don't
>  >> > have to hard code the info into every page.
>  >> > But, my data never returns because the include apparently is
not
>  >> working.
>  >> > If I remove the include and hard code the info, it works.
>  >> >
>  >> > Here is an example of the include statement I am using on my
> pages.
>  >> >
>  >> > 
>  >> >
>  >> > The Connections folder is two level above my form
> page.  Example file
>  >> > structure below.
>  >> >
>  >> > ROOT
>  >> >Connections
>  >> > connection.php
>  >> >Submit
>  >> >Current_Forms
>  >> > My_Form.php
>  >> >
>  >> > I've tried ../../../Connections/connection.php,
>  >> > ../../Connections/connection.php,
> ../Connections/connection.php but
>  >> nothing
>  >> > works.
>  >> >
>  >> > Any ideas what I am doing wrong???
>  >> >
>  >> Set your error_reporting to E_ALL.
>  >> and set display_errors to On
>  >>
>  >> Then you should be able to see all the errors.
>  >>
>  >> Because, without the error messages, we are not going to be able
> to help
>  >> you.
>  >>
>  >> Might I recommend to use include_once instead.  This way, it
> will only
>  >> create one connection
>  >>
>  >> --
>  >> 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
>  >>
>  >>
>  >
>
>




Re: [PHP] Image Information

2007-06-06 Thread Stut

Steve Marquez wrote:

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?


Not without using a client-side technology. PHP can't help you on the 
client-side.


-Stut

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



Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:

If I put an echo into my included file, the echo displays on the screen.
 
But no results are returned.
 
However, if I copy the data from my include file and paste it directly 
into my page, I get the results.


Ok, so that's confirmed that the include file is being included 
properly. I think we need to see the code you're using to get the data 
before we can help any more.


-Stut


On 6/6/07, *Stut* <[EMAIL PROTECTED] > wrote:

Dan Shirah wrote:
 > I have error_reporting set to E_ALL and display_errors is set to On.
 >
 > And no errors are displayed
 >
 > My code run through as it should...passes my include
statement...displays
 > part of the form, but when it gets to a dropdown box that is
populated by
 > the database (Which the connection is set in the include) it
returns an
 > empty drop down and none of the rest of my form is displayed.

Try outputting something in the include file. If that gets displayed
then the problem is most likely that the code you have to get the
dropdown contents is not returning anything.

-Stut

 > On 6/6/07, Jim Lucas <[EMAIL PROTECTED] >
wrote:
 >>
 >> Dan Shirah wrote:
 >> > Okay, I'm stumped!!!
 >> >
 >> > I have all of my database connection info in a file:
connection.php
 >> > This info is stored in a folder: Connections
 >> > Example of connection.php:
 >> > > > $connection = mssql_pconnect('SERVER','user','password') or die
 >> ('server
 >> > connection failed');
 >> > $database = mssql_select_db("my_database", $connection) or die
('DB
 >> > selection failed');
 >> > ?>
 >> >
 >> > I am trying to include the connection.php file in all of my
pages so I
 >> > don't
 >> > have to hard code the info into every page.
 >> > But, my data never returns because the include apparently is not
 >> working.
 >> > If I remove the include and hard code the info, it works.
 >> >
 >> > Here is an example of the include statement I am using on my
pages.
 >> >
 >> > 
 >> >
 >> > The Connections folder is two level above my form
page.  Example file
 >> > structure below.
 >> >
 >> > ROOT
 >> >Connections
 >> > connection.php
 >> >Submit
 >> >Current_Forms
 >> > My_Form.php
 >> >
 >> > I've tried ../../../Connections/connection.php,
 >> > ../../Connections/connection.php,
../Connections/connection.php but
 >> nothing
 >> > works.
 >> >
 >> > Any ideas what I am doing wrong???
 >> >
 >> Set your error_reporting to E_ALL.
 >> and set display_errors to On
 >>
 >> Then you should be able to see all the errors.
 >>
 >> Because, without the error messages, we are not going to be able
to help
 >> you.
 >>
 >> Might I recommend to use include_once instead.  This way, it
will only
 >> create one connection
 >>
 >> --
 >> 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] Image Information

2007-06-06 Thread Steve Marquez
Greetings,

I am trying to get information (width, height, file size) from an image
before it is uploaded. Is there a way to do that?

Thank you,

--
Steve Marquez


Re: [PHP] More include issues

2007-06-06 Thread Dan Shirah

If I put an echo into my included file, the echo displays on the screen.

But no results are returned.

However, if I copy the data from my include file and paste it directly into
my page, I get the results.


On 6/6/07, Stut <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> I have error_reporting set to E_ALL and display_errors is set to On.
>
> And no errors are displayed
>
> My code run through as it should...passes my include
statement...displays
> part of the form, but when it gets to a dropdown box that is populated
by
> the database (Which the connection is set in the include) it returns an
> empty drop down and none of the rest of my form is displayed.

Try outputting something in the include file. If that gets displayed
then the problem is most likely that the code you have to get the
dropdown contents is not returning anything.

-Stut

> On 6/6/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
>>
>> Dan Shirah wrote:
>> > Okay, I'm stumped!!!
>> >
>> > I have all of my database connection info in a file: connection.php
>> > This info is stored in a folder: Connections
>> > Example of connection.php:
>> > > > $connection = mssql_pconnect('SERVER','user','password') or die
>> ('server
>> > connection failed');
>> > $database = mssql_select_db("my_database", $connection) or die ('DB
>> > selection failed');
>> > ?>
>> >
>> > I am trying to include the connection.php file in all of my pages so
I
>> > don't
>> > have to hard code the info into every page.
>> > But, my data never returns because the include apparently is not
>> working.
>> > If I remove the include and hard code the info, it works.
>> >
>> > Here is an example of the include statement I am using on my pages.
>> >
>> > 
>> >
>> > The Connections folder is two level above my form page.  Example file
>> > structure below.
>> >
>> > ROOT
>> >Connections
>> >connection.php
>> >Submit
>> >Current_Forms
>> > My_Form.php
>> >
>> > I've tried ../../../Connections/connection.php,
>> > ../../Connections/connection.php, ../Connections/connection.php but
>> nothing
>> > works.
>> >
>> > Any ideas what I am doing wrong???
>> >
>> Set your error_reporting to E_ALL.
>> and set display_errors to On
>>
>> Then you should be able to see all the errors.
>>
>> Because, without the error messages, we are not going to be able to
help
>> you.
>>
>> Might I recommend to use include_once instead.  This way, it will only
>> create one connection
>>
>> --
>> 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
>>
>>
>




Re: [PHP] More include issues

2007-06-06 Thread Stut

Dan Shirah wrote:

I have error_reporting set to E_ALL and display_errors is set to On.

And no errors are displayed

My code run through as it should...passes my include statement...displays
part of the form, but when it gets to a dropdown box that is populated by
the database (Which the connection is set in the include) it returns an
empty drop down and none of the rest of my form is displayed.


Try outputting something in the include file. If that gets displayed 
then the problem is most likely that the code you have to get the 
dropdown contents is not returning anything.


-Stut


On 6/6/07, Jim Lucas <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> Okay, I'm stumped!!!
>
> I have all of my database connection info in a file: connection.php
> This info is stored in a folder: Connections
> Example of connection.php:
> > $connection = mssql_pconnect('SERVER','user','password') or die 
('server

> connection failed');
> $database = mssql_select_db("my_database", $connection) or die ('DB
> selection failed');
> ?>
>
> I am trying to include the connection.php file in all of my pages so I
> don't
> have to hard code the info into every page.
> But, my data never returns because the include apparently is not
working.
> If I remove the include and hard code the info, it works.
>
> Here is an example of the include statement I am using on my pages.
>
> 
>
> The Connections folder is two level above my form page.  Example file
> structure below.
>
> ROOT
>Connections
>connection.php
>Submit
>Current_Forms
> My_Form.php
>
> I've tried ../../../Connections/connection.php,
> ../../Connections/connection.php, ../Connections/connection.php but
nothing
> works.
>
> Any ideas what I am doing wrong???
>
Set your error_reporting to E_ALL.
and set display_errors to On

Then you should be able to see all the errors.

Because, without the error messages, we are not going to be able to help
you.

Might I recommend to use include_once instead.  This way, it will only
create one connection

--
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] More include issues

2007-06-06 Thread Dan Shirah

I have error_reporting set to E_ALL and display_errors is set to On.

And no errors are displayed

My code run through as it should...passes my include statement...displays
part of the form, but when it gets to a dropdown box that is populated by
the database (Which the connection is set in the include) it returns an
empty drop down and none of the rest of my form is displayed.


On 6/6/07, Jim Lucas <[EMAIL PROTECTED]> wrote:


Dan Shirah wrote:
> Okay, I'm stumped!!!
>
> I have all of my database connection info in a file: connection.php
> This info is stored in a folder: Connections
> Example of connection.php:
>  $connection = mssql_pconnect('SERVER','user','password') or die ('server
> connection failed');
> $database = mssql_select_db("my_database", $connection) or die ('DB
> selection failed');
> ?>
>
> I am trying to include the connection.php file in all of my pages so I
> don't
> have to hard code the info into every page.
> But, my data never returns because the include apparently is not
working.
> If I remove the include and hard code the info, it works.
>
> Here is an example of the include statement I am using on my pages.
>
> 
>
> The Connections folder is two level above my form page.  Example file
> structure below.
>
> ROOT
>Connections
>connection.php
>Submit
>Current_Forms
> My_Form.php
>
> I've tried ../../../Connections/connection.php,
> ../../Connections/connection.php, ../Connections/connection.php but
nothing
> works.
>
> Any ideas what I am doing wrong???
>
Set your error_reporting to E_ALL.
and set display_errors to On

Then you should be able to see all the errors.

Because, without the error messages, we are not going to be able to help
you.

Might I recommend to use include_once instead.  This way, it will only
create one connection

--
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] cannot make directory at remote host

2007-06-06 Thread blueboy
This work localy but not on my remote host. How can I debug it?

if(!(is_dir('images/$customer_id')))
{
mkdir("images/$customer_id", 0700);

}

The file is in the main public_html folder and there is a images folder. 
What should the permissions be?


Thanks

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



Re: [PHP] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
Greg Beaver wrote:
> Eric Butera wrote:
> 
>> My work machine is a OS X iMac that has Apple's php4 standard, plus I
>> have a php4 and php5 custom compiled myself.  I've been able to issue
>> sudo /path/to/php4/bin/pear or /path/to/php5/bin/pear and that
>> installs the packages correctly for each version that I want.
>> Apparently this practice is completely wrong given that long string of
>> commands seen above.

I'll still have to actually install pear/pecl for my custom php5 install,
given that it was installed without pear to begin with.

> 
> Hi Eric,
> 
> For defaults, PEAR relies on a number of constants, including
> PHP_SYSCONFDIR and PHP_LIBDIR.  If these are in fact different for php4
> and php5, then yes, your PEAR will "just work" without change.
> 
> So no, that practice is completely right :)
> 
> I had forgotten this is a possibility, so you might just try it out
> Jochem and see if it works.

I will definitely look into it. either way I now have a better solution
than baking & installing APC by hand.

thanks to everyone for their input.

> 
> Greg
> 

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



Re: [PHP] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Greg Beaver
Eric Butera wrote:

> My work machine is a OS X iMac that has Apple's php4 standard, plus I
> have a php4 and php5 custom compiled myself.  I've been able to issue
> sudo /path/to/php4/bin/pear or /path/to/php5/bin/pear and that
> installs the packages correctly for each version that I want.
> Apparently this practice is completely wrong given that long string of
> commands seen above.

Hi Eric,

For defaults, PEAR relies on a number of constants, including
PHP_SYSCONFDIR and PHP_LIBDIR.  If these are in fact different for php4
and php5, then yes, your PEAR will "just work" without change.

So no, that practice is completely right :)

I had forgotten this is a possibility, so you might just try it out
Jochem and see if it works.

Greg

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



Re: [PHP] More include issues

2007-06-06 Thread Jim Lucas

Dan Shirah wrote:

Okay, I'm stumped!!!

I have all of my database connection info in a file: connection.php
This info is stored in a folder: Connections
Example of connection.php:


I am trying to include the connection.php file in all of my pages so I 
don't

have to hard code the info into every page.
But, my data never returns because the include apparently is not working.
If I remove the include and hard code the info, it works.

Here is an example of the include statement I am using on my pages.



The Connections folder is two level above my form page.  Example file
structure below.

ROOT
   Connections
   connection.php
   Submit
   Current_Forms
My_Form.php

I've tried ../../../Connections/connection.php,
../../Connections/connection.php, ../Connections/connection.php but nothing
works.

Any ideas what I am doing wrong???


Set your error_reporting to E_ALL.
and set display_errors to On

Then you should be able to see all the errors.

Because, without the error messages, we are not going to be able to help you.

Might I recommend to use include_once instead.  This way, it will only create 
one connection

--
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] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Eric Butera

On 6/6/07, Greg Beaver <[EMAIL PROTECTED]> wrote:

Jochem Maas wrote:
> I have a [gentoo] server with 2 apache installations ...
>
> the std distro apache runs with php4 which includes an installation
> of PEAR and PECL.
>
> the second apache is compiled by hand and runs with php5 (also compiled
> by hand) - obviously both of these are installed somewhere other than
> the default. the [custom] php5 installation does not include PEAR/PECL
> (when I built/installed it I skipped that because I was worried I'd get a 
conflict
> with the existing PEAR/PECL install and break something).
>
> I would like to add the APC extension to the php5 setup, normally this is
> as involved as doing the following:
>
>   > pecl install apc
>
> only in this case that would install APC in the php4 setup.
> the question is how do I go about getting a second/custom PEAR/PECL setup 
running
> which I can use with/for the php5 setup. is this even possible? or
> am I stuck with a manual download, compile and install of APC for the
> php5 setup as described here for instance:
> 
http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?

Hi Jochem,

If you're having PEAR questions, ask on the pear-general list.  It's
pure luck that I happened upon your message, and nobody on php-general
seems to know jack about PEAR.

The solution is quite easy.

You need separate configuration files for PEAR in PHP5.  To get this
going, you should first install a local copy of PEAR for PHP5 only.

Assuming you have PEAR in /usr/local/lib/php, the best choice is to
install another copy in /usr/local/lib/php5:

First you'll need to create a new configuration file, which you can save
as "/etc/pear5.conf".  Your php4 conf will be in /etc/pear.conf.  Then
you need to create a new directory for downloads to avoid conflicts
(easy).  The most important part is to set the php_bin variable to the
path to php5 and finally install your custom copy of PEAR.  I assume you
are using "php5" as the CLI for PHP 5.  Change this to the right name in
`which php5` if I'm wrong.

sudo pear config-create /usr/local/lib/php5 /etc/pear5.conf
sudo pear -c /etc/pear5.conf config-set php_bin `which php5`
sudo pear -c /etc/pear5.conf config-set download_dir /tmp/pear5
mkdir /tmp/pear5
chmod 0777 /tmp/pear5
sudo pear -c /etc/pear5.conf up PEAR

At this point you will have a new pear and pecl executable stored in
/usr/local/lib/php5/pear/.  You'll also want to set the ext_dir to the
location of your extension_dir in php.ini for php5.

sudo pear -c /etc/pear5.conf config-set ext_dir /path/to/php5/ext

Finally, as a convenience, you'll probably want to use ln to make
"pear5" and "pecl5" commands

sudo ln -s /usr/local/lib/php5/pear/pear /usr/local/bin/pear5
sudo ln -s /usr/local/lib/php5/pear/pecl /usr/local/bin/pecl5

Lastly, you will *always* want to call with the -c option

pecl5 install APC

will still use your default configuration file at /etc/pear.conf.

pecl5 -c /etc/pear5.conf install APC

will correctly install and configure APC for php5.

Needless to say, this is more complicated than it seems like it should
be, and the next version of the PEAR installer, Pyrus, makes this
process MUCH easier.  Pyrus has only just been started, and so is barely
past proof-of-concept.

I hope this helps out.

Greg

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



My work machine is a OS X iMac that has Apple's php4 standard, plus I
have a php4 and php5 custom compiled myself.  I've been able to issue
sudo /path/to/php4/bin/pear or /path/to/php5/bin/pear and that
installs the packages correctly for each version that I want.
Apparently this practice is completely wrong given that long string of
commands seen above.

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



Re: [PHP] More include issues

2007-06-06 Thread Robert Cummings
On Wed, 2007-06-06 at 13:42 -0400, Dan Shirah wrote:
> Okay, I'm stumped!!!
> 
> I have all of my database connection info in a file: connection.php
> This info is stored in a folder: Connections
> Example of connection.php:
>  $connection = mssql_pconnect('SERVER','user','password') or die ('server
> connection failed');
> $database = mssql_select_db("my_database", $connection) or die ('DB
> selection failed');
> ?>
> 
> I am trying to include the connection.php file in all of my pages so I don't
> have to hard code the info into every page.
> But, my data never returns because the include apparently is not working.
> If I remove the include and hard code the info, it works.
> 
> Here is an example of the include statement I am using on my pages.
> 
> 
> 
> The Connections folder is two level above my form page.  Example file
> structure below.
> 
> ROOT
> Connections
> connection.php
> Submit
> Current_Forms
>  My_Form.php
> 
> I've tried ../../../Connections/connection.php,
> ../../Connections/connection.php, ../Connections/connection.php but nothing
> works.

Yeah, the current path is your document root... so use the following:



Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
hi Greg,

thanks so much for taking the time to give such a detailed run down
(and a complete solution) ...

Greg Beaver wrote:
> Jochem Maas wrote:

...

> 
> Hi Jochem,
> 
> If you're having PEAR questions, ask on the pear-general list.  It's
> pure luck that I happened upon your message, and nobody on php-general
> seems to know jack about PEAR.

they don't indeed :-) I'll make my way over to the pear-general list
in future. thanks for the reminder.

> 
> The solution is quite easy.
> 
> You need separate configuration files for PEAR in PHP5.  To get this
> going, you should first install a local copy of PEAR for PHP5 only.
> 
> Assuming you have PEAR in /usr/local/lib/php, the best choice is to
> install another copy in /usr/local/lib/php5:
> 
> First you'll need to create a new configuration file, which you can save
> as "/etc/pear5.conf".  Your php4 conf will be in /etc/pear.conf.  Then
> you need to create a new directory for downloads to avoid conflicts
> (easy).  The most important part is to set the php_bin variable to the
> path to php5 and finally install your custom copy of PEAR.  I assume you
> are using "php5" as the CLI for PHP 5.  Change this to the right name in
> `which php5` if I'm wrong.
> 
> sudo pear config-create /usr/local/lib/php5 /etc/pear5.conf
> sudo pear -c /etc/pear5.conf config-set php_bin `which php5`
> sudo pear -c /etc/pear5.conf config-set download_dir /tmp/pear5
> mkdir /tmp/pear5
> chmod 0777 /tmp/pear5
> sudo pear -c /etc/pear5.conf up PEAR
> 
> At this point you will have a new pear and pecl executable stored in
> /usr/local/lib/php5/pear/.  You'll also want to set the ext_dir to the
> location of your extension_dir in php.ini for php5.
> 
> sudo pear -c /etc/pear5.conf config-set ext_dir /path/to/php5/ext
> 
> Finally, as a convenience, you'll probably want to use ln to make
> "pear5" and "pecl5" commands
> 
> sudo ln -s /usr/local/lib/php5/pear/pear /usr/local/bin/pear5
> sudo ln -s /usr/local/lib/php5/pear/pecl /usr/local/bin/pecl5
> 
> Lastly, you will *always* want to call with the -c option

I suppose I could setup global [bash] aliases that would
include the -c option. no?

> 
> pecl5 install APC
> 
> will still use your default configuration file at /etc/pear.conf.
> 
> pecl5 -c /etc/pear5.conf install APC
> 
> will correctly install and configure APC for php5.
> 
> Needless to say, this is more complicated than it seems like it should
> be, and the next version of the PEAR installer. 

maybe a bit convoluted, but following the steps you set out is cinch
compared to trying to figuring it out on my own (and hoping I had got it
right).

> Pyrus, makes this
> process MUCH easier.  Pyrus has only just been started, and so is barely
> past proof-of-concept.
> 
> I hope this helps out.

you bet! your detailed explanation is just the ticket!

> 
> Greg

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



Re: [PHP] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Daniel Brown

On 6/6/07, Greg Beaver <[EMAIL PROTECTED]> wrote:

Jochem Maas wrote:
> I have a [gentoo] server with 2 apache installations ...
>
> the std distro apache runs with php4 which includes an installation
> of PEAR and PECL.
>
> the second apache is compiled by hand and runs with php5 (also compiled
> by hand) - obviously both of these are installed somewhere other than
> the default. the [custom] php5 installation does not include PEAR/PECL
> (when I built/installed it I skipped that because I was worried I'd get a 
conflict
> with the existing PEAR/PECL install and break something).
>
> I would like to add the APC extension to the php5 setup, normally this is
> as involved as doing the following:
>
>   > pecl install apc
>
> only in this case that would install APC in the php4 setup.
> the question is how do I go about getting a second/custom PEAR/PECL setup 
running
> which I can use with/for the php5 setup. is this even possible? or
> am I stuck with a manual download, compile and install of APC for the
> php5 setup as described here for instance:
> 
http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?

Hi Jochem,

If you're having PEAR questions, ask on the pear-general list.  It's
pure luck that I happened upon your message, and nobody on php-general
seems to know jack about PEAR.

The solution is quite easy.

You need separate configuration files for PEAR in PHP5.  To get this
going, you should first install a local copy of PEAR for PHP5 only.

Assuming you have PEAR in /usr/local/lib/php, the best choice is to
install another copy in /usr/local/lib/php5:

First you'll need to create a new configuration file, which you can save
as "/etc/pear5.conf".  Your php4 conf will be in /etc/pear.conf.  Then
you need to create a new directory for downloads to avoid conflicts
(easy).  The most important part is to set the php_bin variable to the
path to php5 and finally install your custom copy of PEAR.  I assume you
are using "php5" as the CLI for PHP 5.  Change this to the right name in
`which php5` if I'm wrong.

sudo pear config-create /usr/local/lib/php5 /etc/pear5.conf
sudo pear -c /etc/pear5.conf config-set php_bin `which php5`
sudo pear -c /etc/pear5.conf config-set download_dir /tmp/pear5
mkdir /tmp/pear5
chmod 0777 /tmp/pear5
sudo pear -c /etc/pear5.conf up PEAR

At this point you will have a new pear and pecl executable stored in
/usr/local/lib/php5/pear/.  You'll also want to set the ext_dir to the
location of your extension_dir in php.ini for php5.

sudo pear -c /etc/pear5.conf config-set ext_dir /path/to/php5/ext

Finally, as a convenience, you'll probably want to use ln to make
"pear5" and "pecl5" commands

sudo ln -s /usr/local/lib/php5/pear/pear /usr/local/bin/pear5
sudo ln -s /usr/local/lib/php5/pear/pecl /usr/local/bin/pecl5

Lastly, you will *always* want to call with the -c option

pecl5 install APC

will still use your default configuration file at /etc/pear.conf.

pecl5 -c /etc/pear5.conf install APC

will correctly install and configure APC for php5.

Needless to say, this is more complicated than it seems like it should
be, and the next version of the PEAR installer, Pyrus, makes this
process MUCH easier.  Pyrus has only just been started, and so is barely
past proof-of-concept.

I hope this helps out.

Greg

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




   < doesn't know Jack, but gave the same answer in a simplified
manner earlier anyway.

   Who the %#$@ is Jack?!?

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



[PHP] More include issues

2007-06-06 Thread Dan Shirah

Okay, I'm stumped!!!

I have all of my database connection info in a file: connection.php
This info is stored in a folder: Connections
Example of connection.php:


I am trying to include the connection.php file in all of my pages so I don't
have to hard code the info into every page.
But, my data never returns because the include apparently is not working.
If I remove the include and hard code the info, it works.

Here is an example of the include statement I am using on my pages.



The Connections folder is two level above my form page.  Example file
structure below.

ROOT
   Connections
   connection.php
   Submit
   Current_Forms
My_Form.php

I've tried ../../../Connections/connection.php,
../../Connections/connection.php, ../Connections/connection.php but nothing
works.

Any ideas what I am doing wrong???


Re: [PHP] export to csv

2007-06-06 Thread Haig Dedeyan


Jim Lucas <[EMAIL PROTECTED]> wrote: Haig (Home) wrote:
> Hi everyone, I have a small problem when exporting mysql into csv format.
> 
>  
> 
> The export works fine. The problem is, if the mysql table has a carriage
> return, opening the csv file in excel will display a square box where the
> carriage return is.
> 
>  
> 
> Displaying the table on a web page is fine.
> 
>  
> 
> Thanks for any help.
> 
>  
> 
> Haig
> 
>  
> 
> > 
>  
> 
> $csv_output = 'column1';
> 
> $csv_output .= "\015\012";
> 
> $result = mysql_query("select * from table"); 
> 
> while($row = mysql_fetch_array($result)) 
> 
>{
> 
>   $csv_output .= '"'.$row[column1].'"';


In a more recent post, the op asked a question that is related to this, 
in a way.

Here is what I think your solution would look like

$data = preg_replace("!\r\n|\n|\r!", "\r\n", $row['column1']);
$csv_output .= '"' . $data . '"';

Reason being is that Windows uses "\r\n" for line endings.  More than 
likely you are outputting "\n"  This would cause windows to display one 
of those funky boxes that you are talking about.

PS. be sure and use quotes around your array key names, otherwise you 
might cause a PHP Notice on different systems.

> 
>   $csv_output .= "\015\012";
> 
>}
> 
> header("Content-type: application/vnd.ms-excel");
> 
> header("Content-disposition:  attachment; filename=" .
> 
> date("Y-m-d")."_my_report".".csv");
> 
>print $csv_output;
> 
>exit;  
> 
> mysql_close();
> 
>}
> 
>  
> 
> 

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


Thanks Jim. That did the trick.

Haig

   
-
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot 
with the All-new Yahoo! Mail  

[PHP] Re: second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Greg Beaver
Jochem Maas wrote:
> I have a [gentoo] server with 2 apache installations ...
> 
> the std distro apache runs with php4 which includes an installation
> of PEAR and PECL.
> 
> the second apache is compiled by hand and runs with php5 (also compiled
> by hand) - obviously both of these are installed somewhere other than
> the default. the [custom] php5 installation does not include PEAR/PECL
> (when I built/installed it I skipped that because I was worried I'd get a 
> conflict
> with the existing PEAR/PECL install and break something).
> 
> I would like to add the APC extension to the php5 setup, normally this is
> as involved as doing the following:
> 
>   > pecl install apc
> 
> only in this case that would install APC in the php4 setup.
> the question is how do I go about getting a second/custom PEAR/PECL setup 
> running
> which I can use with/for the php5 setup. is this even possible? or
> am I stuck with a manual download, compile and install of APC for the
> php5 setup as described here for instance:
> http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?

Hi Jochem,

If you're having PEAR questions, ask on the pear-general list.  It's
pure luck that I happened upon your message, and nobody on php-general
seems to know jack about PEAR.

The solution is quite easy.

You need separate configuration files for PEAR in PHP5.  To get this
going, you should first install a local copy of PEAR for PHP5 only.

Assuming you have PEAR in /usr/local/lib/php, the best choice is to
install another copy in /usr/local/lib/php5:

First you'll need to create a new configuration file, which you can save
as "/etc/pear5.conf".  Your php4 conf will be in /etc/pear.conf.  Then
you need to create a new directory for downloads to avoid conflicts
(easy).  The most important part is to set the php_bin variable to the
path to php5 and finally install your custom copy of PEAR.  I assume you
are using "php5" as the CLI for PHP 5.  Change this to the right name in
`which php5` if I'm wrong.

sudo pear config-create /usr/local/lib/php5 /etc/pear5.conf
sudo pear -c /etc/pear5.conf config-set php_bin `which php5`
sudo pear -c /etc/pear5.conf config-set download_dir /tmp/pear5
mkdir /tmp/pear5
chmod 0777 /tmp/pear5
sudo pear -c /etc/pear5.conf up PEAR

At this point you will have a new pear and pecl executable stored in
/usr/local/lib/php5/pear/.  You'll also want to set the ext_dir to the
location of your extension_dir in php.ini for php5.

sudo pear -c /etc/pear5.conf config-set ext_dir /path/to/php5/ext

Finally, as a convenience, you'll probably want to use ln to make
"pear5" and "pecl5" commands

sudo ln -s /usr/local/lib/php5/pear/pear /usr/local/bin/pear5
sudo ln -s /usr/local/lib/php5/pear/pecl /usr/local/bin/pecl5

Lastly, you will *always* want to call with the -c option

pecl5 install APC

will still use your default configuration file at /etc/pear.conf.

pecl5 -c /etc/pear5.conf install APC

will correctly install and configure APC for php5.

Needless to say, this is more complicated than it seems like it should
be, and the next version of the PEAR installer, Pyrus, makes this
process MUCH easier.  Pyrus has only just been started, and so is barely
past proof-of-concept.

I hope this helps out.

Greg

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



Re: [PHP] explode string at new line

2007-06-06 Thread Davi
Em Quarta 06 Junho 2007 13:20, Jim Lucas escreveu:
> Davi wrote:
> > Em Quarta 06 Junho 2007 10:54, Davi escreveu:
> >> But... Why does it happen:
> >>
> >> [code]
> >>
> >> $object=mysql_fetch_object($result);
> >>
> >> $texto = $object->texto;
> >>
> >> $texto=preg_replace("/\r|\n/","",stripslashes($texto));
> >> echo $texto;
> >>
> >> [/code]
> >>
> >> [output]
> >>
> >> Teste
> >> \r\nde formatação!
> >> \r\nTudo funcionando...
> >> \r\n
> >>
> >> [/output]
> >>
> >>
> >> I'm using stripslashse 'cause I'm getting the values from a DB.
> >>
> >
> > If I do:
> >
> > [code]
> >
> > echo "\r\nJust testing... \r\n again...";
> >
> > [/code]
> >
> > The output is:
>
> how and where are you outputting this to?
>

How: echo
Where: Firefox 2.0.0.3

> > [output]
> >
> > Just testing... again...
> >
> > [/output]
> >
> > And the source code (in browser) is:
>
> What OS?
>

SuSE 9.3 (Server)

Gentoo Linux 1.12.9 [2007.0] (Desktop/Development)

> > [output]
> >
> > Just testing...
> > again...
> >
> > [/output]
> >
> >

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Please don't do top-posting, put your reply below the following line.



pgpKvupfZO86S.pgp
Description: PGP signature


Re: [PHP] Re: customer ids

2007-06-06 Thread Burn

Richard Davey ha scritto:

Hi Burn,

Wednesday, June 6, 2007, 4:39:05 PM, you wrote:


Worst thing that can happen is having mysql throw an error while trying
to insert an ID that's already present in the database. It gets more 
complicated and unpredictable if the field isn't required to be unique

at database design level.


Wanting to make it perfectly safe the check should include the INSERT 
statement and continue looping till it's successful as well.


Or just wrap the whole thing in a stored procedure / transaction (it's
what they were invented for after-all :), tasks like this should be
pushed to SQL as much as possible imho.

Cheers,

Rich


True, true :)

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



Re[2]: [PHP] Parse domain from URL

2007-06-06 Thread Richard Davey
Hi Brad,

Wednesday, June 6, 2007, 5:04:41 PM, you wrote:

> Yes, that's basically what my code already does.

> The problem is that what if the url is "http://yahoo.co.uk/"; (note the lack
> of a subdomain)

> Your script thinks that the domain is "co.uk".  Just like my existing code
> does.

> So we can't count on taking the last 2 segments.  And we can't count on
> ignoring the first segment.  (The subdomain could be anything, not just www)

The complete list of top-level domains is neither very long, nor
changes very often. Perhaps a new country/suffix now and again is added or
renamed, but it doesn't happen that much.

In short, I think it'd be much better for you to obtain a full list
and then just remove that element from your hostname. Then you'll know
for a fact that whatever is left is the pure domain (+ sub-domain).

Of course it won't help if someone gives you the IP of a site (or any
other similar variation) instead of a domain name :)

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] explode string at new line

2007-06-06 Thread Jim Lucas

Davi wrote:

Em Quarta 06 Junho 2007 10:54, Davi escreveu:

But... Why does it happen:

[code]

$object=mysql_fetch_object($result);

$texto = $object->texto;

$texto=preg_replace("/\r|\n/","",stripslashes($texto));
echo $texto;

[/code]

[output]

Teste
\r\nde formatação!
\r\nTudo funcionando...
\r\n

[/output]


I'm using stripslashse 'cause I'm getting the values from a DB.

Any kind of tip?

TIA


If I do:

[code]

echo "\r\nJust testing... \r\n again...";

[/code]

The output is:

how and where are you outputting this to?



[output]

Just testing... again...

[/output]

And the source code (in browser) is:

What OS?



[output]

Just testing...
again...

[/output]


Am I missing anything?

TIA




--
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] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
Daniel Brown wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
>> Daniel Brown wrote:
>> > On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
>>
>> ...
>>
>> >
>> >Yeah, my truck, too.  I do computer forensics primarily, so I'm on
>> > the road all the time.  I have a laptop in the front between the
>> > driver and passenger seats with a system in the back hardwired through
>> > an inverter, which is packed with an Everio video camera, RF monitors,
>> > et cetera.
>>
>> the mind boggles - your geek level way surpasses mine :-) - in fact I
>> had to look up 'inverter' :-/
>>
>> can't figure how exactly the camera and rf monitors tie into the
>> forensics,
>> sounds cool though! besides who am I to question a man with a truck
>> packed
>> with more custom electronics that I have in my house :-)
>>
>> >Manually doing the APC module may not be ideal, but if it's an
>> > immediate requirement, you could do it like that for now just to get
>> > it up and going, then work on creating your test environment so that
>> > you'll be ready to go when the need to update or modify the
>> > installation arises.
>>
>> a, seems like the way to go - I can live with that.
>>
>> >
>>
>>
> 
>The camera is just for audiovisual recording of evidence on the
> scene, while the RF monitors, WLAN (A/B/G) scanners, et cetera, are
> for bug detection, AP/Ad Hoc/WiFi hijacking and sniffing, and so on.
> It's a lot of fun, if you're into that kind of geek stuff like I am.

sounds a bit over my head - but it does sound like fun indeed!

>Going back to your original point, however, I do have to agree
> that Plesk upgrades are a nightmare, and I've been doing Linux server
> administration for well over a decade now.  It's so non-standard and
> yet still intertwined that it makes even the simplest system
> modifications (PHP recompilations, for example) turn into a day-long
> project sometimes and sometimes longer, with downtime and loss of
> hair thrown in for good measure!

ah good - in the sense that a 'real' sys admin feels where I'm coming from,
rather than it being just my twisted perception (and lack of sys admin skills)
when it comes to plesk.

hand compiled extensions here I come :-)

> 
> 

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



RE: [PHP] Parse domain from URL

2007-06-06 Thread Brad Fuller
Daniel Brown wrote:
> On 6/6/07, Brad Fuller <[EMAIL PROTECTED]> wrote:
>> Hey guys,
>> 
>> I'm faced with an interesting problem, and wondering if there's an
>> easy solution. 
>> 
>> I need to strip out a domain name from a URL, and ignore subdomains
>> (like www)
>> 
>> I can use parse_url to get the hostname. And my first thought was to
>> take the last 2 segments of the hostname to get the domain.
>  So if the
>> URL is http://www.example.com/
>> Then the domain is "example.com."   If the URL is
>> http://example.org/ then the domain is "example.org." 
>> 
>> This seemed to work perfectly until I come across a URL like
>> http://www.example.co.uk/ My script thinks the domain is "co.uk."
>> 
>> So I added a bit of code to account for this, basically if the 2nd to
>> last segment of the hostname is "co" then take the last 3 segments.
>> 
>> Then I stumbled across a URL like http://www.example.com.au/
>> 
>> So it occurred to me that this is not the best solution, unless I
>> have a definitive list of all exceptions to go off of.
>> 
>> Does anyone have any suggestions?
>> 
>> Any advice is much appreciated.
>> 
>> Thanks,
>> Brad
>> 
>> --
>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
>> visit: http://www.php.net/unsub.php 
>> 
>> 
> 
> Well, it's not very clean, but if you just need to remove
> the subdomain/CNAME from the domain
> 
>  $hostname = parse_url($_SERVER['SERVER_NAME']);
> $domsplit = explode('.',$hostname['path']);
> for($i=1;$i $i == (count($domsplit) - 1) ? $domain .= $domsplit[$i] :
> $domain .= $domsplit[$i]."."; }
> echo $domain;
>> 
> 
> There's probably a much better way to do it, but in the
> interest of a quick response, that's one way.
> 
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107


Dan,

Yes, that's basically what my code already does.

The problem is that what if the url is "http://yahoo.co.uk/"; (note the lack
of a subdomain)

Your script thinks that the domain is "co.uk".  Just like my existing code
does.

So we can't count on taking the last 2 segments.  And we can't count on
ignoring the first segment.  (The subdomain could be anything, not just www)

Thx,

Brad

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



Re: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Crayon Shin Chan
On Wednesday 06 June 2007 21:33, Robert Cummings wrote:

> You certainly can be "approximate" when coding. It's called heuristics
> and it's an absolute necessity in many areas of software development.

But you still have to define _precisely_ how "approximate" you want to be. 

-- 
Crayon

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



Re: [PHP] Parse domain from URL

2007-06-06 Thread Daniel Brown

On 6/6/07, Brad Fuller <[EMAIL PROTECTED]> wrote:

Hey guys,

I'm faced with an interesting problem, and wondering if there's an easy
solution.

I need to strip out a domain name from a URL, and ignore subdomains (like
www)

I can use parse_url to get the hostname. And my first thought was to take
the last 2 segments of the hostname to get the domain.  So if the URL is
http://www.example.com/
Then the domain is "example.com."   If the URL is http://example.org/ then
the domain is "example.org."

This seemed to work perfectly until I come across a URL like
http://www.example.co.uk/
My script thinks the domain is "co.uk."

So I added a bit of code to account for this, basically if the 2nd to last
segment of the hostname is "co" then take the last 3 segments.

Then I stumbled across a URL like http://www.example.com.au/

So it occurred to me that this is not the best solution, unless I have a
definitive list of all exceptions to go off of.

Does anyone have any suggestions?

Any advice is much appreciated.

Thanks,
Brad

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




   Well, it's not very clean, but if you just need to remove the
subdomain/CNAME from the domain



   There's probably a much better way to do it, but in the interest
of a quick response, that's one way.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] Parse domain from URL

2007-06-06 Thread Robert Cummings
On Wed, 2007-06-06 at 11:43 -0400, Brad Fuller wrote:
> Hey guys,
> 
> I'm faced with an interesting problem, and wondering if there's an easy
> solution.
> 
> I need to strip out a domain name from a URL, and ignore subdomains (like
> www)
> 
> I can use parse_url to get the hostname. And my first thought was to take
> the last 2 segments of the hostname to get the domain.  So if the URL is
> http://www.example.com/
> Then the domain is "example.com."   If the URL is http://example.org/ then
> the domain is "example.org."
> 
> This seemed to work perfectly until I come across a URL like
> http://www.example.co.uk/
> My script thinks the domain is "co.uk."
> 
> So I added a bit of code to account for this, basically if the 2nd to last
> segment of the hostname is "co" then take the last 3 segments.
> 
> Then I stumbled across a URL like http://www.example.com.au/
> 
> So it occurred to me that this is not the best solution, unless I have a
> definitive list of all exceptions to go off of.
> 
> Does anyone have any suggestions?
> 
> Any advice is much appreciated.

I'm not sure about in PHP, but using the linux command:

dig www.example.co.uk

seems to have what you want in the Authority section.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re[2]: [PHP] Re: customer ids

2007-06-06 Thread Richard Davey
Hi Burn,

Wednesday, June 6, 2007, 4:39:05 PM, you wrote:

> Worst thing that can happen is having mysql throw an error while trying
> to insert an ID that's already present in the database. It gets more 
> complicated and unpredictable if the field isn't required to be unique
> at database design level.

> Wanting to make it perfectly safe the check should include the INSERT 
> statement and continue looping till it's successful as well.

Or just wrap the whole thing in a stored procedure / transaction (it's
what they were invented for after-all :), tasks like this should be
pushed to SQL as much as possible imho.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Daniel Brown

On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:

Daniel Brown wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:

...

>
>Yeah, my truck, too.  I do computer forensics primarily, so I'm on
> the road all the time.  I have a laptop in the front between the
> driver and passenger seats with a system in the back hardwired through
> an inverter, which is packed with an Everio video camera, RF monitors,
> et cetera.

the mind boggles - your geek level way surpasses mine :-) - in fact I
had to look up 'inverter' :-/

can't figure how exactly the camera and rf monitors tie into the forensics,
sounds cool though! besides who am I to question a man with a truck packed
with more custom electronics that I have in my house :-)

>Manually doing the APC module may not be ideal, but if it's an
> immediate requirement, you could do it like that for now just to get
> it up and going, then work on creating your test environment so that
> you'll be ready to go when the need to update or modify the
> installation arises.

a, seems like the way to go - I can live with that.

>




   The camera is just for audiovisual recording of evidence on the
scene, while the RF monitors, WLAN (A/B/G) scanners, et cetera, are
for bug detection, AP/Ad Hoc/WiFi hijacking and sniffing, and so on.
It's a lot of fun, if you're into that kind of geek stuff like I am.

   Going back to your original point, however, I do have to agree
that Plesk upgrades are a nightmare, and I've been doing Linux server
administration for well over a decade now.  It's so non-standard and
yet still intertwined that it makes even the simplest system
modifications (PHP recompilations, for example) turn into a day-long
project sometimes and sometimes longer, with downtime and loss of
hair thrown in for good measure!


--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



[PHP] Parse domain from URL

2007-06-06 Thread Brad Fuller
Hey guys,

I'm faced with an interesting problem, and wondering if there's an easy
solution.

I need to strip out a domain name from a URL, and ignore subdomains (like
www)

I can use parse_url to get the hostname. And my first thought was to take
the last 2 segments of the hostname to get the domain.  So if the URL is
http://www.example.com/
Then the domain is "example.com."   If the URL is http://example.org/ then
the domain is "example.org."

This seemed to work perfectly until I come across a URL like
http://www.example.co.uk/
My script thinks the domain is "co.uk."

So I added a bit of code to account for this, basically if the 2nd to last
segment of the hostname is "co" then take the last 3 segments.

Then I stumbled across a URL like http://www.example.com.au/

So it occurred to me that this is not the best solution, unless I have a
definitive list of all exceptions to go off of.

Does anyone have any suggestions?

Any advice is much appreciated.

Thanks,
Brad

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



Re: [PHP] Re: customer ids

2007-06-06 Thread Burn

Richard Davey ha scritto:

Hi Burn,

Wednesday, June 6, 2007, 3:55:21 PM, you wrote:


Here's how I do it, for 1 single table though.. you'll have to write
yourself the mod to check on more tables. If you plan to have > 10 
millions records make sure the maxrand is higher.



When the "do" loop exits you have a unique id.



function generateID() {
$minrand = 1;
$maxrand = ;
$uniqueid[0] = mt_rand($minrand, $maxrand);
$uniqueid[1] = $uniqueid[0];
return $uniqueid[1];
}

do {

//New ID generation
$newid = generateID();
//Database check
$sqlcheck = "SELECT youruniqueidhere FROM yourtablehere WHERE 
youruniqueidhere = '".$newid."'";

$conn = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name, $conn);

$rs = mysql_query($sqlcheck, $conn);

$rscount = mysql_num_rows($rs);
} while ($rscount != 0);


Not that it is likely to occur on a low-traffic site, but the above
approach is a race condition waiting to happen I'm afraid. It will
however almost certainly satisfy the needs of the OP as long as his
site stays off digg / slashdot :)

Cheers,

Rich


Thanks for pointing it out,

I'm well aware of it, but I use it in a back-end facility managed by a 
handfull of administrators, and an expected users base within the 
100.000 units. The hit rate is 1:1 Perfectly reasonable with 5 
possible concurrent threads running the code :)


Worst thing that can happen is having mysql throw an error while trying 
to insert an ID that's already present in the database. It gets more 
complicated and unpredictable if the field isn't required to be unique 
at database design level.


Wanting to make it perfectly safe the check should include the INSERT 
statement and continue looping till it's successful as well.


Cheers!

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
Daniel Brown wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:

...

> 
>Yeah, my truck, too.  I do computer forensics primarily, so I'm on
> the road all the time.  I have a laptop in the front between the
> driver and passenger seats with a system in the back hardwired through
> an inverter, which is packed with an Everio video camera, RF monitors,
> et cetera.

the mind boggles - your geek level way surpasses mine :-) - in fact I
had to look up 'inverter' :-/

can't figure how exactly the camera and rf monitors tie into the forensics,
sounds cool though! besides who am I to question a man with a truck packed
with more custom electronics that I have in my house :-)

>Manually doing the APC module may not be ideal, but if it's an
> immediate requirement, you could do it like that for now just to get
> it up and going, then work on creating your test environment so that
> you'll be ready to go when the need to update or modify the
> installation arises.

a, seems like the way to go - I can live with that.

> 

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
Daniel Brown wrote:
> On 6/6/07, Austin C <[EMAIL PROTECTED]> wrote:
>> Why do you have 2 apaches on the same computer? I didnt even know you
>> could
>> do that without causing problems.
>>

I need to run php4 and php5 sites on the same box and
I can't upgrade php4 to php5 for 2 reasons ...

1. upgrading anything in the plesk installation (which included php4 as std way 
back when)
is a nightmare waiting to happen (and I can't afford to have the server down 
due to an upgrade
snafu).
2. some of the many of php4 sites will break under php5 - they are that 
old/crufty -
and I don't have the time to audit and fix all the code in question (not until 
there
are an extra 3 months in a year :-P).

apache2+php4 runs on the public IP address(es) on port 80
apache2+php5 runs on 127.0.0.1 on port 81

I use ProxyPass directives in apache2+php4 to make apache2+php5
available to the public ... this means that domain management can still be
done from within the plesk control panel AND (more importantly) all the stats
generate crap in plesk works as is for all domains (because requests for
sites that are actually run on apache+php5 are funnelled through apache2+php4.

...

> 
>I don't know the exact reason the OP has multiple installations of
> Apache/PHP running, but some reasons may be to have a separate control
> panel, test environment, alternate (redundant) connection swapping, et
> cetera.  

nothing as fancy as all that I'm afraid.

> In any case, as long as it's configured and compiled
> properly, you can have a virtually unlimited number of separate
> servers running on one machine, even all sharing the same interface
> and data sources.
> 

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Daniel Brown

On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:

Daniel Brown wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
>> I have a [gentoo] server with 2 apache installations ...
>>
>> the std distro apache runs with php4 which includes an installation
>> of PEAR and PECL.
>>
>> the second apache is compiled by hand and runs with php5 (also compiled
>> by hand) - obviously both of these are installed somewhere other than
>> the default. the [custom] php5 installation does not include PEAR/PECL
>> (when I built/installed it I skipped that because I was worried I'd
>> get a conflict
>> with the existing PEAR/PECL install and break something).
>>
>> I would like to add the APC extension to the php5 setup, normally this is
>> as involved as doing the following:
>>
>> > pecl install apc
>>
>> only in this case that would install APC in the php4 setup.
>> the question is how do I go about getting a second/custom PEAR/PECL
>> setup running
>> which I can use with/for the php5 setup. is this even possible? or
>> am I stuck with a manual download, compile and install of APC for the
>> php5 setup as described here for instance:
>> 
http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?
>>
>>
>> tia,
>> Jochem
>>
>> PS  - STWF is giving me no joy, everything I find assumes the
>> pecl/pear commands
>> are setup and running.
>>
>> PPS - sorry for the overuse of the word 'setup' :-P
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>Is there any particular reason you couldn't recompile PHP5 with
> the PEAR/PECL packages outside of the path?  A prime example of
> running two separate Apache servers with separate PHP installations is
> cPanel --- if you're familiar with the service, you'll probably
> already know that it uses it's own paths (/var/cpanel,
> /usr/local/cpanel/bin), not those common on the system (/bin, /sbin,
> etc.).

I don't want to recompile because it's in production, and secondly I
don't really know what's going on with the compile/installation when it
comes to pear/pecl.

I can't risk screwing anything up and time constraints don't allow me
to build a test env that matches what I have in production right now ...

it's a plesk box in this case which (imho) makes things a tad more complicated 
...
I'm not too much of a fan of plesk :-/

so I'm still hoping there is a way to install a second pear/pecl setup (with 
that
go-pear thingy that I don't quite understand) and have it 'linked' to a specific
[custom] php installation? ... if not I'll go read up more on pear/pecl setups 
in general
and in the mean time do a manual build of the APC extension (something I can 
comfortably do,
but is not great from a maintainance POV)

>
>I've had different test boxes set up with numerous
> compartmentalized installations --- one of my kitchen machines had
> more than a dozen, just to try to screw it up one day because I was
> bored (yes, I have systems all throughout my house and my truck).

your truck ?? :-)

>
>As long as the PEAR/PECL API version matches the target PHP
> installation API version, you should have no problem.

this is not clear to me - I'm have a horrible 'lacking the required expertise'
feeling :-P

thanks for your input so far.

>




   Yeah, my truck, too.  I do computer forensics primarily, so I'm on
the road all the time.  I have a laptop in the front between the
driver and passenger seats with a system in the back hardwired through
an inverter, which is packed with an Everio video camera, RF monitors,
et cetera.

   Manually doing the APC module may not be ideal, but if it's an
immediate requirement, you could do it like that for now just to get
it up and going, then work on creating your test environment so that
you'll be ready to go when the need to update or modify the
installation arises.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] Re: customer ids

2007-06-06 Thread Richard Davey
Hi Burn,

Wednesday, June 6, 2007, 3:55:21 PM, you wrote:

> Here's how I do it, for 1 single table though.. you'll have to write
> yourself the mod to check on more tables. If you plan to have > 10 
> millions records make sure the maxrand is higher.

> When the "do" loop exits you have a unique id.

> function generateID() {
> $minrand = 1;
> $maxrand = ;
> $uniqueid[0] = mt_rand($minrand, $maxrand);
> $uniqueid[1] = $uniqueid[0];
> return $uniqueid[1];
> }
> 
> do {
> //New ID generation
> $newid = generateID();
> //Database check
> $sqlcheck = "SELECT youruniqueidhere FROM yourtablehere WHERE 
> youruniqueidhere = '".$newid."'";
> $conn = mysql_connect($db_host, $db_username, $db_password);
> mysql_select_db($db_name, $conn);
> 
> $rs = mysql_query($sqlcheck, $conn);
> $rscount = mysql_num_rows($rs);
> } while ($rscount != 0);

Not that it is likely to occur on a low-traffic site, but the above
approach is a race condition waiting to happen I'm afraid. It will
however almost certainly satisfy the needs of the OP as long as his
site stays off digg / slashdot :)

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Jochem Maas
Daniel Brown wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
>> I have a [gentoo] server with 2 apache installations ...
>>
>> the std distro apache runs with php4 which includes an installation
>> of PEAR and PECL.
>>
>> the second apache is compiled by hand and runs with php5 (also compiled
>> by hand) - obviously both of these are installed somewhere other than
>> the default. the [custom] php5 installation does not include PEAR/PECL
>> (when I built/installed it I skipped that because I was worried I'd
>> get a conflict
>> with the existing PEAR/PECL install and break something).
>>
>> I would like to add the APC extension to the php5 setup, normally this is
>> as involved as doing the following:
>>
>> > pecl install apc
>>
>> only in this case that would install APC in the php4 setup.
>> the question is how do I go about getting a second/custom PEAR/PECL
>> setup running
>> which I can use with/for the php5 setup. is this even possible? or
>> am I stuck with a manual download, compile and install of APC for the
>> php5 setup as described here for instance:
>> http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?
>>
>>
>> tia,
>> Jochem
>>
>> PS  - STWF is giving me no joy, everything I find assumes the
>> pecl/pear commands
>> are setup and running.
>>
>> PPS - sorry for the overuse of the word 'setup' :-P
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
>Is there any particular reason you couldn't recompile PHP5 with
> the PEAR/PECL packages outside of the path?  A prime example of
> running two separate Apache servers with separate PHP installations is
> cPanel --- if you're familiar with the service, you'll probably
> already know that it uses it's own paths (/var/cpanel,
> /usr/local/cpanel/bin), not those common on the system (/bin, /sbin,
> etc.).

I don't want to recompile because it's in production, and secondly I
don't really know what's going on with the compile/installation when it
comes to pear/pecl.

I can't risk screwing anything up and time constraints don't allow me
to build a test env that matches what I have in production right now ...

it's a plesk box in this case which (imho) makes things a tad more complicated 
...
I'm not too much of a fan of plesk :-/

so I'm still hoping there is a way to install a second pear/pecl setup (with 
that
go-pear thingy that I don't quite understand) and have it 'linked' to a specific
[custom] php installation? ... if not I'll go read up more on pear/pecl setups 
in general
and in the mean time do a manual build of the APC extension (something I can 
comfortably do,
but is not great from a maintainance POV)

> 
>I've had different test boxes set up with numerous
> compartmentalized installations --- one of my kitchen machines had
> more than a dozen, just to try to screw it up one day because I was
> bored (yes, I have systems all throughout my house and my truck).

your truck ?? :-)

> 
>As long as the PEAR/PECL API version matches the target PHP
> installation API version, you should have no problem.

this is not clear to me - I'm have a horrible 'lacking the required expertise'
feeling :-P

thanks for your input so far.

> 

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



[PHP] Re: customer ids

2007-06-06 Thread Burn

blueboy ha scritto:

Hi,

I want to create random customer ids. I have an auto incremented coulumn but 
I would rather have a 6-8 digit/letter id randomly generated  that can be 
used as a unique identifier across 3 tables. Does anyone have a algorithm to 
generate such a string and can you give the odds against 2 duplicate stings 
being generated?


I know this is a strange ask.


R. 


Here's how I do it, for 1 single table though.. you'll have to write 
yourself the mod to check on more tables. If you plan to have > 10 
millions records make sure the maxrand is higher.


When the "do" loop exits you have a unique id.

function generateID() {
$minrand = 1;
$maxrand = ;
$uniqueid[0] = mt_rand($minrand, $maxrand);
$uniqueid[1] = $uniqueid[0];
return $uniqueid[1];
}

do {
//New ID generation
$newid = generateID();
//Database check
	$sqlcheck = "SELECT youruniqueidhere FROM yourtablehere WHERE 
youruniqueidhere = '".$newid."'";

$conn = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name, $conn);

$rs = mysql_query($sqlcheck, $conn);
$rscount = mysql_num_rows($rs);
} while ($rscount != 0);

Cheers,

Burn

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



Re: [PHP] customer ids

2007-06-06 Thread Zoltán Németh
have you looked at the archives??? I don't think so.
try this link:

http://marc.info/?l=php-general&w=2&r=1&s=random+unique+id&q=b

greets
Zoltán Németh

2007. 06. 6, szerda keltezéssel 15.40-kor blueboy ezt írta:
> Hi,
> 
> I want to create random customer ids. I have an auto incremented coulumn but 
> I would rather have a 6-8 digit/letter id randomly generated  that can be 
> used as a unique identifier across 3 tables. Does anyone have a algorithm to 
> generate such a string and can you give the odds against 2 duplicate stings 
> being generated?
> 
> I know this is a strange ask.
> 
> 
> R. 
> 

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Daniel Brown

On 6/6/07, Austin C <[EMAIL PROTECTED]> wrote:

Why do you have 2 apaches on the same computer? I didnt even know you could
do that without causing problems.



On 6/6/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
> On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > I have a [gentoo] server with 2 apache installations ...
> >
> > the std distro apache runs with php4 which includes an installation
> > of PEAR and PECL.
> >
> > the second apache is compiled by hand and runs with php5 (also compiled
> > by hand) - obviously both of these are installed somewhere other than
> > the default. the [custom] php5 installation does not include PEAR/PECL
> > (when I built/installed it I skipped that because I was worried I'd get
a conflict
> > with the existing PEAR/PECL install and break something).
> >
> > I would like to add the APC extension to the php5 setup, normally this
is
> > as involved as doing the following:
> >
> > > pecl install apc
> >
> > only in this case that would install APC in the php4 setup.
> > the question is how do I go about getting a second/custom PEAR/PECL
setup running
> > which I can use with/for the php5 setup. is this even possible? or
> > am I stuck with a manual download, compile and install of APC for the
> > php5 setup as described here for instance:
> >
http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian
)?
> >
> > tia,
> > Jochem
> >
> > PS  - STWF is giving me no joy, everything I find assumes the pecl/pear
commands
> > are setup and running.
> >
> > PPS - sorry for the overuse of the word 'setup' :-P
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>Is there any particular reason you couldn't recompile PHP5 with
> the PEAR/PECL packages outside of the path?  A prime example of
> running two separate Apache servers with separate PHP installations is
> cPanel --- if you're familiar with the service, you'll probably
> already know that it uses it's own paths (/var/cpanel,
> /usr/local/cpanel/bin), not those common on the system (/bin, /sbin,
> etc.).
>
>I've had different test boxes set up with numerous
> compartmentalized installations --- one of my kitchen machines had
> more than a dozen, just to try to screw it up one day because I was
> bored (yes, I have systems all throughout my house and my truck).
>
>As long as the PEAR/PECL API version matches the target PHP
> installation API version, you should have no problem.
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Thanks, the webmaster of Galacticneo


   I don't know the exact reason the OP has multiple installations of
Apache/PHP running, but some reasons may be to have a separate control
panel, test environment, alternate (redundant) connection swapping, et
cetera.  In any case, as long as it's configured and compiled
properly, you can have a virtually unlimited number of separate
servers running on one machine, even all sharing the same interface
and data sources.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



[PHP] customer ids

2007-06-06 Thread blueboy
Hi,

I want to create random customer ids. I have an auto incremented coulumn but 
I would rather have a 6-8 digit/letter id randomly generated  that can be 
used as a unique identifier across 3 tables. Does anyone have a algorithm to 
generate such a string and can you give the odds against 2 duplicate stings 
being generated?

I know this is a strange ask.


R. 

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



Re: [PHP] second/custom PEAR/PECL installation. possible? how?

2007-06-06 Thread Daniel Brown

On 6/6/07, Jochem Maas <[EMAIL PROTECTED]> wrote:

I have a [gentoo] server with 2 apache installations ...

the std distro apache runs with php4 which includes an installation
of PEAR and PECL.

the second apache is compiled by hand and runs with php5 (also compiled
by hand) - obviously both of these are installed somewhere other than
the default. the [custom] php5 installation does not include PEAR/PECL
(when I built/installed it I skipped that because I was worried I'd get a 
conflict
with the existing PEAR/PECL install and break something).

I would like to add the APC extension to the php5 setup, normally this is
as involved as doing the following:

> pecl install apc

only in this case that would install APC in the php4 setup.
the question is how do I go about getting a second/custom PEAR/PECL setup 
running
which I can use with/for the php5 setup. is this even possible? or
am I stuck with a manual download, compile and install of APC for the
php5 setup as described here for instance:
http://carroll.org.uk/archives/2006/02/02/alternative-php-cache-apc-on-debian)?

tia,
Jochem

PS  - STWF is giving me no joy, everything I find assumes the pecl/pear commands
are setup and running.

PPS - sorry for the overuse of the word 'setup' :-P

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




   Is there any particular reason you couldn't recompile PHP5 with
the PEAR/PECL packages outside of the path?  A prime example of
running two separate Apache servers with separate PHP installations is
cPanel --- if you're familiar with the service, you'll probably
already know that it uses it's own paths (/var/cpanel,
/usr/local/cpanel/bin), not those common on the system (/bin, /sbin,
etc.).

   I've had different test boxes set up with numerous
compartmentalized installations --- one of my kitchen machines had
more than a dozen, just to try to screw it up one day because I was
bored (yes, I have systems all throughout my house and my truck).

   As long as the PEAR/PECL API version matches the target PHP
installation API version, you should have no problem.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] explode string at new line

2007-06-06 Thread Davi
Em Quarta 06 Junho 2007 10:54, Davi escreveu:
> But... Why does it happen:
>
> [code]
>
> $object=mysql_fetch_object($result);
>
> $texto = $object->texto;
>
> $texto=preg_replace("/\r|\n/","",stripslashes($texto));
> echo $texto;
>
> [/code]
>
> [output]
>
> Teste
> \r\nde formatação!
> \r\nTudo funcionando...
> \r\n
>
> [/output]
>
>
> I'm using stripslashse 'cause I'm getting the values from a DB.
>
> Any kind of tip?
>
> TIA

If I do:

[code]

echo "\r\nJust testing... \r\n again...";

[/code]

The output is:

[output]

Just testing... again...

[/output]

And the source code (in browser) is:

[output]

Just testing...
again...

[/output]


Am I missing anything?

TIA

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Please don't do top-posting, put your reply below the following line.



pgpCbBEc0rmeF.pgp
Description: PGP signature


RE: [PHP] Anyone scripted Crossover?

2007-06-06 Thread Edward Kay


> -Original Message-
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: 06 June 2007 14:34
> To: php-general@lists.php.net
> Subject: RE: [PHP] Anyone scripted Crossover?
>
>
> Tijnema,
>
> > > Nothing found in the archive, so asking the question: has
> > anyone done any
> > > scripting of Crossover to control MS Office applications on Linux?
> > >
> > > I would love to move to Linux, but have some apps that create
> > MS Word docs
> > > and some doing Excel parsing.
> > >
> > > Cheers
> > >
> > > George in Edinburgh/Oxford
> >
> > Can't you use some OpenOffice.org tools for that? OOo can open all
> > kind of MS Word and Excel documents.
>
> So, can I create a '*.doc' file on a Linux box? And can I read
> the data from
> an Excel spreadsheet to parse into a MySQL db?
>
> If so, can anyone point me in the right direction for examples etc?
>
> Cheers
>
> George in Edinburgh/Oxford
> ==

If you want to parse .doc and .xls files with a script under Linux, look at
catdoc and xls2csv:
http://www.45.free.net/~vitus/software/catdoc/

Edward

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



Re: [PHP] explode string at new line

2007-06-06 Thread Davi
Em Quarta 06 Junho 2007 02:50, Jim Lucas escreveu:
> Chris wrote:
> > Davi wrote:
> >> Em Terça 05 Junho 2007 23:52, [EMAIL PROTECTED] escreveu:
> >>> That's exactly correct. Except I /think/ you should use "\n" instead of
> >>> '\n'.
> >>
> >> array explode ( string $delimiter, string $string [, int $limit] )
> >>
> >> So, I was wrong...
> >> The right way, probaly, is:
> >>
> >> $str=explode("\n",$_POST["my_text"]);
> >
> > If it's coming from a  you'll want to use "\r\n" because a
> > textarea uses both a carriage return (\r) and newline (\n) to separate.
> >
> > Otherwise each element of the array will have a \r on the end which may
> > end up causing you some issues later on.
>
> I was wondering about this, I seem to recall that window/mac/*nix all do
> it differently.
>
> http://www.sitepoint.com/forums/printthread.php?t=54074
>
> Line breaks
> People want to know how they can retain textarea line breaks in HTML.
> You should store text in the database in its original format (e.g. with
> just newlines) and then use nl2br() to convert newlines to HTML 
> tags on display (thanks to the people here for teaching me that :)).
> That's all good, except for one problem with nl2br(): it doesn't seem to
> convert \r newlines (edit: this has now been fixed in PHP 4.2.0).
>
> PHP Code:
> $txt = preg_replace('/\r\n|\r/', "\n", $txt);
>

Helped... =)

But... Why does it happen:

[code]

$object=mysql_fetch_object($result);

$texto = $object->texto;

$texto=preg_replace("/\r|\n/","",stripslashes($texto));
echo $texto;

[/code]

[output]

Teste
\r\nde formatação!
\r\nTudo funcionando...
\r\n

[/output]


I'm using stripslashse 'cause I'm getting the values from a DB.

Any kind of tip?

TIA


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Please don't do top-posting, put your reply below the following line.



pgpXKjnY1odxa.pgp
Description: PGP signature


Re: [PHP] Anyone scripted Crossover?

2007-06-06 Thread Tijnema

On 6/6/07, George Pitcher <[EMAIL PROTECTED]> wrote:

Tijnema,

> > Nothing found in the archive, so asking the question: has
> anyone done any
> > scripting of Crossover to control MS Office applications on Linux?
> >
> > I would love to move to Linux, but have some apps that create
> MS Word docs
> > and some doing Excel parsing.
> >
> > Cheers
> >
> > George in Edinburgh/Oxford
>
> Can't you use some OpenOffice.org tools for that? OOo can open all
> kind of MS Word and Excel documents.

So, can I create a '*.doc' file on a Linux box? And can I read the data from
an Excel spreadsheet to parse into a MySQL db?

If so, can anyone point me in the right direction for examples etc?

Cheers

George in Edinburgh/Oxford
   ==


You can defenitly open .doc files on a linux box with OOo, i'm only
not sure if it's useful inside a PHP script.
I don't have example code or such, but i think google is big enough for such :)

Tijnema

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



[PHP] file_get_contents() can't fetch files via HTTP from localhost's vhosts

2007-06-06 Thread Burn

Hello all,

I have a dynamically generated javascript library that I want to minigy 
with a PHP port of JSMin, in order to do that I need to first fetch the 
parsed PHP script that generates the JS (complete with comments and 
everything), and then minify it.


The idea is to fetch the file via 
file_get_contents("http://www.vhost.dev/output.php";). This way the file 
gets parsed by PHP within the working environment (in respect of all 
paths, session policies etc..). It works flawlessly across domains, but 
it fails to fetch the file if the domain is a locally hosted apache vhost.


Needless to say, I tried to add the host resolution to /etc/hosts, and 
lynx has no problem to fetch the page.


if I try to execute a passthrough() with the command "php5-cgi 
/path/to/script.php" it breaks auth saving session files.


Any idea how I can achieve parsing with php the contents of the script 
before manipulating it? (The script is too complex to assign it as a 
string to a php variable, which would otherwise empower me to minify it 
without further troubles).


Thanks,

Burn

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



RE: [PHP] Anyone scripted Crossover?

2007-06-06 Thread George Pitcher
Tijnema,

> > Nothing found in the archive, so asking the question: has
> anyone done any
> > scripting of Crossover to control MS Office applications on Linux?
> >
> > I would love to move to Linux, but have some apps that create
> MS Word docs
> > and some doing Excel parsing.
> >
> > Cheers
> >
> > George in Edinburgh/Oxford
>
> Can't you use some OpenOffice.org tools for that? OOo can open all
> kind of MS Word and Excel documents.

So, can I create a '*.doc' file on a Linux box? And can I read the data from
an Excel spreadsheet to parse into a MySQL db?

If so, can anyone point me in the right direction for examples etc?

Cheers

George in Edinburgh/Oxford
==

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



Re: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Robert Cummings
On Wed, 2007-06-06 at 12:01 +0100, Richard Davey wrote:
> Hi,
> 
> Wednesday, June 6, 2007, 11:41:19 AM, you wrote:
> 
> > I want to force users to insert landscape rather portrait images. I don't
> > want to be too pedantic about it but they do need to have an approximate 4x3
> > aspect ratio.
> 
> You can't really be 'approximate' when coding.

You certainly can be "approximate" when coding. It's called heuristics
and it's an absolute necessity in many areas of software development.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Anyone scripted Crossover?

2007-06-06 Thread Tijnema

On 6/6/07, George Pitcher <[EMAIL PROTECTED]> wrote:

Hi,

Nothing found in the archive, so asking the question: has anyone done any
scripting of Crossover to control MS Office applications on Linux?

I would love to move to Linux, but have some apps that create MS Word docs
and some doing Excel parsing.

Cheers

George in Edinburgh/Oxford


Can't you use some OpenOffice.org tools for that? OOo can open all
kind of MS Word and Excel documents.

Tijnema

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



[PHP] Anyone scripted Crossover?

2007-06-06 Thread George Pitcher
Hi,

Nothing found in the archive, so asking the question: has anyone done any
scripting of Crossover to control MS Office applications on Linux?

I would love to move to Linux, but have some apps that create MS Word docs
and some doing Excel parsing.

Cheers

George in Edinburgh/Oxford
==

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



Re: [PHP] Double checking - I should turn off "magic quotes"

2007-06-06 Thread David Robley
Dave M G wrote:

> Robert , PHP General,
> 
> Thank you for replying and explaining the situation clearly.
>> Neither! It means using mysql_real_escape_string():
>> http://www.php.net/manual/en/function.mysql-real-escape-string.php
> 
> I have now made it so each and every queries to the database pass
> through mysql_real_escape_string.

The way you write that makes me hope you understand how
mysql_real_escape_string should be used. You do understand that you don't
run it on the query, rather on the individual string variables that will be
passed to the query.






Cheers
-- 
David Robley

Moderators are not God. God has mercy.
Today is Boomtime, the 11st day of Confusion in the YOLD 3173. 

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



Re: [PHP] Draw function diagram

2007-06-06 Thread Jochem Maas
Khorosh Irani wrote:
> Hi
> I worked alittle with gd
> It is my code for y(x)=sin(x)+cos(x):
> 
>function Graph($rangeLow, $rangeHigh, $step)
>{
>$img = ImageCreate($this->width, $this->height);
>$background_color = imagecolorallocate($img, 0, 0, 0);
>$white = ImageColorAllocate($img, 255, 255, 255);
>imageline($img, $this->width/2, 0,$this->width/2 , $this->height,
> $white);
>imageline($img, 0, $this->height/2, $this->width, $this->height/2,
> $white);
>for ($x=rangeLow;$x<=$rangeHigh,$x+=$step)
>{
> y=sin(x)*cos(x);//custom function
> //i dont know what should write here but i know that I should
> write imageline() function
> }
>header("Content-type: image/jpeg");
>ImageJpeg($img);
>imagedestroy($img);
>}
> 
> 
> could anyone write a simple code that complete this code
> I want to learn it

the best way to learn is when 'anyone' is you - write something, try it, try it 
again
until it works.

given that your studying/using trigonometry I believe it should not be beyond 
you
to figure out some code that generate the pixel coordinates that represent y on 
each iteration
and then plot it using the relevant functions.

and of course you could STFW for some code that could help you get started:

http://www.google.com/search?num=100&q=trigonometry+php+gd

e.g. first result of above query:


http://lorenzod8n.wordpress.com/2007/05/19/plotting-trigonometrical-functions-in-php/

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



Re: [PHP] works in 4.4.2 - breaks in 5.2.1

2007-06-06 Thread Jim Berkey
You are probably right. An attempted new post writes a totally empty file.  I 
was hoping it was just a syntax change in v5, but I discover that the code I 
was using isn't terribly good, so I'm spending some time on php.net and will 
try to create a new guestbook model using a mysql table, and hopefully some 
better formatted php to communicate with it. I'm really glad that the syntax is 
remarkably similar to the newest actionscript language, it makes it much easier 
for me to understand and learn it. This is my first venture into learning php 
the right way, instead of just jiggering with 'found' code, and I'm kinda 
excited that I got pushed into it. I'm looking forward to it.
Thanks,
jimbo

*** REPLY SEPARATOR  ***

On 6/5/2007 at 5:50 PM Richard Lynch wrote:

>Does the xmlString print out?
>
>Cuz my first guess is they turned off RAW_POST_DATA in the upgrade, so
>it's just blank...
>
>On Tue, June 5, 2007 11:34 am, Jim Berkey wrote:
>> I'm familiar with actionscript, but pretty new to php . . .I have a
>> guestbook script that worked fine until my host upgraded to php 5.2.1
>> - can anyone tell me what part of my if statement or variable is
>> breaking in 5.2.1? I send the new data with Flash using
>> xml.sendAndLoad, to the xml file via standalone php file shown below.
>> tia,
>> jimbo
>>
>> > $file = fopen("guestbook.xml", "w+") or die("Can't open XML file");
>> $xmlString = $HTTP_RAW_POST_DATA;
>> if(!fwrite($file, $xmlString)){
>> print "Error writing to XML-file";
>> }
>> print $xmlString."\n\n";
>> fclose($file);
>>
>> exit;
>> ?>
>>
>>
>
>
>--
>Some people have a "gift" link here.
>Know what I want?
>I want you to buy a CD from some indie artist.
>http://cdbaby.com/browse/from/lynch
>Yeah, I get a buck. So?
>
>--
>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] Double checking - I should turn off "magic quotes"

2007-06-06 Thread Jochem Maas
Richard Lynch wrote:
> On Mon, June 4, 2007 9:02 am, Dave M G wrote:
>> I've read on the manual that it's "preferred to code with magic quotes
>> off and to instead escape the data at runtime, as needed":
>>
>> Recently, while configuring my PHP so as to install the GD libraries,
>> that the default option was to have magic quotes turned on.
> 
> What version of PHP did you install?...
> 
> I'm pretty sure they turned MQ off by default in PHP5...
> 
>> I just want to double check here what to do. Should I disable magic
>> quotes on my server?
> 
> YES!
> 
> Turn the dang thing off!
> 
>> Also, I'm developing code that I hope others can use. For the purposes
>> of portability, is it safe to assume that most environments will have
>> magic quotes off, and build for that?
> 
> Nope.
> 
> Use something not unlike:
> if (ini_get('magic_quotes_gpc')){
>   array_map('stripslashes', $_GET);
>   array_map('stripslashes', $_POST);
>   array_map('stripslashes', $_COOKIE);
>   array_map('stripslashes', $_REQUEST);
> }

a few problems with this:

1. array_map doesn't change the input array(s) - so in this example, $_GET et 
al are not actually
changed.
2. there is a fair chance that these arrays may sometimes contain subarrays and 
it's therefore
necessary to actually recurse into any found subarrays and perform stripslashes 
on each
value found there.

I would suggest something like (although this is untested, I'm not 100% sure 
the 'by reference' 2nd
argument is done in the correct manner and there may also be restrictions as to 
using functions
like array_walk_recursive() on super global varaibles):

$ss = 'stripslashes';
array_walk_recursive($_GET, &$ss);

so alternatively (a method I know for sure does work - but is a little less 
clean, given it uses assignment and
a userland recursive function):

function ssRecursive($v) {
return is_array($v) ? array_map('ssRecursive', $v) : stripslashes($v);
}
$_GET = ssRecursive($_GET);


> 

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



Re: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Robin Vickery

On 06/06/07, blueboy <[EMAIL PROTECTED]> wrote:

I want to force users to insert landscape rather portrait images. I don't
want to be too pedantic about it but they do need to have an approximate 4x3
aspect ratio.

This is my code so far.

$max_height = "500"; // This is in pixels
$max_width = "500"; // This is in pixels

list($width, $height, $type, $w) =
getimagesize($_FILES['userfile']['tmp_name']);

if($width > $max_width || $height > $max_height)
{

}


$ratio = 4/3;
$tolerance = 0.1;

if (abs($ratio - $width/$height) > $tolerance) {
 // not approximately the right aspect ratio
}

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



RE: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Edward Kay


> -Original Message-
> From: blueboy [mailto:[EMAIL PROTECTED]
> Sent: 06 June 2007 11:41
> To: php-general@lists.php.net
> Subject: [PHP] checking the aspect ratio of an images
>
>
> I want to force users to insert landscape rather portrait images. I don't
> want to be too pedantic about it but they do need to have an
> approximate 4x3
> aspect ratio.
>
> This is my code so far.
>
> $max_height = "500"; // This is in pixels
> $max_width = "500"; // This is in pixels
>
> list($width, $height, $type, $w) =
> getimagesize($_FILES['userfile']['tmp_name']);
>
> if($width > $max_width || $height > $max_height)
> {
>
> }
>

This is basic maths. 4:3 means and aspect ratio of 1:0.75 or the height is
0.75 times the width.

Therefore, just check that:

if ($height/$width != 0.75) // Image not 4:3 landscape

You seem to imply this is an approx restriction, so just increase your
acceptable range of values, e.g.

$ratio = $height/$width;
if ($ratio < 0.7 || $ratio > 0.8) // Ratio not acceptable.

Edward

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



Re: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Richard Davey
Hi,

Wednesday, June 6, 2007, 11:41:19 AM, you wrote:

> I want to force users to insert landscape rather portrait images. I don't
> want to be too pedantic about it but they do need to have an approximate 4x3
> aspect ratio.

You can't really be 'approximate' when coding. You need to set some
hard values to check against. So work out what your extremes will be
first.

A 4x3 image has an aspect ratio of 1.33

So decide what your max and min ratios will be and then check the
aspect ratio of the image they upload.

If they upload a 320x200 it'll have a ratio of 1.60
If they upload a 200x320 it'll have a ratio of 0.63
If they uploaded a 200x200 the ratio is exactly 1

So if you want the image to be landscape, it'll always have a ratio of
above 1.0. If you don't want it stupidly landscape (i.e. 1600x300)
then just set your maximum ratio to something like 1.6.

Once you've set your boundaries your 'if' statement becomes a whole
lot easier to write.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] Strings

2007-06-06 Thread itoctopus
I noticed that too :)

-- 
itoctopus - http://www.itoctopus.com
"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Tue, 2007-06-05 at 19:57 +0200, Jochem Maas wrote:
>> do you notice the totally weird string delimiters in your original post?
>> using either single quotes or double quotes (if you want variables named 
>> inside
>> the string to be interpolated). read up on php strings here:
>>
>> http://php.net/string
>
> He's probably using MS-Word to write code... those look very similar to
> dumb-quotes. Have you notice they open with a superscript 3 and close
> with a superscript 2?
>
> Cheers,
> Rob.
> -- 
> ..
> | InterJinn Application Framework - http://www.interjinn.com |
> ::
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for   |
> | creating re-usable components quickly and easily.  |
> `' 

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



  1   2   >