OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 12 Apr 2008 10:38:32 -0000 Issue 5400

php-general-digest-helplists.php.net
Date: Sat Apr 12 2008 - 05:38:32 CDT


php-general Digest 12 Apr 2008 10:38:32 -0000 Issue 5400

Topics (messages 272896 through 272926):

Re: Quarters -- ERRORS --
        272896 by: Kirk.Johnson.zootweb.com
        272919 by: Nathan Nobbe

Return an Array and immediately reference an index
        272897 by: Daniel Kolbo
        272898 by: Philip Thompson
        272900 by: Daniel Kolbo
        272906 by: Philip Thompson
        272911 by: Bojan Tesanovic
        272922 by: Jim Lucas
        272924 by: Stut

Re: php local application send mouse click
        272899 by: Daniel Kolbo
        272923 by: Stut

Re: Quarters
        272901 by: Daniel Kolbo
        272908 by: Bill Guion
        272909 by: Robert Cummings
        272913 by: Casey

File Upload Security
        272902 by: Al
        272903 by: mike
        272905 by: Al
        272915 by: Bojan Tesanovic
        272920 by: Wolf

install pecl in debian
        272904 by: hce
        272907 by: Shawn McKenzie
        272910 by: Bojan Tesanovic
        272926 by: hce

Re: File Format
        272912 by: Bojan Tesanovic

How to determine which column "matched"
        272914 by: Rob Gould
        272916 by: Bojan Tesanovic
        272917 by: Robert Cummings
        272918 by: Robert Cummings
        272925 by: Stut

Include problems
        272921 by: GoWtHaM NaRiSiPaLli

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


tedd <tedd.sperlinggmail.com> wrote on 04/11/2008 02:49:21 PM:

> But the critter is dead in the water for all versions of IE -- if --
> I don't figure out a way around the following single statement.
>
> document.getElementById(id).checked = true;
>
> After reading a bunch, it seems that M$ has a better way to do things
> (big surprise there, huh?) and thus does not use the
> document.getElementById(id) thing that everyone else in the world
> uses. Instead, they use something "better" and it's not documented
> well as is typical.
>
> So, what I need is:
>
> if (document.getElementById)
> {
> document.getElementById(id).checked = true;
> }
> else
> {
> <<<<< inset solution here. >>>>>>
> }

The Javascript code below, using either Method 1 or Method 2, works fine
in IE 7. Have you tried running it in Firefox with the error console open?
I am wondering if there isn't a minor syntax error somewhere.

Kirk

<html><head><title></title>

<script type="text/javascript">
function checkme() {

// Method 1 - works fine in IE 7
// if(document.forms[0].test.checked) {
// document.forms[0].test.checked = false;
// }
// else {
// document.forms[0].test.checked = true; // }
// }

// Method 2 - works fine in IE 7
        if(document.getElementById('test').checked) {
          document.getElementById('test').checked = false;
        } else {
          document.getElementById('test').checked = true;
        }
}
</script>
</head>
<body>

<form action="" method="post">
<input type="checkbox" name="test" id="test" onmouseover="checkme();">
Mouse Me
</form>

</body></head></html>

attached mail follows:


On Fri, Apr 11, 2008 at 4:49 PM, tedd <tedd.sperlinggmail.com> wrote:

> Hi gang:
>
> Sorry for the lame app, but the program worked for Safari (Mac and Win).
> However, I did get it to work for FF and a couple of other browsers (Mac and
> Win), see again:
>
> http://webbytedd.com/quarters
>
> But the critter is dead in the water for all versions of IE -- if -- I
> don't figure out a way around the following single statement.
>
> document.getElementById(id).checked = true;
>
> Granted it's javascript, but all that line does is to set a checkbox
> variable (id) to 'on'. Surely, $M code can do that, right?
>
> After reading a bunch, it seems that M$ has a better way to do things (big
> surprise there, huh?) and thus does not use the document.getElementById(id)
> thing that everyone else in the world uses. Instead, they use something
> "better" and it's not documented well as is typical.
>
> Unfortunately, I have not been able to find a M$ work-a-round.
>
> So, what I need is:
>
> if (document.getElementById)
> {
> document.getElementById(id).checked = true;
> }
> else
> {
> <<<<< inset solution here. >>>>>>
> }
>
> All the code has to do is to set a simple checkbox to 'on' in IE.

hmm. looking at the prototype.js lib, which has the $() function to replace
document.getElementById(). it supports either a dom object or a string that
represents an id attribute, but key note is its 'cross-browser' and i dont
see a workaround in there for ms..

function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length;
i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (Object.isString(element))
    element = document.getElementById(element);
  return Element.extend(element);
}

ie has some primitive debugging tools, have you checked one of those to see
if theres an error on the page? if you choke the js interpreter w/ a fatal
error you might kill all subsequent js interpretation on the page :O ie has
been the bane of my existence on more than one occasion.

-nathan

attached mail follows:


Hello,

I want to return an array from function and reference an index all in
one line. Is this possible?

In the code below I want I want $yo to be the array(5,6).

Here is what I've tried,

function returnarray() {
        return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = returnarray()['lose'];
var_dump($yo);

This yields a parse error.

function returnarray() {
        return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = {returnarray()}['lose'];
var_dump($yo);

This yields a parse error.

function returnarray() {
        return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = ${returnarray()}['lose'];
var_dump($yo);

This gives notices as the result of returnarray() is being converted to
a string. $yo === NULL...not what i want.

function returnarray() {
        return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = returnarray()->['lose'];
var_dump($yo);

This yields a parse error.

function returnarray() {
        return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = ${returnarray()}->['lose'];
var_dump($yo);

This yields a parse error.

Thanks for your help in advance.

attached mail follows:


Top-posting side comment: It's not nice to hijack threads.

My comments are below...

On Apr 11, 2008, at 5:33 PM, Daniel Kolbo wrote:
> Hello,
>
> I want to return an array from function and reference an index all
> in one line. Is this possible?
>
> In the code below I want I want $yo to be the array(5,6).
>
> Here is what I've tried,
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = returnarray()['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = {returnarray()}['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = ${returnarray()}['lose'];
> var_dump($yo);
>
> This gives notices as the result of returnarray() is being converted
> to a string. $yo === NULL...not what i want.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = returnarray()->['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = ${returnarray()}->['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> Thanks for your help in advance.

Perhaps these pages may assist you:

http://php.net/manual/en/function.array.php
http://php.net/functions

For more immediate help, I think you want to do something along these
lines:

<?php
function returnArray ($index) {
     $arr = array('lose'=>array(5,6), 'win'=>array(9,8));
     return isset ($arr[$index]) ? $arr[$index] : 'Index not found';
}

$returnTheValueForThis = 'lose';
$result = returnArray ($returnTheValueForThis);
var_dump ($result);
?>

This var_dump will return:

array(2) { [0]=> int(5) [1]=> int(6) }

Hope that helps. Do some more reading in the manual to help yourself
out. ;)

~Philip

attached mail follows:


Philip Thompson wrote:
> Top-posting side comment: It's not nice to hijack threads.
>
> My comments are below...
>
> On Apr 11, 2008, at 5:33 PM, Daniel Kolbo wrote:
>> Hello,
>>
>> I want to return an array from function and reference an index all in
>> one line. Is this possible?
>>
>> In the code below I want I want $yo to be the array(5,6).
>>
>> Here is what I've tried,
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = returnarray()['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = {returnarray()}['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = ${returnarray()}['lose'];
>> var_dump($yo);
>>
>> This gives notices as the result of returnarray() is being converted
>> to a string. $yo === NULL...not what i want.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = returnarray()->['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = ${returnarray()}->['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> Thanks for your help in advance.
>
>
> Perhaps these pages may assist you:
>
> http://php.net/manual/en/function.array.php
> http://php.net/functions
>
> For more immediate help, I think you want to do something along these
> lines:
>
> <?php
> function returnArray ($index) {
> $arr = array('lose'=>array(5,6), 'win'=>array(9,8));
> return isset ($arr[$index]) ? $arr[$index] : 'Index not found';
> }
>
> $returnTheValueForThis = 'lose';
> $result = returnArray ($returnTheValueForThis);
> var_dump ($result);
> ?>
>
> This var_dump will return:
>
> array(2) { [0]=> int(5) [1]=> int(6) }
>
> Hope that helps. Do some more reading in the manual to help yourself
> out. ;)
>
> ~Philip
>

Just to be sure, where you saying I hijacked a thread? If so, please
educate me as to how i did this. Now to the response.

Thanks for the response.

I am familiar with the construction and returning of the arrays and
referencing an index of the array. I understand your code. However,
this is not what I am trying to do.

I could simply do:

function returnarray() {
      return array('lose' => array(5,6), 'win' => array(9,8));
}

$yo = returnarray();
var_dump($yo['lose']);

To get my desired result.

I was just seeing if PHP had the capability to combine those last two
lines into one. I realize the function itself is rather trivial, but
just wanted some function to return an array for the sake of demonstration.

Thanks,

attached mail follows:


On Apr 11, 2008, at 6:31 PM, Daniel Kolbo wrote:
>
> Philip Thompson wrote:
>> Top-posting side comment: It's not nice to hijack threads.
>> My comments are below...
>> On Apr 11, 2008, at 5:33 PM, Daniel Kolbo wrote:
>>> Hello,
>>>
>>> I want to return an array from function and reference an index all
>>> in one line. Is this possible?
>>>
>>> In the code below I want I want $yo to be the array(5,6).
>>>
>>> Here is what I've tried,
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = returnarray()['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = {returnarray()}['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = ${returnarray()}['lose'];
>>> var_dump($yo);
>>>
>>> This gives notices as the result of returnarray() is being
>>> converted to a string. $yo === NULL...not what i want.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = returnarray()->['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = ${returnarray()}->['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> Thanks for your help in advance.
>> Perhaps these pages may assist you:
>> http://php.net/manual/en/function.array.php
>> http://php.net/functions
>> For more immediate help, I think you want to do something along
>> these lines:
>> <?php
>> function returnArray ($index) {
>> $arr = array('lose'=>array(5,6), 'win'=>array(9,8));
>> return isset ($arr[$index]) ? $arr[$index] : 'Index not found';
>> }
>> $returnTheValueForThis = 'lose';
>> $result = returnArray ($returnTheValueForThis);
>> var_dump ($result);
>> ?>
>> This var_dump will return:
>> array(2) { [0]=> int(5) [1]=> int(6) }
>> Hope that helps. Do some more reading in the manual to help
>> yourself out. ;)
>> ~Philip
>
> Just to be sure, where you saying I hijacked a thread? If so,
> please educate me as to how i did this. Now to the response.

If you are viewing a message (in this case, the thread entitled
"Quarters -- ERRORS --") and you hit Reply and change the message to
whatever (in this case, "Return an Array and immediately reference an
index"), it still shows up in the same "thread" as the Quarters one.
This implies that your email has to do with the Quarters one... but it
really doesn't. =D

So, in order to fix this, just hit "New" instead of Reply. =D No harm
done, just good listserv netiquette for people reading their emails
that shove the *same content* emails together. We're all here to
learn, right.

> Thanks for the response.
>
> I am familiar with the construction and returning of the arrays and
> referencing an index of the array. I understand your code.
> However, this is not what I am trying to do.
>
> I could simply do:
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = returnarray();
> var_dump($yo['lose']);
>
> To get my desired result.
>
> I was just seeing if PHP had the capability to combine those last
> two lines into one. I realize the function itself is rather
> trivial, but just wanted some function to return an array for the
> sake of demonstration.
>
> Thanks,

Oooooooh. I see what you're saying now. Sorry for the confusion. To my
knowledge (which is limited ;), I don't think you can do that. This is
somewhat similar to some desired functionality in PHP - I don't
remember the name of it. For example,

<?php
class f1() {
   function f2() {
     echo "Hello";
   }

   function f3() {
     echo "World!";
   }
}

new f1()->f2() . new f1()->f3();
?>

Something like that. Basically, call a class/function and get the
contents directly without instantiating it first. Maybe others have an
opinion on this....

~Philip

attached mail follows:


On Apr 12, 2008, at 12:33 AM, Daniel Kolbo wrote:

> Hello,
>
> I want to return an array from function and reference an index all
> in one line. Is this possible?
>
> In the code below I want I want $yo to be the array(5,6).
>
> Here is what I've tried,
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = returnarray()['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = {returnarray()}['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = ${returnarray()}['lose'];
> var_dump($yo);
>
> This gives notices as the result of returnarray() is being
> converted to a string. $yo === NULL...not what i want.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = returnarray()->['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> function returnarray() {
> return array('lose' => array(5,6), 'win' => array(9,8));
> }
>
> $yo = ${returnarray()}->['lose'];
> var_dump($yo);
>
> This yields a parse error.
>
> Thanks for your help in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

This is not possible in PHP, though you can have a Array wrapper class

function returnarray() {
        return new ArrayObject( array('lose' => array(5,6), 'win' => array
(9,8)) );
}
var_dump (returnarray()->offsetGet('lose'));

or even better make you own wrapper class with __set() and __get()
methods so you can have

var_dump (returnarray()->lose);

of course only in PHP5

Bojan Tesanovic
http://www.carster.us/

attached mail follows:


Bojan Tesanovic wrote:
>
> On Apr 12, 2008, at 12:33 AM, Daniel Kolbo wrote:
>
>> Hello,
>>
>> I want to return an array from function and reference an index all in
>> one line. Is this possible?
>>
>> In the code below I want I want $yo to be the array(5,6).
>>
>> Here is what I've tried,
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = returnarray()['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = {returnarray()}['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = ${returnarray()}['lose'];
>> var_dump($yo);
>>
>> This gives notices as the result of returnarray() is being converted
>> to a string. $yo === NULL...not what i want.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = returnarray()->['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> function returnarray() {
>> return array('lose' => array(5,6), 'win' => array(9,8));
>> }
>>
>> $yo = ${returnarray()}->['lose'];
>> var_dump($yo);
>>
>> This yields a parse error.
>>
>> Thanks for your help in advance.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> This is not possible in PHP, though you can have a Array wrapper class
>
> function returnarray() {
> return new ArrayObject( array('lose' => array(5,6), 'win' =>
> array(9,8)) );
> }
> var_dump (returnarray()->offsetGet('lose'));
>
>
> or even better make you own wrapper class with __set() and __get()
> methods so you can have
>
> var_dump (returnarray()->lose);
>
> of course only in PHP5

Well, not quite so fast saying this is only possible in PHP5

You could do something like this.

<?php

function returnHash() {
   return (object) array('lose' => array(5,6), 'win' => array(9,8));
}

print_r(returnHash()->lose);

?>

Basically, this converts your newly built array into an object, using
the stdClass object.

Then reference the index via an object variable name instead of an array
style access method.

>
>
> Bojan Tesanovic
> http://www.carster.us/
>
>
>
>
>

attached mail follows:


On 12 Apr 2008, at 00:31, Daniel Kolbo wrote:
> Philip Thompson wrote:
>> On Apr 11, 2008, at 5:33 PM, Daniel Kolbo wrote:
>>> I want to return an array from function and reference an index all
>>> in one line. Is this possible?
>>>
>>> In the code below I want I want $yo to be the array(5,6).
>>>
>>> Here is what I've tried,
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = returnarray()['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = {returnarray()}['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = ${returnarray()}['lose'];
>>> var_dump($yo);
>>>
>>> This gives notices as the result of returnarray() is being
>>> converted to a string. $yo === NULL...not what i want.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = returnarray()->['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.
>>>
>>> function returnarray() {
>>> return array('lose' => array(5,6), 'win' => array(9,8));
>>> }
>>>
>>> $yo = ${returnarray()}->['lose'];
>>> var_dump($yo);
>>>
>>> This yields a parse error.

The PHP parser does not support this, but you may see it in a future
version - it's a commonly requested feature.

There are various ways to code around this limitation as other posters
have stated but to me they all add far too much processing to make it
worth saving a line of code and a temporary variable.

-Stut

--
http://stut.net/

attached mail follows:


Wolf wrote:
>
>
> Daniel Kolbo wrote:
>> Hello,
>>
>> I am mostly familiar with php for serving up web pages; however,
>> recently I have been writing a local command line script on my WinXP
>> machine. I have spent the better part of this last week and all of
>> today trying to figure out a way to send a mouse click to a particular
>> window on the screen.
>>
>> I first saw w32api.dll on the php.net site. However, I cannot find
>> this dll, but this searching took me to winbinder and php-gtk2. It
>> seems that I can only get winbinder to get (not send) mouse
>> information: event type and x,y positions. I am not too familiar with
>> php-gtk nor creating dlls.
>>
>> I want to use my local php command line script on my winXP machine to
>> send mouse events (click) to a window. I am open to any ideas on how
>> to do this.
>>
>> For C++ and VB there seems to be the SendMessage() function. Is there
>> a way to tap into that function from my php script?
>>
>> winbinder has a function that wraps the SendMessage() function called
>> wb_send_message, but after literally 9 hours i quit.
>>
>> on the MSDN.microsoft site, I saw the functions mouse_event() and
>> SendInput() of the "user32.dll"
>>
>> http://msdn2.microsoft.com/en-us/library/ms646310.aspx
>> http://msdn2.microsoft.com/en-us/library/aa932376.aspx
>>
>> I copied the "user32.dll" to my php/ext folder and tried loading the
>> "user32.dll" both as an extension directive in php.ini and by using
>> the dl() function in my script (dl() is enabled). However, both
>> methods gave me a PHP warning:
>>
>> as an extension in php.ini it gives the following error:
>>
>> PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)
>> 'user32.dll
>> ' in Unknown on line 0
>>
>> get_loaded_extensions() confirms user32.dll never gets loaded.
>>
>> invoking dl("user32.dll") yields the warning:
>>
>> PHP Warning: dl(): Invalid library (maybe not a PHP library)
>> 'user32.dll' in [my script]
>>
>> Possible ideas:
>> -Load a dll with the dl() function? (Write the dll with VB or C++)
>> -use the w32api_register_function() in php somehow to 'tap' into
>> windows api functions.
>> -use a project that can assist me in this like php-gtk2 or winbinder
>> -maybe someone has a copy of w32api.dll
>> -something about COM objects, though i am really not familiar
>>
>> It seems as though the C languages and VB languages can do this.
>> Perhaps I could write and compile a dll in that language, somehow load
>> it up in php (even though i am having errors doing that currently),
>> then I can use those functions in my dll to send my mouse clicks
>> through php.
>>
>>
>> I am throwing out this question to the community and wondering what
>> your suggestions would be for how to go about sending a mouse click
>> event to my windows api from a php script.
>>
>> I am not interested in writing javascript as this is not a web
>> application.
>>
>> Any thoughts, comments, suggestions, about how to do send mouse events
>> from a php script will be much appreciated.
>>
>> Thanks in advance,
>
>
> Trying to send one TO a screen? Good luck with that. But you really
> should wait at least for a few days for a response from the list before
> reposting the same question with no further information...
>
> What code have you tried? What code works to a point but fails?
>
> Wolf
>
>

Thanks for your response Wolf.

Sorry for the double email, i had just signed up, and I thought the
original didn't go through, b/c i hadn't completed all the verification
steps.

What is TO? You referenced it in your reply.

In addition to the function i mentioned from winbinder wb_send_message()
I have tried:

I tried loading in the user32.dll extension from within the php.ini,
this failed.
I tried loading in the user32.dll from within the script, this failed.

dl("user32.dll")

I tried loading in the php_w32api.dll from within the script (i copied
the php_w32api.dll from php4 into my ext/ folder in php5.

dl("php_w32api.dll");

this worked; however, when I tried registering the functions from within
the script it failed on me.

w32api_register_function("User32.dll",
                          "mouse_event",
                          "void");

I really am at a lose of how to even begin. How would I execute a mouse
click from a php script on a console application?

Thanks,

attached mail follows:


On 12 Apr 2008, at 00:13, Daniel Kolbo wrote:
> In addition to the function i mentioned from winbinder
> wb_send_message() I have tried:
>
> I tried loading in the user32.dll extension from within the php.ini,
> this failed.
> I tried loading in the user32.dll from within the script, this failed.
>
> dl("user32.dll")

The dl function is for loading PHP extensions, not any old DLL. The
same goes for the extensions section of php.ini.

> I tried loading in the php_w32api.dll from within the script (i
> copied the php_w32api.dll from php4 into my ext/ folder in php5.
>
> dl("php_w32api.dll");
>
> this worked; however, when I tried registering the functions from
> within the script it failed on me.
>
> w32api_register_function("User32.dll",
> "mouse_event",
> "void");
>
> I really am at a lose of how to even begin. How would I execute a
> mouse click from a php script on a console application?

1) You should be using SendInput not mouse_event unless you're on
Windows 9x.

2) Why are you trying to do this in PHP? It would be much easier to
develop and test in C# or VB or even C++. At the very least I'd
recommend doing that to get the sequence of API calls worked out and
then port it over to PHP.

-Stut

--
http://stut.net/

attached mail follows:


It was fun! thanks

tedd wrote:
> Hi gang:
>
> Check out my new game:
>
> http://webbytedd.com/quarters/
>
> What do you think?
>
> Cheers,
>
> tedd
>
> PS: I originally wrote the game for the Mac over eight years ago.

attached mail follows:


Maybe you guys should get a Mac. Works just fine for me on a Mac, OS
X, Firefox.

      -----===== Bill =====-----

At 9:49 AM -0400 4/11/08, tedd wrote:

>Hi gang:
>
>Check out my new game:
>
>http://webbytedd.com/quarters/
>
>What do you think?
>
>Cheers,
>
>tedd
>
>PS: I originally wrote the game for the Mac over eight years ago.
>--
>-------
>http://sperling.com http://ancientstones.com http://earthstones.com

--

I plead contemporary insanity.
   

attached mail follows:


On Fri, 2008-04-11 at 21:22 -0400, Bill Guion wrote:
> Maybe you guys should get a Mac. Works just fine for me on a Mac, OS
> X, Firefox.

But then we'd have to use a Mac :/

Worked fine in Opera 9.5. Though I got the undefined variable error too.
That's just a clean code error though... a lot like a PHP undefined var
notice. Mostly my fault for browsing with error messages enabled >:)
It's amazing how sloppy many sites out there are... especial ad
companies.

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

attached mail follows:


On Fri, Apr 11, 2008 at 6:49 AM, tedd <teddsperling.com> wrote:
> Hi gang:
>
> Check out my new game:
>
> http://webbytedd.com/quarters/
>
> What do you think?
>
> Cheers,
>
> tedd
>
> PS: I originally wrote the game for the Mac over eight years ago.
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I won. Finally figured out the secret, without $5 >_>

--
-Casey

attached mail follows:


One of my sites has been hacked and I'm trying to find the hole. The hack code creates dirs with
"nobody" ownership, so it's obvious stuff is not via ftp [ownership would be foo]

Site is virtual host, Linux/Apache

I'm concerned about a file uploader my users use to upload photos.

Can anyone see a hole in this scrip? Can my code upload an executable masquerading as an image file?

$filetype = array("gif", "jpg", "jpeg", "png", "txt", css")

function csvt_file_upload($filetype, $max_size)
{
     $prohibits = array("exe", "php", "inc", "php3", "pl", "bat", "cgi"); //common executables.
     $absolute_max_size = 2000000;

     end($_FILES); //get the "name" used by the html <input.....
     $name = key($_FILES); //could use the register variables, but this is safer.
     if(isset($_FILES[$name]['name'])) $input_name = $_FILES[$name]['name'];

     $error = "no"; //reset for error checks

     if (!isset($filetype)) {
             echo "<p style=\"color:red\"> File type assignment missing </p> ";
             $error = "yes";
     };

     if (!isset($max_size)) {
             echo "<p style=\"color:red\"> Max file size assignment missing.</p>";
             $error = "yes";
     };

     $filename = $_FILES[$name]['name'];
     $tmp_name = $_FILES[$name]['tmp_name'];
     $size = $_FILES[$name]['size'];

     $absolute_path_file = getcwd(). DATA_DIR . $filename;

     if (($size >= $max_size) OR ($size > $absolute_max_size)) {
         echo "<p style=\"color:red\"> File size is too large.</p> ";
         $error = "yes";
     }

     $ext = substr(strrchr($filename, "."), 1); //get the extension, remove the "."
     if (in_array($ext, $prohibits)) {
         echo "<p style=\"color:red\">Illegal file type, executable.</p>\r\n";
         $error = "yes";
     }
     if (is_executable($filename)) {
         echo "<p style=\"color:red\">Illegal file type, executable file.</p>\r\n";
         $error = "yes";
     } //This is a double check in case $prohibits is incomplete.
     if (is_array($filetype) AND !in_array($ext, $filetype)) {
         echo "<p style=\"color:red\">Illegal file type.</p>\r\n";
         $error = "yes";
     }
        if(!is_array($filetype) AND ($filetype != $ext)){
         echo "<p style=\"color:red\">Illegal file type.</p>\r\n";
         $error = "yes";
     }
     if ($error == "yes") {
         echo "<p style=\"color:red\">There was an error(s) with your file selection \"$input_name\"
as the note(s) indicates. Please reselect, or remove your file selection and email for help. </p>\r\n";
     }
        else {
         if(!move_uploaded_file($tmp_name, $absolute_path_file))
                die("<p style=\"color:red\">There was an error saving your file. Check permissions of " . DATA_DIR
. " Must be 777 </p>\r\n");
                
        chmod($absolute_path_file, 0644);
     }

     return;
}

attached mail follows:


How was it "hacked"?

That will help determine what kind of exploit might have been used.

On 4/11/08, Al <newsridersite.org> wrote:
> One of my sites has been hacked and I'm trying to find the hole. The hack
> code creates dirs with "nobody" ownership, so it's obvious stuff is not via
> ftp [ownership would be foo]

attached mail follows:


The hack puts this .htaccess in dozens of dirs
RewriteEngine On

RewriteCond %{HTTP_REFERER}
^http://([a-z0-9_\-]+\.)*(google|msn|yahoo|live|ask|dogpile|mywebsearch|yandex|rambler|aport|mail|gogo|poisk|alltheweb|fireball|freenet|abacho|wanadoo|free|club-internet|aliceadsl|alice|skynet|terra|ya|orange|clix|terravista|gratis-ting|suomi24)\.
[NC]

RewriteCond %{HTTP_REFERER}
[?&](q|query|qs|searchfor|search_for|w|p|r|key|keywords|search_string|search_word|buscar|text|words|su|qt|rdata)\=
 

RewriteCond %{HTTP_REFERER}
![?&](q|query|qs|searchfor|search_for|w|p|r|key|keywords|search_string|search_word|buscar|text|words|su|qt|rdata)\=[^&]+(%3A|%22)
 

RewriteCond %{TIME_SEC} <59

RewriteRule ^.*$ /StartLocs/maps/kapicag/ex3/t.htm [L]
                                                                                                   #
a995d2cc661fa72452472e9554b5520c

The kapicag/ex3/t.htm appears to be phishing site.

mike wrote:
> How was it "hacked"?
>
> That will help determine what kind of exploit might have been used.
>
>
> On 4/11/08, Al <newsridersite.org> wrote:
>> One of my sites has been hacked and I'm trying to find the hole. The hack
>> code creates dirs with "nobody" ownership, so it's obvious stuff is not via
>> ftp [ownership would be foo]

attached mail follows:


I would recommend something more strong
http://www.php.net/manual/en/function.exif-imagetype.php

or if you dont have exif
http://www.php.net/manual/en/function.getimagesize.php
will do also a trick.

One more thing, you are also allowing .txt and .css which may be
potential hole, as Apache can run .css also through PHP engine if
configured to do so.
Sometimes I use PHP to process CSS so I can have dynamic CSS for some
rare cases.

On Apr 12, 2008, at 2:24 AM, Al wrote:

> One of my sites has been hacked and I'm trying to find the hole.
> The hack code creates dirs with "nobody" ownership, so it's obvious
> stuff is not via ftp [ownership would be foo]
>
> Site is virtual host, Linux/Apache
>
> I'm concerned about a file uploader my users use to upload photos.
>
> Can anyone see a hole in this scrip? Can my code upload an
> executable masquerading as an image file?
>
> $filetype = array("gif", "jpg", "jpeg", "png", "txt", css")
>
> function csvt_file_upload($filetype, $max_size)
> {
> $prohibits = array("exe", "php", "inc", "php3", "pl", "bat",
> "cgi"); //common executables.
> $absolute_max_size = 2000000;
>
> end($_FILES); //get the "name" used by the html <input.....
> $name = key($_FILES); //could use the register variables, but
> this is safer.
> if(isset($_FILES[$name]['name'])) $input_name = $_FILES[$name]
> ['name'];
>
> $error = "no"; //reset for error checks
>
> if (!isset($filetype)) {
> echo "<p style=\"color:red\"> File type assignment
> missing </p> ";
> $error = "yes";
> };
>
> if (!isset($max_size)) {
> echo "<p style=\"color:red\"> Max file size assignment
> missing.</p>";
> $error = "yes";
> };
>
> $filename = $_FILES[$name]['name'];
> $tmp_name = $_FILES[$name]['tmp_name'];
> $size = $_FILES[$name]['size'];
>
> $absolute_path_file = getcwd(). DATA_DIR . $filename;
>
>
> if (($size >= $max_size) OR ($size > $absolute_max_size)) {
> echo "<p style=\"color:red\"> File size is too large.</p> ";
> $error = "yes";
> }
>
> $ext = substr(strrchr($filename, "."), 1); //get the extension,
> remove the "."
> if (in_array($ext, $prohibits)) {
> echo "<p style=\"color:red\">Illegal file type,
> executable.</p>\r\n";
> $error = "yes";
> }
> if (is_executable($filename)) {
> echo "<p style=\"color:red\">Illegal file type, executable
> file.</p>\r\n";
> $error = "yes";
> } //This is a double check in case $prohibits is incomplete.
> if (is_array($filetype) AND !in_array($ext, $filetype)) {
> echo "<p style=\"color:red\">Illegal file type.</p>\r\n";
> $error = "yes";
> }
> if(!is_array($filetype) AND ($filetype != $ext)){
> echo "<p style=\"color:red\">Illegal file type.</p>\r\n";
> $error = "yes";
> }
> if ($error == "yes") {
> echo "<p style=\"color:red\">There was an error(s) with
> your file selection \"$input_name\" as the note(s) indicates.
> Please reselect, or remove your file selection and email for help.
> </p>\r\n";
> }
> else {
> if(!move_uploaded_file($tmp_name, $absolute_path_file))
> die("<p style=\"color:red\">There was an error saving your file.
> Check permissions of " . DATA_DIR . " Must be 777 </p>\r\n");
>
> chmod($absolute_path_file, 0644);
> }
>
> return;
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Igor Jocic
http://www.carster.us/

attached mail follows:


Al wrote:
> One of my sites has been hacked and I'm trying to find the hole. The
> hack code creates dirs with "nobody" ownership, so it's obvious stuff is
> not via ftp [ownership would be foo]
>
> Site is virtual host, Linux/Apache
>
> I'm concerned about a file uploader my users use to upload photos.
>
<!-- SNIP -->

First off, file type means NOTHING to people using uploaders. I have had
a number of people try to hack my site with my uploader and they never
succeed.

If you don't parse the first few lines of the file, you're probably
gonna find yourself hacked again. Depending on the size of the machine,
you could just read the whole file and look for php somewhere in it, and
if it exists, erase immediately.

image.php.gif.jpg would pass your test as far as checking extensions.

I have a number of the scripts used by others to try to hack my site
available for download/review. If you search the archives, you should
find them. If not, contact me directly and I'll send you the link to them.

HTH,
Wolf

attached mail follows:


Hi,

I post following message days ago, but could not see it on the list.
Sorry if it is duplicated.

I've installed php5 in debian, but got following problems:

1. I could not find a proper debian package for pecl, search pecl found:

dh-make-php - Creates Debian source packages for PHP PEAR and PECL extensions
php-pear - PEAR - PHP Extension and Application Repository
php4-imagick - ImageMagick module for php4
php5-imagick - ImageMagick module for php5

Could anyone who have installed php in debian advise which pecl
package I should install in debian? I need to install the pecl using
for memcache, lighttpd and mysql.

2. I installed php5 in debian, but there is only /usr/bin/php5-cgi, no
php binary fond in /usr/bin.

$ dpkg -l php5
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii php5 5.2.0-8+etch10 server-side, HTML-embedded scripting languag

Which php package I have been missing for php command?

Thank you.

Kind Regards,

Jim

attached mail follows:


hce wrote:
> Hi,
>
> I post following message days ago, but could not see it on the list.
> Sorry if it is duplicated.
>
> I've installed php5 in debian, but got following problems:
>
> 1. I could not find a proper debian package for pecl, search pecl found:
>
> dh-make-php - Creates Debian source packages for PHP PEAR and PECL extensions
> php-pear - PEAR - PHP Extension and Application Repository
> php4-imagick - ImageMagick module for php4
> php5-imagick - ImageMagick module for php5
>
> Could anyone who have installed php in debian advise which pecl
> package I should install in debian? I need to install the pecl using
> for memcache, lighttpd and mysql.
>
> 2. I installed php5 in debian, but there is only /usr/bin/php5-cgi, no
> php binary fond in /usr/bin.
>
> $ dpkg -l php5
> Desired=Unknown/Install/Remove/Purge/Hold
> | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
> |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
> ||/ Name Version Description
> +++-==============-==============-============================================
> ii php5 5.2.0-8+etch10 server-side, HTML-embedded scripting languag
>
> Which php package I have been missing for php command?
>
> Thank you.
>
> Kind Regards,
>
> Jim
Not sure about debian but ubuntu you install the individual modules, not
all that are included in PECL.

1. apt-get install php5-mysql php5-lighttpd php5-memcache

2. apt-get install php5-cli

-Shawn

attached mail follows:


You need CLI (Comman Line interface) for PHP
most of PECL packages are in apt-get

eg apt-get php-memcache

On Apr 12, 2008, at 3:19 AM, Shawn McKenzie wrote:

> hce wrote:
>> Hi,
>> I post following message days ago, but could not see it on the list.
>> Sorry if it is duplicated.
>> I've installed php5 in debian, but got following problems:
>> 1. I could not find a proper debian package for pecl, search pecl
>> found:
>> dh-make-php - Creates Debian source packages for PHP PEAR and PECL
>> extensions
>> php-pear - PEAR - PHP Extension and Application Repository
>> php4-imagick - ImageMagick module for php4
>> php5-imagick - ImageMagick module for php5
>> Could anyone who have installed php in debian advise which pecl
>> package I should install in debian? I need to install the pecl using
>> for memcache, lighttpd and mysql.
>> 2. I installed php5 in debian, but there is only /usr/bin/php5-
>> cgi, no
>> php binary fond in /usr/bin.
>> $ dpkg -l php5
>> Desired=Unknown/Install/Remove/Purge/Hold
>> | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-
>> installed
>> |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
>> uppercase=bad)
>> ||/ Name Version Description
>> +++-==============-==============-
>> ============================================
>> ii php5 5.2.0-8+etch10 server-side, HTML-embedded
>> scripting languag
>> Which php package I have been missing for php command?
>> Thank you.
>> Kind Regards,
>> Jim
> Not sure about debian but ubuntu you install the individual
> modules, not all that are included in PECL.
>
> 1. apt-get install php5-mysql php5-lighttpd php5-memcache
>
> 2. apt-get install php5-cli
>
> -Shawn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Used Cars
http://www.carster.us/sell-my-car

attached mail follows:


On 4/12/08, Bojan Tesanovic <btesanovicgmail.com> wrote:
> You need CLI (Comman Line interface) for PHP
> most of PECL packages are in apt-get
>
> eg apt-get php-memcache
>
>
>
>
> On Apr 12, 2008, at 3:19 AM, Shawn McKenzie wrote:
>
>
> > hce wrote:
> >
> > > Hi,
> > > I post following message days ago, but could not see it on the list.
> > > Sorry if it is duplicated.
> > > I've installed php5 in debian, but got following problems:
> > > 1. I could not find a proper debian package for pecl, search pecl found:
> > > dh-make-php - Creates Debian source packages for PHP PEAR and PECL
> extensions
> > > php-pear - PEAR - PHP Extension and Application Repository
> > > php4-imagick - ImageMagick module for php4
> > > php5-imagick - ImageMagick module for php5
> > > Could anyone who have installed php in debian advise which pecl
> > > package I should install in debian? I need to install the pecl using
> > > for memcache, lighttpd and mysql.
> > > 2. I installed php5 in debian, but there is only /usr/bin/php5-cgi, no
> > > php binary fond in /usr/bin.
> > > $ dpkg -l php5
> > > Desired=Unknown/Install/Remove/Purge/Hold
> > > |
> Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
> > > |/ Err?=(none)/Hold/Reinst-required/X=both-problems
> (Status,Err: uppercase=bad)
> > > ||/ Name Version Description
> > >
> +++-==============-==============-============================================
> > > ii php5 5.2.0-8+etch10 server-side, HTML-embedded scripting
> languag
> > > Which php package I have been missing for php command?
> > > Thank you.
> > > Kind Regards,
> > > Jim
> > >
> > Not sure about debian but ubuntu you install the individual modules, not
> all that are included in PECL.
> >
> > 1. apt-get install php5-mysql php5-lighttpd php5-memcache
> >
> > 2. apt-get install php5-cli
> >
> > -Shawn
> >

Thanks Shawn and Bojan. I have already insalled php5-memcache,
php5-mysql. What is the pecl package for the following error:

Catchable fatal error: Object of class MDB2_Error could not be
converted to string....

Thank you.

Kind Regards,

Jim

attached mail follows:


I bet there is no native PHP methods for that kind of file, but you
can easily check the headers of wave file , you need to have a
specification or at least have 3 wave files of PCM and CCITT ,
compare the first 100 characters of that file, and you will get the clue
and logic how to recognize one from the other.
in PHP open a file read 100++ bytes and apply a logic to distinguish
formats.

After that you can use some external program to convert from one
format to other eg

<?php

system(' wavconvert_to_CCITT.exe some_pcm.wave ') ;
?>

On Apr 11, 2008, at 9:20 PM, adminbuskirkgraphics.com wrote:

> Wave editor?
> Here is my dilemma.
>
> In php I have written a script to upload a wave file to the server
> for the C Sharp application to use. No problems on upload or
> streaming from the file to the web. My issue comes when the format
> of the wave file is PCM and not CCITT u-Law. The device cannot play
> a PCM formatted wave file. Problem comes in when the end user just
> picks a wave file to use for this option and does not have the
> format correct.
>
> Is there a wave format change option in php?
> Has or does anyone know of a solution in php for this?
> Is there a way I can check the format of the wave file before
> uploading?
>
>
>
> Richard L. Buskirk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Igor Jocic
http://www.carster.us/

attached mail follows:


I'm trying to figure out a way that SQL can pass a flag to PHP to say which column "matched" during a query.

Let's say for instance that I want to search for the word "apple" in both column "producer", and column "designation". I was hoping I could do something like this:

Select producer, flag=1 from wine
where producer like '%apple%'
UNION
Select designation, flag=2 from wine
where designation like '%apple%'

and then in each row that comes back, I could determine which column did that match by doing a PHP analysis of the "flag" value. However, this doesn't appear to be the right way to go about this (mySQL doesn't like these flag=1, flag=2 things.

Can someone help steer me in the right direction?

attached mail follows:


Why so complicated

On Apr 12, 2008, at 5:25 AM, Rob Gould wrote:

> I'm trying to figure out a way that SQL can pass a flag to PHP to
> say which column "matched" during a query.
>
> Let's say for instance that I want to search for the word "apple"
> in both column "producer", and column "designation". I was hoping
> I could do something like this:

<?php
$slq = "select producer, designation from wine where designation
like '%apple%' and producer like '%apple%' ";
$rs = mysql_query($sql);

while( $row = mysql_fetch_row($rs) ){
    echo $row[0] ; // producer
        echo $row[1] ; // designation
}

?>

>
>
> Select producer, flag=1 from wine
> where producer like '%apple%'
> UNION
> Select designation, flag=2 from wine
> where designation like '%apple%'
>
>
>
> and then in each row that comes back, I could determine which
> column did that match by doing a PHP analysis of the "flag" value.
> However, this doesn't appear to be the right way to go about this
> (mySQL doesn't like these flag=1, flag=2 things.
>
> Can someone help steer me in the right direction?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Igor Jocic
http://www.carster.us/

attached mail follows:


On Fri, 2008-04-11 at 20:25 -0700, Rob Gould wrote:
> I'm trying to figure out a way that SQL can pass a flag to PHP to say which column "matched" during a query.
>
> Let's say for instance that I want to search for the word "apple" in both column "producer", and column "designation". I was hoping I could do something like this:
>
>
> Select producer, flag=1 from wine
> where producer like '%apple%'
> UNION
> Select designation, flag=2 from wine
> where designation like '%apple%'

<?php

$query =
    "SELECT "
   ." producer, "
   ." (producer like '%apple%') AS producerMatched "
   ."WHERE "
   ." producer like '%apple%' "
   ."UNION SELECT "
   ." designation, "
   ." (designation like '%apple%') AS designationMatched "
   ."WHERE "
   ." designation like '%apple%' ";

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

attached mail follows:


On Fri, 2008-04-11 at 23:42 -0400, Robert Cummings wrote:
> On Fri, 2008-04-11 at 20:25 -0700, Rob Gould wrote:
> > I'm trying to figure out a way that SQL can pass a flag to PHP to say which column "matched" during a query.
> >
> > Let's say for instance that I want to search for the word "apple" in both column "producer", and column "designation". I was hoping I could do something like this:
> >
> >
> > Select producer, flag=1 from wine
> > where producer like '%apple%'
> > UNION
> > Select designation, flag=2 from wine
> > where designation like '%apple%'
>
> <?php
>
> $query =
> "SELECT "
> ." producer, "
> ." (producer like '%apple%') AS producerMatched "
     ."FROM "
     ." wine "
> ."WHERE "
> ." producer like '%apple%' "
> ."UNION SELECT "
> ." designation, "
> ." (designation like '%apple%') AS designationMatched "
     ."FROM "
     ." wine "
> ."WHERE "
> ." designation like '%apple%' ";

Sorry, forgot the FROM clause. BTW, you shouldn't use a union, this can
be cleaned up to the following query:

<?php

    $query =
        "SELECT "
       ." producer, "
       ." (producer like '%apple%') AS producerMatched, "
       ." designation, "
       ." (designation like '%apple%') AS designationMatched "
       ."FROM "
       ." wine "
       ."WHERE "
       ." producer like '%apple%' "
       ." OR "
       ." designation like '%apple%' ";

?>

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

attached mail follows:


On 12 Apr 2008, at 04:25, Rob Gould wrote:
> I'm trying to figure out a way that SQL can pass a flag to PHP to
> say which column "matched" during a query.
>
> Let's say for instance that I want to search for the word "apple" in
> both column "producer", and column "designation". I was hoping I
> could do something like this:
>
> Select producer, flag=1 from wine
> where producer like '%apple%'
> UNION
> Select designation, flag=2 from wine
> where designation like '%apple%'
>
> and then in each row that comes back, I could determine which column
> did that match by doing a PHP analysis of the "flag" value.
> However, this doesn't appear to be the right way to go about this
> (mySQL doesn't like these flag=1, flag=2 things.

select producer as field1, 1 as flag from wine where producer like
'%apple%'
union
select designation as field1, 2 as flag from wine where designation
like '%apple%'

But as other posters have pointed out a union is a lot more work for
the DB engine to do when you could easily grab both fields in a single
query.

-Stut

--
http://stut.net/

attached mail follows:


Hi PHP Experts,

I am writing a wrapper over some existing code and when I hoped that I
almost successfully completed it, I ran into the wall.

The wrapper file is in /var/www/sites/project/ as xyz.php and the file
includes some of the files from various paths.
Starting with
==============
// Importing Init.php for initializing the libraries
include_once("checkout/controller/Init.php");

and this Init.php in /var/www/sites/project/checkout/controller loads the
configuration file and code is as below.

============================================
if(file_exists("../common/config.ini")) {
  $configData = parse_ini_file("../common/config.ini");
} else {
  $configData = false;
}
if (!$configData) {
  die("An error occurred while trying to get ".
      "confidential config data. Please ensure that the ".
      "pathname to this file in Init.php ".
      "is correct.");
}
============================================

This config.php file is in /var/www/sites/project/common/ but there is some
messup in the path and its not setting to the right path as it must looking
for the file with include path set to /var/www/sites/project/ rather
/var/www/sites/project/checkout(it works if I keep the xyz.php file in
checkout folder. But I want this file to be in parent folder for various
other reasons and I cant figure out for nuts how to make this path thing
work.

Thanks,
Gowtham.N