Re: [PHP-WIN] Substr function

2004-12-13 Thread tg-php
In addition to substr() and explode() already mentioned, check out some of 
these:

basename() - Returns filename component of path
http://us2.php.net/manual/en/function.basename.php

strrpos() - Find position of last occurrence of a char in a string
http://us2.php.net/manual/en/function.strrpos.php

$filepath = "/something/somethingelse/filename.ext";

You could use basename() to get the full filename with exension then use
  $basename = basename($filepath);

Or you could use:

  $basename = substr(strrpos($filepath,"/")+1);

Then use:
  list($file,$ext) = explode(".",$basename);
.. to get your extension.

I think that's right.  If you don't do the +1, I believe you'll get the "/" in 
your filename and you don't want that part.

I think basename() is probably your best bet if you have the full file path to 
start with.  substr() works great if you know where to split the string but 
using PHP's functions to their fullest capability is always good tood.

Good luck!  HTH!

-TG
*** new email address [EMAIL PROTECTED]
*** old email address [EMAIL PROTECTED]  (Stupid Chapter 11)



= = = Original message = = =

Hi can anyone explain to me how to manipluate strings. I have generated
a file name

($_FILES['documenturl']['name'])

Out of this server variable I need to grab the file and the extension
and put them into seperate fields for database upload. Any idea how to
do this by using substr?

Thanks
Steven


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: AW: [PHP-WIN] Word COM Object

2005-01-07 Thread tg-php
Creating a new document in Word, inserting Page Breaks then saving it as a web 
page revealed that Word seems to use CSS tags to show the line breaks in HTML. 
The only odditiy I see is that when I load the HTML back into Word, mine is 
still set to "View -> Web Page Layout" or something (Word 2003) which doesn't 
show the page breaks (since you don't have page breaks in HTML) but if you set 
it to "View -> Normal" the page breaks are in there.

Anyway, generating HTML like the following should give you page breaks when 
loaded into Word:






Test 1








Test 1




Test 2




Test 3








Really you probably just need this as the page break:



Not sure what "clear=all" does, but the "page-break-before" is standard CSS 
(CSS2 I believe) that's telling it to insert the page break before the  tag 
(right? I think that's right).

Maybe that helps.. if not, post again   "Ask again later" - Magic 8 Ball  :)

-TG


= = = Original message = = =

Thank you for reply.  I figured out how to do that but now my issue is
that since my styling is all done in HTML...I'm trying to bring over the
HTML for each person's BIO, followed by a page break then the next
person's BIO followed by a page break...and so on...

The obvious problem is that if I use the Word COM object to insert the
HTML...the HTML isnt parsed and all I get is the HTML source code...but
the page breaks work great.  If I save the file first as HTML then open it
using the Word COM object then save it as a doc, it parses correctly...but
since there is no HTML page break function...all of the bios run one after
the other, when what I really need is each Bio starting on a new page.

This is killing me!
Ron

>From: Sven Schnitzke
>To: '[PHP-WIN]'
>Sent: 01/07/2005 8:15 AM
>Hi,
>sorry for accidentally sending private mail first ! Now to  the  list:
>
>to insert a pagebreak just leave out the parameter entirely. It's
default:
>
>~$word->Selection->InsertBreak();
>
>but for clarity you may want to specify it, so do it the positional way
(it's the 1st one):
>
>~$word->Selection->InsertBreak(wdPageBreak);
>
>Named parms don't seem to be supported by PHP COM.
>
>HTH
>-- 
>Sven
>
>> -Urspr~ngliche Nachricht-
>> Von:[EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
>> Gesendet am:~Mittwoch, 5. Januar 2005 18:55
>> An:[EMAIL PROTECTED]
>> Betreff:~[PHP-WIN] Word COM Object
>>
>>
>> I have successfully made a PHP script that takes dynamically generated
>> HTML and creates a Word Doc then saves it to the server and creates a
link
>> to itself.  This is fine and dandy but now I have to do a multipage
>> document using several dynamically generated pages...this isnt a
problem
>> BUT I need to put a page break following each dynamically generated
page.
>> Is there some MS WORD command that I could embed in the HTML I am
>> generating that will cause a page break?
>>
>> This seemingly simple task is killing me.
>>
>> Ron
>>
>>
>>
>>
>>
>>
>
>-- 
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: AW: [PHP-WIN] Word COM Object

2005-01-07 Thread tg-php
No prob, hope it helps.   Usually, if Word or whatever application you're 
working with knows how to do something then usually you can work it backwards 
(start with the finished product and trace it back a little) to figure out how 
they do it or what standard they use get the job done.  Sometimes there are 
some special little codes that aren't really obvious that will do the job.

Try exporting an Excel spreadsheet to HTML ("Save for web" or whatever) and 
take a look at THAT code.  If you have a formula like "=B2+5" and B2 is "2", 
the cell with the formula will have the value "7" between the  but 
then there's a code embedded in there that's ignored by web browsers that 
actually has the formula so Excel knows how to reconstruct it.  It's kind of 
cool but definitely useful to know that you can do things like that.

I did a thing once that generated an HTML table with some embedded Excel tags.  
It displayed correctly in HTML and then you could click a "Download" or "Open 
in Excel" button and just send some custom headers to pretend it was an .XLS 
file and the document would open in Excel with all the formulas and things in 
the right place...  all without having to mess with PEAR Excel Writer (??) or 
creating an .XLS file itself.

Anyway, good luck.  I think there are probably lots of ways to skin this 
particular cat.  Play around with different methods.

-TG

= = = Original message = = =

Wow thanks!

I will try this out.

I really appreciate the help.

Ron

>From: [EMAIL PROTECTED]
>To: php-windows@lists.php.net
>Sent: 01/07/2005 9:54 AM
>Creating a new document in Word, inserting Page Breaks then saving it as
a web page revealed that Word seems to use CSS tags to show the line
breaks in HTML. The only odditiy I see is that when I load the HTML back
into Word, mine is still set to "View -> Web Page Layout" or something
(Word 2003) which doesn't show the page breaks (since you don't have page
breaks in HTML) but if you set it to "View -> Normal" the page breaks are
in there.
>
>Anyway, generating HTML like the following should give you page breaks
when loaded into Word:
>
>
>
>
>
>
>Test 1
>
>
>
>
>
>
>
>
>Test 1
>
>style='page-break-before:always'>
>
>
>Test 2
>
>style='page-break-before:always'>
>
>
>Test 3
>
>
>
>
>
>
>
>
>Really you probably just need this as the page break:
>
>
>
>Not sure what "clear=all" does, but the "page-break-before" is standard
CSS (CSS2 I believe) that's telling it to insert the page break before the
 tag (right? I think that's right).
>
>Maybe that helps.. if not, post again   "Ask again later" - Magic 8 Ball
:)
>
>-TG
>
>
>= = = Original message = = =
>
>Thank you for reply.  I figured out how to do that but now my issue is
>that since my styling is all done in HTML...I'm trying to bring over the
>HTML for each person's BIO, followed by a page break then the next
>person's BIO followed by a page break...and so on...
>
>The obvious problem is that if I use the Word COM object to insert the
>HTML...the HTML isnt parsed and all I get is the HTML source code...but
>the page breaks work great.  If I save the file first as HTML then open
it
>using the Word COM object then save it as a doc, it parses
correctly...but
>since there is no HTML page break function...all of the bios run one
after
>the other, when what I really need is each Bio starting on a new page.
>
>This is killing me!
>Ron
>
>>From: Sven Schnitzke
>>To: '[PHP-WIN]'
>>Sent: 01/07/2005 8:15 AM
>>Hi,
>>sorry for accidentally sending private mail first ! Now to  the  list:
>>
>>to insert a pagebreak just leave out the parameter entirely. It's
>default:
>>
>>~$word->Selection->InsertBreak();
>>
>>but for clarity you may want to specify it, so do it the positional way
>(it's the 1st one):
>>
>>~$word->Selection->InsertBreak(wdPageBreak);
>>
>>Named parms don't seem to be supported by PHP COM.
>>
>>HTH
>>-- 
>>Sven
>>
>>> -Urspr~ngliche Nachricht-
>>> Von:[EMAIL PROTECTED]
[SMTP:[EMAIL PROTECTED]
>>> Gesendet am:~Mittwoch, 5. Januar 2005 18:55
>>> An:[EMAIL PROTECTED]
>>> Betreff:~[PHP-WIN] Word COM Object
>>>
>>>
>>> I have successfully made a PHP script that takes dynamically generated
>>> HTML and creates a Word Doc then saves it to the server and creates a
>link
>>> to itself.  This is fine and dandy but now I have to do a multipage
>>> document using several dynamically generated pages...this isnt a
>problem
>>> BUT I need to put a page break following each dynamically generated
>page.
>>> Is there some MS WORD command that I could embed in the HTML I am
>>> generating that will cause a page break?
>>>
>>> This seemingly simple task is killing me.
>>>
>>> Ron
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>-- 
>>PHP Windows Mailing List (http://www.

[PHP-WIN] RE: [PHP] php editor

2005-01-13 Thread tg-php
It's true that googling would produce a list of PHP-happy editors, but the 
intended question seems to be more along the lines of "What does everyone like? 
 Use?  Prefer?"   That's not something that's always found on lists you'd get 
off of google.

Helpful responses aren't always ones that are technically correct.

-TG

= = = Original message = = =

"Know any goog ones?"

funny you should mention goog.. if you google'd "php editor" youd have
your answer by now..

cheers
phpninja

-Original Message-
From: William Stokes [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 13, 2005 8:02 AM
To: php-general@lists.php.net
Subject: [PHP] php editor

Hello,

I'm quite new with writing php code. I was considering of using some kind of
php editor program to help with the syntax. Know any goog ones?

Thanks
-Will


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Re: SpreadSheet_Excel_Writer PEAR package

2005-01-19 Thread tg-php
First, I have to admit that I don't have any experience with PEAR's Excel 
Writer, but I have quite a bit of Excel experience (including Excel+VBA so I 
got some experience with the internal workings via code).

foreground color should be for the text and/or pattern color.  bgcolor should 
be for the cell color.  In the example used in that link, a pattern is set and 
the foreground color is set to 22.  Most likely this 'works' because the 
pattern is being colored, not the cell background.

I'm not sure what color index 22 is or pattern 2, but this seems like a bad 
solution (or at least not the 'right' solution) to what's being asked.

The quest was if you have pattern set to 0 (no pattern I would think), why a 
background color doesn't work properly.

Right now I don't have a good answer for anyone, but wanted to break down what 
was already mentioned and say that you might want to keep looking for a better 
solution.  No offense Torsten.  But I'm thinking that if Louis puts any data 
into that cell, it's going to show up in the 'fgcolor' color which may not be 
acceptable to what he's trying to do.

But hey... I could be wrong too. It's happened before. hah.

Louis!  You might check on the PEAR mailing list as well.. check their archives 
and such.  Someone may have had a similar problem and they most likely 
discussed it there before they did here. http://pear.php.net

Good luck!  Let us know if you find a solution.  I have an interest in 
PHP<->Excel stuff, but havn't had any  need for it recently.  So I'm eager to 
learn of any issues with PEAR's Excel Writer or other PHP/Excel solutions.

Thanks!

-TG


= = = Original message = = =

"Louis Young" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi there
>
> Why does my background color not show if I set a cells pattern to 0?
>
> Cheers
> Louis

Hi Louis,

take a look here:
http://marc.theaimsgroup.com/?l=pear-general&m=108127548918900&w=2

Have you tried setFgColor()?

Regards, Torsten


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Re: PHP MS-DOS

2005-01-26 Thread tg-php
I think people get confused when they talk about "Windows apps" and such.  I'm 
not sure that I can clarify things that much, but I wanted to point out some 
stuff that might help people understand a little better.  Please, anyone who 
has more intimate knowledge of this, feel free to correct me or add to what 
I've said.


When people think Windows, they think GUI.  So then you ask yourself, "Why does 
PHP need a GUI if we're only trying to run it in command line mode?".  I guess 
one answer is that you really DONT need Windows, but in the evolution from DOS 
to Windows there were some things done that were never added to the older 
DOS-only systems that PHP requires.

It's probably more accurate to say that PHP, even command line, is a win32 app. 
 This means that it's using some win32 calls/functions/whatever that you can't 
get in a DOS-only environment.  Probably not even the DOS that's installed on a 
bootable floppy created under a newer version of Windows (DOS 7?  They up to 
DOS 8 or so yet?  I havn't made a bootable floppy since Windows 98 so I don't 
know).

I havn't checked out the PHP CLI mentioned, but if it still needs win32 
functions, then it's probably not going to work on a bootable floppy/cdrom 
without something special to help it (or a recompiling to make it not a win32 
app).

I did find a product called unWin that emulates win32 calls, but it looks like 
you have to pay for it.  Still, if that's a hard requirement for an application 
you're creating for a job or something, it might be worth looking into.

You can find unWin and unDos at:
http://www.smxinfo.com/rtos/dos/undwinpb.htm

If I screwed something up, feel free to correct me.  If you have more questions 
or I was unclear, feel free to ask and I'll try to be more clear.

-TG

= = = Original message = = =

Yes, but it's still a windows app.. :p I think it uses windows funtionality,
that doesn't exist in dos (with dos I don't mean console windows, I mean
real dos, with no windows loaded at all).. It's not using windows specific
stuff, or at least it doesn't really depend on it, but it uses stuff that I
doubt exists in dos..

-- 
// DvDmanDT
MSN: dvdmandt~hotmail.com
Mail: dvdmandt~telia.com
"Jean-Philippe Palha" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Try PHP CLI, it's the command line version of PHP
> (look at the CLI folder in your PHP distrib)
>
> Jean-Philippe PALHA ([EMAIL PROTECTED])
> IMA'DIFF - 13, rue Damesme - 75013 Paris  FRANCE
> Tel : 33 1 53 80 89 89 - Fax : 33 1 53 80 89 81
> Web : http://www.imadiff.com
> --
> --
>
> "DvDmanDT" <[EMAIL PROTECTED]> sur mercredi 26 janvier 2005 ~ 15:45
+0100:
> >I don't think you could get it to run under dos.. You could recompile it
> >ofcorse, but I doubt it would work anyway.. I think it uses some
> >functionality that wouldn't be possible under dos.. But it's only a
> >guess..
> >
> >-- 
> >// DvDmanDT
> >MSN: dvdmandt~hotmail.com
> >Mail: dvdmandt~telia.com
> >"Shawn McKenzie" <[EMAIL PROTECTED]> skrev i meddelandet
> >news:[EMAIL PROTECTED]
> >> Is it possible to run the current win32 PHP under DOS only?  I have a
> >> bootable DOS disk with PHP and when I attempt to run it I get "This
> >> program can not run in DOS mode.".
> >>
> >> Is there a DOS binary???
> >>
> >> TIA
> >> -Shawn
> >
> >-- 
> >PHP Windows Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] From Browser to Print - ?????

2005-01-27 Thread tg-php
Check into maybe using CSS2 page breaks.  I don't see any way to make PHP do 
it, but CSS2 has facilities for that.

Try this:



Requires IE 5.5 if I remember right.

-TG

= = = Original message = = =

I have some PHP scripts that put output to the browser. I can then print them. 
However, I want to have the pages form feed at specific places so the printouts 
look nice.  How can I do that?

Thanks.

Mike


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] outlook calendar

2005-02-07 Thread tg-php
= = = Original message = = =

> Good morning,
> 
> Is it possible to reach the data of the outlook calendar (on a server
> exchange) with php?
> 
> Thank you for advance

I've never tried using PHP to connect to an Exchange server directly, but I've 
done some stuff with using PHP to connect via COM to Outlook itself (and let 
Outlook do all the hard work of getting data from Exchange).

Here's some sample code to read calendar entries.  Remember, you have to have 
Outlook currently running on the PC that PHP is running on.

Good luck!

-TG

 Activate;

# This is your mailbox name just like it appears in your Folders view.  It 
might be 'Inbox' or something else.
$targetmailboxname = "Personal Folders";

# This is the folder you're looking for.  In this case, I'm looking for 
calendar items, but you can look for
# any folder.  You need to add another loop to look for subfolders.  Although 
there's probably a better
# way, that's how I did it when I needed to get to Personal 
Folders/Inbox/Subfoldername
$targetfoldername = "Calendar";

$objNamespace = $comobjOutlook->GetNameSpace("MAPI");
$objFolders = $objNamespace->Folders();
$mailboxcount = $objFolders -> Count();

$foundmailbox = FALSE;
for ($i=1; $i<=$mailboxcount; $i++) {
  $folderitem = $objFolders ->Item($i);
  if ($folderitem -> Name == $targetmailboxname) {
$objMailbox = $folderitem;
$foundmailbox = TRUE;
  }
}

$foundcal = FALSE;
if ($foundmailbox) {
  $objFolders = $objMailbox->Folders();
  $foldercount = $objFolders -> Count();

  for ($i=1; $i<=$foldercount; $i++) {
$folderitem = $objFolders -> Item($i);
if ($folderitem -> Name == $targetfoldername) {
  $objCalendar = $folderitem;
  $foundcal = TRUE;
}
  }

  if ($foundcal) {
$objItems = $objCalendar->Items();
$itemcount = $objItems->Count();

for ($i=1; $i<=$itemcount; $i++) {
  $apptitem = $objItems -> Item($i);
  $apptstart = $apptitem -> Start();
  $apptend = $apptitem -> End();
  $apptallday = $apptitem -> AllDayEvent();
  $apptrecur = $apptitem -> IsRecurring();
  $apptsubject = $apptitem -> Subject();
  $apptlocation = $apptitem -> Location();

  $secondsadj = $apptstart - 14400;
  $startadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970));

  $secondsadj = $apptend - 14400;
  $endadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970));

  if($apptallday) { $allday = "All Day"; } else { $allday = ""; }
  if($apptrecur) { $recurring = "Recurring"; } else { $recurring = ""; }

  echo "$apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n";
  if ($allday <> "" OR $recurring <> "") echo "$allday $recurring\r\n";
  echo "\r\n\r\n";
}

  } else {
die ("Did not find calendar folder");
  }

} else {
  die("Did not find target mailbox: $targetmailboxname");
}
?>



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] outlook calendar

2005-02-07 Thread tg-php
You know, I forgot but I think that depending on the version of Outlook, you 
might have to replace the "outlook.application" with something else.

Maybe not.. hmm.. I can't find any examples where something other than 
'outlook.application' is used.  Maybe I'm wrong there.

At any rate, I'd check to make sure you're instantiating the COM object.  Maybe 
try connecting to Excel or another MS program via COM.

I havn't played with PHP5 yet, so can't tell ya if it does anythig differently 
or needs any extra TLC.

Let us know if you find anything interesting.

-TG

= = = Original message = = =

[EMAIL PROTECTED] wrote:
> $comobjOutlook = new COM("outlook.application") or die("Unable to instantiate 
> outlook"); $comobjOutlook -> Activate;
>

PHP 5.0.3 crashed after trying this... it complained that there was no
property named "Activate".  I then tried changing Activate to Activate()
in case it was supposed to be a method, but that failed as well.  So
much for copy and paste, is it ever that easy?

I always have problems with COM.  :-/  Perhaps there is another issue
that I'm unaware of that is preventing me from using COM and / or
preventing Outlook from responding correctly?  Anyone know what I might try?

I should probably add: I'm running Win2K v5.00.2195 (with all critical
updates).  I will try running this code on my WinXP laptop later to see
if the OS is my issue...


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP-WIN] Re: [PHP] Re: Storing CCN's Again...

2005-02-09 Thread tg-php
Yeah, Richard's got it exactly right.  Companies like Amazon NEED to have a 
million precautions in place because it's not just the possible money lost to 
their customers, but the excessive amounts of BUSINESS lost (and trust in 
Amazon as a reliable and secure financial institution).  One incident of the 
credit card info leaking out can cost Amazon literally millions, even if it's 
only one CCN and it never gets used fraudulently.   Hell, just the RUMOR of it 
happening can cost them way too much.

But yes.. no system is unbeatable.  If you can't get directly to the CCNs, you 
can possibly get to them further 'upstream' after they've been decoded.  Or, 
more common than electronic hacking, is for someone within the organization to 
take sensitive financial statements without having to do any hacking, just 
betraying the trust of their employers.  The human is always the weakest link 
in any security scheme anyway.

I wouldn't recommend anyone other than a highly trained professional (or 
someone who's going to hire a professional to audit the system after it's 
built) to attempt ot do something like store credit card numbers.

The idea behind security in this instance is to make the effort not worth the 
payoff.  Some hackers do things for the challenge and bragging rights, but 
chances are, someone who's after CCNs is going to be selling them or using 
them.  So unless they're totally stupid or just bored and want a challenge, 
they're going to be thinking about a couple of things:

1. What's the financial payoff for succeeding (either in selling the CCNs or 
using them personally.. in either case it could be for the credit or for 
identity theft of another kind)

2. What's the risk and possible penalties for getting caught.


If the payoff is greater than the risk (in their mind), then it's worth it.   
If they can steal a couple thousand CCNs with one COPY command and spend 2 
weeks, a month, whatever offline running a brute force cracking program that 
will get them ALL the CCNs, then it's worth it.  If you're using suitably 
strong enough encryption then it could take them nearly forever to get the 
info, but it's still not foolproof.

PGP, for example, produces very strongly encrypted data.  But if someone has 
your private key and a public key that's used to decrypt the data, then all 
they have to do is run a brute force crack on the PGP passphrase used to 
decrypt it.  They're not attacking the data and it's encryption, they're 
attacking the passphrase.

If you can decrypt the data, someone else can too... with the right tools and 
keys and time.

Hell, you don't even need to get to the CCN data if someone can get in and pose 
as a legitmate user and order products from your site using the stored CCNs.  
That might limit what they can buy, but it's still someone using a CCN that's 
not theirs.

Too much liability for my tastes.  I'd purchase a pre-made, hopefully secure, 
and guarenteed CCN management package or service.

People get real twitchy about money and bosses get real twitchy about their 
employees creating stuff that can bring down the company due to lawsuits and 
liability.  C. Y. A.  :)

-TG


= = = Original message = = =

[EMAIL PROTECTED] wrote:
>> Amazon store Credit Card Number in their databases. Are we saying that
>> someone could hack into their database server and steal the numbers?

YES!

Wasn't PayPal widely publicized as a victim of such an event?

Why would you think Amazon would be any better/safer?

No system is unbeatable.

So somebody *could* break in.

You can be damn sure they work really hard to avoid that.

>> Or
>>  have Amazon gone far enough to protect their data?

How far is "far enough"?

> I supose they use a similar tactic as i have, and have a two way
> encryption
> method.

I suppose they do a LOT more than that.

They might, just as an example, have a network setup like this:

 Seg 1Seg 2   Seg 3
Internet <---> Public Servers <---> CC Processing Servers <---> CC Storage
Servers

Where Seg 1 and Seg 2 and Seg 3 are all on:
  Completely different sub-networks
  Completely different network cards
  Completely different routers, hubs, switches
  Completely different color-coded network cables
  .
  .
  .

And, of course, they use two-way encryption of the data that *IS* on the
CC Servers, so while the secret decoder ring is on the CC Processing
Server, you'd have to break into CC Processing, get the ring, break into
CC Storage, and then apply the ring from CC Processing to the data in CC
Storage.  Is this starting to sound like an Adventure Game or what?

They then severely restrict the source code and network access that can
work with Seg 3, with an EXTREMELY limited API, internal documented,
security audited, clean-room access, armed guards on all hardware setup,
etc

Instead of breaking into CC Storage with your secret decoder ring from CC
Processing, you can maybe find a flaw in the API of Seg 3, and sniff ou

[PHP-WIN] Re: [PHP] Removing Items from an Array

2005-10-13 Thread tg-php
Thanks for the addition Jochem..  one reason I post here, even if it's a basic 
example, is because if there's a better way or a chance to learn something new, 
I want to have that opportunity.  Thanks again!

-TG

= = = Original message = = =

Id like to continue where TG left off ...

hth.

[EMAIL PROTECTED] wrote:
> If I understand what you're asking, then maybe this will help:
> 
> $arrset1 = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1);
> $arrset2 = array("Couches" => 6, "Chairs" => 2, "Benches" => 5);
> 
> $alldataarr["Fruits"] = $arrset1;
> $alldataarr["Furniture"] = $arrset2;
> 
> Say we want to remove "Chairs", and let's do it the hard way:
> 
> foreach ($alldataarr as $key => $data) 
>   foreach ($data as $subkey => $subdata) 
> if ($subkey == "Chairs) 
>   unset($alldataarr[$key][$subkey]);
> 
>   
> 
> 
> using foreach $arr as $key => $data you can get the key/index name as well as 
> the actual value stored in that part of your array.  Then all you have to do 
> is refer back up to the main array using the current $key/$subkey values as 
> your indexes.
> 

$filter = array(
~'Fruits'=> array('Apples' => 1, 'Oranges' => 1),
~'Furniture' => array('Couches' => 1, 'Chairs' => 1),
);

$alldataarr = array();
$alldataarr["Fruits"] = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1);
$alldataarr["Furniture"] = array("Couches" => 6, "Chairs" => 2, "Benches" => 5);

foreach ($alldataarr as $key => $data) 
if (!isset($filter[$key]) 
~// we want it all;.
~continue;

$alldataarr[$key]= array_intersect_keys($data, $filter[$key]);



// heres one I prepared earlier:


/**
  * array_intersect_keys()
  *^--- the internal function (php5.x+?) has no 's'
  *
  * returns the all the items in the 1st array whose keys are found in any of 
the other arrays
  *
  * @return array()
  */
function array_intersect_keys()

 $args   = func_get_args();
 $originalArray  = $args[0];
 $res= array();

 if(!is_array($originalArray))  return $res; 

 for($i=1;$i $data) 
 if (isset($originalArray[$key]) && !isset($res[$key])) 
 $res[$key] = $originalArray[$key];
 
 
 

 return $res;





> 
> Basic example, but I think you can modify this to work with what you're doing.
> 
> Let me know if you have any questions about this example.
> 
> -TG
> 
> 
> 
> = = = Original message = = =
> 
> Hi all,
> 
> I'm really struggling here! I have a large, multi-dimensional array that
> I want to "clean-up" a bit before committing to a database.
> 
> I want to remove quite a bit of the array but using the KEYs not the
> values. I know the keys I want to keep and I know the keys I want to get
> rid of. I want to keep the structure and sequence of the array in tact. 
> 
> All of the array traversing functions in PHP seem to either: only work
> on the values, or do not allow the removal of elements of the array!
> 
> Can anyone offer a clue bat to a tired old array walker!
> 
> Thanks
> 
> Alan
> 
> 
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Is this a PHP bug?

2005-10-17 Thread tg-php
Thanks for the vote of confidence, Ross. hah.  *shrug*

At any rate, I was wrong about one thing.  Mis-remembered something about 
converting a string to a int.  It doesn't pull all numbers out of the string, 
it only pulls leading numbers.

$address = "123 Main St Apt 45";

echo intval($address);

outputs "123" not "12345"

But as explained, the lack of numbers (specifically at the front end of the 
string) produces a numerical zero.

As to "numbers should be converted to strings" that was sort of my initial 
thoughts when I started using PHP, but now that I've used it for a while, I 
think the "convert to lowest common denominator" method works better.  Either 
way, it was a judgement call on the part of the PHP development team and it's 
how PHP operates.

So at this point it's kind of like saying "This house really should have a 
basement" after the house is built.  Maybe there's a good reason why they 
didn't put a basement in to start with and technically it's possible to add a 
basement if they changed their mind, but at what cost.

At any rate, known, predictable and intentional behavior is not a bug.  

-TG

= = = Original message = = =

I'm yet to be convinced it isn't a bug. I suspect it is a bug that has been 
around so long that they can't afford to fix it or it may break many 
applications that for various peculiar reasons rely on it to behave as it does 
for their code to work.

For those who have tried to defend its behaviour, this is my logic.

1. The == operator means, by definition, "don't worry about variable 'type', 
just compare the values"
   (This is probably the single thing I love about PHP more than anything else)

2. If the numeric variable $x is given ANY other numeric value other than zero, 
   the logic behaves correctly as you read it

So it is irrational for program logic to vary between a zero value and, for 
aguments sake, a numeric value of 42.

Regarding specifically TG's explanation below, I believe he is wrong. If you 
compare a numeric type and a string type using ==, PHP should convert the 
number to a string and compare the two from there.

Anyway, not expecting any answers to this, just a point of note and a strange 
quirk to keep at the back of your head when consciously comparing numeric / 
string variables.

Ross

[EMAIL PROTECTED] wrote:
> It's because PHP is trying to convert different var types into a common var 
> type and then compare them when you use ==.  === means compare value AND type 
> so that's why it fails.
> 
> Your string, 'Some kind of string' is getting converted down to the lowest 
> common denominator, an int.  Since there are no numbers in the string to grab 
> onto, it gets converted to nothing, an int value of zero.
> 
> If you had $x = "0" or if $y had contained numbers at all, it wouldn't have 
> passed.
> 
> But this is why when you use $x.'' it works properly because now you have 
> "0", it's been converted to a string value "0".  Good catch on 
> that though, shows good methodical debugging :)
> 
> So in the future, either use === or be extra aware of your variable types and 
> make sure you're comparing properly.
> 
> Good luck!
> 
> -TG
> 
> = = = Original message = = =
> 
> $x = 0; // Numeric zero
> $y = 'Some kind of string';
> 
> if ($x == $y) echo 'they equal using ==';
> if ($x === $y) echo 'they equal using ===';
> 
> The above will echo 'they equal using =='.
> 
> The values don't look very equal to me.
> 
> Can anyone explain the logic behind this?
> 
> I'm heading home now but look forward to your explanations tomorrow.
> 
> PS
> 
> Incidently, to 'fix' it so it behaves as it should, you can code:
> 
> if ($x.'' == $y.'') echo 'this will not print and all is good.';
> 
> Regards .. Ross
> 
> 
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
> 
> 

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP-WIN] Re: [PHP] PDF printing under windows.

2005-10-25 Thread tg-php
Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically, /dev/printer or 
/dev/lpr or whatever the *nix specific is, it does have a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and such, I'm 
not sure, but I know that some printers can decode PDF's internally so that'd 
work out great.

2. Second point... If all you need is a simple print function and you have 
exec() privs, why not try to find a DOS based printing solution.  The copy 
command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command line 
options:

"PrintFile also works well with command line (DOS) programs. It has several 
command line options and can read data from command line standard input, e.g. a 
command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary because you 
can configure Windows printers to support DOS (although I havn't done this in 
ages, I assume you still can in XP) so in theory the normal DOS "print" command 
would pipe through Windows drivers and print handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of these 
options should pipe the file through Windows which in turn, could possibly send 
it through the proper printing method.   If not, you might be able to look in 
your registry and find the right-click "Print..." option and see if it's 
something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to say 
"How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document" (I 
think this is specific to having the full Acrobat installed)
3. Below the area where all the file extensions are in HKEY_CLASSES_ROOT there 
are the actual named app section (that way, ".gif" and ".jpg" can both point to 
Photoshop.document" or something.. get it?)  So search for "AcroExch.Document" 
in this case
4. Expand that tree and look for "shell". These are all the things that show up 
on your right-click menu.  In this case, we have a "print" section. Under each 
of these entries, there should be (but sometimes not) a "command" branch.  This 
is what's run when you select that option from the right-click menu.  And 
voila! We find that the command to use Acrobat to print (which can be executed 
from command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate selecting 
right-click PRINT on a PDF file.


Crossposting this to PHP-Win for their benefit too since this is more Windows 
related than PHP General.

I see lots of ways to potentially solve this problem without using COM.

I loved messing with COM (with or without PHP) for a while, but it's not a 
great general solution to things unless you absolutely HAVE to control the app 
(which is very cool and slick sometimes, but not for something as simple as 
printing).

Hope this gives you some new avenues to persue.  Best of luck!

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.


___
Sent by ePrompte

[PHP-WIN] Re: [PHP] PDF printing under windows.

2005-10-25 Thread tg-php
David.. I think I accidentally deleted your last message, but I believe you 
said something about Acrobat not closing after it gets done printing.  Here are 
a few thoughts:

1. If you right click on something and select "print" and it performs the 
command line action listed in the registry as mentioned below, it SHOULD exit 
when done printing. If it doesn't, it could be an app issue.

2. If you use COM and app doesn't close properly, you might want to look at the 
app "Close" as well as "Quit" methods.  If I recall, you can do one, or the 
other, but an instance of the app may still hover invisible in the background.  
I remember using both (in a certain order.. reversing the order made it so the 
app still stayed loaded.. the correct order though made sure the app closed 
properly).

3. If a certain file type (like say Excel files for instance) requires a 
specific app to interpret it's data for output, then you kind of can't get 
around loading the app in order to print it.  Unless you can find a smaller 
view/print-only app that's made for handling that app's data files.   In the 
case of PDF, if you're lucky then your printer knows how to decode them and you 
might get away with piping the raw binary file directly to the print device 
(LPTx in the case of DOS/Windows.. where "x" is of course the number of the 
printer device.  Might have to mount the printer to that port though or do the 
DOS printer config in Windows).   The printer needs intelligible data from the 
PC if it doesn't natively know how to handle the file.  So again, you need the 
real app or a reader type app to load in order to send the printer proper data.


If you get the print command line out of the registry as listed below, then it 
SHOULD exit properly.  If not, it's a problem with the app and not with your 
code.  Try performing the CLI command in a command prompt and see if the app 
exits properly before doing it in PHP.Something as common (and an open 
standard) like PDF, you should be able to find other DOS and/or Windows apps 
that'll print it, but you'll probably still have to use the command line and 
exec() call of some kind, unless you use COM which is overly complicated and 
burdensome in my opinion.

-TG

= = = Original message = = =

Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically, /dev/printer or 
/dev/lpr or whatever the *nix specific is, it does have a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and such, I'm 
not sure, but I know that some printers can decode PDF's internally so that'd 
work out great.

2. Second point... If all you need is a simple print function and you have 
exec() privs, why not try to find a DOS based printing solution.  The copy 
command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command line 
options:

"PrintFile also works well with command line (DOS) programs. It has several 
command line options and can read data from command line standard input, e.g. a 
command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary because you 
can configure Windows printers to support DOS (although I havn't done this in 
ages, I assume you still can in XP) so in theory the normal DOS "print" command 
would pipe through Windows drivers and print handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of these 
options should pipe the file through Windows which in turn, could possibly send 
it through the proper printing method.   If not, you might be able to look in 
your registry and find the right-click "Print..." option and see if it's 
something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to say 
"How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document" (I 
think this is specific to having the full Acrobat installed)
3. Below the area where all the file extensions are in HKEY_CLASSES_ROOT there 
are the actual named app section (that way, ".gif" and ".jpg" can both point to 
Photoshop.document" or something.. get it?)  So search for "AcroExch.Document" 
in this case
4. Expand that tree and look for "shell". These are all the things that show up 
on your right-click menu.  In this case, we have a "print" section. Under each 
of these entries, there should be (but sometimes not) a "command" branch.  This 
is what's run when you select that option from the right-click menu.  And 
voila! We find that the command to use Acrobat to print (which can be executed 
from command line on a Windows machine) is

[PHP-WIN] Re: [PHP] PDF printing under windows.

2005-10-25 Thread tg-php
This is really dumb and overly simple, which is probably why it was missed/not 
brought up, but it just occurred to me that, assuming you have a browser-based 
interface to your app, why don't you just send the PDF to the browser for 
printing?  Then it should use the Acrobat Reader plugin to open the app then 
just have the user (you?) click the print button?  Or do you want it totally 
one-button click and that's it?

Just a thought. 

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Cam control

2006-04-18 Thread tg-php
There's probably libraries out there for dealing with serial and parallel 
operations with PHP and I'm sure someone will point one out.  In the meantime 
and maybe as an addition to it, you might check out Winbinder 
(http://www.winbinder.com)  it's a native Windows API interface for PHP that's 
just great!

I looked through the sample files (WinBinder\Code\Samples after you download 
and decompress the package) and there's one for accessing serial ports.  Looks 
like you could just change COM1 to LPT1 and do some tweaking to get it to do 
what you need.

Here's the function in serial.phpw that opens the serial port:

function open_serial($portname)
{
~global $CreateFile;

~return wb_call_function($CreateFile, array(
~~$portname,
~~GENERIC_READ | GENERIC_WRITE,
~~0,
~~null,
~~OPEN_EXISTING,
~~0,
~~0
~));
}

$portname at this point is COM1 I believe.

Good luck!

-TG

= = = Original message = = =

I have a pan and tilt mechanism with an opto-isolated circuit board that 
connects to the LPT port. What I am trying to do is control it totally 
in PHP.  Can anyone point me in the right direction for info on 
communicating directly with the LPT port? Or has someone done this already?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: [PHP-WIN] @mssql_connect() versus mssql_connect()

2006-10-13 Thread tg-php
As mentioned, the @ suppresses any errors, warnings, notices, etc that the 
command will give.  This is typically considered really bad programming 
practice.

If you resort to using an @ to suppress, one of two things is an issue:

1. Either error reporting is set to high and you're getting warnings and 
notices when you don't want to...  in which case you can just turn down the 
error reporting a bit.

2. Or there's an error and instead of trying to fix the error and program 
correctly, the programmer choses to just bury the error.  Which isn't so good.


The only time I've ever had to use @ to suppress an error was with an fgets() 
call that produced the following error:

"Warning: fgets(): SSL: fatal protocol error in /var/www/secure/scriptname.php"

I didn't save the link to the bug, but it's apparently a bug in PHP and the 
only solution I found was to suppress the error and everything works fine 
(despite the warning).

-TG

= = = Original message = = =

The @ is for error suppression

-Original Message-
From: Alf Stockton [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 12:00 AM
To: php-windows
Subject: [PHP-WIN] @mssql_connect() versus mssql_connect()

What is the difference between @mssql_connect() and mssql_connect()?
i.e. What is the relevance of the prefixed @?

--
Regards,
Alf Stockton~~www.stockton.co.za
 
You may my glories and my state dispose, But not my griefs; still am I
king of those.
~~-- William Shakespeare, "Richard II"
My email disclaimer is available at www.stockton.co.za/disclaimer.html

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

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Problem with removable media

2006-11-15 Thread tg-php
Styve,

Here's a block of code I borrowed (see comment block) and use to scan active 
drives on a Windows PC.  It uses the is_dir() which may still not work for you, 
but maybe it does it differently than you did.

Also, I believe you can access Windows API functions that can return the status 
of a drive without throwing an error box.  
http://www.php.net/manual/en/ref.w32api.php  (I think this is your best bet, 
just means diving into the Windows API and figuring out how to get the two to 
work together properly)

Another thing to look at is maybe head over to http://www.winbinder.com and see 
if any of those guys have found a good way to do it, since not only is it PHP + 
Windows specific, but non-web browser based coding that deals directly with 
Windows API issues.

And lastly, may be able to get info via COM interface with some other Windows 
apps, but I think this is a long shot and kind of sloppy:  
http://us2.php.net/com

Let us know if you find a good solution.  Good luck!

-TG

#
#
# The following code as found at: 
http://www.php.net/manual/en/ref.filesystem.php
# Simple enough code, but m2pc saved me some typing so I'm giving credit here. 
Thanks for sharing your code!
#
# The only things I changed were some formatting and
#
#

  # m2pc (at) hotmail.com
  # 07-Oct-2004 12:18
  # After searching all over the place to find a function to do what I wanted, 
I wrote the following:

  /*
  **  Returns an array of valid drives on the system (a:, b:, etc.)
  */
  function getSystemDrives() {

   // Initialize
   $aResult = Array ();

   // Loop from A-Z and try opening the root dir
   for ($letter = 'A'; $letter <= 'Z'; $letter ++) {
 if (is_dir ($letter . ":"))
   $aResult [] = $letter . ":";
   }

   // Return results
   return ($aResult);
  }

  # It simply returns an array of valid drives as seen from the server (A:, B:, 
etc.).  This obviously is targeted to Win32 installations only.
#


= = = Original message = = =

Hi folks,

I have a PHP apps who let people listen to audio files. Those files are
mainly store on the hard drive of the server. But the old ones are
backed up on DVD and purged from the hard drive. I need to offer the
possibility to listen to the files on the DVD. So, I have tried
different things:

I have added an alias in Apache configuration pointing to the DVD drive.
The problem is that as Apache validate is configuration on start, if
there is no disk in the drive, the service refuses to start. This
implied that we ALWAYS had to have a disk in the drive in case of a
server reboot. This solution was not retained after the test phase.

One of the other things that I have tried is to add an entry in the PHP
application configuration so we can configure the path to the DVD drive.
With that approach, Apache is always able to start correctly. I can also
listen to the files stores on the DVD. The problem comes when I try to
access to file on the DVD drive and there is no disk in the drive. All
the functions I have tried (file_exists(), is_dir(), etc.) make a
message box to appear on the server (There is no disk in the drive,
blabla... Abort, Retry, Ignore). This cause the session on the client to
hangs (waiting for the message box on the server). I have not been able
to suppress or prevent the message box to appear.

Writing a restoration application, is out of scope (not enough time left
on the project). Moving to PHP5 to have better error handling to.

Have any of you had to work on accessing removable media?

My server conf.:
Windows 2000 server SP4
Apache 2.0.50
PHP 4.3.3
The DVD drive is DVD-RAM

Best regards.

Styve



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] php installed on IIS: changes to php.ini not taking affect

2007-01-10 Thread tg-php
I had a similar issue a couple years ago when I was running Apache/PHP on a 
Windows box at a previous job.  The information below helped.  Check all the 
locations (regardless of what PHP is reporting it's using for php.ini's path).  
Try making some simple change that will show up on phpinfo().  You should find 
it eventually.

Good luck!

-TG

http://www.php.net/manual/en/install.windows.php

"php.ini is searched in these locations (in order):

* SAPI module specific location (PHPIniDir directive in Apache 2, -c command 
line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH 
environment variable in THTTPD)
* The PHPRC environment variable. Before PHP 5.2.0 this was checked after the 
registry key mentioned below.
* HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
* Current working directory (for CLI)
* The web server's directory (for SAPI modules), or directory of PHP (otherwise 
in Windows)
* Windows directory (C:\windows or C:\winnt) (for Windows), or 
--with-config-file-path compile time option"

= = = Original message = = =

I have php 5.2 up and running on IIS 5.1.

phpinfo tells me php is looking for my ini file in C:\Windows...I place 
the file there, edit it, restart the server but I don't see the changes 
I've made.

I've been dealing with this for a day and can't seem to find any 
information as to what's causing this problem.

I've tried adding C:\PHP to my system path where C:\PHP is where php 
lives. I also have PHPRC pointing ot C:\PHP...not sure if either of 
those would have anything to do with my problem.


Does anyone have any ideas?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] php installed on IIS: changes to php.ini not taking affect

2007-01-10 Thread tg-php
Could be a permissions issue with reading the new php.ini file you created.

On this page, it tells you how to figure out what user your IIS is executing as:
http://www.php.net/manual/en/install.windows.iis.php

"
1. In IIS Admin, go to Application Pools
2. Right click on the pool your site is running under and click properties. 
3. Go to the Identity tab and see what user is selected. 
4. Give that user permissions to your php files/directory.
"

If all else fails and you want to see if it's a permissions thing, set 
permissions to "Everyone - Full Control" on your php.ini file.  Bad security, 
but it should tell you if it's a permissions issue or not.


-TG

= = = Original message = = =

okay...turns out there was something strange going on with my ini file. 
I copied its contents into a new file, saved that as "php.ini"...now 
whenever I drop that in either C:\Windows or C:\PHP php will not 
execute. If I move the file out of either of those two directories, it 
executes fine.

Does this make any sense?


[EMAIL PROTECTED] wrote:
> I had a similar issue a couple years ago when I was running Apache/PHP on a 
> Windows box at a previous job.  The information below helped.  Check all the 
> locations (regardless of what PHP is reporting it's using for php.ini's 
> path).  Try making some simple change that will show up on phpinfo().  You 
> should find it eventually.
> 
> Good luck!
> 
> -TG
> 
> http://www.php.net/manual/en/install.windows.php
> 
> "php.ini is searched in these locations (in order):
> 
> * SAPI module specific location (PHPIniDir directive in Apache 2, -c command 
> line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH 
> environment variable in THTTPD)
> * The PHPRC environment variable. Before PHP 5.2.0 this was checked after the 
> registry key mentioned below.
> * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
> * Current working directory (for CLI)
> * The web server's directory (for SAPI modules), or directory of PHP 
> (otherwise in Windows)
> * Windows directory (C:\windows or C:\winnt) (for Windows), or 
> --with-config-file-path compile time option"
> 
> = = = Original message = = =
> 
> I have php 5.2 up and running on IIS 5.1.
> 
> phpinfo tells me php is looking for my ini file in C:\Windows...I place 
> the file there, edit it, restart the server but I don't see the changes 
> I've made.
> 
> I've been dealing with this for a day and can't seem to find any 
> information as to what's causing this problem.
> 
> I've tried adding C:\PHP to my system path where C:\PHP is where php 
> lives. I also have PHPRC pointing ot C:\PHP...not sure if either of 
> those would have anything to do with my problem.
> 
> 
> Does anyone have any ideas?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] php installed on IIS: changes to php.ini not taking affect

2007-01-11 Thread tg-php
Try checking out phpinfo() when it works and compare that to what's in your 
php.ini and look for the differences.  Maybe some option or extension or 
something you're trying to run is exploding.  Maybe print out the successful 
phpinfo() and your php.ini that's causing the trouble and go over both with a 
fine toothed comb.

-TG

= = = Original message = = =

Thanks for the suggestion...I tried that...i didn't make a difference.

Here's another thing I noticed. PHP seems to be using the default 
settings. When I drop a php.ini file in C:\Windows (where php is looking 
for my ini file) php fails execute. If I remove the ini file...the code 
executes fine.

[EMAIL PROTECTED] wrote:
> Could be a permissions issue with reading the new php.ini file you created.
> 
> On this page, it tells you how to figure out what user your IIS is executing 
> as:
> http://www.php.net/manual/en/install.windows.iis.php
> 
> "
> 1. In IIS Admin, go to Application Pools
> 2. Right click on the pool your site is running under and click properties. 
> 3. Go to the Identity tab and see what user is selected. 
> 4. Give that user permissions to your php files/directory.
> "
> 
> If all else fails and you want to see if it's a permissions thing, set 
> permissions to "Everyone - Full Control" on your php.ini file.  Bad security, 
> but it should tell you if it's a permissions issue or not.
> 
> 
> -TG
> 
> = = = Original message = = =
> 
> okay...turns out there was something strange going on with my ini file. 
> I copied its contents into a new file, saved that as "php.ini"...now 
> whenever I drop that in either C:\Windows or C:\PHP php will not 
> execute. If I move the file out of either of those two directories, it 
> executes fine.
> 
> Does this make any sense?
> 
> 
> [EMAIL PROTECTED] wrote:
>> I had a similar issue a couple years ago when I was running Apache/PHP on a 
>> Windows box at a previous job.  The information below helped.  Check all the 
>> locations (regardless of what PHP is reporting it's using for php.ini's 
>> path).  Try making some simple change that will show up on phpinfo().  You 
>> should find it eventually.
>>
>> Good luck!
>>
>> -TG
>>
>> http://www.php.net/manual/en/install.windows.php
>>
>> "php.ini is searched in these locations (in order):
>>
>> * SAPI module specific location (PHPIniDir directive in Apache 2, -c command 
>> line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH 
>> environment variable in THTTPD)
>> * The PHPRC environment variable. Before PHP 5.2.0 this was checked after 
>> the registry key mentioned below.
>> * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
>> * Current working directory (for CLI)
>> * The web server's directory (for SAPI modules), or directory of PHP 
>> (otherwise in Windows)
>> * Windows directory (C:\windows or C:\winnt) (for Windows), or 
>> --with-config-file-path compile time option"
>>
>> = = = Original message = = =
>>
>> I have php 5.2 up and running on IIS 5.1.
>>
>> phpinfo tells me php is looking for my ini file in C:\Windows...I place 
>> the file there, edit it, restart the server but I don't see the changes 
>> I've made.
>>
>> I've been dealing with this for a day and can't seem to find any 
>> information as to what's causing this problem.
>>
>> I've tried adding C:\PHP to my system path where C:\PHP is where php 
>> lives. I also have PHPRC pointing ot C:\PHP...not sure if either of 
>> those would have anything to do with my problem.
>>
>>
>> Does anyone have any ideas?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Fw: COM surgery

2007-01-16 Thread tg-php
There's thousands of things you can access via COM.  Windows uses it 
extensively.  Every application in Microsoft Office uses COM.  I've used COM 
between Excel and MapPoint to generate maps (and yeah, I created a PHP script 
to access MapPoint directly.. but it was just easier to do it via Excel).

Check out some of the examples in the PHP documentation:

http://www.php.net/manual/en/ref.com.php


Also, if you want to mess around with COM, try loading up MS Word or Excel (I 
like Excel myself since you can use the cells to output your data and keep it 
somewhat straight for debugging and general display).

Also, MS Office apps have a fairly nice debugger that is aware of the COM 
references you've set up so it will autocomplete methods and properties as you 
type (even give you lists).  I found it easier to sketch out what I needed in 
there first, then work on translating it to PHP.

Another tip...  you won't just be dealing with methods (actions, 'verbs') and 
properties (adjectives) but also objects will be returned (of various types) 
and collections (of objects).

Here's an example from mappoint:

# Connect to MapPoint and define some objects
$comobjMapPoint = new COM("mappoint.application") or die("Unable to instantiate 
mappoint");
$comobjMapPoint -> Activate();
$comobjMapPoint -> Visible = FALSE;
$mapobjActiveMap = $comobjMapPoint -> ActiveMap();
$routeobjActiveRoute = $mapobjActiveMap -> ActiveRoute();


Also.. you might find it helpful to search for the application you're trying to 
connect to and the key words "object model", at least in the Microsoft world.  
Despite MS being kinda dumb sometimes, the Excel and MapPoint object models 
online are actually really well documented.

http://msdn2.microsoft.com/en-us/library/wss56bz7(vs.80).aspx

http://msdn2.microsoft.com/en-us/library/aa723478.aspx

Hopefully that'll give you a good headstart.   But if your quest was "what 
applications can I connect to via COM", the answer is going to be too long to 
list.. You should figure out what you WANT to connect to and see if it supports 
COM.  Lots of stuff does.

Good luck!

-TG

= = = Original message = = =

- Original Message -
From: "gunawan" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, January 16, 2007 11:57 AM
Subject: COM surgery


> i read the com and interested using in my program..
> but the help (php manual chm) don't give what i need
> example :
> $word = new COM("word.application") or die("Unable to instantiate Word");
> echo "Loaded Word, version $word->Version\n";
>
> metods:
> $obj = new COM("Application.ID");
> what i want to build nextt is not a main problem right now, what i want to
> ask was about how many Aplication.id able to receive by this com
> i have only:
> 1. word.application
> 2. ADODB.Connection
> 3. excel.application
> are there any application.id ??
>
>


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Fw: COM surgery

2007-01-17 Thread tg-php
Ok, I see two main questions/problems..

1. An example of COM with Excel

2. How do you use COM with Word to set font size 20 and centered text?


Keep in mind that there may be better ways to solve the problems you have, but 
for the time being we'll use this as an excuse to play with COM.

#1 - There are at least 6 examples of using COM with Excel on php.net, so check 
there first.

Address: http://us2.php.net/manual/en/ref.com.php
Authors:
a dot kulikov at pool4tool dot com 13-Mar-2006 09:36
bruce at yourweb dot com dot au 23-Apr-2005 05:47
Jack dot CHLiang at gmail dot com 10-Apr-2005 10:02
markshane1 at fuse dot net 10-May-2004 04:41
dwt at myrealbox dot com 27-Aug-2002 03:31
madon at cma-it dot com 07-Mar-2002 12:59

#2. Again, check the page above and look for these authors:
pelegk2 at walla DOT co DOT il 13-Feb-2005 08:49
Shawn Coppock 11-Aug-2004 01:15
angelo [at] mandato  com 03-Jun-2004 11:37
#no author name# 03-Oct-2003 12:55
php at dictim dot com 06-Sep-2003 01:17
admin at purplerain dot org 19-Apr-2002 04:34

Since you had a specific question about Word, let's see if we can give a quick 
example.

Starting with Shawn Coppock's example, because he already has the font size 
done, we just need to figure out how to do centering.

The easiest way to do this is to figure out how to do it in Word VBA (Visual 
Basic for Applications) then figure out the equivalent PHP.  The built in VBA 
editor for MS Office apps is actually really good for learning on.  Hit ALT-F11 
to pull up the VBA editor, then right click on the tree on the left and do 
"INSERT MODULE".

Here's what I got in VBA:

Sub main()
  Selection.Font.Size = 20
  Selection.TypeText ("test")
  Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
End Sub

Took a minute to find the proper way to do 'center', but apparently it's a 
paragraph property.

Now using the PHP example...

Version}\n";
// TG: Changed this to 1 so you can see what's going on
$word->Visible = 1;
$word->Documents->Add();
$word->Selection->Font->Size = 20;
$word->Selection->TypeText("$content");
$word->Selection->ParagraphFormat->Alignment = wdAlignParagraphCenter;

$word->quit();
echo "done";
?>

Notice that I defined "wdAlignParagraphCenter".  Because in the VBA example, we 
just did "= wdAlignParagraphCenter".  This is a constant pre-defined inside 
Word.  Easiest way to figure out what the actual value is, is to do:

Selection.TypeText (wdAlignParagraphCenter)

This outputs "1".. therefore, defining PHP constant of the same name to be "1".

Sorry, don't have time to test this, but it should be close to correct.

One note about COM stuff in general.  After you run your script a few things, 
check your process list and make sure the application isn't still running in 
the background.  I forget exactly what it was, but if you don't close your COM 
application properly, it'll stay running and take up valuable system memory.

$word->close();  // Only closes the document and not the app?
$word->quit();   // Quits and closes application?

The only other tip I can give you is that in Excel, there are two ways of 
referring to cells.  One like "A1" (column A, row 1) and one is "1,1" (column 
1, row 1).  I never found a way to use "A1" type notation via PHP.  You may be 
able to, but by default you're probably going to have to use "1,1" type 
notation.

This should be more than enough to get you going.  Check out the other 
examples, learn how to write VBA code inside Word and Excel then translate it 
to PHP.  Check out the lists of objects, properties, methods and collections on 
Microsoft.com listed under Word Object Model and Excel Object Model.

It will take a lot of trial and error before you get things right, probably.  
But most of it's not too difficult if you get the basics down.

-TG

= = = Original message = = =

- Original Message -
From: <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, January 17, 2007 12:04 AM
Subject: Re: [PHP-WIN] Fw: COM surgery


> There's thousands of things you can access via COM.  Windows uses it
extensively.  Every application in Microsoft Office uses COM.  I've used COM
between Excel and MapPoint to generate maps (and yeah, I created a PHP
script to access MapPoint directly.. but it was just easier to do it via
Excel).
>
> Check out some of the examples in the PHP documentation:
>
> http://www.php.net/manual/en/ref.com.php
>
>
> Also, if you want to mess around with COM, try loading up MS Word or Excel
(I like Excel myself since you can use the cells to output your data and
keep it somewhat straight for debugging and general display).
>
> Also, MS Office apps have a fairly nice debugger that is aware of the COM
references you've set up so it will autocomplete methods and properties as
you type (even give you lists).  I found it easier to sketch out what I
needed in there first, then work on translating it to PHP.
>
> Another tip...  you won't just be dealing with methods (actions, 'verbs')
and properties (adjectives) but also o

Re: [PHP-WIN] PHP generated Excel Spreadsheets

2007-05-22 Thread tg-php
I don't see why you'd have compatibility issues with Excel 2007.  In theory, 
Excel_Writer (which we've used where I work but it's been a while since I've 
messed with it) creates either 97 or 2000 style Excel spreadsheets, which 
should be importable into Excel 2007 with no problem.

I've used the other methods mentioned too and all work well if you have people 
downloading the excel file or viewing in excel via web page.  If you need to 
create an XLS file without downloading via a browser, then you're better off 
trying to get Excel Writer to work, even though it's capabilities are kind of 
limited.

Some people may mention COM, but that's kind of an ugly solution.  You'd need 
Excel installed on the machine you had PHP running on and you gotta be really 
sure you close Excel properly when you're done using it.  If I recall, there's 
a "close" function that only closes the worksheet.  You need to do like 
Application.Exit or maybe it was Quit or something to get it to actally close 
the Excel application.  Otherwise, you'll get a copy of Excel running for each 
time the script is run (server crash anyone?)

Outputting to CSV or HTML with an Excel header, as demonstrated already, are 
good quick and dirty solutions.   Or you can create a page that's an HTML table 
and use Excel's "Import -> Web Query" function to pull the table when you open 
the pre-made Excel spreadsheet and auto-refresh the data from the Web Query.

Good luck however you decide to do it.

-TG

= = = Original message = = =

Using PEAR :: Spreadsheet_Excel_Writer

I am having compatibility issues with Excel 2007.

Has anyone else experienced issues and got solutions?


Dale Attree

PHP Developer

Jacklin Enterprises

tel: +27 11 265 4282

mobile: +27 83 407 2911
fax: +27 11 314 2984

 

 



***
The information contained in this e-mail is confidential and may be subject to 
legal privilege. 
Access to this e-mail by anyone other than the intended recipient is 
unauthorised.

If you are not the intended recipient you must not use, copy, distribute or 
disclose the e-mail or any part of its contents or take any action in reliance 
on it. If you have received this e-mail in error, please notify us immediately 
by e-mail ([EMAIL PROTECTED]) or telephone (+27 11 265 4200).
This message is free of all known viruses. It has been screened for viruses by 
Blockmail.
***


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Query Syntax - WHERE fieldname1='fieldvalue1'ANDfieldname2='fieldvalue2'

2007-05-22 Thread tg-php
Couple of things..  I'm not sure (and too lazy to look it up) if something like 
"category" is a reserved word, but you can try enclosing your field/table names 
in backticks (? whatever they're called.. the single quote looking character on 
the tilde)

SELECT * FROM `classifieds` WHERE `trans_type` = 'For Sale' AND `category` 
='Boats'

or...

$query = "SELECT `$field_name` FROM `classifieds` WHERE `$field_name1` =
'$field_value1' AND `$field_name2` ='$field_value2'";

Making sure your variables always have values.  As mentioned, echoing out your 
$query to see what it translates to can be very useful.

Last thing is to make sure your variables don't contain characters that, 
unescaped, can screw up your query.  Stuff like apostrophes and such.

Best way to do this, and ensure some level of security, is to use 
mysql_real_escape_string().

I don't usually use variables for my field and table names, but I'm guessing 
you can use this function (and that it's recommended to do so anytime you use a 
variable in your SQL) for those as well as values.

$field_name = mysql_real_escape_string($field_name);
$field_name1 = mysql_real_escape_string($field_name1);
$field_value1 = mysql_real_escape_string($field_value1);
$field_name2 = mysql_real_escape_string($field_name2);
$field_value2 = mysql_real_escape_string($field_value2);

$query = "SELECT `$field_name` FROM `classifieds` WHERE `$field_name1` =
'$field_value1' AND `$field_name2` ='$field_value2'";

Or do it inline or write a function wrapper to make it easier to read or 
however you want to do it.


Operation precedence shouldn't be an issue.  I usually run into that when 
dealing with an "OR" situation as well as "AND"s.  Since you have a really 
basic AND-only situation, you shouldn't have to worry about parens.


Maybe that'll help a little.  If not, write back with some of your echo'd SQL 
$query stuff.

-TG





= = = Original message = = =

This did not work. But thank you for trying.

Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your 
SQL syntax; check the manual that corresponds to your MySQL server version 
for the right syntax to use near 'FROM classifieds WHERE (trans_type = 'For 
Sale') AND (trans_type ='For Sale')' at line 1 in 
C:\apache2triad\htdocs\sunlakes\test3.php on line 82




""Luis Moreira (ESI-GSQP)"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
I think you have an "operator\precedence" issue.

Try

$query = "SELECT $field_name FROM classifieds
WHERE
($field_name1 = '$field_value1')
AND
($field_name2 ='$field_value2')
";

This will stop you from eventually ANDing the wrong pair...


-Original Message-
From: Mark Abrams [mailto:[EMAIL PROTECTED]
Sent: ter~a-feira, 22 de Maio de 2007 16:07
To: php-windows@lists.php.net
Subject: [PHP-WIN] Query Syntax - WHERE fieldname1='fieldvalue1'
ANDfieldname2='fieldvalue2'

Query Syntax -



I have a syntax error when I am using an AND in the WHERE clause for a
double field=value restriction



#1 RUNS OK

$query = "SELECT $field_name FROM classifieds WHERE $field_name =
'$field_value'";



$result = mysql_query($query) or die(mysql_error());



#2 FAILS

$query = "SELECT $field_name FROM classifieds WHERE $field_name1 =
'$field_value1' AND $field_name2 ='$field_value2'";



$result = mysql_query($query) or die(mysql_error());



dies with the following message:



Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your

SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'FROM classifieds WHERE trans_type = 'For
Sale' AND category ='Boats'' at line 1 in C:\apache2triad\htdocs\



Background: I call a function and pass a $field_name = $field_value pair.
This works OK.  When I add a second field_name = $field_value pair the query

dies.



Data excerpt from TABLE classifieds:

trans_type = Free
category = Books





Also, Can anyone recommend a good book on mySQL / php?  I could not find a
good example of my problem in the online manual http://www.mysql.com/doc.



TIA

Mark

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

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: [PHP-WIN] Query Syntax - WHERE fieldname1='fieldvalue1'ANDfieldname2='fieldvalue2'

2007-05-22 Thread tg-php
`` shouldn't react the same as ''.

If it does though, maybe try using them but putting your variables outside the 
quotes:

$query = "SELECT `" . $field_name . "` FROM `classifieds` WHERE `" . 
$field_name1 ."` = '" . $field_value1 . "' AND `" . $field_name2 . "` ='" . 
$field_value2 . "'";


And check what the other poster said about the "SELECT FROM" with no value for 
$field_name.

This is going to be something really simple and basic.

-TG

= = = Original message = = =

Thanks - but it doesn't work   `` interprets the literal value $field_name
as the column name and not its contents "trans_type".

Warning: mysql_query() [http://www.mysql.com/doc]: Unknown column '' in
'field list' in C:\apache2triad\htdocs\sunlakes\test3.php on line 83
Unknown column '' in 'field list'



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 22, 2007 10:57 AM
To: php-windows@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Query Syntax - WHERE
fieldname1='fieldvalue1'ANDfieldname2='fieldvalue2'

Couple of things..  I'm not sure (and too lazy to look it up) if something
like "category" is a reserved word, but you can try enclosing your
field/table names in backticks (? whatever they're called.. the single quote
looking character on the tilde)

SELECT * FROM `classifieds` WHERE `trans_type` = 'For Sale' AND `category`
='Boats'

or...

$query = "SELECT `$field_name` FROM `classifieds` WHERE `$field_name1` =
'$field_value1' AND `$field_name2` ='$field_value2'";

Making sure your variables always have values.  As mentioned, echoing out
your $query to see what it translates to can be very useful.

Last thing is to make sure your variables don't contain characters that,
unescaped, can screw up your query.  Stuff like apostrophes and such.

Best way to do this, and ensure some level of security, is to use
mysql_real_escape_string().

I don't usually use variables for my field and table names, but I'm guessing
you can use this function (and that it's recommended to do so anytime you
use a variable in your SQL) for those as well as values.

$field_name = mysql_real_escape_string($field_name);
$field_name1 = mysql_real_escape_string($field_name1);
$field_value1 = mysql_real_escape_string($field_value1);
$field_name2 = mysql_real_escape_string($field_name2);
$field_value2 = mysql_real_escape_string($field_value2);

$query = "SELECT `$field_name` FROM `classifieds` WHERE `$field_name1` =
'$field_value1' AND `$field_name2` ='$field_value2'";

Or do it inline or write a function wrapper to make it easier to read or
however you want to do it.


Operation precedence shouldn't be an issue.  I usually run into that when
dealing with an "OR" situation as well as "AND"s.  Since you have a really
basic AND-only situation, you shouldn't have to worry about parens.


Maybe that'll help a little.  If not, write back with some of your echo'd
SQL $query stuff.

-TG



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] photo gallery plugin

2007-07-26 Thread tg-php
Gallery2 and Coppermine are two big PHP photo gallery apps.

http://gallery.menalto.com/

http://coppermine-gallery.net/index.php

= = = Original message = = =

Does anyone have a recommendation on a photo gallery plug in that works with 
php and mySQL.  I have a car club and want to allow members to load their 
cars pics and specs to the site.

TAI
Mark 

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] ORDER BY is not sorting

2007-07-31 Thread tg-php
I can't really see anything wrong with what you have there.  It shouldn't 
matter that your SQL is inside the query function, although I like to build the 
query in a variable outside the query function, but either way it should work.

And you're obviously getting data and not an error, right?

What happens if you leave the "DESC" off?  Does it come back 4, 3, 2, 1?  or 
still 1, 2, 3, 4?

You might try displaying more data from the result set to see if there's some 
other issue.  

And have you tested the SQL statement just using MySQL via command line, 
phpMyAdmin, WinSQL, Navicat, or something like that?

-TG

= = = Original message = = =

Sorry, this seams very trivial but I can not sort the result set for any 
field.  What am I doing wrong?


php & mySQL 5


'


?>

1
2
3
4


TIA
Mark

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] ORDER BY is not sorting

2007-07-31 Thread tg-php
Spaces would affect sorting if the spaces appeared in the actual rowID data.  
If rowID is stored as text of some kind, then yeah, maybe he'd have an issue.  
But I have a feeling you're talking about the code itself and whether to put 
the quer into a variable or not (rebuting what I said).

Here's his code:

> $table_name ='users';
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");

Code looks fine.   $table_name gets substituted for it's value, 'users'.  There 
are no extra spaces in the variable data.  Even if there was, that's fine.  If 
it were something like this, he'd have a problem:

> $result = mysql_query("SELECT * FROM ` $table_name` ORDER BY rowID DESC");

Then it would look for a table named users.  Which probably doesn't 
exist.

Also.. that doesn't relate to the sorting issue since sorting is on 'rowID' 
within that table, which isn't defined in a variable, but stated explicitly in 
the query.

So not sure what you're saying about spaces messing things up.

-TG


= = = Original message = = =

Well, if you have blank spaces on the field's beginning it won't sort
correctly, it will put the blank spaces on the last results on that case.

On 7/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> I can't really see anything wrong with what you have there.  It shouldn't
> matter that your SQL is inside the query function, although I like to build
> the query in a variable outside the query function, but either way it should
> work.
>
> And you're obviously getting data and not an error, right?
>
> What happens if you leave the "DESC" off?  Does it come back 4, 3, 2,
> 1?  or still 1, 2, 3, 4?
>
> You might try displaying more data from the result set to see if there's
> some other issue.
>
> And have you tested the SQL statement just using MySQL via command line,
> phpMyAdmin, WinSQL, Navicat, or something like that?
>
> -TG
>
> = = = Original message = = =
>
> Sorry, this seams very trivial but I can not sort the result set for any
> field.  What am I doing wrong?
>
>
> php & mySQL 5
>
>
> 
> ...
>
>$table_name ='users';
>
> // Select records
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID
> DESC");
>
>
> // Loop through the record set
> while($row = mysql_fetch_array($result))
>  print 'rowID ='  .$row['rowID']. ''
>
>
> ?>
>
> 1
> 2
> 3
> 4
>
>
> TIA
> Mark
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Bruno Policarpo
[EMAIL PROTECTED]
MSN [EMAIL PROTECTED]


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-WIN] Array Question

2007-08-17 Thread tg-php
I assume you're getting fields with the same name from pulling data from two or 
more tables.  Something like "SELECT * FROM TABLE1, TABLE2 WHERE TABLE1.id = 
TABLE2.id" or something like that.

At any rate, if you can.. it's always good to name the fields you want to pull 
instead of using "SELECT *".  I know it's a pain sometimes, but in this case it 
may be somewhat necessary.

What you can do is use an alias for the duplicate field name.  Something like 
this:

"SELECT TABLE1.id as id1, TABLE2.id as id2 FROM"

Then in your array, it'll be $mydata['id1'] and $mydata['id2']

Works the same with a single table pull and I usually alias the table names too:

SELECT t1.id id1, t2.id id2 FROM TABLE1 t1, TABLE2 t2 WHERE t1.id = t2.id

(can't remember if you can use the alias in the WHERE to make it "id1 = id2" or 
not)

The "as" is usually optional, but sometimes nice to keep things clear.  In some 
flavors of SQL it's required.

-TG

= = = Original message = = =

I have pull a bunch of data from an SQL database through a query.  The problem 
I am running into is I pull two fields with the exact same name.  How do I grab 
the right info?  I have been using mydata ~ the array name.  
mydata['contactID']  Should I instead use the array value so mydata[8]?




___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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