Re: [PHP] Help with logic :(

2005-10-11 Thread Jochem Maas

Richard Lynch wrote:

On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:


create a function to check if the rndnumber=couponcode row count = 0
if not then redo rndnumber if it does = 0 then insert rndnumber



N!

You are creating a RACE CONDITION in which ONE user might generate a
'valid' code, and ANOTHER user might generate a 'valid' code AT THE
SAME TIME, and then they BOTH get the same coupon code.

The probability of this is very very very low, but still NOT zero.

And it's the kind of thing that won't show up in testing, but sure as
God made little green apples, it WILL happen at the worst possible
time after you "go live"


lol. Richard you should write a book :-) (or should that be 'another book'?)



The database engine has a *TON* of code in it to avoid this kind of
Bad Thing happening.

Use it.

create a UNIQUE INDEX on the column that needs to be unique.

Trap the INSERT error.



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



Re: [PHP] Problem w/ Hidden Input Fields

2005-10-11 Thread Jochem Maas

Jason Ferguson wrote:

Jochem,

Thanks for the response. I actually solved the problem a few days
ago... I'm suprised this message never went out to the list until
today.

I actually WANTED one to override the other in this case. The user
should be able to choose one of the default radio buttons (in which
case the hidden field would work) or be able to provide their own by
typing/pasting it into the text box.


I see - then I recommend that you reNAME both elements to 'txtKeyValue[]'.
this will cause php to create an array for you so you can always get to
both values. e.g.

print_r($_POST['txtKeyValue']); // Array

that will give you a numerically indexed array, if you rename the textboxes
individually to 'txtKeyValue[default]' and 'txtKeyValue[other]'
you will have an associative array with a structure like:

$arr = array(
'default'   => 
'ABQIh2cCTTmAE6T4OXjecIFe5BQMxb4e6BwgeSB7cBu9SbVQSak6ARTgAPoctbx36BXXgbYZONZls0B1LQ',
'other' => '',
);

there is no intrisic need to give the elements an id at all (regardless
never give 2 elements on one page the same id.)



I got around the problem by temporarily using a rather ugly switch
statement until I revist the problem in a later release.


I like switch statements, my favorite is the rather evil use
of switch()'ing on true:

switch (true) {
case (/* arbitrary boolean expression */):
break;
// .. and so on
}



Jason

On 10/10/05, Jochem Maas <[EMAIL PROTECTED]> wrote:


hi Jason,

Jason Ferguson wrote:


I have a  field with a value 86 characters long.
Here is the entire form:

 
 
 

 Rootsweb
 
 
 
 
 Other Site:



this text input has the same name, seeing as it comes after the
hidden field it will be submitted after it (in terms of the order
of the POST vars) too. the value of second incoming txtKeyValue
effectively overwrites the first - result is you always see an empty value.

after thought:
you can work around it with javascript or php (and possibly changing
'txtKeyValue' to 'txtKeyValue[]'), or just change the name of
one of the fields :-)



 
 
 

 
 
 
 
 
 
 
 
 

 
 

However, when I submit and do a print_r($_POST), there is no value for
$_POST['txtKeyValue'].

Note: the setWizardAction() function sets the 
attribute so the Prev/Next buttons work correctly.

The application is very close to being complete, so I need help ASAP


don't quite follow that logic ;-)

.


Jason






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



RE: [PHP] Problem w/ Hidden Input Fields

2005-10-11 Thread Kim Madsen
Hello

> -Original Message-
> From: Jason Ferguson [mailto:[EMAIL PROTECTED]
> Sent: Sunday, October 09, 2005 5:55 PM
> To: php-general@lists.php.net
> Subject: [PHP] Problem w/ Hidden Input Fields
> 
> I have a  field with a value 86 characters long.
> Here is the entire form:
> 
>action="">
>   
>   
> 
>type="radio" name="radioKey" value="2"
> checked="checked" />Rootsweb
>type="hidden" name="txtKeyValue" id="txtKeyValue"
> maxlength="90"
> value="ABQIh2cCTTmAE6T4OXjecIFe5BQMxb4e6BwgeSB7cBu9SbVQSak6ARTgAPoctbx
> 36BXXgbYZONZls0B1LQ"
> />
>   
>   
>   
>type="radio" name="radioKey" value="2" />Other Site:
> 
>   
>   
>   
> 
>type="button" name="btnGenTemplate" id="btnGenTemplate"
> value="Generate HTML" onclick="setWizardAction('genHTML.php')" />
>   
>   
>   
>type="button" name="btnPrev" id="btnPrev" value="<--
> Prev" disabled="true" />
>type="button" name="btnNext" id="btnNext" value="Next
> -->" onclick="setWizardAction('mmwizard1.php')"/>
>type="button" name="btnFinish" id="btnFinish" value =" Finish" />
>   
>   
> 
>   
>   
> 
> However, when I submit and do a print_r($_POST), there is no value for
> $_POST['txtKeyValue'].

Because You later in the form set: 



It´s overwritten then.

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper



ComX Networks A/S
Naverland 31, 2 
DK-2600 Glostrup
Denmark
Phone: +45 70 25 74 74
direct: +45 32 87 73 93
Fax: +45 70 25 73 74
Web: www.comx.dk
E-mail: [EMAIL PROTECTED]

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



Re: [PHP] PHP5 Soap + .NET Webservice

2005-10-11 Thread Chris Hemmings

Thanks Richard,

I think I might start on a slightly simpler service, it seems MS has 
done its best to complicate everything.


I have managed to get something working, but, god knows why the their 
example web service is sending back schema data as well as the result 
data, quite over the top.  I'm guessing it helps their .NET stuff all 
work together nicely.


Anyway, thanks again.

Chris.

Richard Lynch wrote:

On Mon, October 10, 2005 4:40 am, Chris Hemmings wrote:


Can anyone explain how this works, and, how to fix it.  I'm can't find
any documentation on the problem I am having.



colon-separated name-spaces in XML are a relatively new development.

Your XML parser probably is not up to speed on them yet...

You'd have to upgrade your XML parser, or replace it with one that is
aware of this newer XML format.

I forget the precise terminology for colon-separated name-spaces in
XML, so your first task is to find out what the heck it's called. :-)



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



[PHP] Sequential multiple file download?

2005-10-11 Thread David Merritt
All,

Is there a way to do a sequential multiple file download?  I have the scenario
where based on various factors/inputs a user ends up with a list of files to
download from the web server.  This is an array of filenames from 1 to x total
number of files.  I want the user to be able to select/click one time in the
browser to start the download of the first file in the list, then have the
standard browser download/save to dialog kick box in for where to save the first
file to.  Once the first file has downloaded, I then want the second file in the
list to start downloading, kick in the std. dialog box again for the user to 
save
the second file, and so on until all files in the list have been 
sent/downloaded.

I know I could zip all the files together on the server first and then download
the one single file but for this application I need to do the sequential,
individual file download, one file at a time.

I’m open to any solution whether it be PHP, PHP/Javascript, or any other
language.  Obviously all PHP would be the preferred choice as the rest of the
site application is PHP but the functionality required overrides everything 
else.

TIA,

Dave Merritt
[EMAIL PROTECTED]

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



Re: [PHP] storing passwords in $_SESSION

2005-10-11 Thread Terence



Richard Davey wrote:


Agreed totally, I am curious as to why this question seems to get
asked a LOT though. I wonder what it is that causes this? (other than
inexperience) I mean there must be some common end result these
developers are hoping to obtain, resulting in a password being stashed
away in a session var.


What about this scenario. A system developed using procedures / 
functions to update data without direct table access. Bypassing the 
single user account from the application to the database (which most web 
based apps use), each procedure requires additional parameters 
(username,password) which then verifies the user (from a user lookup 
table) before executing the stored procedure. This makes the system more 
secure in case the web app username and password is breached which 
usually has full access to the db.


Of course storing it in a session is a no-no, so what I am trying to get 
at is,perhaps a reason for storing the password "somewhere".


Your thoughts Richard?

Thanks!

Warm Regards
Terence

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



[PHP] php5.1RC/COM/Word

2005-10-11 Thread George Pitcher
Hi,

My dev machine has PHP 5.1RC installed (no problems so far, apart from
this), its on Win XP. My server is running PHP 5.0.4 on Win NT.

I'm building some MS Word docs and it works fine except when I need to add
something that uses more than one parameter - eg.:

$word->Selection->ParagraphFormat->TabStops->Add->Position(418,0,0);

Whenever I use something that needs more than one parameter, I get my Word
document generated up to that point and an error message on the web page:
"PHP Fatal error: Uncaught exception 'com_exception' with message 'Error
[0x8002000e] Invalid number of parameters.'".

Does anyone know of a solution?

No smart-Alec replies please.

cheers

George in Oxford

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



Re: [PHP] php5.1RC/COM/Word

2005-10-11 Thread Jochem Maas

George Pitcher wrote:

Hi,

My dev machine has PHP 5.1RC installed (no problems so far, apart from
this), its on Win XP. My server is running PHP 5.0.4 on Win NT.

I'm building some MS Word docs and it works fine except when I need to add
something that uses more than one parameter - eg.:

$word->Selection->ParagraphFormat->TabStops->Add->Position(418,0,0);

Whenever I use something that needs more than one parameter, I get my Word
document generated up to that point and an error message on the web page:
"PHP Fatal error: Uncaught exception 'com_exception' with message 'Error
[0x8002000e] Invalid number of parameters.'".


you should be using a try/catch block (lets assume for now that the error
msg is correct and COM is not broken as such):

try {
/* do stuff ... e.g. */
$word->Selection->ParagraphFormat->TabStops->Add->Position(418,0,0);
} catch (com_exception $e) {
print_r($e); // or do some better error handling
}

catching the exception will give you the opportunity to continue the
script (rather than having to swallow a fatal error) - the fact that your
getting an exception is either because you really are using the wrong
number of parameters or the COM extension is broken in 5.1 (I guess -
maybe check bugs.php.net to see if someone has filed anything regarding this)

btw there is also the keyword 'throw' that complements try/catch - the manual
explains the basics of exception throwing and catching much better than I
can (be bothered to ;-)



Does anyone know of a solution?

No smart-Alec replies please.


thats kinda asking for it ;-)

"stop your fatal error; don't run the script; garanteed to work
on all platforms"



cheers

George in Oxford



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



Re: [PHP] Get Mac Address

2005-10-11 Thread Ben Sagal
I did mention this is an INTRANET server so all clients are be local,
there are no router between the clients and the server.

how would i go about accessing arp from php, (the server runs Linux)?

Ben

On 10/10/05, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
> That will give you the *local* mac address, not that of the user
> visiting your page. The problem is the fact that the mac address is not
> sent as part of the REQUEST. As such it's not possible for PHP to find
> out what it is. So, unfortunately, no. (Though it's a very common
> question on this list)
>
> - tul
>
> Rory Browne wrote:
> > On unix
> > man arp
> >
> > on windows
> > arp/h
> > arp/help
> > arp/?
> >
> > sorry for short and sweet resp, but I'm falling asleep.
> >
> > On 10/9/05, Ben Sagal <[EMAIL PROTECTED]> wrote:
> >
> >>I have a local intranet server, running apache1.3+php4.  Is it
> >>possible to get the mac address of computes which access on of my php
> >>pages?
> >>
> >>Ben
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >>
>
>

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



Re: [PHP] ARG: Seg Faults with PHP 5.0.5, now on Solaris and SLES9

2005-10-11 Thread Jochem Maas

Chuck wrote:
Yes, prefork is what I am using. 


ah ok.

Also made sure and linked with pthread 


php + threads are not bedfellows - maybe try dropping
pthread as your AcceptMutex apache directive?

otherwise it could be time to crack open gdb and run apache
through it try and figure out exactly where the problem lies:

something like (I googled for it):

$> gdb /usr/local/apache/bin/httpd
> run -X -DSSL -f /usr/local/apache/conf/httpd.conf


also/alternatively try recompiling php with only the --with-apxs configure
flag - if that works recompile, each time adding a single flag,
this may pinpoint the problem some more.

... and you could try stepping down to 5.0.4 and wait until 5.1 has
a stable release.


as well.

-CC

On 10/10/05, *Jochem Maas* <[EMAIL PROTECTED] 
> wrote:


Chuck wrote:
 > After 3 months of headache and intermittent seg faults on Solaris
9, we
 > decided to give SLES 9 a try.
 >
 > Now we get continuous seg faults.
 >
 > I am running apache 2.0.54 on SLES 9 with all updates, and Oracle
 > 10.2.0.1 .
 > (everything is the 32-bit flavor)
 >
 > I built PHP as follows:
 > adcinfops02:/usr/local/httpd-2.0.54/htdocs #./configure
 > --prefix=/usr/local/php-5.0.5
--with-apxs2=/usr/local/httpd-2.0.54/bin/apxs

long shot: which worker module do you have enabled in httpd.conf?
you can only use 'pre-fork' with php.

 > --enable-cli --enable-debug
--with-config-file-path=/usr/local/php-5.0.5/lib
 >  --with-zlib --with-bz2 --enable-ftp --with-gettext
 > --enable-mbstring --with-ncurses
--with-oci8=/u01/app/oracle/product/10.2
 > --enable-session --enable-sockets --enable-shared --disable-xml
 > --disable-libxml --disable-dom --with-jpeg-dir=/usr/lib
 > --with-png-dir=/usr/lib --with-zlib-dir=/usr/lib
--with-xpm-dir=/usr/lib
 > --disable-simplexml --without-pear
 >
 > Here is the simply php page that seg faults _every_ time it is
called. (On
 > solaris, it only seg faulted 25% of the time)
 > 
 > putenv("ORACLE_HOME=/u01/app/oracle/product/10.2");
 > putenv("ORACLE_SID=ADCDM02");
 > putenv("TNS_ADMIN=/var/opt/oracle");
 >
 >
 > $ora = ociplogon("dm","mypassword", "MYSID");
 >
 > $stmt=OCIParse($ora, "select USERNAME from dba_users");
 > $res=OCIExecute($stmt);
 >
 > $rows = OCIFetchstatement($stmt, $results);
 >
 > print "DEBUG: rows=$rows\n";
 >
 > $keys = array_keys($results);
 > foreach($keys as $key)
 > {
 > print "$key\n";
 > }
 > for($i=0; $i < $rows; $i++)
 > {
 > print " " . $results["USERNAME"][$i] . "\n";
 > }
 >
 > OCIFreeStatement($stmt);
 > OCILogoff($ora);
 >
 > ?>
 >
 >
 > I can run this script 100 times from the command line ( # php
oratest.php )
 > and not a single seg fault.
 >
 > Anyone have any idea why this is happenning?
 >
 > Also, is there a config, any OS, any version, and combination AT
ALL, where
 > PHP is reliable when using Oracle 10g as the back end? Any
configuration at
 > all?
 >
 > Thx,
 > CC
 > --
 >




--

To reply to this message, remove 'N_O_S_P_A_M' from the reply-to address.


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



RE: [PHP] Sequential multiple file download?

2005-10-11 Thread Jay Blanchard
[snip]
Is there a way to do a sequential multiple file download?  
[/snip]

I think that the only way to do this in PHP is to zip 'em up and download
that file, but it is an interesting concept and I can see where it would
come in handy. I think that the problem lies in the fact that there would
have to be one request for each of the selected files for download. Each
subsequent request, in order to keep the sequential order of things, would
have to be made at the tail end of the previous request. You might could do
this with a set of JavaScript commands combined with PHP's sleep() and
header("Location:..."), but my guess is that it would not be pretty.

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



[PHP] Run a php script as a separate thread/process

2005-10-11 Thread Tommy Jensehaugen
Hi,
Anyone knows how to start a php script as a separate thread/process from 
another php script?

example.php:



The reason why I want to do this is because separate_script.php has to be 
fully executed even if the request for example.php is stopped in the middle 
of "more logic".
I am using PHP Version 4.3.11.

Thank you very much for your help..

Cheers,
Tommy 


[PHP] Run a php script as a separate thread/process

2005-10-11 Thread Tommy Jensehaugen
Hi,
Anyone knows how to start a php script as a separate thread/process from 
another php script?

example.php:



The reason why I want to do this is because separate_script.php has to be 
fully executed even if the request for example.php is stopped in the middle 
of "more logic".
I am using PHP Version 4.3.11.

Thank you very much for your help..

Cheers,
Tommy 

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



Re: [PHP] Run a php script as a separate thread/process

2005-10-11 Thread Petar Nedyalkov
On Tuesday 11 October 2005 14:12, Tommy Jensehaugen wrote:
> Hi,
> Anyone knows how to start a php script as a separate thread/process from
> another php script?

Yes, you can check: http://bg.php.net/manual/en/ref.exec.php for details.

>
> example.php:
>
>  some logic
>
>
> execute('separate_script.php');
> more logic
>
>
> ?>
>
> The reason why I want to do this is because separate_script.php has to be
> fully executed even if the request for example.php is stopped in the middle
> of "more logic".
> I am using PHP Version 4.3.11.
>
> Thank you very much for your help..
>
> Cheers,
> Tommy

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436


pgpeIeTeZxuzR.pgp
Description: PGP signature


Re: [PHP] Help with logic :(

2005-10-11 Thread aaronjw
Hi Richard,

Ok... I do already have a Unique index on the column but this process is
something that I cannot echo out the error code to the user. The code is
generated on the fly when an order an is placed so you can see... I can't
echo out the error to the customer.

Can I do an if statement IF an error is returned to try generatre another
randon code and keep going until one is available? I can do this all
intenrally without the customer knowing/seeing anything?

Hope I am making some sense. Not trying to confuse the issue.

Thanks. Appreciate your thoughts.

Aaron

> On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
>> create a function to check if the rndnumber=couponcode row count = 0
>> if not then redo rndnumber if it does = 0 then insert rndnumber
>
> N!
>
> You are creating a RACE CONDITION in which ONE user might generate a
> 'valid' code, and ANOTHER user might generate a 'valid' code AT THE
> SAME TIME, and then they BOTH get the same coupon code.
>
> The probability of this is very very very low, but still NOT zero.
>
> And it's the kind of thing that won't show up in testing, but sure as
> God made little green apples, it WILL happen at the worst possible
> time after you "go live"
>
> The database engine has a *TON* of code in it to avoid this kind of
> Bad Thing happening.
>
> Use it.
>
> create a UNIQUE INDEX on the column that needs to be unique.
>
> Trap the INSERT error.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] looking for code to delete from lists..

2005-10-11 Thread bruce
hi.

i'm generating a list

  ++
  ||
  |  foo   |
  |  cat   |
  |  . |
  |  . |
  |  . |
  ||
  ++

cancel/submit

i want to give the user the ability to delete single/multiple rows from the
list. i then want to be able to write/submit the resulting list. any code
samples, or pointers to apps that all ready do this would be appreciated.
i'd prefer to not reinvent the wheel!

i'm thinking that i could create a select/option list, and then allow the
user to select any items that they want to delete. the app would then
iterate through the array on the submit, and do an update on the db tbls..

thanks

-bruce
[EMAIL PROTECTED]

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



RE: [PHP] looking for code to delete from lists..

2005-10-11 Thread Kilbride, James
Multiple Select form element, submit button. On submit iterate through
the submitted sequence to delete from the database(or use a delete from
statement that has the list of items depending on other work you want to
do on the list before deletion). HTML_QuickForm gives you an easy way to
generate the list.

James Kilbride 

> -Original Message-
> From: bruce [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 11, 2005 10:06 AM
> To: php-general@lists.php.net
> Subject: [PHP] looking for code to delete from lists..
> 
> hi.
> 
> i'm generating a list
> 
>   ++
>   ||
>   |  foo   |
>   |  cat   |
>   |  . |
>   |  . |
>   |  . |
>   ||
>   ++
> 
> cancel/submit
> 
> i want to give the user the ability to delete single/multiple 
> rows from the list. i then want to be able to write/submit 
> the resulting list. any code samples, or pointers to apps 
> that all ready do this would be appreciated.
> i'd prefer to not reinvent the wheel!
> 
> i'm thinking that i could create a select/option list, and 
> then allow the user to select any items that they want to 
> delete. the app would then iterate through the array on the 
> submit, and do an update on the db tbls..
> 
> thanks
> 
> -bruce
> [EMAIL PROTECTED]
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Help with logic :(

2005-10-11 Thread Dan McCullough
Yes I believe that is what Richard was saying about "Trap the INSERT
error", you should get an error back from the database about having a
problem with the insert instead of showing that error you will want to
add some logic that when that error occurs you simply generate another
number.

On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi Richard,
>
> Ok... I do already have a Unique index on the column but this process is
> something that I cannot echo out the error code to the user. The code is
> generated on the fly when an order an is placed so you can see... I can't
> echo out the error to the customer.
>
> Can I do an if statement IF an error is returned to try generatre another
> randon code and keep going until one is available? I can do this all
> intenrally without the customer knowing/seeing anything?
>
> Hope I am making some sense. Not trying to confuse the issue.
>
> Thanks. Appreciate your thoughts.
>
> Aaron
>
> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
> >> create a function to check if the rndnumber=couponcode row count = 0
> >> if not then redo rndnumber if it does = 0 then insert rndnumber
> >
> > N!
> >
> > You are creating a RACE CONDITION in which ONE user might generate a
> > 'valid' code, and ANOTHER user might generate a 'valid' code AT THE
> > SAME TIME, and then they BOTH get the same coupon code.
> >
> > The probability of this is very very very low, but still NOT zero.
> >
> > And it's the kind of thing that won't show up in testing, but sure as
> > God made little green apples, it WILL happen at the worst possible
> > time after you "go live"
> >
> > The database engine has a *TON* of code in it to avoid this kind of
> > Bad Thing happening.
> >
> > Use it.
> >
> > create a UNIQUE INDEX on the column that needs to be unique.
> >
> > Trap the INSERT error.
> >
> > --
> > Like Music?
> > http://l-i-e.com/artists.htm
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>

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



[PHP] mssql_*() functions and stored procedures

2005-10-11 Thread Chris Boget

Looking through the documentation, I see that I can use

mssql_init()
mssql_bind()
mssql_execute()

to execute those stored procedures that have parameters.
But what about those SPs which just return a value?  If I
have the following SP

CREATE PROCEDURE MySP
AS
 DECLARE @resultCode int
 SELECT @resultCode = 539
 RETURN @resultCode
GO

And execute the above as follows

DECLARE @result int;
EXEC @result = MySP;
PRINT @result;

within Query Analyzer, how do I emulate this using the mssql_*()
functions?  Whenever I try to just run the EXEC, I keep getting an
error message saying that I have to declare the @result variable.
I've tried to declare the variable in a seperate mssql_query() call
but that doesn't seem to have an effect.  So how can I do this w/o
getting an error w/r/t variable declaration?

thnx,
Christoph

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



RE: [PHP] Get Mac Address

2005-10-11 Thread Jim Moseby
> -Original Message-
> From: Ben Sagal [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 11, 2005 7:05 AM
> To: M. Sokolewicz
> Cc: Rory Browne; php-general@lists.php.net
> Subject: Re: [PHP] Get Mac Address
> 
> 
> I did mention this is an INTRANET server so all clients are be local,
> there are no router between the clients and the server.
> 
> how would i go about accessing arp from php, (the server runs Linux)?
> 

Hi Ben,

Try:

/* notice the backtics, and that arp on linux usually needs to run as root
*/
$arpoutput = `/sbin/arp -a`; 

JM

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



Re: [PHP] Run a php script as a separate thread/process

2005-10-11 Thread Silvio Porcellana
Tommy Jensehaugen wrote:
>
> 
> 
> The reason why I want to do this is because separate_script.php has to be 
> fully executed even if the request for example.php is stopped in the middle 
> of "more logic".
> I am using PHP Version 4.3.11.
> 

You might also want to give a look at this:
http://php.net/manual/en/function.ignore-user-abort.php

HTH, cheers.
Silvio

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



Re: [PHP] Help with logic :(

2005-10-11 Thread Jochem Maas

Dan McCullough wrote:

Yes I believe that is what Richard was saying about "Trap the INSERT
error", you should get an error back from the database about having a
problem with the insert instead of showing that error you will want to
add some logic that when that error occurs you simply generate another
number.


I concur! the OP has the idea :-)



On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Hi Richard,

Ok... I do already have a Unique index on the column but this process is
something that I cannot echo out the error code to the user. The code is
generated on the fly when an order an is placed so you can see... I can't
echo out the error to the customer.

Can I do an if statement IF an error is returned to try generatre another
randon code and keep going until one is available? I can do this all
intenrally without the customer knowing/seeing anything?

Hope I am making some sense. Not trying to confuse the issue.

Thanks. Appreciate your thoughts.

Aaron



On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:


create a function to check if the rndnumber=couponcode row count = 0
if not then redo rndnumber if it does = 0 then insert rndnumber


N!

You are creating a RACE CONDITION in which ONE user might generate a
'valid' code, and ANOTHER user might generate a 'valid' code AT THE
SAME TIME, and then they BOTH get the same coupon code.

The probability of this is very very very low, but still NOT zero.

And it's the kind of thing that won't show up in testing, but sure as
God made little green apples, it WILL happen at the worst possible
time after you "go live"

The database engine has a *TON* of code in it to avoid this kind of
Bad Thing happening.

Use it.

create a UNIQUE INDEX on the column that needs to be unique.

Trap the INSERT error.

--
Like Music?
http://l-i-e.com/artists.htm

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









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



[PHP] Speed/Efficiency Question: Large array into DB

2005-10-11 Thread Alan Lord
Hi All,

Not being a professional programmer I am looking for some advice about
the best way to do the following:

I have a large multidimensional array (up to 7Mb) It contains a list of
categories in a fairly normal Cat_ID and Parent_ID arrangement. The
array also contains a great deal of superfluous information which I want
to ignore. 

I wish to walk through the entire array, select 4 key/value pairs from
each sub-array and write those to my Database (Keys are: Cat_ID,
Parent_ID, CatName, CatLevel). I wish to ignore all other key/values in
each array.

I'm guessing that I should use array_walk_recursive() and apply my test
for valid keys then write this into my db... But, should I do this for
each iteration, or make a new array with just the information I need
then write that into my DB? And do I use a transaction/commit block and
try to do the whole thing in one db-write or again, INSERT on each step
through my array?

Oh yes, the key names in the array correspond to field names in my
database.

Sorry it's a bit long-winded...

Thanks in advance for any suggestions.

Alan

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



[PHP] Obsession with BC

2005-10-11 Thread GamblerZG
Recently, I asked my hosting provider when they are going to switch to 
PHP5. They replied that it will not happen any time soon, since they 
will install PHP5 only on new servers. Their reasoning was simple: PHP5 
will inevitably break some old scripts, and it's just not worh all the 
trouble. Such attitude is common, and it totally makes sence from a 
business perspective. That begs the question, why PHP developers are so 
worried about maintaining BC? There is a simple alternative:





So what's the reasoning behind BC maintenanse?

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



Re: [PHP] Help with logic :(

2005-10-11 Thread aaronjw
Thanks everyone. Makes sense. Now I got another issue.

When I try to see if an error exists I get this:

Warning: mysql_error(): supplied argument is not a valid MySQL-Link
resource in /home//public_html/Store/test.php on line 14

Is there a setting somewhere that I need to set to make sure this is
available?

Thanks and sorry is these are dumb-ass questions :)

Aaron


> Yes I believe that is what Richard was saying about "Trap the INSERT
> error", you should get an error back from the database about having a
> problem with the insert instead of showing that error you will want to
> add some logic that when that error occurs you simply generate another
> number.
>
> On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Hi Richard,
>>
>> Ok... I do already have a Unique index on the column but this process is
>> something that I cannot echo out the error code to the user. The code is
>> generated on the fly when an order an is placed so you can see... I
>> can't
>> echo out the error to the customer.
>>
>> Can I do an if statement IF an error is returned to try generatre
>> another
>> randon code and keep going until one is available? I can do this all
>> intenrally without the customer knowing/seeing anything?
>>
>> Hope I am making some sense. Not trying to confuse the issue.
>>
>> Thanks. Appreciate your thoughts.
>>
>> Aaron
>>
>> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
>> >> create a function to check if the rndnumber=couponcode row count = 0
>> >> if not then redo rndnumber if it does = 0 then insert rndnumber
>> >
>> > N!
>> >
>> > You are creating a RACE CONDITION in which ONE user might generate a
>> > 'valid' code, and ANOTHER user might generate a 'valid' code AT THE
>> > SAME TIME, and then they BOTH get the same coupon code.
>> >
>> > The probability of this is very very very low, but still NOT zero.
>> >
>> > And it's the kind of thing that won't show up in testing, but sure as
>> > God made little green apples, it WILL happen at the worst possible
>> > time after you "go live"
>> >
>> > The database engine has a *TON* of code in it to avoid this kind of
>> > Bad Thing happening.
>> >
>> > Use it.
>> >
>> > create a UNIQUE INDEX on the column that needs to be unique.
>> >
>> > Trap the INSERT error.
>> >
>> > --
>> > Like Music?
>> > http://l-i-e.com/artists.htm
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Help with logic :(

2005-10-11 Thread Dan McCullough
got some code so we can see?

On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Thanks everyone. Makes sense. Now I got another issue.
>
> When I try to see if an error exists I get this:
>
> Warning: mysql_error(): supplied argument is not a valid MySQL-Link
> resource in /home//public_html/Store/test.php on line 14
>
> Is there a setting somewhere that I need to set to make sure this is
> available?
>
> Thanks and sorry is these are dumb-ass questions :)
>
> Aaron
>
>
> > Yes I believe that is what Richard was saying about "Trap the INSERT
> > error", you should get an error back from the database about having a
> > problem with the insert instead of showing that error you will want to
> > add some logic that when that error occurs you simply generate another
> > number.
> >
> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Hi Richard,
> >>
> >> Ok... I do already have a Unique index on the column but this process is
> >> something that I cannot echo out the error code to the user. The code is
> >> generated on the fly when an order an is placed so you can see... I
> >> can't
> >> echo out the error to the customer.
> >>
> >> Can I do an if statement IF an error is returned to try generatre
> >> another
> >> randon code and keep going until one is available? I can do this all
> >> intenrally without the customer knowing/seeing anything?
> >>
> >> Hope I am making some sense. Not trying to confuse the issue.
> >>
> >> Thanks. Appreciate your thoughts.
> >>
> >> Aaron
> >>
> >> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
> >> >> create a function to check if the rndnumber=couponcode row count = 0
> >> >> if not then redo rndnumber if it does = 0 then insert rndnumber
> >> >
> >> > N!
> >> >
> >> > You are creating a RACE CONDITION in which ONE user might generate a
> >> > 'valid' code, and ANOTHER user might generate a 'valid' code AT THE
> >> > SAME TIME, and then they BOTH get the same coupon code.
> >> >
> >> > The probability of this is very very very low, but still NOT zero.
> >> >
> >> > And it's the kind of thing that won't show up in testing, but sure as
> >> > God made little green apples, it WILL happen at the worst possible
> >> > time after you "go live"
> >> >
> >> > The database engine has a *TON* of code in it to avoid this kind of
> >> > Bad Thing happening.
> >> >
> >> > Use it.
> >> >
> >> > create a UNIQUE INDEX on the column that needs to be unique.
> >> >
> >> > Trap the INSERT error.
> >> >
> >> > --
> >> > Like Music?
> >> > http://l-i-e.com/artists.htm
> >> >
> >> > --
> >> > PHP General Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>

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



Re: [PHP] Help with logic :(

2005-10-11 Thread aaronjw


This SHOULD error out but I'm getting the error instead.

It's just a test page to test my logic...

A
> got some code so we can see?
>
> On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Thanks everyone. Makes sense. Now I got another issue.
>>
>> When I try to see if an error exists I get this:
>>
>> Warning: mysql_error(): supplied argument is not a valid MySQL-Link
>> resource in /home//public_html/Store/test.php on line 14
>>
>> Is there a setting somewhere that I need to set to make sure this is
>> available?
>>
>> Thanks and sorry is these are dumb-ass questions :)
>>
>> Aaron
>>
>>
>> > Yes I believe that is what Richard was saying about "Trap the INSERT
>> > error", you should get an error back from the database about having a
>> > problem with the insert instead of showing that error you will want to
>> > add some logic that when that error occurs you simply generate another
>> > number.
>> >
>> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> >> Hi Richard,
>> >>
>> >> Ok... I do already have a Unique index on the column but this process
>> is
>> >> something that I cannot echo out the error code to the user. The code
>> is
>> >> generated on the fly when an order an is placed so you can see... I
>> >> can't
>> >> echo out the error to the customer.
>> >>
>> >> Can I do an if statement IF an error is returned to try generatre
>> >> another
>> >> randon code and keep going until one is available? I can do this all
>> >> intenrally without the customer knowing/seeing anything?
>> >>
>> >> Hope I am making some sense. Not trying to confuse the issue.
>> >>
>> >> Thanks. Appreciate your thoughts.
>> >>
>> >> Aaron
>> >>
>> >> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
>> >> >> create a function to check if the rndnumber=couponcode row count =
>> 0
>> >> >> if not then redo rndnumber if it does = 0 then insert rndnumber
>> >> >
>> >> > N!
>> >> >
>> >> > You are creating a RACE CONDITION in which ONE user might generate
>> a
>> >> > 'valid' code, and ANOTHER user might generate a 'valid' code AT THE
>> >> > SAME TIME, and then they BOTH get the same coupon code.
>> >> >
>> >> > The probability of this is very very very low, but still NOT zero.
>> >> >
>> >> > And it's the kind of thing that won't show up in testing, but sure
>> as
>> >> > God made little green apples, it WILL happen at the worst possible
>> >> > time after you "go live"
>> >> >
>> >> > The database engine has a *TON* of code in it to avoid this kind of
>> >> > Bad Thing happening.
>> >> >
>> >> > Use it.
>> >> >
>> >> > create a UNIQUE INDEX on the column that needs to be unique.
>> >> >
>> >> > Trap the INSERT error.
>> >> >
>> >> > --
>> >> > Like Music?
>> >> > http://l-i-e.com/artists.htm
>> >> >
>> >> > --
>> >> > PHP General Mailing List (http://www.php.net/)
>> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >
>> >> >
>> >>
>> >>
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Obsession with BC

2005-10-11 Thread Robert Cummings
On Tue, 2005-10-11 at 12:41, GamblerZG wrote:
> Recently, I asked my hosting provider when they are going to switch to 
> PHP5. They replied that it will not happen any time soon, since they 
> will install PHP5 only on new servers. Their reasoning was simple: PHP5 
> will inevitably break some old scripts, and it's just not worh all the 
> trouble. Such attitude is common, and it totally makes sence from a 
> business perspective. That begs the question, why PHP developers are so 
> worried about maintaining BC? There is a simple alternative:
> 
>  function class_method($var){ }
> ?>
>  class clazz implements Something{
>  function method($var) {
>  }
> }
> ?>
> 
> So what's the reasoning behind BC maintenanse?

Ummm, maybe your speaking alien, but could you clarify how that solves
the problem you are addressing?

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

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



RE: [PHP] Help with logic :(

2005-10-11 Thread Kilbride, James
Did you remember to open the database connection? 

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 11, 2005 1:34 PM
> To: Dan McCullough
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Help with logic :(
> 
>  
>   include ("../utils.inc");
> 
>   $date = date("U");
>   $dateExpire = $date + 90 * 86400;
> 
>   $code = "jack";
> 
>   $query = "INSERT INTO CouponTable VALUES 
> ('','$date','0','$code','preset','$dateExpire','3.75')";
> 
>   $result = mysql_query($query);
> 
>   echo mysql_error($result);
> 
> ?>
> 
> This SHOULD error out but I'm getting the error instead.
> 
> It's just a test page to test my logic...
> 
> A
> > got some code so we can see?
> >
> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Thanks everyone. Makes sense. Now I got another issue.
> >>
> >> When I try to see if an error exists I get this:
> >>
> >> Warning: mysql_error(): supplied argument is not a valid 
> MySQL-Link 
> >> resource in /home//public_html/Store/test.php on line 14
> >>
> >> Is there a setting somewhere that I need to set to make 
> sure this is 
> >> available?
> >>
> >> Thanks and sorry is these are dumb-ass questions :)
> >>
> >> Aaron
> >>
> >>
> >> > Yes I believe that is what Richard was saying about "Trap the 
> >> > INSERT error", you should get an error back from the 
> database about 
> >> > having a problem with the insert instead of showing that 
> error you 
> >> > will want to add some logic that when that error occurs 
> you simply 
> >> > generate another number.
> >> >
> >> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> >> Hi Richard,
> >> >>
> >> >> Ok... I do already have a Unique index on the column but this 
> >> >> process
> >> is
> >> >> something that I cannot echo out the error code to the 
> user. The 
> >> >> code
> >> is
> >> >> generated on the fly when an order an is placed so you 
> can see... 
> >> >> I can't echo out the error to the customer.
> >> >>
> >> >> Can I do an if statement IF an error is returned to try 
> generatre 
> >> >> another randon code and keep going until one is 
> available? I can 
> >> >> do this all intenrally without the customer knowing/seeing 
> >> >> anything?
> >> >>
> >> >> Hope I am making some sense. Not trying to confuse the issue.
> >> >>
> >> >> Thanks. Appreciate your thoughts.
> >> >>
> >> >> Aaron
> >> >>
> >> >> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
> >> >> >> create a function to check if the rndnumber=couponcode row 
> >> >> >> count =
> >> 0
> >> >> >> if not then redo rndnumber if it does = 0 then 
> insert rndnumber
> >> >> >
> >> >> > N!
> >> >> >
> >> >> > You are creating a RACE CONDITION in which ONE user might 
> >> >> > generate
> >> a
> >> >> > 'valid' code, and ANOTHER user might generate a 
> 'valid' code AT 
> >> >> > THE SAME TIME, and then they BOTH get the same coupon code.
> >> >> >
> >> >> > The probability of this is very very very low, but 
> still NOT zero.
> >> >> >
> >> >> > And it's the kind of thing that won't show up in testing, but 
> >> >> > sure
> >> as
> >> >> > God made little green apples, it WILL happen at the worst 
> >> >> > possible time after you "go live"
> >> >> >
> >> >> > The database engine has a *TON* of code in it to 
> avoid this kind 
> >> >> > of Bad Thing happening.
> >> >> >
> >> >> > Use it.
> >> >> >
> >> >> > create a UNIQUE INDEX on the column that needs to be unique.
> >> >> >
> >> >> > Trap the INSERT error.
> >> >> >
> >> >> > --
> >> >> > Like Music?
> >> >> > http://l-i-e.com/artists.htm
> >> >> >
> >> >> > --
> >> >> > PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, 
> >> >> > visit: http://www.php.net/unsub.php
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> > --
> >> > PHP General Mailing List (http://www.php.net/) To unsubscribe, 
> >> > visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: 
> > http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Help with logic :(

2005-10-11 Thread Silvio Porcellana
[EMAIL PROTECTED] wrote:
>  
>   include ("../utils.inc");
> 
>   $date = date("U");
>   $dateExpire = $date + 90 * 86400;
> 
>   $code = "jack";
> 
>   $query = "INSERT INTO CouponTable VALUES
> ('','$date','0','$code','preset','$dateExpire','3.75')";
> 
>   $result = mysql_query($query);
> 
>   echo mysql_error($result);
> 
> ?>
> 
> This SHOULD error out but I'm getting the error instead.
> 
> It's just a test page to test my logic...
> 

If you read carefully this page:

http://php.net/mysql_error

you will notice that it says that you need to pass to mysql_error *the
MySQL connection*. Not the resource returned by mysql_query.

HTH, cheers
Silvio

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



RE: [PHP] Help with logic :(

2005-10-11 Thread aaronjw
It's open because if I remove the mysql_error(); and change the value for
$code it will insert.

A

> Did you remember to open the database connection?
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, October 11, 2005 1:34 PM
>> To: Dan McCullough
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Help with logic :(
>>
>> >
>>  include ("../utils.inc");
>>
>>  $date = date("U");
>>  $dateExpire = $date + 90 * 86400;
>>
>>  $code = "jack";
>>
>>  $query = "INSERT INTO CouponTable VALUES
>> ('','$date','0','$code','preset','$dateExpire','3.75')";
>>
>>  $result = mysql_query($query);
>>
>>  echo mysql_error($result);
>>
>> ?>
>>
>> This SHOULD error out but I'm getting the error instead.
>>
>> It's just a test page to test my logic...
>>
>> A
>> > got some code so we can see?
>> >
>> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> >> Thanks everyone. Makes sense. Now I got another issue.
>> >>
>> >> When I try to see if an error exists I get this:
>> >>
>> >> Warning: mysql_error(): supplied argument is not a valid
>> MySQL-Link
>> >> resource in /home//public_html/Store/test.php on line 14
>> >>
>> >> Is there a setting somewhere that I need to set to make
>> sure this is
>> >> available?
>> >>
>> >> Thanks and sorry is these are dumb-ass questions :)
>> >>
>> >> Aaron
>> >>
>> >>
>> >> > Yes I believe that is what Richard was saying about "Trap the
>> >> > INSERT error", you should get an error back from the
>> database about
>> >> > having a problem with the insert instead of showing that
>> error you
>> >> > will want to add some logic that when that error occurs
>> you simply
>> >> > generate another number.
>> >> >
>> >> > On 10/11/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> >> >> Hi Richard,
>> >> >>
>> >> >> Ok... I do already have a Unique index on the column but this
>> >> >> process
>> >> is
>> >> >> something that I cannot echo out the error code to the
>> user. The
>> >> >> code
>> >> is
>> >> >> generated on the fly when an order an is placed so you
>> can see...
>> >> >> I can't echo out the error to the customer.
>> >> >>
>> >> >> Can I do an if statement IF an error is returned to try
>> generatre
>> >> >> another randon code and keep going until one is
>> available? I can
>> >> >> do this all intenrally without the customer knowing/seeing
>> >> >> anything?
>> >> >>
>> >> >> Hope I am making some sense. Not trying to confuse the issue.
>> >> >>
>> >> >> Thanks. Appreciate your thoughts.
>> >> >>
>> >> >> Aaron
>> >> >>
>> >> >> > On Mon, October 10, 2005 3:24 pm, Dan McCullough wrote:
>> >> >> >> create a function to check if the rndnumber=couponcode row
>> >> >> >> count > >> 0
>> >> >> >> if not then redo rndnumber if it does = 0 then
>> insert rndnumber
>> >> >> >
>> >> >> > N!
>> >> >> >
>> >> >> > You are creating a RACE CONDITION in which ONE user might
>> >> >> > generate
>> >> a
>> >> >> > 'valid' code, and ANOTHER user might generate a
>> 'valid' code AT
>> >> >> > THE SAME TIME, and then they BOTH get the same coupon code.
>> >> >> >
>> >> >> > The probability of this is very very very low, but
>> still NOT zero.
>> >> >> >
>> >> >> > And it's the kind of thing that won't show up in testing, but
>> >> >> > sure
>> >> as
>> >> >> > God made little green apples, it WILL happen at the worst
>> >> >> > possible time after you "go live"
>> >> >> >
>> >> >> > The database engine has a *TON* of code in it to
>> avoid this kind
>> >> >> > of Bad Thing happening.
>> >> >> >
>> >> >> > Use it.
>> >> >> >
>> >> >> > create a UNIQUE INDEX on the column that needs to be unique.
>> >> >> >
>> >> >> > Trap the INSERT error.
>> >> >> >
>> >> >> > --
>> >> >> > Like Music?
>> >> >> > http://l-i-e.com/artists.htm
>> >> >> >
>> >> >> > --
>> >> >> > PHP General Mailing List (http://www.php.net/) To
>> unsubscribe,
>> >> >> > visit: http://www.php.net/unsub.php
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> > PHP General Mailing List (http://www.php.net/) To unsubscribe,
>> >> > visit: http://www.php.net/unsub.php
>> >> >
>> >> >
>> >>
>> >>
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/) To
>> unsubscribe, visit:
>> > http://www.php.net/unsub.php
>> >
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/) To
>> unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Help with logic :(

2005-10-11 Thread John Nichel

[EMAIL PROTECTED] wrote:



This SHOULD error out but I'm getting the error instead.

It's just a test page to test my logic...

A


Check to see if there is an error first

if ( ! $result = mysql_query ( $query ) ) {
echo ( mysql_error() );
}

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

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



Re: [PHP] Help with logic :(

2005-10-11 Thread Dan McCullough
$result = mysql_query($query) or die(mysql_error());

On 10/11/05, Silvio Porcellana <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> >  >
> >   include ("../utils.inc");
> >
> >   $date = date("U");
> >   $dateExpire = $date + 90 * 86400;
> >
> >   $code = "jack";
> >
> >   $query = "INSERT INTO CouponTable VALUES
> > ('','$date','0','$code','preset','$dateExpire','3.75')";
> >
> >   $result = mysql_query($query);
> >
> >   echo mysql_error($result);
> >
> > ?>
> >
> > This SHOULD error out but I'm getting the error instead.
> >
> > It's just a test page to test my logic...
> >
>
> If you read carefully this page:
>
> http://php.net/mysql_error
>
> you will notice that it says that you need to pass to mysql_error *the
> MySQL connection*. Not the resource returned by mysql_query.
>
> HTH, cheers
> Silvio
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Obsession with BC

2005-10-11 Thread Richard Davey
Hi,

Tuesday, October 11, 2005, 5:41:53 PM, you wrote:

> Recently, I asked my hosting provider when they are going to switch
> to PHP5. They replied that it will not happen any time soon, since
> they will install PHP5 only on new servers. Their reasoning was
> simple: PHP5 will inevitably break some old scripts, and it's just
> not worh all the trouble. Such attitude is common, and it totally
> makes sence from a business perspective.

It does? I wouldn't waste my money with a host that was unable to
provide PHP 5 support, at least in some way. I think the "it will
break lots of scripts" is a cop-out. There are various ways to allow
both on one server. Assuming they're technically proficient enough of
course.

Cheers,

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

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



Re: [PHP] Obsession with BC

2005-10-11 Thread GamblerZG





Ummm, maybe your speaking alien, but could you clarify how that solves
the problem you are addressing?


First, if every version of the language would have it's own tag, then 
there would be no need to maintain BC beyond reasonable necessity.


Second, hosing providers would be more apt to uprade. They would simply 
add new module without removing the old one. This way both old and new 
scripts would work perfectly fine without the need for some kind of 
compatibility mode.


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



Re: [PHP] Obsession with BC

2005-10-11 Thread Dan McCullough
None of my code breaks from 4 to 5, I also run a small hosting company
and I upgrade when I see improvements to the software that would
warrent an upgrade.  MySQL 4.1.12, Apache 2, PHP5.  I also think its a
cop out by those who dont have alot of time to upgrade their 30+
servers.  Another stall or cop-out would be were currently testing
php5 and will have an evaluation in a few weeks *cough* months.

On 10/11/05, Richard Davey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Tuesday, October 11, 2005, 5:41:53 PM, you wrote:
>
> > Recently, I asked my hosting provider when they are going to switch
> > to PHP5. They replied that it will not happen any time soon, since
> > they will install PHP5 only on new servers. Their reasoning was
> > simple: PHP5 will inevitably break some old scripts, and it's just
> > not worh all the trouble. Such attitude is common, and it totally
> > makes sence from a business perspective.
>
> It does? I wouldn't waste my money with a host that was unable to
> provide PHP 5 support, at least in some way. I think the "it will
> break lots of scripts" is a cop-out. There are various ways to allow
> both on one server. Assuming they're technically proficient enough of
> course.
>
> Cheers,
>
> Rich
> --
> Zend Certified Engineer
> http://www.launchcode.co.uk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Obsession with BC

2005-10-11 Thread Kilbride, James
4 to 5 does break a lot of code. On the other hand I agree it's a cop
out. On the final hand, if you pass the pages off from apache to a php
exe or module.. How does Apache know which one to pass it to? Php4 or
Php5? If I have both php4 and php5 code in a page should i run both
sections or only the sections listed for php5(if it's on php5)? If I
only run one then I am maintaining two code branches in the same files.
Seems like a bad idea to me. I don't really see how that idea would work
well. And I do think it seems like a cop out that they can't provide
php5 somehow. 

James Kilbride 

> -Original Message-
> From: Dan McCullough [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 11, 2005 2:04 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Obsession with BC
> 
> None of my code breaks from 4 to 5, I also run a small 
> hosting company and I upgrade when I see improvements to the 
> software that would warrent an upgrade.  MySQL 4.1.12, Apache 
> 2, PHP5.  I also think its a cop out by those who dont have 
> alot of time to upgrade their 30+ servers.  Another stall or 
> cop-out would be were currently testing
> php5 and will have an evaluation in a few weeks *cough* months.
> 
> On 10/11/05, Richard Davey <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Tuesday, October 11, 2005, 5:41:53 PM, you wrote:
> >
> > > Recently, I asked my hosting provider when they are going 
> to switch 
> > > to PHP5. They replied that it will not happen any time 
> soon, since 
> > > they will install PHP5 only on new servers. Their reasoning was
> > > simple: PHP5 will inevitably break some old scripts, and 
> it's just 
> > > not worh all the trouble. Such attitude is common, and it totally 
> > > makes sence from a business perspective.
> >
> > It does? I wouldn't waste my money with a host that was unable to 
> > provide PHP 5 support, at least in some way. I think the "it will 
> > break lots of scripts" is a cop-out. There are various ways 
> to allow 
> > both on one server. Assuming they're technically proficient 
> enough of 
> > course.
> >
> > Cheers,
> >
> > Rich
> > --
> > Zend Certified Engineer
> > http://www.launchcode.co.uk
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: 
> > http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Obsession with BC

2005-10-11 Thread GamblerZG

It does? I wouldn't waste my money with a host that was unable to
provide PHP 5 support, at least in some way. I think the "it will
break lots of scripts" is a cop-out. There are various ways to allow
both on one server. Assuming they're technically proficient enough of
course.


'What is the best way to get to get to Detroit from here?'
'You don't need to go to Detroit. It's cold in there. San-Francisco is 
much better.'


Do you see the problem here? You're not adressing the issue I spoke about.

Issue: I think BC slows down the evolution of the language. I know for 
sure it makes some people less willing to upgrade. And there are ways of 
avoding unnecessary BC maintenance altogether.


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



Re: [PHP] Obsession with BC

2005-10-11 Thread Dan McCullough
The real problem is that it generates customer service and support
calls to the hosting company, which they dont like to have to deal
with, because in the end it will be a coding issue and most of the
people out there wont realize it and get mad and leave.

On 10/11/05, Kilbride, James <[EMAIL PROTECTED]> wrote:
> 4 to 5 does break a lot of code. On the other hand I agree it's a cop
> out. On the final hand, if you pass the pages off from apache to a php
> exe or module.. How does Apache know which one to pass it to? Php4 or
> Php5? If I have both php4 and php5 code in a page should i run both
> sections or only the sections listed for php5(if it's on php5)? If I
> only run one then I am maintaining two code branches in the same files.
> Seems like a bad idea to me. I don't really see how that idea would work
> well. And I do think it seems like a cop out that they can't provide
> php5 somehow.
>
> James Kilbride
>
> > -Original Message-
> > From: Dan McCullough [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, October 11, 2005 2:04 PM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] Obsession with BC
> >
> > None of my code breaks from 4 to 5, I also run a small
> > hosting company and I upgrade when I see improvements to the
> > software that would warrent an upgrade.  MySQL 4.1.12, Apache
> > 2, PHP5.  I also think its a cop out by those who dont have
> > alot of time to upgrade their 30+ servers.  Another stall or
> > cop-out would be were currently testing
> > php5 and will have an evaluation in a few weeks *cough* months.
> >
> > On 10/11/05, Richard Davey <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > Tuesday, October 11, 2005, 5:41:53 PM, you wrote:
> > >
> > > > Recently, I asked my hosting provider when they are going
> > to switch
> > > > to PHP5. They replied that it will not happen any time
> > soon, since
> > > > they will install PHP5 only on new servers. Their reasoning was
> > > > simple: PHP5 will inevitably break some old scripts, and
> > it's just
> > > > not worh all the trouble. Such attitude is common, and it totally
> > > > makes sence from a business perspective.
> > >
> > > It does? I wouldn't waste my money with a host that was unable to
> > > provide PHP 5 support, at least in some way. I think the "it will
> > > break lots of scripts" is a cop-out. There are various ways
> > to allow
> > > both on one server. Assuming they're technically proficient
> > enough of
> > > course.
> > >
> > > Cheers,
> > >
> > > Rich
> > > --
> > > Zend Certified Engineer
> > > http://www.launchcode.co.uk
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/) To
> > unsubscribe, visit:
> > > http://www.php.net/unsub.php
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To
> > unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

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



RE: [PHP] Obsession with BC

2005-10-11 Thread Kilbride, James
I don't mean replace php4 with 5, but it seems odd they can't provide 5
to those users that want it. Keeping php4 for those places that were in
place originally. Especially since not providing any php5 will also
cause people to get mad and leave.

James Kilbride 

> -Original Message-
> From: Dan McCullough [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 11, 2005 2:19 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Obsession with BC
> 
> The real problem is that it generates customer service and 
> support calls to the hosting company, which they dont like to 
> have to deal with, because in the end it will be a coding 
> issue and most of the people out there wont realize it and 
> get mad and leave.
> 
> On 10/11/05, Kilbride, James <[EMAIL PROTECTED]> wrote:
> > 4 to 5 does break a lot of code. On the other hand I agree 
> it's a cop 
> > out. On the final hand, if you pass the pages off from 
> apache to a php 
> > exe or module.. How does Apache know which one to pass it 
> to? Php4 or 
> > Php5? If I have both php4 and php5 code in a page should i run both 
> > sections or only the sections listed for php5(if it's on 
> php5)? If I 
> > only run one then I am maintaining two code branches in the 
> same files.
> > Seems like a bad idea to me. I don't really see how that idea would 
> > work well. And I do think it seems like a cop out that they can't 
> > provide
> > php5 somehow.
> >
> > James Kilbride
> >
> > > -Original Message-
> > > From: Dan McCullough [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, October 11, 2005 2:04 PM
> > > To: php-general@lists.php.net
> > > Subject: Re: [PHP] Obsession with BC
> > >
> > > None of my code breaks from 4 to 5, I also run a small hosting 
> > > company and I upgrade when I see improvements to the 
> software that 
> > > would warrent an upgrade.  MySQL 4.1.12, Apache 2, PHP5.  I also 
> > > think its a cop out by those who dont have alot of time 
> to upgrade 
> > > their 30+ servers.  Another stall or cop-out would be 
> were currently 
> > > testing
> > > php5 and will have an evaluation in a few weeks *cough* months.
> > >
> > > On 10/11/05, Richard Davey <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > Tuesday, October 11, 2005, 5:41:53 PM, you wrote:
> > > >
> > > > > Recently, I asked my hosting provider when they are going
> > > to switch
> > > > > to PHP5. They replied that it will not happen any time
> > > soon, since
> > > > > they will install PHP5 only on new servers. Their 
> reasoning was
> > > > > simple: PHP5 will inevitably break some old scripts, and
> > > it's just
> > > > > not worh all the trouble. Such attitude is common, and it 
> > > > > totally makes sence from a business perspective.
> > > >
> > > > It does? I wouldn't waste my money with a host that was 
> unable to 
> > > > provide PHP 5 support, at least in some way. I think 
> the "it will 
> > > > break lots of scripts" is a cop-out. There are various ways
> > > to allow
> > > > both on one server. Assuming they're technically proficient
> > > enough of
> > > > course.
> > > >
> > > > Cheers,
> > > >
> > > > Rich
> > > > --
> > > > Zend Certified Engineer
> > > > http://www.launchcode.co.uk
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/) To
> > > unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/) To unsubscribe, 
> > > visit: http://www.php.net/unsub.php
> > >
> > >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Speed/Efficiency Question: Large array into DB

2005-10-11 Thread Brent Baisley
Sounds to me like you are trying to import data. In which case it  
would be best to create a text file and import it rather than putting  
PHP in the middle.


But if you are going us to PHP, I would not do individual INSERTs.  
The overhead will really slow things down with number of inserts you  
are doing. Use the multiple value insert syntax and do multiple bulk  
inserts or just one big one. Although doing one big one will end up  
being an all or nothing deal. With multiple bulk inserts, you'd be  
able to write to a log file between inserts so you can track it's  
progress.


I would step through the array, creating the string for inserting  
(value1, value2, value3, value4),(value1, value2, value3, value4), 
(value1, value2, value3, value4),...



On Oct 11, 2005, at 12:28 PM, Alan Lord wrote:


Hi All,

Not being a professional programmer I am looking for some advice about
the best way to do the following:

I have a large multidimensional array (up to 7Mb) It contains a  
list of

categories in a fairly normal Cat_ID and Parent_ID arrangement. The
array also contains a great deal of superfluous information which I  
want

to ignore.

I wish to walk through the entire array, select 4 key/value pairs from
each sub-array and write those to my Database (Keys are: Cat_ID,
Parent_ID, CatName, CatLevel). I wish to ignore all other key/ 
values in

each array.

I'm guessing that I should use array_walk_recursive() and apply my  
test

for valid keys then write this into my db... But, should I do this for
each iteration, or make a new array with just the information I need
then write that into my DB? And do I use a transaction/commit block  
and
try to do the whole thing in one db-write or again, INSERT on each  
step

through my array?

Oh yes, the key names in the array correspond to field names in my
database.

Sorry it's a bit long-winded...

Thanks in advance for any suggestions.

Alan

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





--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



Re: [PHP] Obsession with BC

2005-10-11 Thread Robert Cummings
On Tue, 2005-10-11 at 13:57, GamblerZG wrote:
> >> >>function class_method($var){ }
> >>?>
> >> >>class clazz implements Something{
> >> function method($var) {
> >> }
> >>}
> >>?>
> > 
> > Ummm, maybe your speaking alien, but could you clarify how that solves
> > the problem you are addressing?
> 
> First, if every version of the language would have it's own tag, then 
> there would be no need to maintain BC beyond reasonable necessity.
> 
> Second, hosing providers would be more apt to uprade. They would simply 
> add new module without removing the old one. This way both old and new 
> scripts would work perfectly fine without the need for some kind of 
> compatibility mode.

Sounds like whole different nightmare. I for one don't want to have to
go through all of my code and change http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Picture loaded but not shown

2005-10-11 Thread Bagus Nugroho
Hi,
 
I have problem with picture again.
My picture is loaded, but not shown. It look like if show pictures on internet 
setting is disable.
I was re-install both Apache, mysql and PHP, but can not solved.
 
If anyone have this problem previously, please share
 
Thanks in advance;
regards


Re[2]: [PHP] Obsession with BC

2005-10-11 Thread Richard Davey
Hi,

Tuesday, October 11, 2005, 7:14:05 PM, you wrote:

> Issue: I think BC slows down the evolution of the language. I know
> for sure it makes some people less willing to upgrade. And there are
> ways of avoding unnecessary BC maintenance altogether.

Beyond not staying stuck in the past? Not really. You either code for
PHP4 or you code for 5. If you're really lucky (or just write really
basic scripts) then your code will run on both. If your host doesn't
support 5, they need to wake-up and smell the roses.

Introducing a  tag is the wrong way to address it, never mind
being at the wrong end of the pipeline. If you want to control support
from a code point of view, it's not difficult to detect which version
of PHP your running under. But allowing for that through your entire
codebase is just a tad more work, to say the least.

Backwards compatibility doesn't slow down the evolution of a language
- having no users slows down the evolution of a language. And if PHP
was to totally change its language structure on every new version, I
can't think of too many people that would continue using it. The
changes from 4 to 5 are significant, but not overwhelmingly so. I
envisage that change from 5 to 6 will be significantly less of a jump.

Cheers,

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

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



RE: [PHP] Speed/Efficiency Question: Large array into DB

2005-10-11 Thread Alan Lord
Thanks for the reply.

I am indeed importing data, but from far away over the 'net, and it
changes frequently so needs  updating regularly.

I like the idea of creating a file (I'll do it ram rather than a text
file I think) with the insert strings...

Thanks

Alan

> -Original Message-
> From: Brent Baisley [mailto:[EMAIL PROTECTED] 
> Sent: 11 October 2005 19:35
> To: Alan Lord
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Speed/Efficiency Question: Large array into DB
> 
> Sounds to me like you are trying to import data. In which 
> case it would be best to create a text file and import it 
> rather than putting PHP in the middle.
> 
> But if you are going us to PHP, I would not do individual INSERTs.  
> The overhead will really slow things down with number of 
> inserts you are doing. Use the multiple value insert syntax 
> and do multiple bulk inserts or just one big one. Although 
> doing one big one will end up being an all or nothing deal. 
> With multiple bulk inserts, you'd be able to write to a log 
> file between inserts so you can track it's progress.
> 
> I would step through the array, creating the string for 
> inserting (value1, value2, value3, value4),(value1, value2, 
> value3, value4), (value1, value2, value3, value4),...
> 
> 
> On Oct 11, 2005, at 12:28 PM, Alan Lord wrote:
> 
> > Hi All,
> >
> > Not being a professional programmer I am looking for some 
> advice about 
> > the best way to do the following:
> >
> > I have a large multidimensional array (up to 7Mb) It 
> contains a list 
> > of categories in a fairly normal Cat_ID and Parent_ID 
> arrangement. The 
> > array also contains a great deal of superfluous information which I 
> > want to ignore.
> >
> > I wish to walk through the entire array, select 4 key/value 
> pairs from 
> > each sub-array and write those to my Database (Keys are: Cat_ID, 
> > Parent_ID, CatName, CatLevel). I wish to ignore all other 
> key/ values 
> > in each array.
> >
> > I'm guessing that I should use array_walk_recursive() and apply my 
> > test for valid keys then write this into my db... But, should I do 
> > this for each iteration, or make a new array with just the 
> information 
> > I need then write that into my DB? And do I use a 
> transaction/commit 
> > block and try to do the whole thing in one db-write or 
> again, INSERT 
> > on each step through my array?
> >
> > Oh yes, the key names in the array correspond to field names in my 
> > database.
> >
> > Sorry it's a bit long-winded...
> >
> > Thanks in advance for any suggestions.
> >
> > Alan
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: 
> > http://www.php.net/unsub.php
> >
> >
> >
> 
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
> 
> 
> 

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



[PHP] PDO & pgsql?

2005-10-11 Thread Jeffrey Sambells
I've been playing with the new PDO stuff in PHP 5.1 and am having  
trouble running queries on our database.


I've installed PDO and pdo_pgsql through the pear/pecl installer and  
am trying to use a PostgreSQL 8.x DB. The connection is created fine,  
logged in etc. but when I try to run a query I get a generic SQL  
HY000 error. On the database server, the postgres log reports:



ERROR:  prepared statement "pdo_pgsql_stmt_081ed42c" does not exist


and here's a bit of additional debug stuff from PHP and PDO:


PDO_ATTR_ERRMODE: 0
PDO_ATTR_CLIENT_VERSION: 8.0.2
PDO_ATTR_CONNECTION_STATUS: Connection OK; waiting to send.
PDO_ATTR_SERVER_VERSION: PostgreSQL 8.0.3 on i686-pc-linux-gnu,  
compiled by GCC gcc (GCC) 3.3.5 (Debian 1:3.3.5-13)


and errorInfo() returns:

array(3) {
  [0]=>
  string(5) "HY000"
  [1]=>
  int(7)
  [2]=>
  string(0) ""
}



I am thinking it is something in the PDO_pgsql extension but thought  
I'd ask if anyone has any ideas why it's not working?


Thanks.

-Jeff

~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 office
519.897.2552 mobile

~~
Get Mozilla Firefox at
http://spreadfirefox.com

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



Re: [PHP] mssql_*() functions and stored procedures

2005-10-11 Thread Jochem Maas

Chris Boget wrote:

Looking through the documentation, I see that I can use

mssql_init()
mssql_bind()
mssql_execute()

to execute those stored procedures that have parameters.
But what about those SPs which just return a value?  If I
have the following SP

CREATE PROCEDURE MySP
AS
 DECLARE @resultCode int
 SELECT @resultCode = 539
 RETURN @resultCode
GO

And execute the above as follows

DECLARE @result int;
EXEC @result = MySP;
PRINT @result;


in firebird I would do something like:

SELECT result FROM MySP

maybe that works for you in mssql?



within Query Analyzer, how do I emulate this using the mssql_*()
functions?  Whenever I try to just run the EXEC, I keep getting an
error message saying that I have to declare the @result variable.
I've tried to declare the variable in a seperate mssql_query() call
but that doesn't seem to have an effect.  So how can I do this w/o


is it possible to start a transaction first then run the 2 queries?


getting an error w/r/t variable declaration?

thnx,
Christoph



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



Re: [PHP] Obsession with BC

2005-10-11 Thread Jochem Maas

Robert Cummings wrote:

On Tue, 2005-10-11 at 13:57, GamblerZG wrote:






Ummm, maybe your speaking alien, but could you clarify how that solves
the problem you are addressing?


First, if every version of the language would have it's own tag, then 
there would be no need to maintain BC beyond reasonable necessity.


Second, hosing providers would be more apt to uprade. They would simply 
add new module without removing the old one. This way both old and new 
scripts would work perfectly fine without the need for some kind of 
compatibility mode.



Sounds like whole different nightmare. I for one don't want to have to


yeah - they did this with php3 -> php4, it was a mightmare according to the 
devs,
not so long they reiterated the 'never again' stand point on
[EMAIL PROTECTED]


go through all of my code and change 

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



Re: [PHP] Obsession with BC

2005-10-11 Thread GamblerZG

On the final hand, if you pass the pages off from apache to a php
exe or module.. How does Apache know which one to pass it to? Php4 or
Php5? 


By the processing instruction target. That's what it's there for. I 
guess php 5 and 4 are not the best examples, since php5 already uses 
'


If I have both php4 and php5 code in a page should i run both
sections or only the sections listed for php5(if it's on php5)?


You shouldn't run any sections, and give an error. The whole point is to 
separate different versions of the language instead of mixing them. Do 
you know a lot of scripts which use features specific to both php4 and 
php5? I don't. And it's an awful practice anyway.


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



RE: [PHP] Obsession with BC

2005-10-11 Thread Kilbride, James
Perhaps I'm missing something but doesn't Apache hand off to PHP before
it looks at anything inside the file? Doesn't it hand it off at the fact
that the target is SomeFile.php. So the tag  -Original Message-
> From: GamblerZG [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 11, 2005 2:57 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Obsession with BC
> 
> > On the final hand, if you pass the pages off from apache to 
> a php exe 
> > or module.. How does Apache know which one to pass it to? Php4 or 
> > Php5?
> 
> By the processing instruction target. That's what it's there 
> for. I guess php 5 and 4 are not the best examples, since 
> php5 already uses ' PHP6, and ' 
> > If I have both php4 and php5 code in a page should i run 
> both sections 
> > or only the sections listed for php5(if it's on php5)?
> 
> You shouldn't run any sections, and give an error. The whole 
> point is to separate different versions of the language 
> instead of mixing them. Do you know a lot of scripts which 
> use features specific to both php4 and php5? I don't. And 
> it's an awful practice anyway.
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Obsession with BC

2005-10-11 Thread GamblerZG

Kilbride, James wrote:

Perhaps I'm missing something but doesn't Apache hand off to PHP before
it looks at anything inside the file? Doesn't it hand it off at the fact
that the target is SomeFile.php. So the tag files to php5.. 


I guess you're right. Different filenames would be more appropriate. 
Doing it with different tags is not impossible, but it would not be 
handled by 2 separate modules.


> You can already do this as far as I know.

I _would_ be able to do it if had my own server with full access to 
htconfig. But then I would just use PHP5, since it's so much better than 
4. Moreover, separation is not encouraged by the language itself. There 
are de-facto standards, and handling 5 and 4 separately is not one of 
them. Why?


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



[PHP] onChange js running a php function

2005-10-11 Thread Dan McCullough
Its been awhile since I tried this so I was wondering if anyone had
any luck with this.

I need to get a list of tables from a database, which means I have to
run a function, I would like to have an onChange event run when I
change my selection in a select menu, that would send the value for
the select menu to a php function.
can that be done?

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



Re: [PHP] onChange js running a php function

2005-10-11 Thread tg-php
First, I want to beat everyone to the punch in yelling at you.. "This is not a 
PHP question!!! RTFM STFU NOOB"  or something stupid like that.  hah

But, maybe it seems like it COULD be a PHP question. And it's definitely 
relevant to PHP development, so how about we give a REAL answer instead of just 
yelling. :)

Here's what I think..

1. onChange runs a JS function that checks the value of the SELECT that just 
changed
2. JS function then redirects to the same script but with 
scriptname.php?select=selectvalue
3. PHP reads the $_GET['select'] selectvalue and performs appropriate DB pull

Voila! (or viola if you're more musical than french)

-TG

= = = Original message = = =

Its been awhile since I tried this so I was wondering if anyone had
any luck with this.

I need to get a list of tables from a database, which means I have to
run a function, I would like to have an onChange event run when I
change my selection in a select menu, that would send the value for
the select menu to a php function.
can that be done?


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

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



Re: [PHP] Obsession with BC

2005-10-11 Thread Stephen Leaf
On Tuesday 11 October 2005 01:56 pm, GamblerZG wrote:
> > On the final hand, if you pass the pages off from apache to a php
> > exe or module.. How does Apache know which one to pass it to? Php4 or
> > Php5?
>
> By the processing instruction target. That's what it's there for. I
> guess php 5 and 4 are not the best examples, since php5 already uses
> '
> > If I have both php4 and php5 code in a page should i run both
> > sections or only the sections listed for php5(if it's on php5)?
>
> You shouldn't run any sections, and give an error. The whole point is to
> separate different versions of the language instead of mixing them. Do
> you know a lot of scripts which use features specific to both php4 and
> php5? I don't. And it's an awful practice anyway.

I personally know that my code will break if ran on php4.
This is not because I have bad practices. it's because I choose to use the 
better functions of php5 verse the older and not so good functions of php4.
specifically I am talking about the XSL and DOM functions.
I also know that I had to update my php4 scripts because they removed the 
older functions in php5. this again is not bad practice it was using the 
available functions in php4 and the devs removing them in 5.

http://www.php.net/manual/en/ref.xslt.php
http://www.php.net/manual/en/ref.xsl.php

right there you have examples of how 4 scripts break in 5 and 5 breaks in 4.
anyone who uses/used these functions is stuck in 1 version or the other.

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



Re: [PHP] onChange js running a php function

2005-10-11 Thread Brent Baisley
As someone else mentioned, this isn't really PHP. You could be using  
any server side language. It's really a javascript question.


But to answer your question, the functionality you are looking for  
has lately been being solved by using AJAX. Search the list archives  
for some links to some quick tutorials on how to implement  
Asynchronous JAvascript requests. The X in AJAX is XML, but you don't  
have to transfer the data using XML, you can use plain text.


On the server side, PHP can't tell that it is getting a request from  
a javascript function, so there's really nothing special to do in PHP.



On Oct 11, 2005, at 4:11 PM, Dan McCullough wrote:


Its been awhile since I tried this so I was wondering if anyone had
any luck with this.

I need to get a list of tables from a database, which means I have to
run a function, I would like to have an onChange event run when I
change my selection in a select menu, that would send the value for
the select menu to a php function.
can that be done?

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





--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



Re: [PHP] Obsession with BC

2005-10-11 Thread GamblerZG

Richard Davey wrote:

You either code for PHP4 or you code for 5.


That's exactly my point.


Backwards compatibility doesn't slow down the evolution of a language


Not true. Quite a few of the discussions of new features and even some 
bugfixes end up on "can't be done because of BC".



And if PHP
was to totally change its language structure on every new version, I
can't think of too many people that would continue using it. 


Did I say something about totally changing the language structure? Where?

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



[PHP] object as function argument

2005-10-11 Thread Björn Bartels
Hello there,

myab ths a stupid question, but i didn't find anything inside the php
docs:

is it possibe to pass an object (like $foo = new myObject(); ) to a
function as its argument (like my_func($foo); )

thanx a lot

Björn Bartels
-Development/IT-Services-

--
dbusiness.de gmbh
digital business & printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org

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

Re: [PHP] object as function argument

2005-10-11 Thread Jasper Bryant-Greene

Björn Bartels wrote:

myab ths a stupid question, but i didn't find anything inside the php
docs:

is it possibe to pass an object (like $foo = new myObject(); ) to a
function as its argument (like my_func($foo); )


Yes, but if you're using PHP 4 you may want to define the function as 
taking that argument by reference (&$foo) unless you want to pass a copy 
of the object.


It would have taken you less time to write a test script and see for 
yourself than to search the docs and then post to the list...


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] Get Mac Address

2005-10-11 Thread Rory Browne
> Hi Ben,
>
> Try:
>
> /* notice the backtics, and that arp on linux usually needs to run as root
Which means that you either have to install sudo, or set the suid bit.


> */
> $arpoutput = `/sbin/arp -a`;

Do a "man arp" on linux to see what form of the arp command you want.
It's a while since I used it.

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

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



[PHP] Re: Sequential multiple file download?

2005-10-11 Thread Oliver Grätz
This can't be easily done. The natural way of doing this would involve
sending some HTTP headers but this is not possible once you've started
sending data for the first file.

The hard way of doing this is a 2-way approach where you have two
connections: a data connection and a control connection. This of course
requires you to use JavaScript. The control connection to the server
would periodically be asking if sending a download has finished. This
could be done with Ajax techniques and some kind of server side database
or session store for the information about the finished downloads. The
other connection would then be triggered as a redirect from JavaScript
that fires up another download.

Of course there might be other solutions but none of them are really
easy to implement. If you are targeting a closed audience you might
change your approach to sending some kind of download list that triggers
a download manager.


AllOLLi

Byers: "What proof do you have?"
Bond: "I got this!"
Byers: "You're on the phone, Jimmy!"
[Lone Gunmen 09]

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



[PHP] Re: Store a variable name in a database field.

2005-10-11 Thread Oliver Grätz
Yep, code sample, please. Your question is not describing your problem
clearly enough.

OLLi

If at first you don't succeed, call it version 1.0

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



[PHP] trouble with generating the file attachment

2005-10-11 Thread Ricardo Ferreira








Hi, 

 

I have the
two files which I send as an attachment.
One is simple form with a file upload box. The
other is the corresponding PHP file which sends the
information via e-mail. I used the code
provided here (http://pt.php.net/de/imap_mail_compose)
but something must be wrong.
Perhaps you can provide me with some explanation

 

Thanks

 

RF 






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