[PHP] newbie question about storing big5 codes into mysql-5.0.24a

2007-03-23 Thread Man-wai Chang

create table temp ( big5 char(2) ) character set big5 collate big5_bin;
insert into temp ( big5 ) values ( 0x9f54 );
insert into temp ( big5 ) values ( 0x9f53 );

The 2nd query will report duplicated key. How should I fix the problem?

-- 
  .~.   Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
 / v \  Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10)  Linux 2.6.20.4
  ^ ^   15:46:01 up 2:58 1 user load average: 2.32 1.73 1.48
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

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



[PHP] Re: Another SimpleXMLElement question...

2007-03-23 Thread Haydar TUNA
Hello,
This is Simple XML extensions. The SimpleXML extension requires PHP 5!. For 
this reason you can only use other XML extensions such as XML parser.:)


-- 
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

"Mikey" <[EMAIL PROTECTED]>, haber iletisinde sunlari 
yazdi:[EMAIL PROTECTED]
> If at first you don't succeed...
>
> Our production environment is running on an old version of PHP 5.0 and 
> cannot be easily updated.  My problem is that I have developed code 
> against a new version and it has the SimpleXMLElement::addChild() 
> function, but this is not present on the older version of PHP.
> Does anyone know how to work around this?  Can I just treat the 
> SimpleXMLElement object as an array and append as I see fit?
>
> regards,
>
> Mikey 

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



Re: [PHP] usage of flock

2007-03-23 Thread Myron Turner

Richard Lynch wrote:

On Fri, March 23, 2007 7:52 pm, Yvan Strahm wrote:
  

I am confused with the flock function and its usage. I have jobs which
are
stored in a database, these jobs are run by a series of job_runners
scripts
but sometimes the job_runners stop ( server or php crash-down). So i
put a
job_controller in crontab to check  regularly if the  runners run. But
after
a while I have a bunch of job_controller running, so to avoid that I
tried
to use flock.

I try to put this in the job_controller:

$wouldblock=1;
$f=fopen("controller.lock", "r");
flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");

hoping that as long as the first job_controller run or don't close the
file
handle, a second job_controller won't be able to lock the
controller.lockfile and die, but it didn't work.

I also try this:

$wouldblock=1;
$f=fopen("controller.php", "r");
flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");

hoping the first job_controller will lock it-self, but it didn't work.

I also thought of writing in the lock file the PID of the first
job_controller and then compare it and if it doesn't match then die,
but my
main concern is , if the server crash down the "surviving" lock file
will
prevent any job_controller to start.

So how could prevent multiple instance of the same script? Is flock
the best
way?



You can do it with flock, but then you end up sooner or later with a
locked file from an "exit" or killed script, and then you have to know
to remove locks older than X minutes.

You could also just do a "mkdir" for your lock, and check its
filemtime.  You could even use "touch" within loop of the script to
make sure the script is still going, and safely assume that any lock
older than X seconds is stale and can be ignored/removed.
  
I've never used locks in PHP, but have used them in Perl.  In Perl a 
lock is automatically released on exit or when the locked file is 
closed.  Is that not the same in PHP?  According the the man page for 
the C version of flock, it too releases the lock on close and C's exit 
closes all streams.  So, Perl is consistent with that.  Just wondering 
for myself it this isn't the case with PHP, in case I ever  want to use 
a lock.


It's not clear to me from the original question, Yvan, whether you are 
able to get any lock at all.  That is, if you are using LOCK_NB and a 
lock is already on the locked file, then the lock will be refused and 
the call will return immediately without a lock.  So, the only way to 
use LOCK_NB is in a loop.  Generally, this is not recommended, because 
in the time the loop gets back to making a second call, another file 
might have gotten the lock.  However, in your case this might not 
matter, since you are the only one sending out these job controllers, 
and eventually all your processes will have had a chance at the lock file.


On the other hand, if you use LOCK_EX, the call will block until a lock 
is available.  Again, in your case this might not matter either.  The 
danger here is that you will get a process that doesn't shut down.  You 
can deal with this by setting an alarm which is caught using a signal 
handler that can exit the process.


If you use LOCK_NB with a loop, you can also break out of the loop and 
exit after a time as well. You'd probably want to use sleep to time your 
loop, not a counter, since the counter might swallow up cpu.


--

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

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



RE: [PHP] Question before upgrading to 5

2007-03-23 Thread Jake McHenry
Yea, that's what I was planning on doing, but the way I had my original
configure options file set up it would have over written php4... Which turns
out after my testing today it would have been ok :) ... But I installed a
new copy of apache and php just to be safe... It only took an extra 10
minutes... No biggie.. 

Thanks 
Jake
 

> -Original Message-
> From: Richard Lynch [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 8:59 PM
> To: Jake McHenry
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Question before upgrading to 5
> 
> On Thu, March 22, 2007 6:23 am, Jake McHenry wrote:
> >
> > Sorry about the delivery and read requests.. I was tired 
> and forgot to
> > turn
> > them off for the list..
> >
> >> alternatively you can search for 'Rasmus' and 'ProxyPass' in the
> >> list
> >> archive and use Rasmus' rather cool ProxyPass solution to running
> >> both
> >> php4 and php5 ... his explanation should give you enough info
> >> to set it up.
> >>
> >
> > I don't need them running parallel, only both installed
> 
> In that case, carefully commenting in/out the right LoadModule and so
> on in httpd.conf should let you switch back and forth.
> 
> Just be sure to re-start Apache after you change.
> 
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



RE: [PHP] Configure question

2007-03-23 Thread Jake McHenry
I scanned over it quick.. Looks interesting.. Thanks :) I'll get into it
more tomorrow

Jake 

> -Original Message-
> From: Jochem Maas [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 7:58 PM
> To: Jake McHenry
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Configure question
> 
> Jake McHenry wrote:
> > I searched the archives... Haven't seen an answer to this yet
> > 
> > Does anyone know why Virtual Directory Support is enabled 
> on windows, but
> > disabled on unix? And what exactly is it? I know I can enable it by
> > --enable-maintainer-zts, but it says in configure that it 
> is "Thread Safety"
> > for code maintainers only What exactly does this do? I found one
> > reference by google that says funky stuff may happen with 
> this enabled...??
> > I haven't tested it, I could try and let everyone know, but 
> thought I would
> > ask first.
> 
> I can't really give you an answer that is worth ,
> but this blog post might interest you:
> 
> http://blog.libssh2.org/index.php?/archives/22-What-the-heck-i
> s-TSRMLS_CC-anyway.html
> 
> also I would recommend searching the internals list archives 
> - stuff like this
> gets discussed there more and more often.
> 
> > 
> > 
> > Thanks,
> > Jake
> > 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release 
> Date: 3/22/2007 7:44 AM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



RE: [PHP] What is wrong with this function please?

2007-03-23 Thread Jake McHenry
Have you changed anything in an hour? I'm too lazy to compare the two
emails...

Jake 

> -Original Message-
> From: Robin Wilson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 10:46 PM
> To: php-general@lists.php.net
> Subject: [PHP] What is wrong with this function please?
> 
> Hello
> 
> I'm trying to do a function that emails users and sends an 
> attachment. But I 
> think something is in the wrong order or something as when I send it 
> Exchange discards it.
> 
> This is the function which I have put together from various sources:
> 
> I would really appreciate any help as I have been up half the 
> night and got 
> nowhere!
> Thanks
> Robin
> 
> function sendMail($to, $toName, $from, $fromName, $subject, $message, 
> $uploadfile, $fileName, $fileType, $fileSize) {
>  $eol="\r\n";
>   $mime_boundary=md5(time());
> 
>   # Common Headers
>   $headers .= 'From: '. $fromName .' <'. $from .'>'.$eol;
>   $headers .= 'Reply-To: '. $toName .' <'. $to .'>'.$eol;
>   $headers .= 'Return-Path: '. $fromName.' <'. $from 
> .'>'.$eol;// these 
> two to set reply address
>   $headers .= "Message-ID: 
> <".$mime_boundary."@".$_SERVER['SERVER_NAME'].">".$eol;
>   $headers .= "X-Mailer: PHP v".phpversion().$eol;  
> // These two to 
> help avoid spam-filters
> 
>   # Boundry for marking the split & Multitype Headers
>   $headers .= 'MIME-Version: 1.0'.$eol;
>   $headers .= "Content-Type: multipart/related; 
> boundary=\"".$mime_boundary."\"".$eol;
> 
>  $msg = " ";
> 
>  if ($uploadfile != "") {
>   # File for Attachment
>$file_name = substr($uploadfile, (strrpos($uploadfile, 
> "/")+1));
> 
>$handle=fopen($uploadfile, 'rb');
>$f_contents=fread($handle, $fileSize);
>$f_contents=chunk_split(base64_encode($f_contents));   
>  //Encode The 
> Data For Transition using base64_encode();
>fclose($handle);
> 
># Attachment
>$msg .= "--".$mime_boundary.$eol;
>$msg .= "Content-Type: ".$fileType."; 
> name=\"".$file_name."\"".$eol;
>$msg .= "Content-Transfer-Encoding: base64".$eol;
>$msg .= "Content-Disposition: attachment; 
> filename=\"".$file_name."\"".$eol.$eol; // !! This line needs 
> TWO end of 
> lines !! IMPORTANT !!
>$msg .= $f_contents.$eol.$eol;
>  }
> 
>  # Setup for text OR html
>$msg .= "Content-Type: multipart/alternative".$eol;
> 
># Text Version
>$msg .= "--".$mime_boundary.$eol;
>$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
>$msg .= "Content-Transfer-Encoding: 8bit".$eol;
>$msg .= strip_tags(str_replace("", "\n", $message)).$eol.$eol;
> 
># HTML Version
>$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
>$msg .= "Content-Transfer-Encoding: 8bit".$eol;
>$msg .= $message.$eol.$eol;
> 
># Finished
>$msg .= "--".$mime_boundary."--".$eol.$eol;  // finish 
> with two eol's for 
> better security. see Injection.
> 
> 
>  // Mail it
>  mail($to, $subject, $msg, $headers);
> }
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release 
> Date: 3/22/2007 7:44 AM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



RE: [PHP] What is wrong with this function please?

2007-03-23 Thread Jake McHenry
I take it there are no errors... And your using windows... Sending to
exchange... I guess with seeing what you posted, I would start by echoing
out what you have in  $to, $subject, $msg, $headers. Are there any errors in
Exchange logs? Do you see the message coming into Exchange queue?

Jake


> -Original Message-
> From: Robin Wilson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 9:53 PM
> To: php-general@lists.php.net
> Subject: [PHP] What is wrong with this function please?
> 
> Hello
> 
> I'm trying to do a function that emails users and sends an 
> attachment. But I 
> think something is in the wrong order or something as when I send it 
> Exchange discards it.
> 
> This is the function which I have put together from various sources:
> 
> I would really appreciate any help as I have been up half the 
> night and got 
> nowhere!
> Thanks
> Robin
> 
> function sendMail($to, $toName, $from, $fromName, $subject, $message, 
> $uploadfile, $fileName, $fileType, $fileSize) {
>  $eol="\r\n";
>   $mime_boundary=md5(time());
> 
>   # Common Headers
>   $headers .= 'From: '. $fromName .' <'. $from .'>'.$eol;
>   $headers .= 'Reply-To: '. $toName .' <'. $to .'>'.$eol;
>   $headers .= 'Return-Path: '. $fromName.' <'. $from 
> .'>'.$eol;// these 
> two to set reply address
>   $headers .= "Message-ID: 
> <".$mime_boundary."@".$_SERVER['SERVER_NAME'].">".$eol;
>   $headers .= "X-Mailer: PHP v".phpversion().$eol;  
> // These two to 
> help avoid spam-filters
> 
>   # Boundry for marking the split & Multitype Headers
>   $headers .= 'MIME-Version: 1.0'.$eol;
>   $headers .= "Content-Type: multipart/related; 
> boundary=\"".$mime_boundary."\"".$eol;
> 
>  $msg = " ";
> 
>  if ($uploadfile != "") {
>   # File for Attachment
>$file_name = substr($uploadfile, (strrpos($uploadfile, 
> "/")+1));
> 
>$handle=fopen($uploadfile, 'rb');
>$f_contents=fread($handle, $fileSize);
>$f_contents=chunk_split(base64_encode($f_contents));   
>  //Encode The 
> Data For Transition using base64_encode();
>fclose($handle);
> 
># Attachment
>$msg .= "--".$mime_boundary.$eol;
>$msg .= "Content-Type: ".$fileType."; 
> name=\"".$file_name."\"".$eol;
>$msg .= "Content-Transfer-Encoding: base64".$eol;
>$msg .= "Content-Disposition: attachment; 
> filename=\"".$file_name."\"".$eol.$eol; // !! This line needs 
> TWO end of 
> lines !! IMPORTANT !!
>$msg .= $f_contents.$eol.$eol;
>  }
> 
>  # Setup for text OR html
>$msg .= "Content-Type: multipart/alternative".$eol;
> 
># Text Version
>$msg .= "--".$mime_boundary.$eol;
>$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
>$msg .= "Content-Transfer-Encoding: 8bit".$eol;
>$msg .= strip_tags(str_replace("", "\n", $message)).$eol.$eol;
> 
># HTML Version
>$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
>$msg .= "Content-Transfer-Encoding: 8bit".$eol;
>$msg .= $message.$eol.$eol;
> 
># Finished
>$msg .= "--".$mime_boundary."--".$eol.$eol;  // finish 
> with two eol's for 
> better security. see Injection.
> 
> 
>  // Mail it
>  mail($to, $subject, $msg, $headers);
> } 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release 
> Date: 3/22/2007 7:44 AM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



[PHP] What is wrong with this function please?

2007-03-23 Thread Robin Wilson

Hello

I'm trying to do a function that emails users and sends an attachment. But I 
think something is in the wrong order or something as when I send it 
Exchange discards it.


This is the function which I have put together from various sources:

I would really appreciate any help as I have been up half the night and got 
nowhere!

Thanks
Robin

function sendMail($to, $toName, $from, $fromName, $subject, $message, 
$uploadfile, $fileName, $fileType, $fileSize) {

$eol="\r\n";
 $mime_boundary=md5(time());

 # Common Headers
 $headers .= 'From: '. $fromName .' <'. $from .'>'.$eol;
 $headers .= 'Reply-To: '. $toName .' <'. $to .'>'.$eol;
 $headers .= 'Return-Path: '. $fromName.' <'. $from .'>'.$eol;// these 
two to set reply address
 $headers .= "Message-ID: 
<".$mime_boundary."@".$_SERVER['SERVER_NAME'].">".$eol;
 $headers .= "X-Mailer: PHP v".phpversion().$eol;  // These two to 
help avoid spam-filters


 # Boundry for marking the split & Multitype Headers
 $headers .= 'MIME-Version: 1.0'.$eol;
 $headers .= "Content-Type: multipart/related; 
boundary=\"".$mime_boundary."\"".$eol;


$msg = " ";

if ($uploadfile != "") {
 # File for Attachment
  $file_name = substr($uploadfile, (strrpos($uploadfile, "/")+1));

  $handle=fopen($uploadfile, 'rb');
  $f_contents=fread($handle, $fileSize);
  $f_contents=chunk_split(base64_encode($f_contents));//Encode The 
Data For Transition using base64_encode();

  fclose($handle);

  # Attachment
  $msg .= "--".$mime_boundary.$eol;
  $msg .= "Content-Type: ".$fileType."; name=\"".$file_name."\"".$eol;
  $msg .= "Content-Transfer-Encoding: base64".$eol;
  $msg .= "Content-Disposition: attachment; 
filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of 
lines !! IMPORTANT !!

  $msg .= $f_contents.$eol.$eol;
}

# Setup for text OR html
  $msg .= "Content-Type: multipart/alternative".$eol;

  # Text Version
  $msg .= "--".$mime_boundary.$eol;
  $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  $msg .= strip_tags(str_replace("", "\n", $message)).$eol.$eol;

  # HTML Version
  $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  $msg .= $message.$eol.$eol;

  # Finished
  $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for 
better security. see Injection.



// Mail it
mail($to, $subject, $msg, $headers);
}

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



[PHP] What is wrong with this function please?

2007-03-23 Thread Robin Wilson

Hello

I'm trying to do a function that emails users and sends an attachment. But I 
think something is in the wrong order or something as when I send it 
Exchange discards it.


This is the function which I have put together from various sources:

I would really appreciate any help as I have been up half the night and got 
nowhere!

Thanks
Robin

function sendMail($to, $toName, $from, $fromName, $subject, $message, 
$uploadfile, $fileName, $fileType, $fileSize) {

$eol="\r\n";
 $mime_boundary=md5(time());

 # Common Headers
 $headers .= 'From: '. $fromName .' <'. $from .'>'.$eol;
 $headers .= 'Reply-To: '. $toName .' <'. $to .'>'.$eol;
 $headers .= 'Return-Path: '. $fromName.' <'. $from .'>'.$eol;// these 
two to set reply address
 $headers .= "Message-ID: 
<".$mime_boundary."@".$_SERVER['SERVER_NAME'].">".$eol;
 $headers .= "X-Mailer: PHP v".phpversion().$eol;  // These two to 
help avoid spam-filters


 # Boundry for marking the split & Multitype Headers
 $headers .= 'MIME-Version: 1.0'.$eol;
 $headers .= "Content-Type: multipart/related; 
boundary=\"".$mime_boundary."\"".$eol;


$msg = " ";

if ($uploadfile != "") {
 # File for Attachment
  $file_name = substr($uploadfile, (strrpos($uploadfile, "/")+1));

  $handle=fopen($uploadfile, 'rb');
  $f_contents=fread($handle, $fileSize);
  $f_contents=chunk_split(base64_encode($f_contents));//Encode The 
Data For Transition using base64_encode();

  fclose($handle);

  # Attachment
  $msg .= "--".$mime_boundary.$eol;
  $msg .= "Content-Type: ".$fileType."; name=\"".$file_name."\"".$eol;
  $msg .= "Content-Transfer-Encoding: base64".$eol;
  $msg .= "Content-Disposition: attachment; 
filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of 
lines !! IMPORTANT !!

  $msg .= $f_contents.$eol.$eol;
}

# Setup for text OR html
  $msg .= "Content-Type: multipart/alternative".$eol;

  # Text Version
  $msg .= "--".$mime_boundary.$eol;
  $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  $msg .= strip_tags(str_replace("", "\n", $message)).$eol.$eol;

  # HTML Version
  $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  $msg .= $message.$eol.$eol;

  # Finished
  $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for 
better security. see Injection.



// Mail it
mail($to, $subject, $msg, $headers);
} 


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



Re: [PHP] Name Capitalization

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 1:03 pm, Paul Novitski wrote:
> At 3/21/2007 04:57 AM, Shafiq Rehman wrote:
>>Some problems are universal and we cannot fix them in computer
>> science. I
>>think it's better to educate/guide your visitors about such names
>> that they
>>write in correct capitalization
>
>
> In this case, the OP has an existing list of names he wants to
> de-capitalize, not an ongoing stream of new names from people who
> might be trained.

The solution remains:

Hire a human.

The computer will never get accurate enough.

The exception might be if you are dealing with MILLIONS of names,
where a filter would pay off.  You'd still need human review and a
validation process that involved human oversight to a significant
percentage.

I do not think the OP has millions of names.

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

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



Re: [PHP] Reuse PHP functions in a third-party application

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 3:34 am, Robert Enyedi wrote:
> Thanks for the info. Under these circumstances I suppose that the CGI
> calling mode is the best suited.
>
> On the other hand this option might raise some performance penalty. I
> wonder if better performance could be achieved if I would use a socket
> based call interface to my module running inside the running PHP
> server.

Possibly.

Worth trying if you can get the sockets to work quickly.

You could always try the CLI first, and see if performance is "good
enough"

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

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



Re: [PHP] Out source files

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 4:36 am, Manuel Vacelet wrote:
> My main question is "What happens if there is bug in my application,
> if someone exploit a vulnerability of php or apache?".

You will never ever have 100% guarantee that it's safe.

Anybody who tells you that you do is lying.

Or very stupid.

Or quite possibly both. :-)

So the answer to this one will always be "There *might* be some way
this can be cracked"

Your job is to reduce risk, not eliminate it completely.  If your boss
or client is telling you differently, you might as well quit right
now, because they don't understand your job, and you are taking all
the risks, not they, and that's just plain wrong.

> First threat:
> Due to the usage of PHP as an apache module, a vulnerability in one of
> these 3 elements can let cracker by pass the application security
> model (by pass the group access rights) because I cannot have
> protection at the OS level (because to be able to server the file for
> all groups my application must be able to read all the data whatever
> the protection is).

You could consider reducing this risk by having a separate pool of
Apache servers for each group, with their own user running Apache, so
that they do not have read access to the other groups' files. 
Performance may suck, particularly for a large number of groups, and
this will not "scale" well.

Another option, as I understand it, is to run one Apache, but a
different FastCGI per vhost, with different user and files owned by
that user. (I'm less certain that this is possible...)  FCGI
performance rivals Module, and also scales well, as I understand it.

> Second threat:
> As I already explained, a cracker could upload with standards
> procedure a dangerous executable and with some vulnerabilities makes
> it executable and runs it.

To reduce this risk, you could attempt to closely monitor users, and
limit access to the box as much as possible.

A cron job to do ps aux and then grep out the jobs you EXPECT to
see, and raise an alarm for anything "unusual" might be do-able.  This
is a "blacklist" approach, so not perfect, but worth trying,
considering the effort it would take (minimal, really)

Store the executables on a DIFFERENT box, with, perhaps, only root and
nobody user.  Kinda hard for 'nobody' to get access.  And if they get
'root', well, it's game over for that box anyway.

You could even consider applying a "secret" reversible function (such
as 2-way encryption) that would make the file saved on disk
non-operable as an executable file.  I.e., your potential cracker has
to gain access to the box, get the file to be 'executable', *AND*
guess which algorithm you did to the file and undo that into another
file, and then execute the un-scrambled file.  It is somewhat of
"security through obscurity" but as another hurdle in a line of
defence, is worth at least considering.

> I hope this clarify my needs,

You may want to try to get in touch with OpenSource people who host
binary files in large numbers, such as SourceForge, and ask what they
do.  It's not really PHP-specific, at the level that you are worrying
about.

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

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Edward Vermillion


On Mar 23, 2007, at 8:32 PM, Jake McHenry wrote:




On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with

PHP4 and GD

lib
2.0.33 and everything produces with them got rejected so far. I was
also
going through the comments on php.net regarding self-written
Bicubical
algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much

better when

using the 'mogrify' tool from this package, yet not good enough
for my
designers.

Of course, their expectations are very high because of their daily
usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows
library.
Using a commercial package would be completely fine for

me, however I

just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.




What are their expectations and what is the use for the final output?

Also, what are they saying is wrong with the files? (I'm guessing
they are to 'fuzzy', that's the main gripe I have with GD. But it
doesn't stop me from using it to resize images for a web
page, unless
you're resizing large images with text down to a 'usable' size.)

Are they just being 'designers' and nothing is going to be good
enough but photoshop?

Maybe PHP/Unix isn't the way to go?

Ed



Yea.. Go mac if you want the best for pics :) and its still unix :



That's the only reason I'm on a mac... instead of linux like I'd  
rather be.


If you don't *have* to be using php/unix, there are some nice hooks  
into photoshop either through javascript, applescript or (at least  
with ps7 years ago) vb.net. I've done some automation through that  
before and had very good results resizing and archiving images for a  
professional photo lab. Maybe a web service into a mac box with  
photoshop? Really depends on what you're trying to do and what your  
setup is.


Ed

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



Re: [PHP] Flash animation without install Flash!

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 4:58 am, Helder Lopes wrote:
> Because the problems with virus in internet the people dont install
> activex
> controls.
> My question is:
>
> How to put a flash in the website without asking the person to install
> activex control??

A) There is no PHP in this question.
B) Flash does not rely on ActiveX to work in any way.
C) Note that some people (me) have given up completely on Flash, and
never install that either, so you're losing at least one visitor just
by using Flash.

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

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



Re: [PHP] trouble with function openssl_csr_new()

2007-03-23 Thread Richard Lynch




On Wed, March 21, 2007 5:05 am, Albert Kopka wrote:
>
> Hi ...
>
> I want to generate certificate for smardcard login (MS Win-XP)
> and for do that the subject of certificate should contain same key
> (in key:value of $dn) multiple times for example ...
>
> cert generated by ca suplied with W-2003 server for smartcard login
> contains:
>   Subject: DC = local, DC = foo, CN = Users, CN = bar
>
> but $dn is an array ... so if I define array as:
>
> $dn = array ( "DC" => "local", "DC" => "foo" );
>
> I've got array with one key:value pair "DC" => "foo" ...
>
> Is there any other way to pass the $dn to function ...
> (using other structure ... or formated string ... )
> or mayby I can use other function whitch supports repeated keys ?

WILD GUESS!!!

If the person who wrote openssl_csr_new() thinks like I do, maybe:
$dn = array("DC"=>array("local","foo"), "CN"=>"Users");

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

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



Re: [PHP] read only texbox to html with php

2007-03-23 Thread Richard Lynch
The fact that you are using stripslashes tells me that something is
very very very wrong somewhere...

For output to the textarea, just htmlentities should be sufficient.

Emailing HTML "enhanced" newsletter will reduce the number of people
who actually read the dang thing, you know.

On Wed, March 21, 2007 6:51 am, Ross wrote:
> I have a readonly textbox that gets mailed as a newsletter. The text
> is a
> standard covering letter. The problem is when I try and convert it to
> html
> it doesn't work  It is inserted into a variable via a form textarea
> $mail_text.
>
>  "available on the web site  href="http://www.myurl.org";>http://www.myurl.org so you can see
> who is
> doing."
>
> I tried this
>
> htmlentities((stripslashes($mail_text)));
>
>
> Any ideas?
>
> R.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

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



Re: [PHP] Re: Random Unique ID

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 5:40 pm, [EMAIL PROTECTED] wrote:
> Thanks.  Yes, I check for errors.  But there are other types of errors
> so I'd need to verify that it is a duplicate key error and, in my
> ignorance, I have not yet figured out how to do that programatically.
> I worry about getting into an infinite loop.

Untested code:

//create table test_id (id char(32) unique not null primary key));

$success = 0;
while (!$success){
  $id = md5(uniqid());
  $query = "insert into test_id (id) values('$id')";
  $result = mysql_query($query);
  if (!$result){
//I don't promise 1023 is right.
//force a duplicate as a test to confirm
if (mysql_errno() == 1023){
  //duplicate key
  //we'll loop back and try with another
}
else{
  echo "Something went wrong with our database. Sorry.";
  error_log(mysql_error());
  break;
}
  }
  else{
$success = 1;
  }
}

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

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



Re: [PHP] Random Unique ID

2007-03-23 Thread Richard Lynch
Use auto_increment.

It's not random, but you should never show it to the end user anyway,
so who cares?

Another option is to use http://php.net/uniqid and you can create a
UNIQUE INDEX on the column and simply check mysql_errno() to see if
it's 1023 (or is it 2023?) when you insert to see if you had a
collision.

On Wed, March 21, 2007 12:18 pm, [EMAIL PROTECTED] wrote:
> Hello,
>
> I want to add a random unique ID to a Mysql table.  Collisions
> are unlikely but possible so to handle those cases I'd like to
> regenerate the random ID until there is no collision and only
> then add my row.  Any suggestions for a newbie as to the right
> way to go about doing this?
>
> Best,
>
> Craig
>
>  --
>  - Virtual Phonecards - Instant Pin by Email  -
>  -   Large Selection - Great Rates-
>  - http://speedypin.com/?aff=743&co_branded=1 -
>  --
>
>
> **
> **
> *  Craig Spencer *
> *  [EMAIL PROTECTED]*
> **
> **
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

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



RE: [PHP] High quality image resizing

2007-03-23 Thread Jake McHenry
> 
> > On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:
> >> I'm searching for a high quality image resizing facility to be used
> >> within PHP in an Unix/Linux environment.
> >>
> >> Probably everyone will now answer: imagecopyresampled()
> >>
> >> However, the quality of that functionality doesn't match the
> >> expectations of our designers. I've done my tests with 
> PHP4 and GD  
> >> lib
> >> 2.0.33 and everything produces with them got rejected so far. I was
> >> also
> >> going through the comments on php.net regarding self-written  
> >> Bicubical
> >> algorithm functions, yet their outcome didn't match.
> >>
> >> My next step was to try ImageMagick. The quality is much 
> better when
> >> using the 'mogrify' tool from this package, yet not good enough  
> >> for my
> >> designers.
> >>
> >> Of course, their expectations are very high because of their daily
> >> usage
> >> of Photoshop. During my research I was running over
> >> http://resizr.lord-lance.com/ which uses an commercial Windows
> >> library.
> >> Using a commercial package would be completely fine for 
> me, however I
> >> just haven't found anything, thus this message.
> >>
> >> Whether the tool is a PHP library or just an ordinary Unix command
> >> doesn't matter, as long as it is usable from within PHP.
> >
> 
> What are their expectations and what is the use for the final output?
> 
> Also, what are they saying is wrong with the files? (I'm guessing  
> they are to 'fuzzy', that's the main gripe I have with GD. But it  
> doesn't stop me from using it to resize images for a web 
> page, unless  
> you're resizing large images with text down to a 'usable' size.)
> 
> Are they just being 'designers' and nothing is going to be good  
> enough but photoshop?
> 
> Maybe PHP/Unix isn't the way to go?
> 
> Ed
> 

Yea.. Go mac if you want the best for pics :) and its still unix :

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



RE: [PHP] Job Opportunity

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 2:09 pm, Warren Vail wrote:
> Too bad we have to constrain our messages to fit the threading
> algorithm of
> your list server.  Another case of where man becomes servant to the
> machine?

If one "replies" to a message, and changes the "Subject" there are, in
most sane systems, message IDs within the headers that most sane
message readers will honor.

If YOUR reader isn't doing that, then perhaps you're the one who ought
to wake up. :-)

I got no idea if the OP really hijacked the thread or if Jim's reader
is just [bleeped], mind you.  Only presenting an alternative
possiblity.

That said:

It would be POLITE to include the location in a region-specific job
posting.

It would be POLITE to ask the incredibly active NY PHP User Group
rather than a global mailing list -- there's almost no way in hell
you're going to get a better answer here than in a localized group. 
If nobody there found you anybody, you're in deep trouble.

I'd also suggest changing either the money or the
skills/requirements/description.  $65/hour in NYC for somebody with
enough experience to handle PHP Security in your application just
doesn't sound right to this naive reader...

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

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



Re: [PHP] Performance: While or For loop

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 7:54 pm, Tijnema ! wrote:
> On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> Folks:
>>
>> How often do you use a loop of any kind in PHP with enough
>> iterations
>> that this is even significant?
>>
>> Write the code that makes sense.
>>
>> Optimize the biggest bottleneck until performance is acceptable.
>
> It was more likely to get an idea if there was a real difference or
> not, and apparently there is not really a big difference.
>
> But well if you are going to create a script where 1000+ loops are,
> you might get a few seconds faster script :)

I believe we are seeing times for 1000 iterations around 4 seconds?

Or was it 26 seconds?

Whatever.

That means that at 1000 iterations, you are "saving" how much time?

.00026 seconds?
.4 seconds?

Puhleaze.

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

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



Re: [PHP] close session when browser is closed

2007-03-23 Thread Richard Lynch
If you set the session timeout to 0, then it dies when the browser is
quit.

On Wed, March 21, 2007 12:37 pm, Alain Roger wrote:
> Hi,
>
> I would like to know what is the best solution for my problem.
>
> When a user is connected to a https page and a session is open, if
> user
> close his browser, the session ID is still active in the browser
> "history".
> It means that next time when user will start his browser, the browser
> will
> re-use the same session ID and will work with php pages without any
> problem.
>
> I was thinking to use cookie to solve this issue, but what should i do
> when
> user browser refuse cookies ?
>
> thanks a lot,
>
> --
> Alain
> 
> Windows XP SP2
> PostgreSQL 8.1.4
> Apache 2.0.58
> PHP 5
>


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

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



Re: [PHP] usage of flock

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 7:52 pm, Yvan Strahm wrote:
> I am confused with the flock function and its usage. I have jobs which
> are
> stored in a database, these jobs are run by a series of job_runners
> scripts
> but sometimes the job_runners stop ( server or php crash-down). So i
> put a
> job_controller in crontab to check  regularly if the  runners run. But
> after
> a while I have a bunch of job_controller running, so to avoid that I
> tried
> to use flock.
>
> I try to put this in the job_controller:
>
> $wouldblock=1;
> $f=fopen("controller.lock", "r");
> flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");
>
> hoping that as long as the first job_controller run or don't close the
> file
> handle, a second job_controller won't be able to lock the
> controller.lockfile and die, but it didn't work.
>
> I also try this:
>
> $wouldblock=1;
> $f=fopen("controller.php", "r");
> flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");
>
> hoping the first job_controller will lock it-self, but it didn't work.
>
> I also thought of writing in the lock file the PID of the first
> job_controller and then compare it and if it doesn't match then die,
> but my
> main concern is , if the server crash down the "surviving" lock file
> will
> prevent any job_controller to start.
>
> So how could prevent multiple instance of the same script? Is flock
> the best
> way?

You can do it with flock, but then you end up sooner or later with a
locked file from an "exit" or killed script, and then you have to know
to remove locks older than X minutes.

You could also just do a "mkdir" for your lock, and check its
filemtime.  You could even use "touch" within loop of the script to
make sure the script is still going, and safely assume that any lock
older than X seconds is stale and can be ignored/removed.

A final option is to use 'exec' to figure out if another process is
running already:
//bail out if it's already running:
$pid = getmypid();
$command = "/bin/ps aux | grep " . __FILE__ . " | grep -v grep ";
exec($command, $existing, $error);
if ($error) die("OS Error: $error\n" . implode("\n", $existing) . "\n");
$other_count = 0;
foreach($existing as $procline){
  if (!strstr($procline, " $pid ")) $other_count++;
}
if ($other_count) exit;

This allows you to be sure there is always one, and only one, running
prcess or this file, with no assumptions about lock files maybe being
stale.

I use different ones at different times, depending on what the process
needs to do, and how critical it is that it runs frequently.

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

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Edward Vermillion





On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with PHP4 and GD  
lib

2.0.33 and everything produces with them got rejected so far. I was
also
going through the comments on php.net regarding self-written  
Bicubical

algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much better when
using the 'mogrify' tool from this package, yet not good enough  
for my

designers.

Of course, their expectations are very high because of their daily
usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows
library.
Using a commercial package would be completely fine for me, however I
just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.




What are their expectations and what is the use for the final output?

Also, what are they saying is wrong with the files? (I'm guessing  
they are to 'fuzzy', that's the main gripe I have with GD. But it  
doesn't stop me from using it to resize images for a web page, unless  
you're resizing large images with text down to a 'usable' size.)


Are they just being 'designers' and nothing is going to be good  
enough but photoshop?


Maybe PHP/Unix isn't the way to go?

Ed

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



Re: [PHP] Performance: While or For loop

2007-03-23 Thread Robert Cummings
On Sat, 2007-03-24 at 01:54 +0100, Tijnema ! wrote:
> On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
> > On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote:
> > > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote:
> > >> Your test isn't exactly fair. The for loop has no statements in it,
> > >> and
> > >> the while loop has one. Your tests show while as approx 7% faster,
> > >> while
> > >> a modified test shows an approximate 30% speed improvement:
> > >>
> > >> Do this:
> > >>
> > >> for ($i=0;$i<1000;$i++) {}
> > >>
> > >> v.s.:
> > >>
> > >> $i = 0;
> > >> while ($i++ < 1000) {}
> > >>
> > >> The above while loop is 30% faster than the for. A little teaking on
> > >> the
> > >> for loop, it's faster still:
> >
> > Folks:
> >
> > How often do you use a loop of any kind in PHP with enough iterations
> > that this is even significant?
> >
> > Write the code that makes sense.
> >
> > Optimize the biggest bottleneck until performance is acceptable.

It's not optimization if you just happen to write optimal code out of
habit. It's already done.

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] Passing variables

2007-03-23 Thread Richard Lynch
example.com?char_id=43&char=Bilbo

There is nothing about _ and (int) at all.

And, technically, you should use an HTML Entity on the & in your HTML
output, so it turns into &


On Wed, March 21, 2007 9:49 pm, Jeff wrote:
> I want to thank you all for clearing me up on setting the
> register_globals
> to ON issue!! I have refrained from doing so and my code is running
> great
> with the $_GET.
>
> I am having NO trouble passing my "single" variable to the next page
> using..
>
> echo "Edit";
>
> as when the next page that load actually shows the character info, so
> basically you can see you are dealing with the correct record.
>
> NOW.
>
> I want to pass two variables to a delete page. The charid and the char
> name.
> Here is what I have but it will only pass the 1st variable ?charid
>
> echo " ?char=".$myrow["char_name"]."\">Delete";
>
> I get the 1st variable using the $charid = (int)$_GET['charid']; (on
> the
> next page)
>
> I do however NOT get
>
> $charname = $_GET["char"] to pull the name out. (on the next page)
>
> I've tried putting a comma, a &, a % between the variables ie..
>
> echo " ?char=".$myrow["char_name"]."\">Delete";
>
> but it just won't let me pull the $_GET["char"]
>
> I have even tried $_GET['char'] but am under the impression '_' are
> for
> integers and "_" are for text? Anyway, can someone please let me know
> the
> PROPER way to pass the two or more variables?
>
> Thanks WAY in advance!!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

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



Re: [PHP] Check a string does not contain invalid characters

2007-03-23 Thread Richard Lynch
On Wed, March 21, 2007 11:15 pm, John Comerford wrote:
> I want to accept a character string which I will use as a unique user
> id.  I want to check the string to ensure the user has not typed
> characters that I consider to be invalid as part of a user id.  I was
> thinking of doing something along the lines of:
>
> if (strpbrk($userid, '[EMAIL PROTECTED]&*()_+=-{}[]\\|;\':"<>?,./`') <> null) 
> {
> blah, blah, blah..
>
> but I think that would still leave me open to control characters.
> I am thinking maybe I should loop through the string character by
> character and check it's ascii value (using ord) is within the range
> of
> a-z and A-Z ?
> Is this the best way of achieving this ?  Is there a php command to do
> something similar ?  I have done a few web searches and haven't come
> up
> with much.

You do not want to "blacklist" certain characters and, as you have
noticed, miss the control characters or something you didn't think of.

You want to "whitelist" the characters that you DO accept.

Something like this:

if (!preg_match('|^[a-z0-9_-]+$|i', $username)){
  echo "INVALID USERNAME!";
}

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

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



RE: [PHP] Question before upgrading to 5

2007-03-23 Thread Richard Lynch
On Thu, March 22, 2007 6:23 am, Jake McHenry wrote:
>
> Sorry about the delivery and read requests.. I was tired and forgot to
> turn
> them off for the list..
>
>> alternatively you can search for 'Rasmus' and 'ProxyPass' in the
>> list
>> archive and use Rasmus' rather cool ProxyPass solution to running
>> both
>> php4 and php5 ... his explanation should give you enough info
>> to set it up.
>>
>
> I don't need them running parallel, only both installed

In that case, carefully commenting in/out the right LoadModule and so
on in httpd.conf should let you switch back and forth.

Just be sure to re-start Apache after you change.

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

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



Re: [PHP] Question before upgrading to 5

2007-03-23 Thread Richard Lynch

No, you can't load both PHP4 and PHP5 into the same Apache as Modules.

You can run one as CGI.

You can use proxy_server in one to shuttle requests to a different
Apache pool.

On Thu, March 22, 2007 12:07 am, Jake McHenry wrote:
> Hi everyone,
>
> I just got done going through all my configure options for php5, and
> finally
> configure finished successfully... I didn't install it yet, have a
> question.
> Can I have both 4 and 5 installed temporarily until I'm sure all my
> scripts
> work ok? They should, I've been careful, but I want to be sure since
> this is
> the only server I currently have. I was going to install a virtual
> copy of
> fedora and do testing, but I don't have time, hopefully someone can
> answer.
> I think I just have to change the prefix to something other than
> default and
> load the new module in httpd. If I had more time I would do this the
> right
> way, but we all know how that goes...
>
> If this will work, I can then just uninstall 4.. Hopefully it won't
> break
> anything.
>
> I'll post my configure options if anyone would like to double
> check
>
> Thanks,
> Jake
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.16/729 - Release Date:
> 3/21/2007
> 7:52 AM
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

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



Re: [PHP] Performance: While or For loop

2007-03-23 Thread Tijnema !

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

On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote:
> On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote:
>> Your test isn't exactly fair. The for loop has no statements in it,
>> and
>> the while loop has one. Your tests show while as approx 7% faster,
>> while
>> a modified test shows an approximate 30% speed improvement:
>>
>> Do this:
>>
>> for ($i=0;$i<1000;$i++) {}
>>
>> v.s.:
>>
>> $i = 0;
>> while ($i++ < 1000) {}
>>
>> The above while loop is 30% faster than the for. A little teaking on
>> the
>> for loop, it's faster still:

Folks:

How often do you use a loop of any kind in PHP with enough iterations
that this is even significant?

Write the code that makes sense.

Optimize the biggest bottleneck until performance is acceptable.


It was more likely to get an idea if there was a real difference or
not, and apparently there is not really a big difference.

But well if you are going to create a script where 1000+ loops are,
you might get a few seconds faster script :)

Tijnema


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




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



[PHP] usage of flock

2007-03-23 Thread Yvan Strahm

Hello All,

I am confused with the flock function and its usage. I have jobs which are
stored in a database, these jobs are run by a series of job_runners scripts
but sometimes the job_runners stop ( server or php crash-down). So i put a
job_controller in crontab to check  regularly if the  runners run. But after
a while I have a bunch of job_controller running, so to avoid that I tried
to use flock.

I try to put this in the job_controller:

$wouldblock=1;
$f=fopen("controller.lock", "r");
flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");

hoping that as long as the first job_controller run or don't close the file
handle, a second job_controller won't be able to lock the
controller.lockfile and die, but it didn't work.

I also try this:

$wouldblock=1;
$f=fopen("controller.php", "r");
flock($f, LOCK_EX+LOCK_NB, $wouldblock) or die("Error! cant lock!");

hoping the first job_controller will lock it-self, but it didn't work.

I also thought of writing in the lock file the PID of the first
job_controller and then compare it and if it doesn't match then die, but my
main concern is , if the server crash down the "surviving" lock file will
prevent any job_controller to start.

So how could prevent multiple instance of the same script? Is flock the best
way?

Thanks in advance for your time and help

cheers

yvan


Re: [PHP] Performance: While or For loop

2007-03-23 Thread Richard Lynch
On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote:
> On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote:
>> Your test isn't exactly fair. The for loop has no statements in it,
>> and
>> the while loop has one. Your tests show while as approx 7% faster,
>> while
>> a modified test shows an approximate 30% speed improvement:
>>
>> Do this:
>>
>> for ($i=0;$i<1000;$i++) {}
>>
>> v.s.:
>>
>> $i = 0;
>> while ($i++ < 1000) {}
>>
>> The above while loop is 30% faster than the for. A little teaking on
>> the
>> for loop, it's faster still:

Folks:

How often do you use a loop of any kind in PHP with enough iterations
that this is even significant?

Write the code that makes sense.

Optimize the biggest bottleneck until performance is acceptable.

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

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Markus Fischer
Richard Lynch wrote:
> Perhaps you could run GIMP from the command line to get it to re-size...

Thanks .. very interesting idea. I'll see if I can make this feasable.
Having the server running without X may be problematic .. not
impossible, but probably hard.

> You should also consider what quality setting you are using to dump
> out the JPEG.
> 
> Maybe imagecopyresampled would have been fine if you cranked up the
> JPEG output quality setting to a higher value...

For quality reference I was using the highest (=100) value which, as
described, didn't meet the expactations.

thanks,
- Markus

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



Re: [PHP] Creating an FTP account on the fly from PHP

2007-03-23 Thread Richard Lynch
On Thu, March 22, 2007 5:20 pm, PHP Fusebox wrote:
> I built a CMS that lets a super user create and manage basic users
> (among lots of other things). I want basic users to get an FTP account
> that is automatically associated with their website user account, and
> managed from my add/edit user form. For example if I create a user
> named [EMAIL PROTECTED] for him to login to my web app, I want my
> users to be able to use their same login name and password to access
> their web folder via FTP.
>
> I am running on LAMP on a CPanel server with ProFTP as the FTP server
> software, but I have no clue how to get PHP to be able to create,
> edit, or delete an FTP account. Can someone point me in the right
> direction?
>
> I can see the Form field names and URLs in the CPanel forms where this
> is set up, but is it safe to CURL these same URLs from my app? That
> seems like a big security risk.

It's as big a security risk as you make it, with how carefully you
write your script, and guard access to it.

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

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



Re: [PHP] getting a variable from a file

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 5:47 am, Ross wrote:
> I am using a script to generate a sitemap. It displays the page names
> (mypage.php) but I want it to display the titles. The page heads and
> 
> are generated dynamically so the line below does not work
>
>  if(preg_match("'(.+)'i", $f, $matches)){
>
> However all the paged titles are stored in a variable $pageTitle. On
> every
> page like this
>
> $pageTitle="Who We Are";
>
> how can I retrieve this variable? I tried
>
> echo $pageTitle and $_GET['pageTitle']

I'm confused...

In your sitemap script, are you scraping your own site?  The
preg_match should work.  but you could punt and use strpos since you
know exactly what case/attributes are on your own TITLE tags.

Or are you trying to have the page output update the sitemap on every
page view?

Or...???


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

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



Re: [PHP] Add New Records Only!

2007-03-23 Thread Richard Lynch
If the table is "small", you could maybe do:

delete from foo where id in (select b.id from foo as a, foo as b where
a.id < b.id and a.field1 = b.field1 and a.field2 = b.field2 and ...)

Another option would be to just create a UNIQUE INDEX on the fields
you think "should" be unique, and then your second insert is gonna
fail, and you can just ignore that.

On Fri, March 23, 2007 11:51 am, Satyam wrote:
> Delete from table where id = (select min(id) from table group by
> field1,
> field2 ,...  having count(id) > 1)
>
> Id is the unique primary key, fieldn are the fields that can be
> duplicated.
> Each time this runs it will remove one occurence of the all duplicated
> records.  You'd have to run it several times until it deletes no more
> records.   In MySql, you cannot have the same table in the 'delete'
> and in
> the subquery, thus, you will have to first insert the id's in an
> auxiliary
> table and then delete the records.
>
> Satyam
>
> - Original Message -
> From: "Rahul Sitaram Johari" <[EMAIL PROTECTED]>
> To: "Mark" ; "PHP" 
> Sent: Friday, March 23, 2007 5:24 PM
> Subject: Re: [PHP] Add New Records Only!
>
>
>>
>> Ave,
>>
>> "Three: Insert everything and remove duplicates later."
>>
>> Out of the suggested options, this option is sounding the most sane
>> attainable on my end. I don't have a complete grip on how to
>> accomplish
>> this, but certainly sounds feasible. Let me look at ways to achieve
>> this.
>>
>> Thanks!
>>
>> On 3/23/07 11:36 AM, "Mark"  wrote:
>>
>>> Rahul Sitaram Johari wrote:
>>>
>>> As far as I can see, there is probably only three ways to do this:
>>>
>>> One: Make sure your dbase system contains unique primary key
>>> capability,
>>> and
>>> use it to avoid duplicates.
>>> Two: query for the row, if it isn't there insert it. (You'll have
>>> to deal
>>> with concurrency with locking or something)
>>> Three: Insert everything and remove duplicates later.
>>>
 Ave,

 Let me explain what I¹m trying to do. Unfortunately it¹s not a
 very
 simple
 Add/Update transaction.
 Basically I gather records from multiple mySQL tables and add them
 to a
 DBF
 (dbase) database.  I wrote a code which was able to accomplish
 this
 without any problems and the add_records goes very smooth.

 However, I have to modify this program now so that only ³New²
 records,
 i.e., records that have not yet been transferred, are added into
 the
 DBF.
 In other words, any records that are being added, which already
 exist in
 the DBF, should not be added.

 If it were just adding records from one mySQL to another mySQL, I
 could
 easily use INSERT IGNORE or the Unique Key fundamental ­ however,
 since
 I¹m adding from multiple mySQL tables into DBF, I¹m not sure how
 to go
 about doing this.

 Here¹s my code that takes records from multiple mySQL tables and
 adds
 them
 to a DBF.

 // define the array with mySQL Table Names & Identifier
 $tChoice = array(
"lodispo" => "VB",
"lodispo_osma" => "ATL",
"lodispo_osmh" => "HOU",
"lodispo_osmn" => "NSV",
"lodispo_osmp" => "PAA",
"lodispo_osmj" => "JAX",
"lodispo_osmt" => "TPA",
"lodispo_dmam" => "MET",
"lodispo_osmf" => "FTM",
"lodispo_hfglend" => "GLEND",
   "lodispo_hfmesa" => "MESA",
   "lodispo_hfphenx" => "PHENX",
 );


 // open DBF in read-write mode
 $db2 = dbase_open($theDBFfile, 2);
 if (!$db2) {
   echo "Fatal Error: Unable to open
 database";
   exit;
 }

 else {

 // Let's Run Array Loops!
 foreach ($tChoice as $tblQ => $bxQ) {

 // connect to mySQL tables one by one
 mysql_select_db($database_imslead_transfer,
 $imslead_transfer); $query_loDispo = "SELECT * FROM
 $tblQ";
 $loDispo = mysql_query($query_loDispo,
 $imslead_transfer) or
 die(mysql_error());
 $row_loDispo = mysql_fetch_assoc($loDispo);
 $totalRows_loDispo = mysql_num_rows($loDispo);

 // write mySql data to Dbf
 do {
  dbase_add_record($db2, array(
  $row_loDispo['phone'],
  $row_loDispo['comments'],
  $row_loDispo['starttime'],
  $row_loDispo['endtime'],
  $row_loDispo['dispo'],
  $row_loDispo['loanofficer'],
  $row_loDispo['verifier'],
  $bxQ));
  } while ($row_loDispo =
 mysql_fetch_assoc($loDispo));
 }

 dbase_close($db2);
 }

 Any suggestions would be

Re: [PHP] Configure question

2007-03-23 Thread Jochem Maas
Jake McHenry wrote:
> I searched the archives... Haven't seen an answer to this yet
> 
> Does anyone know why Virtual Directory Support is enabled on windows, but
> disabled on unix? And what exactly is it? I know I can enable it by
> --enable-maintainer-zts, but it says in configure that it is "Thread Safety"
> for code maintainers only What exactly does this do? I found one
> reference by google that says funky stuff may happen with this enabled...??
> I haven't tested it, I could try and let everyone know, but thought I would
> ask first.

I can't really give you an answer that is worth ,
but this blog post might interest you:

http://blog.libssh2.org/index.php?/archives/22-What-the-heck-is-TSRMLS_CC-anyway.html

also I would recommend searching the internals list archives - stuff like this
gets discussed there more and more often.

> 
> 
> Thanks,
> Jake
> 

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



Re: [PHP] POST a variable

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 10:07 am, Dan Shirah wrote:
> The reason I have to use it as I posted is because I am using
> Microsoft SQL
> server instead of MySQL.  And I haven't found a php function for MSSQL
> that
> works the same as mysql_insert_id()

I guarantee that there is a way to do it in MSSQL, somehow...

I think it might be:

SELECT @INSERT;

Or maybe it was:

SELECT @@INSERT

Something like that.

Find a SQL Server list and ask them.  They'll know for sure.

> I figure the odds of another record being inserted inbetween the time
> it
> takes to go from step 3 to step 4 are very, very minimal.  We're
> talking
> about MAYBE a 2-3 millisecond gap?

No, we are NOT talking about a 2-3 millisecond gap.

As soon as your server gets even a little busy, your script is getting
"interrupted" by the other scripts trying to run, and you are just
playing russian roulette on whether it happens now or tomorrow that
you get this all messed up.

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

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



Re: [PHP] POST a variable

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 9:45 am, Dan Shirah wrote:
> Okay, I feel like the correct answer to this is about 2mm back in my
> grey
> matter.
>
> 1. I have a query that pulls the last row number when a newly inserted
> record is added:
>
> $maximum="SELECT MAX(payment_id) FROM payment_request";
>   $max_result=mssql_query($maximum);
>   while($max=mssql_fetch_row($max_result)){
>   }
>   $max_id = $max[0];

DO NOT DO THIS!!!

As soon as *TWO* people hit your site at the same time, this will blow
up in your face.

Use this:
http://php.net/mysql_insert_id

> 2. I have multiple selections for the user to pick, but regardless of
> what
> they choose I want the $max_id variable to be passed to the next page.
>
> 3.  Would I go about this by assigning $max_id to a hidden field like
> below?
>
> " size="5"
> maxlength="10" name="max_id" />

Yes.

Though the size and maxlength are kinda silly on a "hidden" input...

> 4.  And then to retrieve this value on my next page just get it out of
> $_POST['max_id']  ??
>
> Does that all sound correct?

Try it and see.

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

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Richard Lynch
You don't need a function to do something repeatedly.

You need some kind of loop, such as 'while', 'for' or 'foreach'

Try working through a PHP / MySQL tutorial, as it will cover this.

On Fri, March 23, 2007 10:55 am, Dwayne Heronimo wrote:
> Dear all,
>
> hmm.. sorry the $previewstext thing was a typo in my mail.
>
> But yes it is working but it will only display the first record of the
> recordset. I have like a list for items with short text in a page and
> of
> course made a query to make the database variables available. Which
> where
> the variable $row_show_cat['text']; comes from.
>
> This is why I thought that i may have to rewrite it into a function to
> display the $row_show_cat['text']; in a repeated reagion.
>
>
> I have rewritten my function:
>
>   function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;
>
>  return $previewtext;
> }
> ?>
>
> And to to show it later in the page:
> 
> but this still won't anywould display anything. :S
>
> Please let me know.
>
> ""Tijnema !"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
>>> Dear All,
>>>
>>> I am very new to programming. I want to make a preview text that
>>> would
>>> display only a part of the text that is a text field in a database.
>>>
>>> //Begin Make preview string
>>>
>>>  $minitxt = $row_show_cat['text'];
>>>  $len = strlen($minitxt);
>>>
>>>  if ($len > 235)
>>>  {
>>>  $len = 235;
>>>  }
>>>  else
>>>  {
>>>  $len = $len;
>>>  }
>>>
>>>  $newstring = substr($minitxt,0,$len);
>>>
>>>  $previewtext = $newstring;
>>>
>>> //End Make preview string
>>>
>>> But if I want to display this somewhere in the page it will only
>>> display
>>> the
>>> first record of at every text column row >> ?>
>>>
>>> Althought I am very new to php and programming. I thought maybe I
>>> should
>>> rewrite it into a function. But my function won't work.
>>>
>>>
>>> function previewString($showcatvar) {
>>>
>>>  $minitxt = $showcatvar;
>>>  $len = strlen($minitxt);
>>>
>>>  if ($len > 235)
>>>  {
>>>  $len = 235;
>>>  }
>>>  else
>>>  {
>>>  $len = $len;
>>>  }
>>>
>>>  $newstring = substr($minitxt,0,$len);
>>>
>>>  $previewtext = $newstring;
>>>
>>>  $previewtext = $whowcatvar;
>>>
>>> }
>>>
>>>
>>> and to display it in the page:
>>>
>>> 
>>>
>>> IT displays notthing. But I think I am doing somthing wrong. I am
>>> assigning
>>> the wrong variables to the $row_show_cat['text']) ???
>>>
>>> Please let me know
>>
>> I'm currently not sure why your first piece of code isn't working,
>> but
>> the second is quite simple. You aren't returning any variable in
>> your
>> function, and so it won't output anything. Add the following:
>> return $previewtext;
>> Just before the }
>>
>> Then it will return something, but i think not what you wanted to :(
>>
>> Tijnema
>>>
>>> --
>>> 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
>
>


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

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 10:18 am, Dwayne Heronimo wrote:
> function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }

Take out this whole "else" block -- Assigning a variable to itself is
just silly.

>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;

You need to RETURN some value here, for the function to give back the
"answer" so that your echo below has something to print out.

http://php.net/return


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

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:
> I'm searching for a high quality image resizing facility to be used
> within PHP in an Unix/Linux environment.
>
> Probably everyone will now answer: imagecopyresampled()
>
> However, the quality of that functionality doesn't match the
> expectations of our designers. I've done my tests with PHP4 and GD lib
> 2.0.33 and everything produces with them got rejected so far. I was
> also
> going through the comments on php.net regarding self-written Bicubical
> algorithm functions, yet their outcome didn't match.
>
> My next step was to try ImageMagick. The quality is much better when
> using the 'mogrify' tool from this package, yet not good enough for my
> designers.
>
> Of course, their expectations are very high because of their daily
> usage
> of Photoshop. During my research I was running over
> http://resizr.lord-lance.com/ which uses an commercial Windows
> library.
> Using a commercial package would be completely fine for me, however I
> just haven't found anything, thus this message.
>
> Whether the tool is a PHP library or just an ordinary Unix command
> doesn't matter, as long as it is usable from within PHP.

Perhaps you could run GIMP from the command line to get it to re-size...

You should also consider what quality setting you are using to dump
out the JPEG.

Maybe imagecopyresampled would have been fine if you cranked up the
JPEG output quality setting to a higher value...

You'll pay for it in filesize, though.

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

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



Re: [PHP] php support

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 12:31 pm, Richard Dunne wrote:
> Can anyone tell me where to get support for this?  php5 undefined
> function pg_connect()
> Is there a specific mailig list fro users?

It means you did not correctly compile/install the PostgreSQL
extension to php.

If you compiled from source, go back to your configure directory and
look at the config.log output and figure out why PostgreSQL was not
detected.

If you are using RPMs or some other package management, you need to
get postgresql-devel and postgresql and php-postgresql in some
fashion.

This probably best fits on the "install" list.

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

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



RE: [PHP] Alternatives to PHPLib for authentication, session management, etc

2007-03-23 Thread Jake McHenry
If it still works, then why switch? I wrote my own auth routines Phplib
was last released last summer? That's not TOO old
http://phplib.sourceforge.net/

Jake


> 
> Hi.
> 
> Been using PHP since the 2.0 days, and been using PHPLib 
> since 2000 as 
> the main method of user authentication (logging in/out during same 
> session), and simultaneously use it to give the users who are 
> logged in different permissions.
> 
> Since PHPLib has long ago stopped (at least in my opinion) active 
> development, I am wondering what other systems people use to 
> deal with 
> authentication and permission levels.
> 
> I'd love to hear about complete libraries/methods that I could use as 
> a replacement for PHPLib with the minimum of fuss.
> 
> 
> 
> As an example, in the pages I do NOT want to protect, I 
> merely need to 
> create a variable: $AUTHENTICATION = "off";
> and my global includes check for that:
> 
> if ($AUTHENTICATION != "off") {
> page_open(
>array("sess" => "Example_Session",
>  "auth" => "Example_Auth",
>  "perm" => "Example_Perm"));
> }
> 
> Which causes PHPLib authentication to be ignored for that 
> page.  Every 
> other page authenticates via the page_open() function.  
> PHPLib does it 
> all behind the sceneswhich makes it very easy.
> 
> 
> So, basically I'm looking for a system that works better than what 
> I've got w/ PHPLib, that will be fairly easy to maintain  -- as well 
> as drop-in as a replacement in the 100s of websites that I've 
> developed that use that authentication scheme.
> 
> Thanks in advance,
> mark
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release 
> Date: 3/22/2007 7:44 AM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



[PHP] Configure question

2007-03-23 Thread Jake McHenry
I searched the archives... Haven't seen an answer to this yet

Does anyone know why Virtual Directory Support is enabled on windows, but
disabled on unix? And what exactly is it? I know I can enable it by
--enable-maintainer-zts, but it says in configure that it is "Thread Safety"
for code maintainers only What exactly does this do? I found one
reference by google that says funky stuff may happen with this enabled...??
I haven't tested it, I could try and let everyone know, but thought I would
ask first.


Thanks,
Jake

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



[PHP] Alternatives to PHPLib for authentication, session management, etc

2007-03-23 Thread Mark R. Cervarich

Hi.

Been using PHP since the 2.0 days, and been using PHPLib since 2000 as 
the main method of user authentication (logging in/out during same 
session), and simultaneously use it to give the users who are 
logged in different permissions.


Since PHPLib has long ago stopped (at least in my opinion) active 
development, I am wondering what other systems people use to deal with 
authentication and permission levels.


I'd love to hear about complete libraries/methods that I could use as 
a replacement for PHPLib with the minimum of fuss.




As an example, in the pages I do NOT want to protect, I merely need to 
create a variable: $AUTHENTICATION = "off";

and my global includes check for that:

if ($AUTHENTICATION != "off") {
   page_open(
  array("sess" => "Example_Session",
"auth" => "Example_Auth",
"perm" => "Example_Perm"));
}

Which causes PHPLib authentication to be ignored for that page.  Every 
other page authenticates via the page_open() function.  PHPLib does it 
all behind the sceneswhich makes it very easy.



So, basically I'm looking for a system that works better than what 
I've got w/ PHPLib, that will be fairly easy to maintain  -- as well 
as drop-in as a replacement in the 100s of websites that I've 
developed that use that authentication scheme.


Thanks in advance,
mark

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



[PHP] Re: High quality image resizing

2007-03-23 Thread Markus Fischer
Hi,

Al wrote:
> Suggest visiting the IM forums and asking for help.
> 
> Also, try resizing some images here
> http://studio.webbyland.com/MagickStudio/scripts/MagickStudio.cgi

thanks for the hints, I'll give them a try.

> I use php exec() for my work.

Same here. I know there are PHP libraries out there, but I think for the
end-product it shouldn't matter.

- Markus

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



Re: [PHP] POST a variable

2007-03-23 Thread Børge Holen
On Friday 23 March 2007 15:45, Dan Shirah wrote:
> Okay, I feel like the correct answer to this is about 2mm back in my grey
> matter.
>
> 1. I have a query that pulls the last row number when a newly inserted
> record is added:
>
> $maximum="SELECT MAX(payment_id) FROM payment_request";
>   $max_result=mssql_query($maximum);
>   while($max=mssql_fetch_row($max_result)){
>   }
>   $max_id = $max[0];
>
> 2. I have multiple selections for the user to pick, but regardless of what
> they choose I want the $max_id variable to be passed to the next page.
>
> 3.  Would I go about this by assigning $max_id to a hidden field like
> below?
>
> " size="5"
> maxlength="10" name="max_id" />
>
> 4.  And then to retrieve this value on my next page just get it out of
> $_POST['max_id']  ??
>
> Does that all sound correct?

If it works correctly it probably is... 

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



[PHP] Re: How to get class constants with there value?

2007-03-23 Thread Steve
Doesn't that destroy the entire reason for having variables within a class 
in the first place? Why not set them as private and use accessors and 
mutators to mess with their values? If you aren't going to use those, why 
not just create global variables and functions? You basically lose your 
entire reason for having a class if you allow scripts to just reach inside 
of it and take whatever they want.


"Mathijs" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello there,
>
> I use PHP5, and i wanted to know if there is an option to extract class 
> constants with there name and value without using Refelection.
>
> Now i need to create a reflection of the class to get the info.
>
> Is there something like get_class_variables for constants??
>
> Thx in advanced. 

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



Re: [PHP] References challenge with PHP4

2007-03-23 Thread Jochem Maas
Martin Alterisio wrote:
> 2007/3/20, Jochem Maas <[EMAIL PROTECTED] >:
> 
> Robert Cummings wrote:
> > On Tue, 2007-03-20 at 11:52 +0100, Jochem Maas wrote:
> >> ok, I tried it in a whole number of variations -
> >> no joy.
> >>
> >> you should use php5 if you want this kind of reference
> >> stuff - in php5 it just works, php 4 will give you big headaches.
> >
> > Now now, don't be calling PHP5 "ALL THAT" when it can't do it right
> > either (or did you not check it using PHP5 ;) ;)
> 
> god knows what I did - obviously something different to what I thought
> I was testing :-/
> 
> > Everything works fine
> > in PHP4 (also for PHP5 in this case if you just understand that static
> > vars are buggy *lol* -- and this is first time I've noticed this
> bug).
> 
> I have never run into this bug before ... nice catch, seems like
> a viable item for a bug report.
> 
> 
> Actually, is not a bug, is expected behaviour and documented in the manual
> 
> http://php.net/static
> 
> See the last section, named "references with global and static variables"

I have 2 issues with this:

1. the docs specify php4/ZendEngine1 which suggests php5 is not prone to
this implementation error, the following code seems to suggest that from the 
user's
POV the problem no longer exists (as long as there is no use of the reference 
operator
inconjunction with objects) in php5 (using the erf operator in php5 with 
objects is
almost always wrong anyway):

class Test {
public $foo;
private static $inst;
function get() { if(!isset(self::$inst)) self::$inst = new self; return 
self::$inst; }
}
$foo = Test::get();
$foo2 = Test::get();

$foo->foo = "foo";
var_dump($foo, $foo2, ($foo === $foo2));

$foo2->foo = "bar";
var_dump($foo, $foo2);

2. should I have to care about the way something is implemented internally
in order to use a given piece of language functionality without running into
problems that have a serious wtf factor? I feel not.

oh well.

> 
> static and global are implemented internally as references, that makes
> storing references into static variables impossible (which can be solved
> by using arrays of references as seen in Robert Cummings example).

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Tijnema !

On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote:

2007. 03. 23, péntek keltezéssel 17.30-kor Dwayne Heronimo ezt írta:
> YES this works thank nemeth:

your welcome but please call me Zoltán ;)
(my first name is Zoltán. in Hungary we write names the opposite order
than anywhere else ;) so that's why my mailbox is set to display 'Németh
Zoltán' but I sign my mails as 'Zoltán Németh' showing that my first
name is Zoltán and last name is Németh :) )

greets
Zoltán Németh


Ever thought of reversing it in your mailbox?

Or use a virtual name like me ;)

Tijnema


>
>   function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  return $previewtext;
> }
> ?>
>
> and to display it:
>
> 
>
> cheers
>
> Dwayne
>
>
>
>
> ""Nmeth Zoltn"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > 2007. 03. 23, pntek keltezssel 16.55-kor Dwayne Heronimo ezt rta:
> >> Dear all,
> >>
> >> hmm.. sorry the $previewstext thing was a typo in my mail.
> >>
> >> But yes it is working but it will only display the first record of the
> >> recordset. I have like a list for items with short text in a page and of
> >> course made a query to make the database variables available. Which where
> >> the variable $row_show_cat['text']; comes from.
> >>
> >> This is why I thought that i may have to rewrite it into a function to
> >> display the $row_show_cat['text']; in a repeated reagion.
> >>
> >>
> >> I have rewritten my function:
> >>
> >>  >>  function previewString($showcatvar) {
> >>
> >>  $minitxt = $showcatvar;
> >>  $len = strlen($minitxt);
> >>
> >>  if ($len > 235)
> >>  {
> >>   $len = 235;
> >>  }
> >>  else
> >>  {
> >>   $len = $len;
> >>  }
> >>
> >>  $newstring = substr($minitxt,0,$len);
> >>
> >>  $previewtext = $newstring;
> >>
> >>  $previewtext = $whowcatvar;
> >
> > what is the meaning of the above line???
> > you are giving an undefined value (default NULL) to $previewtext, just
> > after you gave it the right value
> > delete that line and you might be well
> >
> > greets
> > Zoltn Nmeth
> >
> >>
> >>  return $previewtext;
> >> }
> >> ?>
> >>
> >> And to to show it later in the page:
> >> 
> >> but this still won't anywould display anything. :S
> >>
> >> Please let me know.
> >>
> >> ""Tijnema !"" <[EMAIL PROTECTED]> wrote in message
> >> news:[EMAIL PROTECTED]
> >> > On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
> >> >> Dear All,
> >> >>
> >> >> I am very new to programming. I want to make a preview text that would
> >> >> display only a part of the text that is a text field in a database.
> >> >>
> >> >> //Begin Make preview string
> >> >>
> >> >>  $minitxt = $row_show_cat['text'];
> >> >>  $len = strlen($minitxt);
> >> >>
> >> >>  if ($len > 235)
> >> >>  {
> >> >>  $len = 235;
> >> >>  }
> >> >>  else
> >> >>  {
> >> >>  $len = $len;
> >> >>  }
> >> >>
> >> >>  $newstring = substr($minitxt,0,$len);
> >> >>
> >> >>  $previewtext = $newstring;
> >> >>
> >> >> //End Make preview string
> >> >>
> >> >> But if I want to display this somewhere in the page it will only
> >> >> display
> >> >> the
> >> >> first record of at every text column row 
> >> >>
> >> >> Althought I am very new to php and programming. I thought maybe I
> >> >> should
> >> >> rewrite it into a function. But my function won't work.
> >> >>
> >> >>
> >> >> function previewString($showcatvar) {
> >> >>
> >> >>  $minitxt = $showcatvar;
> >> >>  $len = strlen($minitxt);
> >> >>
> >> >>  if ($len > 235)
> >> >>  {
> >> >>  $len = 235;
> >> >>  }
> >> >>  else
> >> >>  {
> >> >>  $len = $len;
> >> >>  }
> >> >>
> >> >>  $newstring = substr($minitxt,0,$len);
> >> >>
> >> >>  $previewtext = $newstring;
> >> >>
> >> >>  $previewtext = $whowcatvar;
> >> >>
> >> >> }
> >> >>
> >> >>
> >> >> and to display it in the page:
> >> >>
> >> >> 
> >> >>
> >> >> IT displays notthing. But I think I am doing somthing wrong. I am
> >> >> assigning
> >> >> the wrong variables to the $row_show_cat['text']) ???
> >> >>
> >> >> Please let me know
> >> >
> >> > I'm currently not sure why your first piece of code isn't working, but
> >> > the second is quite simple. You aren't returning any variable in your
> >> > function, and so it won't output anything. Add the following:
> >> > return $previewtext;
> >> > Just before the }
> >> >
> >> > Then it will return something, but i think not what you wanted to :(
> >> >
> >> > Tijnema
> >> >>
> >> >> --
> >> >> 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] preview string with strlen PHP (help)

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 17.30-kor Dwayne Heronimo ezt írta:
> YES this works thank nemeth:

your welcome but please call me Zoltán ;)
(my first name is Zoltán. in Hungary we write names the opposite order
than anywhere else ;) so that's why my mailbox is set to display 'Németh
Zoltán' but I sign my mails as 'Zoltán Németh' showing that my first
name is Zoltán and last name is Németh :) )

greets
Zoltán Németh

> 
>   function previewString($showcatvar) {
> 
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
> 
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
> 
>  $newstring = substr($minitxt,0,$len);
> 
>  $previewtext = $newstring;
> 
>  return $previewtext;
> }
> ?>
> 
> and to display it:
> 
> 
> 
> cheers
> 
> Dwayne
> 
> 
> 
> 
> ""Nmeth Zoltn"" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > 2007. 03. 23, pntek keltezssel 16.55-kor Dwayne Heronimo ezt rta:
> >> Dear all,
> >>
> >> hmm.. sorry the $previewstext thing was a typo in my mail.
> >>
> >> But yes it is working but it will only display the first record of the
> >> recordset. I have like a list for items with short text in a page and of
> >> course made a query to make the database variables available. Which where
> >> the variable $row_show_cat['text']; comes from.
> >>
> >> This is why I thought that i may have to rewrite it into a function to
> >> display the $row_show_cat['text']; in a repeated reagion.
> >>
> >>
> >> I have rewritten my function:
> >>
> >>  >>  function previewString($showcatvar) {
> >>
> >>  $minitxt = $showcatvar;
> >>  $len = strlen($minitxt);
> >>
> >>  if ($len > 235)
> >>  {
> >>   $len = 235;
> >>  }
> >>  else
> >>  {
> >>   $len = $len;
> >>  }
> >>
> >>  $newstring = substr($minitxt,0,$len);
> >>
> >>  $previewtext = $newstring;
> >>
> >>  $previewtext = $whowcatvar;
> >
> > what is the meaning of the above line???
> > you are giving an undefined value (default NULL) to $previewtext, just
> > after you gave it the right value
> > delete that line and you might be well
> >
> > greets
> > Zoltn Nmeth
> >
> >>
> >>  return $previewtext;
> >> }
> >> ?>
> >>
> >> And to to show it later in the page:
> >> 
> >> but this still won't anywould display anything. :S
> >>
> >> Please let me know.
> >>
> >> ""Tijnema !"" <[EMAIL PROTECTED]> wrote in message
> >> news:[EMAIL PROTECTED]
> >> > On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
> >> >> Dear All,
> >> >>
> >> >> I am very new to programming. I want to make a preview text that would
> >> >> display only a part of the text that is a text field in a database.
> >> >>
> >> >> //Begin Make preview string
> >> >>
> >> >>  $minitxt = $row_show_cat['text'];
> >> >>  $len = strlen($minitxt);
> >> >>
> >> >>  if ($len > 235)
> >> >>  {
> >> >>  $len = 235;
> >> >>  }
> >> >>  else
> >> >>  {
> >> >>  $len = $len;
> >> >>  }
> >> >>
> >> >>  $newstring = substr($minitxt,0,$len);
> >> >>
> >> >>  $previewtext = $newstring;
> >> >>
> >> >> //End Make preview string
> >> >>
> >> >> But if I want to display this somewhere in the page it will only 
> >> >> display
> >> >> the
> >> >> first record of at every text column row 
> >> >>
> >> >> Althought I am very new to php and programming. I thought maybe I 
> >> >> should
> >> >> rewrite it into a function. But my function won't work.
> >> >>
> >> >>
> >> >> function previewString($showcatvar) {
> >> >>
> >> >>  $minitxt = $showcatvar;
> >> >>  $len = strlen($minitxt);
> >> >>
> >> >>  if ($len > 235)
> >> >>  {
> >> >>  $len = 235;
> >> >>  }
> >> >>  else
> >> >>  {
> >> >>  $len = $len;
> >> >>  }
> >> >>
> >> >>  $newstring = substr($minitxt,0,$len);
> >> >>
> >> >>  $previewtext = $newstring;
> >> >>
> >> >>  $previewtext = $whowcatvar;
> >> >>
> >> >> }
> >> >>
> >> >>
> >> >> and to display it in the page:
> >> >>
> >> >> 
> >> >>
> >> >> IT displays notthing. But I think I am doing somthing wrong. I am
> >> >> assigning
> >> >> the wrong variables to the $row_show_cat['text']) ???
> >> >>
> >> >> Please let me know
> >> >
> >> > I'm currently not sure why your first piece of code isn't working, but
> >> > the second is quite simple. You aren't returning any variable in your
> >> > function, and so it won't output anything. Add the following:
> >> > return $previewtext;
> >> > Just before the }
> >> >
> >> > Then it will return something, but i think not what you wanted to :(
> >> >
> >> > Tijnema
> >> >>
> >> >> --
> >> >> 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: Download tracker/counter

2007-03-23 Thread Mikey

Robert Wolfe wrote:
[snip]


1)  Allow the downloads of said files.


readfile() is your friend here, although you will need to search around 
for the right HTTP headers to send as well.




2)  Count the number of time a file has been downloaded.


You could either look into creating a serialized array and 
writing/reading from that file - although you may have concurrency 
issues with this, or you could look into writing the counts into a 
database table (SQLlite, mySQL - you have a number of options here. 
There are *lots* of net tutorials for this.




3)  Record the IP addresses of the machines that download the files.


http://uk3.php.net/manual/en/reserved.variables.php#reserved.variables.server


REMOTE_ADDR is the one you need.

HTH,

Mikey

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



Re: [PHP] Random Unique ID

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 15.13-kor tedd ezt írta:
> At 9:15 AM +0100 3/23/07, Németh Zoltán wrote:
> >2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
> >>  At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
> >>  >2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> >>  >
> >>  >  > As for efficiency, that's probably not 
> >>even worth mentioning in this case.
> >>  >
> >>  >why not? you would use 2 sql queries while I would use one most of the
> >>  >time and 2 in case of already reserved ID - that is almost twice as much
> >>  >processor time
> >>  >that may count much if the routine is used frequently
> >>
> >>  Go ahead, try it, and tell me how much time it cost.
> >>
> >>  From experience, there are things one can spend
> >>  their time optimizing and there are other things
> >>  that one should be able to see that aren't worth
> >>  pursing.
> >>
> >>  I've been wrong before, but you're open to 
> >>prove me wrong again, if you like.
> >
> >okay, I've got up earlier and made a little benchmark. The result
> >suprised me, and proved you right. ;)
> 
> Németh:
> 
> Thanks for trying, but I said what I did because 
> I knew from experience that these types of 
> actions are blinding fast and getting faster all 
> the time.
> 
> I'm not suggesting to dispense with looking for 
> less operations, but sometimes the effort doesn't 
> exceed other benefits in readability, easier 
> logic, simpler code, and time spent developing 
> code. We have been rather slow to realize changes 
> the speed and memory of hardware.
> 
> For example, we recently had a discussion on the 
> difference between using " " a "concern". When in fact, if is of no noticeable 
> or significant concern at all. It's like 
> discussing a grain of sand on the beach.
> 
> Not that you did this, but sometimes it's best to 
> figure out what's important and what's not before 
> making it an issue.

yeah, you're right again :)
(however my first name is still Zoltán instead of Németh ;) )

that's what I did now. I figured out it's not important. thanks for
inspiring me to do that :)

greets
Zoltán Németh

> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> 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



[PHP] Re: How to get class constants with there value?

2007-03-23 Thread Mikey

Mathijs wrote:

Hello there,

I use PHP5, and i wanted to know if there is an option to extract class 
constants with there name and value without using Refelection.


Now i need to create a reflection of the class to get the info.

Is there something like get_class_variables for constants??

Thx in advanced.


Read the first user contributed note for this page - I think that is 
your answer...


http://uk3.php.net/manual/en/function.get-class-vars.php

HTH,

Mikey

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



Re: [PHP] Add New Records Only!

2007-03-23 Thread Mark
Rahul Sitaram Johari wrote:

> 
> Ave,
> 
> It's definitely not live data, so that is not a problem at all. But I'm
> not sure I understand your method very well.
> 
> I do understand getting data from both the existing DBF and the multiple
> mySQL tables into a temporary mySQL table. But if I do go ahead and do
> that, I guess I could write a 'delete-duplicates' kind of code that
> deletes all rows in that temporary table which are duplicates, and then
> add the leftover into the DBF.
> 
> Not sure how this sounds, or how close this is to what you were saying.
> And not even sure how to implement this.

Actually, I was thinking about this, and if you can control the order of the
records coming to you, you can do a simple merge reduction.

What you do is issue a number of SQL queries to your databases
simultaneously. Something like:

SELECT * from mytable order by myrow

Then, in the receiving code, have an array of SQL connections. More pseudo
code for you:

// Seed the array
for($i=0; $i < $num_sql_cons; i++)
{
$sql_record[$i] = sql_get_next($dbs[$i]);
}

while(1)
{
$smallest=0;
// Find the smallest record
for($i=1; $i < $num_sql_cons; $i++)
{
if($sql_record[$i]->myrow < $sql_record[$smallest]->myrow)
$smallest = $i; 
else if($sql_record[$i]->myrow == $sql_record[$i]->myrow)
$sql_record[$i]= sql_get_next($dbs[$i]);
}
write_record($sql_record[$smallest]);
$sql_record[$smallest] = sql_get_next($dbs[$smallest]);
}

Then make sure that last few are unique and you are done.

> 
> 
> On 3/23/07 2:27 PM, "markw@mohawksoft.com"  wrote:
> 
>>> 
>>> Ave,
>>> 
>>> "Three: Insert everything and remove duplicates later."
>>> 
>>> Out of the suggested options, this option is sounding the most sane
>>> attainable on my end. I don't have a complete grip on how to accomplish
>>> this, but certainly sounds feasible. Let me look at ways to achieve
>>> this.
>>> 
>>> Thanks!
>>> 
>> 
>> I'm not sure how live this data is, but it should be easy to do if you
>> are merely replicating and don't need this stuff all live all the time.
>> 
>> basically, query all databases, get all the data, and store in a
>> temporary database. Then query all the data in the temporary database and
>> order by your primary key. Save a copy of your primary key for each next
>> row. If the subsequent primary key is the same as the previous one, it is
>> a duplicate record and ignore it.
>> 
>> like this: (pseudo code)
>> 
>> $primary_key = "";
>> while(!eof())
>> {
>>$record = get_next_record();
>> 
>> if($record->primary_key != $primary_key)
>> {
>>store_new_record($record);
>>$primary_key = $record->primary_key;
>> }
>> }
>> 
>> 
>> }
>> 
>>> On 3/23/07 11:36 AM, "Mark"  wrote:
>>> 
 Rahul Sitaram Johari wrote:
 
 As far as I can see, there is probably only three ways to do this:
 
 One: Make sure your dbase system contains unique primary key
 capability, and
 use it to avoid duplicates.
 Two: query for the row, if it isn't there insert it. (You'll have to
 deal
 with concurrency with locking or something)
 Three: Insert everything and remove duplicates later.
 
> Ave,
> 
> Let me explain what I¹m trying to do. Unfortunately it¹s not a very
> simple
> Add/Update transaction.
> Basically I gather records from multiple mySQL tables and add them to
> a DBF
> (dbase) database.  I wrote a code which was able to accomplish this
> without any problems and the add_records goes very smooth.
> 
> However, I have to modify this program now so that only ³New² records,
> i.e., records that have not yet been transferred, are added into the
> DBF.
> In other words, any records that are being added, which already exist
> in
> the DBF, should not be added.
> 
> If it were just adding records from one mySQL to another mySQL, I
> could easily use INSERT IGNORE or the Unique Key fundamental ­
> however, since I¹m adding from multiple mySQL tables into DBF, I¹m not
> sure how to go about doing this.
> 
> Here¹s my code that takes records from multiple mySQL tables and adds
> them
> to a DBF.
> 
> // define the array with mySQL Table Names & Identifier
> $tChoice = array(
>"lodispo" => "VB",
>"lodispo_osma" => "ATL",
>"lodispo_osmh" => "HOU",
>"lodispo_osmn" => "NSV",
>"lodispo_osmp" => "PAA",
>"lodispo_osmj" => "JAX",
>"lodispo_osmt" => "TPA",
>"lodispo_dmam" => "MET",
>"lodispo_osmf" => "FTM",
>"lodispo_hfglend" => "GLEND",
>   "lodispo_hfmesa" => "MESA",
>   "lodispo_hfphenx" => "PHENX",
> );
> 
> 
> // open DBF in read-write mode
> $db2 = dbase_open($theDBFf

RE: [PHP] IP to City detection

2007-03-23 Thread William Lovaton
Hi,

Thanks to all of you who helped me out.  I think this one is the best
option for now, it even has an API for PHP 4 and another one for PHP 5.

PHP 4: http://www.maxmind.com/download/geoip/api/php/
PHP 5: http://pear.php.net/package/Net_GeoIP/

Cheers,


-William



El mié, 21-03-2007 a las 14:53 +0200, Hidayet Dogan escribió:
> There's a MaxMind's GeoLite City service for that. It's free.
> 
> http://www.maxmind.com/app/geolitecity
> 
> On Wed, 21 Mar 2007, Jim Moseby wrote:
> 
> >> Hi people,
> >>
> >> Is there a way to detect the city of a person based on the IP
> >> address? I
> >> mean something like ip2nation http://www.ip2nation.com/ but for cities
> >> so I can use it in my PHP web application.
> >>
> >> Thanks for any help you can give me,
> >>
> >> -William
> >>
> >
> >
> > I have one that 'sort of' works.  It might be a start for you.  I don't take
> > credit for it, but I can't find in the source code any credits.  I'll send
> > it to you off list.
> >
> > 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



Re: [PHP] Re: Random Unique ID

2007-03-23 Thread Satyam
I'm sorry if I am repeating something that has been said, but in the 
comments to:


http://es2.php.net/manual/en/function.uniqid.php

there is a little piece of code that generates UUID as per RFC 4122, and 
those get as unique as they come.  MySql has a UUID() function and so do any 
database engine that supports replication, since that's the only way to 
ensure keys won't get repeated over multiple servers.


Satyam




- Original Message - 
From: <[EMAIL PROTECTED]>

To: 
Sent: Friday, March 23, 2007 7:48 PM
Subject: [PHP] Re: Random Unique ID



Robert Cummings writes:

Bleh, you can solve this with at most 2 queries.


Thanks.  That is a bit different than what I was thinking
about but it might work for my purposes.  Thanks also to all
the other people who made suggestions.
It appears to me that ther are 3 distinct approaches.
1)  Generate a random number.  Query the DB to see if it has been
used before and if so generate another random number and repeat.  It
seems to me that this would require that the DB be locked for the
checking and insertion to make sure a duplicate was not slipped in.
2)  Generate a random number.  Make a trial insertion for a unique
field.  If the insertion fails repeat.  This functions just like the
above but uses Mysql's native behavior to handle the checking so no
user locking is necessary.  Almost all the time this will require
only 1 insertion whereas the above will require 2 or more accesses.
3)  Generate a unique identifier from the record sequence number.  Since
the sequence number is guaranteed to be unique the identifier will also
be unique and can be used without any worry.  There are various schemes
I can think of by which the unique identifier, altho uniquely determined
by the sequence number, can be generated so that it will not reveal the
sequence number and appear unpredictable.  This will require 3 accesses
to the DB (insertion, mysql_insert_id, and update).
I have a number of options to try and think about.  Thanks again.
Best,
Craig
--
- Virtual Phonecards - Instant Pin by Email  -
-   Large Selection - Great Rates-
- http://speedypin.com/?aff=743&co_branded=1 -
-- 



**
**
*  Craig Spencer *
*  [EMAIL PROTECTED]*
**
**
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 
22/03/2007 7:44





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



Re: [PHP] Random Unique ID

2007-03-23 Thread tedd

At 9:15 AM +0100 3/23/07, Németh Zoltán wrote:

2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:

 At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
 >2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
 >
 >  > As for efficiency, that's probably not 
even worth mentioning in this case.

 >
 >why not? you would use 2 sql queries while I would use one most of the
 >time and 2 in case of already reserved ID - that is almost twice as much
 >processor time
 >that may count much if the routine is used frequently

 Go ahead, try it, and tell me how much time it cost.

 From experience, there are things one can spend
 their time optimizing and there are other things
 that one should be able to see that aren't worth
 pursing.

 I've been wrong before, but you're open to 
prove me wrong again, if you like.


okay, I've got up earlier and made a little benchmark. The result
suprised me, and proved you right. ;)


Németh:

Thanks for trying, but I said what I did because 
I knew from experience that these types of 
actions are blinding fast and getting faster all 
the time.


I'm not suggesting to dispense with looking for 
less operations, but sometimes the effort doesn't 
exceed other benefits in readability, easier 
logic, simpler code, and time spent developing 
code. We have been rather slow to realize changes 
the speed and memory of hardware.


For example, we recently had a discussion on the 
difference between using ""a "concern". When in fact, if is of no noticeable 
or significant concern at all. It's like 
discussing a grain of sand on the beach.


Not that you did this, but sometimes it's best to 
figure out what's important and what's not before 
making it an issue.


Cheers,

tedd

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



Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

Ah, got it.

Thanks a lot for the help Satyam!


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:


It seems to me @@identity should sufice, and it certainly does not need to
be any 'new' function, since it had been there for quite a while.  My
feeling is that those added functions might be used for elaborate stored
procedures, where you might be dealing with multiple tables or some fancy
administrative uses.  You certainly DON'T want any function that gives you
the last identity of some other connection!

$get_max = "SELECT @@identity";
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_fetch_row($max_result);
echo $max_id[0];

Though the fetch will return only one record with only one field, it will
still return that as an array, even if it only contains one element, so
you
still need to add the [0].  Unfortunately, PHP doesn't allow the brackets
to
a function that returns an array.

You might use mssql_result instead:

$get_max = "SELECT @@identity";
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_result($max_result,0,0);
echo $max_id;


Satyam

- Original Message -
From: "Dan Shirah" <[EMAIL PROTECTED]>
To: "Satyam" <[EMAIL PROTECTED]>
Cc: "php-general" 
Sent: Friday, March 23, 2007 7:48 PM
Subject: Re: [PHP] POST a variable


Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = "SELECT scope_identity()";
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_fetch_row($max_result);
echo "$max_id";

But all my echo returns is "array" instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of
the
table that produced the value, and regardless of the scope of the
statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that
produced
the value.


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:
>
>  I don't really know about the scope_identity() function, neither much
> about @@identity.  I know that the names preceded by @@ are MSSQL
internal
> variables and I think that is the one you are looking for, I just
checked
> in
> the on-line MS documentation, but have no SQL server active at this
> moment,
> nor have I dealt with one for the last few years, though I did use
> auto-increment fields and I certainly was able to retrieve the last id,
> somehow.  I might be wrong and there might be another function or
variable
> that gives you the value, but it looks to me @@identity is the one you
are
> looking for.
>
> There is no need in your code to do any while, if the SQL statement
> doesn't fail and triggers the die(), you can rest assured you'll get a
> record with a single field, even if it only contains a null, that's the
> way
> with variables, you can't fail on them, though they might return null.
>
> Satyam
>
>
> - Original Message -
> *From:* Dan Shirah <[EMAIL PROTECTED]>
>  *To:* Satyam <[EMAIL PROTECTED]>
> *Sent:* Friday, March 23, 2007 7:14 PM
> *Subject:* Re: [PHP] POST a variable
>
>
> Satyam, I'm trying to retrieve the id using the identity method, but I
do
> not get anything returned.  Do you see anything wrong with this code?
>
> $get_max = "SELECT scope_identity()";
>   $max_result = mssql_query($get_max) or die(mssql_error());
>   while($max=mssql_fetch_row($max_result)){
> }
> $max_id = $max[0];
>   echo "$max_id";
>
>
> On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:
> >
> > Do a 'select @@identity', it will give you the last record id.  The
gap
> > in
> > between steps 3 and 4, brief as it may seem, is enough to get you in
> > trouble.
> >
> > Satyam
> >
> >
> >
> > - Original Message -
> > From: "Dan Shirah" <[EMAIL PROTECTED]>
> > To: "Németh Zoltán" < [EMAIL PROTECTED]>
> > Cc: "php-general" 
> > Sent: Friday, March 23, 2007 4:07 PM
> > Subject: Re: [PHP] POST a variable
> >
> >
> > The reason I have to use it as I posted is because I am using
Microsoft
> > SQL
> > server instead of MySQL.  And I haven't found a php function for MSSQL
> > that
> > works the same as mysql_insert_id()
> >
> > So, to come out with a comparable function with pretty reliable
results,
> > I
> > follow this process:
> >
> > 1. User enters data into form
> > 2. User submits form
> > 3. Save page inserts info into the database
> > 4. Directly after the insert statement is my SELECT MAX query
> > 5. I assign the retrieved value to a hidden field
> > 6. I pass this value to the next form
> >
> > I figure the odds of another

[PHP] Another SimpleXMLElement question...

2007-03-23 Thread Mikey

If at first you don't succeed...

Our production environment is running on an old version of PHP 5.0 and 
cannot be easily updated.  My problem is that I have developed code 
against a new version and it has the SimpleXMLElement::addChild() 
function, but this is not present on the older version of PHP.
Does anyone know how to work around this?  Can I just treat the 
SimpleXMLElement object as an array and append as I see fit?


regards,

Mikey

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



Re: [PHP] POST a variable

2007-03-23 Thread Satyam
It seems to me @@identity should sufice, and it certainly does not need to 
be any 'new' function, since it had been there for quite a while.  My 
feeling is that those added functions might be used for elaborate stored 
procedures, where you might be dealing with multiple tables or some fancy 
administrative uses.  You certainly DON'T want any function that gives you 
the last identity of some other connection!


$get_max = "SELECT @@identity";
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo $max_id[0];

Though the fetch will return only one record with only one field, it will 
still return that as an array, even if it only contains one element, so you 
still need to add the [0].  Unfortunately, PHP doesn't allow the brackets to 
a function that returns an array.


You might use mssql_result instead:

$get_max = "SELECT @@identity";
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_result($max_result,0,0);
 echo $max_id;


Satyam

- Original Message - 
From: "Dan Shirah" <[EMAIL PROTECTED]>

To: "Satyam" <[EMAIL PROTECTED]>
Cc: "php-general" 
Sent: Friday, March 23, 2007 7:48 PM
Subject: Re: [PHP] POST a variable


Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = "SELECT scope_identity()";
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo "$max_id";

But all my echo returns is "array" instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of the
table that produced the value, and regardless of the scope of the statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:


 I don't really know about the scope_identity() function, neither much
about @@identity.  I know that the names preceded by @@ are MSSQL internal
variables and I think that is the one you are looking for, I just checked 
in
the on-line MS documentation, but have no SQL server active at this 
moment,

nor have I dealt with one for the last few years, though I did use
auto-increment fields and I certainly was able to retrieve the last id,
somehow.  I might be wrong and there might be another function or variable
that gives you the value, but it looks to me @@identity is the one you are
looking for.

There is no need in your code to do any while, if the SQL statement
doesn't fail and triggers the die(), you can rest assured you'll get a
record with a single field, even if it only contains a null, that's the 
way

with variables, you can't fail on them, though they might return null.

Satyam


- Original Message -
*From:* Dan Shirah <[EMAIL PROTECTED]>
 *To:* Satyam <[EMAIL PROTECTED]>
*Sent:* Friday, March 23, 2007 7:14 PM
*Subject:* Re: [PHP] POST a variable


Satyam, I'm trying to retrieve the id using the identity method, but I do
not get anything returned.  Do you see anything wrong with this code?

$get_max = "SELECT scope_identity()";
  $max_result = mssql_query($get_max) or die(mssql_error());
  while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
  echo "$max_id";


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:
>
> Do a 'select @@identity', it will give you the last record id.  The gap
> in
> between steps 3 and 4, brief as it may seem, is enough to get you in
> trouble.
>
> Satyam
>
>
>
> - Original Message -
> From: "Dan Shirah" <[EMAIL PROTECTED]>
> To: "Németh Zoltán" < [EMAIL PROTECTED]>
> Cc: "php-general" 
> Sent: Friday, March 23, 2007 4:07 PM
> Subject: Re: [PHP] POST a variable
>
>
> The reason I have to use it as I posted is because I am using Microsoft
> SQL
> server instead of MySQL.  And I haven't found a php function for MSSQL
> that
> works the same as mysql_insert_id()
>
> So, to come out with a comparable function with pretty reliable results,
> I
> follow this process:
>
> 1. User enters data into form
> 2. User submits form
> 3. Save page inserts info into the database
> 4. Directly after the insert statement is my SELECT MAX query
> 5. I assign the retrieved value to a hidden field
> 6. I pass this value to the next form
>
> I figure the odds of another record being inserted inbetween the time it
> takes to go from step 3 to step 4 are very, very minimal.  We're talking
> about MAYBE a 2-3 millisecond gap?
>
>
> On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote:

Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = "SELECT scope_identity()";
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo "$max_id";

But all my echo returns is "array" instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of the
table that produced the value, and regardless of the scope of the statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:


 I don't really know about the scope_identity() function, neither much
about @@identity.  I know that the names preceded by @@ are MSSQL internal
variables and I think that is the one you are looking for, I just checked in
the on-line MS documentation, but have no SQL server active at this moment,
nor have I dealt with one for the last few years, though I did use
auto-increment fields and I certainly was able to retrieve the last id,
somehow.  I might be wrong and there might be another function or variable
that gives you the value, but it looks to me @@identity is the one you are
looking for.

There is no need in your code to do any while, if the SQL statement
doesn't fail and triggers the die(), you can rest assured you'll get a
record with a single field, even if it only contains a null, that's the way
with variables, you can't fail on them, though they might return null.

Satyam


- Original Message -
*From:* Dan Shirah <[EMAIL PROTECTED]>
 *To:* Satyam <[EMAIL PROTECTED]>
*Sent:* Friday, March 23, 2007 7:14 PM
*Subject:* Re: [PHP] POST a variable


Satyam, I'm trying to retrieve the id using the identity method, but I do
not get anything returned.  Do you see anything wrong with this code?

$get_max = "SELECT scope_identity()";
  $max_result = mssql_query($get_max) or die(mssql_error());
  while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
  echo "$max_id";


On 3/23/07, Satyam <[EMAIL PROTECTED]> wrote:
>
> Do a 'select @@identity', it will give you the last record id.  The gap
> in
> between steps 3 and 4, brief as it may seem, is enough to get you in
> trouble.
>
> Satyam
>
>
>
> - Original Message -
> From: "Dan Shirah" <[EMAIL PROTECTED]>
> To: "Németh Zoltán" < [EMAIL PROTECTED]>
> Cc: "php-general" 
> Sent: Friday, March 23, 2007 4:07 PM
> Subject: Re: [PHP] POST a variable
>
>
> The reason I have to use it as I posted is because I am using Microsoft
> SQL
> server instead of MySQL.  And I haven't found a php function for MSSQL
> that
> works the same as mysql_insert_id()
>
> So, to come out with a comparable function with pretty reliable results,
> I
> follow this process:
>
> 1. User enters data into form
> 2. User submits form
> 3. Save page inserts info into the database
> 4. Directly after the insert statement is my SELECT MAX query
> 5. I assign the retrieved value to a hidden field
> 6. I pass this value to the next form
>
> I figure the odds of another record being inserted inbetween the time it
> takes to go from step 3 to step 4 are very, very minimal.  We're talking
> about MAYBE a 2-3 millisecond gap?
>
>
> On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote:
> >
> > 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> > > Okay, I feel like the correct answer to this is about 2mm back in my
>
> > grey
> > > matter.
> > >
> > > 1. I have a query that pulls the last row number when a newly
> inserted
> > > record is added:
> > >
> > > $maximum="SELECT MAX(payment_id) FROM payment_request";
> > >   $max_result=mssql_query($maximum);
> > >   while($max=mssql_fetch_row($max_result)){
> > >   }
> > >   $max_id = $max[0];
> > >
> > > 2. I have multiple selections for the user to pick, but regardless
> of
> > what
> > > they choose I want the $max_id variable to be passed to the next
> page.
> > >
> > > 3.  Would I go about this by assigning $max_id to a hidden field
> like
> > below?
> > >
> > > " size="5"
> > > maxlength="10" name="max_id" />
> > >
> > > 4.  And then to retrieve this value on my next page just get it out
> of
> > > $_POST['max_id']  ??
> > >
> > > Does that all sound correct?
> >
> > basically yes
> > but if you want the id of the row you just inserted, using
> > mysql_insert_id() is better because if another insert is happening at
> > the same time, select max() may give you incorrect result
> >
> > greets
> > Zoltán Németh
> >
> >
>
>
>
> 
-

[PHP] Re: Random Unique ID

2007-03-23 Thread ccspencer
Robert Cummings writes: 


Bleh, you can solve this with at most 2 queries.


Thanks.  That is a bit different than what I was thinking
about but it might work for my purposes.  Thanks also to all
the other people who made suggestions. 


It appears to me that ther are 3 distinct approaches.
1)  Generate a random number.  Query the DB to see if it has been
used before and if so generate another random number and repeat.  It
seems to me that this would require that the DB be locked for the
checking and insertion to make sure a duplicate was not slipped in.
2)  Generate a random number.  Make a trial insertion for a unique
field.  If the insertion fails repeat.  This functions just like the
above but uses Mysql's native behavior to handle the checking so no
user locking is necessary.  Almost all the time this will require
only 1 insertion whereas the above will require 2 or more accesses.
3)  Generate a unique identifier from the record sequence number.  Since
the sequence number is guaranteed to be unique the identifier will also
be unique and can be used without any worry.  There are various schemes
I can think of by which the unique identifier, altho uniquely determined
by the sequence number, can be generated so that it will not reveal the
sequence number and appear unpredictable.  This will require 3 accesses
to the DB (insertion, mysql_insert_id, and update). 

I have a number of options to try and think about.  Thanks again. 

Best, 

Craig 


--
- Virtual Phonecards - Instant Pin by Email  -
-   Large Selection - Great Rates-
- http://speedypin.com/?aff=743&co_branded=1 -
-- 



**
**
*  Craig Spencer *
*  [EMAIL PROTECTED]*
**
** 


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



Re: [PHP] Add New Records Only!

2007-03-23 Thread Rahul Sitaram Johari
Ave,

> A better solution would be to add a column in the MySQL table, maybe call it
> "processed" with a default value of 0, and update this value to 1 with each
> row inserted.  Then you are only querying records where processed=0.
> Of course this will not work if you cannot modify the MySQL table.

I have to tell you that this is probably the most efficient & feasible
method suggested yet! Let me take a look at my structure & application and
see how efficiently this can be implemented.

I did think about the cron job midnight update initially - and while it
looked like a possible method, my only problem was that occasionally a
manual update would be required, and I would need a program in place that is
able to handle that. If it were solely an automatic midnight update, I would
have certainly gone the cron way with a date limitation.

Thanks!


On 3/23/07 2:17 PM, "Brad Fuller" <[EMAIL PROTECTED]> wrote:

> Rahul wrote:
>> Ave,
>> 
>> It's definitely not live data, so that is not a problem at all. But I'm
>> not
>> sure I understand your method very well.
>> 
>> I do understand getting data from both the existing DBF and the multiple
>> mySQL tables into a temporary mySQL table. But if I do go ahead and do
>> that,
>> I guess I could write a 'delete-duplicates' kind of code that deletes all
>> rows in that temporary table which are duplicates, and then add the
>> leftover
>> into the DBF.
>> 
>> Not sure how this sounds, or how close this is to what you were saying.
>> And
>> not even sure how to implement this.
> 
> 
> Do you need to update this more than once a day?  Is there a date field in
> all the tables?
> 
> If you can do it daily, then query for records from the previous day and run
> it once daily at midnight via cron job.
> 
> If it has to be done more often than once a day there are other solutions.
> 
> One thing I thought is to store the name of the table it came from along
> with the primary key in that table.  These 2 fields combined will be your
> unique identifier.  Store this in your DBF and check for existence before
> you insert.
> 
> With that solution in mind however you're still querying for the entire set
> of data which is very inefficient.
> 
> A better solution would be to add a column in the MySQL table, maybe call it
> "processed" with a default value of 0, and update this value to 1 with each
> row inserted.  Then you are only querying records where processed=0.
> Of course this will not work if you cannot modify the MySQL table.
> 
> Best of luck,
> 
> Brad

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



Re: [PHP] php support

2007-03-23 Thread Brad Bonkoski

Richard Dunne wrote:

Tried that.

PHP Warning: PHP Startup:Unable to load dynamic library 
'./php_pgsql.dll' The specified module could not be found.

Fatal Error: Call to undefined function pg_connect()

Read here for some info:
http://www.sitepoint.com/article/use-postgresql-php-windows/3

Not finding your dll...not sure where those should be stored, might try 
the "find" function in windows.
Otherwise, post back to the list (with reply-all) as others might have 
better experiences with this.

-B
 
I might have to use JSP instead of PHP.
 
Richard

- Original Message 
From: Brad Bonkoski <[EMAIL PROTECTED]>
To: Richard Dunne <[EMAIL PROTECTED]>
Sent: Friday, March 23, 2007 6:12:08 PM
Subject: Re: [PHP] php support

Richard Dunne wrote:
> Postgresql 8.2 and PHP5.2.1  using php installer.zip installed on
> windows XP
>  
> Do you know if postgresql is built into any php version?
>  
Should be...but you have to activate it..


find your php.ini file
and look for the line:
;extension=php_pgsql.dll
-->remove the ; at the beginning of it!
Then restart PHP and try again.
-B

> Richard
>
> - Original Message 
> From: Brad Bonkoski <[EMAIL PROTECTED]>
> To: Richard Dunne <[EMAIL PROTECTED]>
> Cc: php-general@lists.php.net
> Sent: Friday, March 23, 2007 5:48:19 PM
> Subject: Re: [PHP] php support
>
> Richard Dunne wrote:
> > Can anyone tell me where to get support for this?  
> Here

> > php5 undefined function pg_connect()
> >  
> postgresql was not built into your version of PHP.

> Perhaps post which platform your run on, and other information like
> using a pre-canned binary or are building for source.
> -B
> > Is there a specific mailig list fro users?
> >
> > Thanks,
> >
> > Richard Dunne
> >
> >
> >  
> >
> 


> > Expecting? Get great news right away with email Auto-Check.
> > Try the Yahoo! Mail Beta.
> > http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
> >
>
>
> 
> Food fight?
> 
> 


> Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> 
>




Get your own web address. 

Have a HUGE year through Yahoo! Small Business. 



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



RE: [PHP] Amazon AWS + SimpleXML

2007-03-23 Thread Brad Fuller
> -Original Message-
> From: Myron Turner [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 20, 2007 10:24 AM
> To: Brad Fuller
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Amazon AWS + SimpleXML
> 
> Brad Fuller wrote:
> > Hey guys,
> >
> > I'm having trouble trying to parse XML results from an Alexa Web
> information
> > service from amazon.com, using SimpleXML.
> >
> >
> >
> 
> I found a site which deals with handling namespaces in SimpleXML.  That
> and the nested tags are probably what are giving you trouble,   This is
> the url:
> http://www-128.ibm.com/developerworks/xml/library/x-simplexml.html
> 
> You might also want to look at XML_PullParser.  I've written a script
> which does the job:
>   http://mturner.org/pullParser/amazon.phps
> The result is:
> http://mturner.org/pullParser/amazon.php
> 
> You can download the class files at
> http://www.mturner.org/XML_PullParser/
>  If  you decide to use it, download the most recent version, which is
> 1.3.2.

Thank you very much Myron, and sorry for the delayed response.

My boss has put the project on hold for now so I haven't had the chance to
test it yet, but I did download the source, and after looking over it I'm
pretty confident that it will get the job done :)

Cheers,

Brad

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



RE: [PHP] Add New Records Only!

2007-03-23 Thread Brad Fuller
Rahul wrote:
> Ave,
> 
> It's definitely not live data, so that is not a problem at all. But I'm
> not
> sure I understand your method very well.
> 
> I do understand getting data from both the existing DBF and the multiple
> mySQL tables into a temporary mySQL table. But if I do go ahead and do
> that,
> I guess I could write a 'delete-duplicates' kind of code that deletes all
> rows in that temporary table which are duplicates, and then add the
> leftover
> into the DBF.
> 
> Not sure how this sounds, or how close this is to what you were saying.
> And
> not even sure how to implement this.


Do you need to update this more than once a day?  Is there a date field in
all the tables?

If you can do it daily, then query for records from the previous day and run
it once daily at midnight via cron job.

If it has to be done more often than once a day there are other solutions.

One thing I thought is to store the name of the table it came from along
with the primary key in that table.  These 2 fields combined will be your
unique identifier.  Store this in your DBF and check for existence before
you insert.

With that solution in mind however you're still querying for the entire set
of data which is very inefficient.

A better solution would be to add a column in the MySQL table, maybe call it
"processed" with a default value of 0, and update this value to 1 with each
row inserted.  Then you are only querying records where processed=0.
Of course this will not work if you cannot modify the MySQL table.

Best of luck,

Brad

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



Re: [PHP] Name Capitalization

2007-03-23 Thread Paul Novitski

At 3/21/2007 04:57 AM, Shafiq Rehman wrote:

Some problems are universal and we cannot fix them in computer science. I
think it's better to educate/guide your visitors about such names that they
write in correct capitalization



In this case, the OP has an existing list of names he wants to 
de-capitalize, not an ongoing stream of new names from people who 
might be trained.


Regards,
Paul 


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



Re: [PHP] Add New Records Only!

2007-03-23 Thread Rahul Sitaram Johari

Ave,

It's definitely not live data, so that is not a problem at all. But I'm not
sure I understand your method very well.

I do understand getting data from both the existing DBF and the multiple
mySQL tables into a temporary mySQL table. But if I do go ahead and do that,
I guess I could write a 'delete-duplicates' kind of code that deletes all
rows in that temporary table which are duplicates, and then add the leftover
into the DBF. 

Not sure how this sounds, or how close this is to what you were saying. And
not even sure how to implement this.


On 3/23/07 2:27 PM, "markw@mohawksoft.com"  wrote:

>> 
>> Ave,
>> 
>> "Three: Insert everything and remove duplicates later."
>> 
>> Out of the suggested options, this option is sounding the most sane
>> attainable on my end. I don't have a complete grip on how to accomplish
>> this, but certainly sounds feasible. Let me look at ways to achieve this.
>> 
>> Thanks!
>> 
> 
> I'm not sure how live this data is, but it should be easy to do if you are
> merely replicating and don't need this stuff all live all the time.
> 
> basically, query all databases, get all the data, and store in a temporary
> database. Then query all the data in the temporary database and order by
> your primary key. Save a copy of your primary key for each next row. If
> the subsequent primary key is the same as the previous one, it is a
> duplicate record and ignore it.
> 
> like this: (pseudo code)
> 
> $primary_key = "";
> while(!eof())
> {
>$record = get_next_record();
> 
> if($record->primary_key != $primary_key)
> {
>store_new_record($record);
>$primary_key = $record->primary_key;
> }
> }
> 
> 
> }
> 
>> On 3/23/07 11:36 AM, "Mark"  wrote:
>> 
>>> Rahul Sitaram Johari wrote:
>>> 
>>> As far as I can see, there is probably only three ways to do this:
>>> 
>>> One: Make sure your dbase system contains unique primary key capability,
>>> and
>>> use it to avoid duplicates.
>>> Two: query for the row, if it isn't there insert it. (You'll have to
>>> deal
>>> with concurrency with locking or something)
>>> Three: Insert everything and remove duplicates later.
>>> 
 Ave,
 
 Let me explain what I¹m trying to do. Unfortunately it¹s not a very
 simple
 Add/Update transaction.
 Basically I gather records from multiple mySQL tables and add them to a
 DBF
 (dbase) database.  I wrote a code which was able to accomplish this
 without any problems and the add_records goes very smooth.
 
 However, I have to modify this program now so that only ³New² records,
 i.e., records that have not yet been transferred, are added into the
 DBF.
 In other words, any records that are being added, which already exist
 in
 the DBF, should not be added.
 
 If it were just adding records from one mySQL to another mySQL, I could
 easily use INSERT IGNORE or the Unique Key fundamental ­ however, since
 I¹m adding from multiple mySQL tables into DBF, I¹m not sure how to go
 about doing this.
 
 Here¹s my code that takes records from multiple mySQL tables and adds
 them
 to a DBF.
 
 // define the array with mySQL Table Names & Identifier
 $tChoice = array(
"lodispo" => "VB",
"lodispo_osma" => "ATL",
"lodispo_osmh" => "HOU",
"lodispo_osmn" => "NSV",
"lodispo_osmp" => "PAA",
"lodispo_osmj" => "JAX",
"lodispo_osmt" => "TPA",
"lodispo_dmam" => "MET",
"lodispo_osmf" => "FTM",
"lodispo_hfglend" => "GLEND",
   "lodispo_hfmesa" => "MESA",
   "lodispo_hfphenx" => "PHENX",
 );
 
 
 // open DBF in read-write mode
 $db2 = dbase_open($theDBFfile, 2);
 if (!$db2) {
   echo "Fatal Error: Unable to open
 database";
   exit;
 }
 
 else {
 
 // Let's Run Array Loops!
 foreach ($tChoice as $tblQ => $bxQ) {
 
 // connect to mySQL tables one by one
 mysql_select_db($database_imslead_transfer,
 $imslead_transfer); $query_loDispo = "SELECT * FROM $tblQ";
 $loDispo = mysql_query($query_loDispo, $imslead_transfer)
 or
 die(mysql_error());
 $row_loDispo = mysql_fetch_assoc($loDispo);
 $totalRows_loDispo = mysql_num_rows($loDispo);
 
 // write mySql data to Dbf
 do {
  dbase_add_record($db2, array(
  $row_loDispo['phone'],
  $row_loDispo['comments'],
  $row_loDispo['starttime'],
  $row_loDispo['endtime'],
  $row_loDispo['dispo'],
  $row_loDispo['loanofficer'],
  $row_loDispo['verifier'],
  $bxQ))

RE: [PHP] php support

2007-03-23 Thread Jake McHenry
Look at phpinfo(), you probably don't have PQSql support installed...

Jake
 

> -Original Message-
> From: Richard Dunne [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 1:31 PM
> To: php-general@lists.php.net
> Subject: [PHP] php support
> 
> Can anyone tell me where to get support for this?  php5 
> undefined function pg_connect() 
> Is there a specific mailig list fro users?
> 
> Thanks,
> 
> Richard Dunne
> 
> 
>  
> __
> __
> Expecting? Get great news right away with email Auto-Check. 
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release 
> Date: 3/22/2007 7:44 AM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007
7:44 AM
 

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



Re: [PHP] Add New Records Only!

2007-03-23 Thread markw
>
> Ave,
>
> "Three: Insert everything and remove duplicates later."
>
> Out of the suggested options, this option is sounding the most sane
> attainable on my end. I don't have a complete grip on how to accomplish
> this, but certainly sounds feasible. Let me look at ways to achieve this.
>
> Thanks!
>

I'm not sure how live this data is, but it should be easy to do if you are
merely replicating and don't need this stuff all live all the time.

basically, query all databases, get all the data, and store in a temporary
database. Then query all the data in the temporary database and order by
your primary key. Save a copy of your primary key for each next row. If
the subsequent primary key is the same as the previous one, it is a
duplicate record and ignore it.

like this: (pseudo code)

$primary_key = "";
while(!eof())
{
   $record = get_next_record();

if($record->primary_key != $primary_key)
{
   store_new_record($record);
   $primary_key = $record->primary_key;
}
}


}

> On 3/23/07 11:36 AM, "Mark"  wrote:
>
>> Rahul Sitaram Johari wrote:
>>
>> As far as I can see, there is probably only three ways to do this:
>>
>> One: Make sure your dbase system contains unique primary key capability,
>> and
>> use it to avoid duplicates.
>> Two: query for the row, if it isn't there insert it. (You'll have to
>> deal
>> with concurrency with locking or something)
>> Three: Insert everything and remove duplicates later.
>>
>>> Ave,
>>>
>>> Let me explain what I¹m trying to do. Unfortunately it¹s not a very
>>> simple
>>> Add/Update transaction.
>>> Basically I gather records from multiple mySQL tables and add them to a
>>> DBF
>>> (dbase) database.  I wrote a code which was able to accomplish this
>>> without any problems and the add_records goes very smooth.
>>>
>>> However, I have to modify this program now so that only ³New² records,
>>> i.e., records that have not yet been transferred, are added into the
>>> DBF.
>>> In other words, any records that are being added, which already exist
>>> in
>>> the DBF, should not be added.
>>>
>>> If it were just adding records from one mySQL to another mySQL, I could
>>> easily use INSERT IGNORE or the Unique Key fundamental ­ however, since
>>> I¹m adding from multiple mySQL tables into DBF, I¹m not sure how to go
>>> about doing this.
>>>
>>> Here¹s my code that takes records from multiple mySQL tables and adds
>>> them
>>> to a DBF.
>>>
>>> // define the array with mySQL Table Names & Identifier
>>> $tChoice = array(
>>>"lodispo" => "VB",
>>>"lodispo_osma" => "ATL",
>>>"lodispo_osmh" => "HOU",
>>>"lodispo_osmn" => "NSV",
>>>"lodispo_osmp" => "PAA",
>>>"lodispo_osmj" => "JAX",
>>>"lodispo_osmt" => "TPA",
>>>"lodispo_dmam" => "MET",
>>>"lodispo_osmf" => "FTM",
>>>"lodispo_hfglend" => "GLEND",
>>>   "lodispo_hfmesa" => "MESA",
>>>   "lodispo_hfphenx" => "PHENX",
>>> );
>>>
>>>
>>> // open DBF in read-write mode
>>> $db2 = dbase_open($theDBFfile, 2);
>>> if (!$db2) {
>>>   echo "Fatal Error: Unable to open
>>> database";
>>>   exit;
>>> }
>>>
>>> else {
>>>
>>> // Let's Run Array Loops!
>>> foreach ($tChoice as $tblQ => $bxQ) {
>>>
>>> // connect to mySQL tables one by one
>>> mysql_select_db($database_imslead_transfer,
>>> $imslead_transfer); $query_loDispo = "SELECT * FROM $tblQ";
>>> $loDispo = mysql_query($query_loDispo, $imslead_transfer)
>>> or
>>> die(mysql_error());
>>> $row_loDispo = mysql_fetch_assoc($loDispo);
>>> $totalRows_loDispo = mysql_num_rows($loDispo);
>>>
>>> // write mySql data to Dbf
>>> do {
>>>  dbase_add_record($db2, array(
>>>  $row_loDispo['phone'],
>>>  $row_loDispo['comments'],
>>>  $row_loDispo['starttime'],
>>>  $row_loDispo['endtime'],
>>>  $row_loDispo['dispo'],
>>>  $row_loDispo['loanofficer'],
>>>  $row_loDispo['verifier'],
>>>  $bxQ));
>>>  } while ($row_loDispo = mysql_fetch_assoc($loDispo));
>>> }
>>>
>>> dbase_close($db2);
>>> }
>>>
>>> Any suggestions would be highly appreciated.
>>>
>>> Thanks,
>>>
>>> ~~~
>>> Rahul Sitaram Johari
>>> CEO, Twenty Four Seventy Nine Inc.
>>>
>>> W: http://www.rahulsjohari.com
>>> E: [EMAIL PROTECTED]
>>>
>>> ³I morti non sono piu soli ... The dead are no longer lonely²
>
>
>

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



Re: [PHP] php support

2007-03-23 Thread Brad Bonkoski

Richard Dunne wrote:
Can anyone tell me where to get support for this?  

Here
php5 undefined function pg_connect() 
  

postgresql was not built into your version of PHP.
Perhaps post which platform your run on, and other information like 
using a pre-canned binary or are building for source.

-B

Is there a specific mailig list fro users?

Thanks,

Richard Dunne


 

Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 
  


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



[PHP] php support

2007-03-23 Thread Richard Dunne
Can anyone tell me where to get support for this?  php5 undefined function 
pg_connect() 
Is there a specific mailig list fro users?

Thanks,

Richard Dunne


 

Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

Re: [PHP] Add New Records Only!

2007-03-23 Thread Satyam
Delete from table where id = (select min(id) from table group by field1, 
field2 ,...  having count(id) > 1)


Id is the unique primary key, fieldn are the fields that can be duplicated. 
Each time this runs it will remove one occurence of the all duplicated 
records.  You'd have to run it several times until it deletes no more 
records.   In MySql, you cannot have the same table in the 'delete' and in 
the subquery, thus, you will have to first insert the id's in an auxiliary 
table and then delete the records.


Satyam

- Original Message - 
From: "Rahul Sitaram Johari" <[EMAIL PROTECTED]>

To: "Mark" ; "PHP" 
Sent: Friday, March 23, 2007 5:24 PM
Subject: Re: [PHP] Add New Records Only!




Ave,

"Three: Insert everything and remove duplicates later."

Out of the suggested options, this option is sounding the most sane
attainable on my end. I don't have a complete grip on how to accomplish
this, but certainly sounds feasible. Let me look at ways to achieve this.

Thanks!

On 3/23/07 11:36 AM, "Mark"  wrote:


Rahul Sitaram Johari wrote:

As far as I can see, there is probably only three ways to do this:

One: Make sure your dbase system contains unique primary key capability, 
and

use it to avoid duplicates.
Two: query for the row, if it isn't there insert it. (You'll have to deal
with concurrency with locking or something)
Three: Insert everything and remove duplicates later.


Ave,

Let me explain what I¹m trying to do. Unfortunately it¹s not a very 
simple

Add/Update transaction.
Basically I gather records from multiple mySQL tables and add them to a
DBF
(dbase) database.  I wrote a code which was able to accomplish this
without any problems and the add_records goes very smooth.

However, I have to modify this program now so that only ³New² records,
i.e., records that have not yet been transferred, are added into the 
DBF.

In other words, any records that are being added, which already exist in
the DBF, should not be added.

If it were just adding records from one mySQL to another mySQL, I could
easily use INSERT IGNORE or the Unique Key fundamental ­ however, since
I¹m adding from multiple mySQL tables into DBF, I¹m not sure how to go
about doing this.

Here¹s my code that takes records from multiple mySQL tables and adds 
them

to a DBF.

// define the array with mySQL Table Names & Identifier
$tChoice = array(
   "lodispo" => "VB",
   "lodispo_osma" => "ATL",
   "lodispo_osmh" => "HOU",
   "lodispo_osmn" => "NSV",
   "lodispo_osmp" => "PAA",
   "lodispo_osmj" => "JAX",
   "lodispo_osmt" => "TPA",
   "lodispo_dmam" => "MET",
   "lodispo_osmf" => "FTM",
   "lodispo_hfglend" => "GLEND",
  "lodispo_hfmesa" => "MESA",
  "lodispo_hfphenx" => "PHENX",
);


// open DBF in read-write mode
$db2 = dbase_open($theDBFfile, 2);
if (!$db2) {
  echo "Fatal Error: Unable to open
database";
  exit;
}

else {

// Let's Run Array Loops!
foreach ($tChoice as $tblQ => $bxQ) {

// connect to mySQL tables one by one
mysql_select_db($database_imslead_transfer,
$imslead_transfer); $query_loDispo = "SELECT * FROM $tblQ";
$loDispo = mysql_query($query_loDispo, $imslead_transfer) or
die(mysql_error());
$row_loDispo = mysql_fetch_assoc($loDispo);
$totalRows_loDispo = mysql_num_rows($loDispo);

// write mySql data to Dbf
do {
 dbase_add_record($db2, array(
 $row_loDispo['phone'],
 $row_loDispo['comments'],
 $row_loDispo['starttime'],
 $row_loDispo['endtime'],
 $row_loDispo['dispo'],
 $row_loDispo['loanofficer'],
 $row_loDispo['verifier'],
 $bxQ));
 } while ($row_loDispo = mysql_fetch_assoc($loDispo));
}

dbase_close($db2);
}

Any suggestions would be highly appreciated.

Thanks,

~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²


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




--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 
22/03/2007 7:44





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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Dwayne Heronimo
YES this works thank nemeth:

 235)
 {
  $len = 235;
 }
 else
 {
  $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

 return $previewtext;
}
?>

and to display it:



cheers

Dwayne




""Németh Zoltán"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 2007. 03. 23, péntek keltezéssel 16.55-kor Dwayne Heronimo ezt írta:
>> Dear all,
>>
>> hmm.. sorry the $previewstext thing was a typo in my mail.
>>
>> But yes it is working but it will only display the first record of the
>> recordset. I have like a list for items with short text in a page and of
>> course made a query to make the database variables available. Which where
>> the variable $row_show_cat['text']; comes from.
>>
>> This is why I thought that i may have to rewrite it into a function to
>> display the $row_show_cat['text']; in a repeated reagion.
>>
>>
>> I have rewritten my function:
>>
>> >  function previewString($showcatvar) {
>>
>>  $minitxt = $showcatvar;
>>  $len = strlen($minitxt);
>>
>>  if ($len > 235)
>>  {
>>   $len = 235;
>>  }
>>  else
>>  {
>>   $len = $len;
>>  }
>>
>>  $newstring = substr($minitxt,0,$len);
>>
>>  $previewtext = $newstring;
>>
>>  $previewtext = $whowcatvar;
>
> what is the meaning of the above line???
> you are giving an undefined value (default NULL) to $previewtext, just
> after you gave it the right value
> delete that line and you might be well
>
> greets
> Zoltán Németh
>
>>
>>  return $previewtext;
>> }
>> ?>
>>
>> And to to show it later in the page:
>> 
>> but this still won't anywould display anything. :S
>>
>> Please let me know.
>>
>> ""Tijnema !"" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
>> >> Dear All,
>> >>
>> >> I am very new to programming. I want to make a preview text that would
>> >> display only a part of the text that is a text field in a database.
>> >>
>> >> //Begin Make preview string
>> >>
>> >>  $minitxt = $row_show_cat['text'];
>> >>  $len = strlen($minitxt);
>> >>
>> >>  if ($len > 235)
>> >>  {
>> >>  $len = 235;
>> >>  }
>> >>  else
>> >>  {
>> >>  $len = $len;
>> >>  }
>> >>
>> >>  $newstring = substr($minitxt,0,$len);
>> >>
>> >>  $previewtext = $newstring;
>> >>
>> >> //End Make preview string
>> >>
>> >> But if I want to display this somewhere in the page it will only 
>> >> display
>> >> the
>> >> first record of at every text column row 
>> >>
>> >> Althought I am very new to php and programming. I thought maybe I 
>> >> should
>> >> rewrite it into a function. But my function won't work.
>> >>
>> >>
>> >> function previewString($showcatvar) {
>> >>
>> >>  $minitxt = $showcatvar;
>> >>  $len = strlen($minitxt);
>> >>
>> >>  if ($len > 235)
>> >>  {
>> >>  $len = 235;
>> >>  }
>> >>  else
>> >>  {
>> >>  $len = $len;
>> >>  }
>> >>
>> >>  $newstring = substr($minitxt,0,$len);
>> >>
>> >>  $previewtext = $newstring;
>> >>
>> >>  $previewtext = $whowcatvar;
>> >>
>> >> }
>> >>
>> >>
>> >> and to display it in the page:
>> >>
>> >> 
>> >>
>> >> IT displays notthing. But I think I am doing somthing wrong. I am
>> >> assigning
>> >> the wrong variables to the $row_show_cat['text']) ???
>> >>
>> >> Please let me know
>> >
>> > I'm currently not sure why your first piece of code isn't working, but
>> > the second is quite simple. You aren't returning any variable in your
>> > function, and so it won't output anything. Add the following:
>> > return $previewtext;
>> > Just before the }
>> >
>> > Then it will return something, but i think not what you wanted to :(
>> >
>> > Tijnema
>> >>
>> >> --
>> >> 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: High quality image resizing

2007-03-23 Thread Al
I'd be surprised if Imagemagick won't do the job. It has a terrific amount of 
tools; but there is a bit of a learning curve.


Suggest visiting the IM forums and asking for help.

Also, try resizing some images here 
http://studio.webbyland.com/MagickStudio/scripts/MagickStudio.cgi


I use php exec() for my work.

Markus Fischer wrote:

Hi,

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with PHP4 and GD lib
2.0.33 and everything produces with them got rejected so far. I was also
going through the comments on php.net regarding self-written Bicubical
algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much better when
using the 'mogrify' tool from this package, yet not good enough for my
designers.

Of course, their expectations are very high because of their daily usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows library.
Using a commercial package would be completely fine for me, however I
just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.

thanks for any hints,
- Markus


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



Re: [PHP] Add New Records Only!

2007-03-23 Thread Rahul Sitaram Johari

Ave,

"Three: Insert everything and remove duplicates later."

Out of the suggested options, this option is sounding the most sane
attainable on my end. I don't have a complete grip on how to accomplish
this, but certainly sounds feasible. Let me look at ways to achieve this.

Thanks!

On 3/23/07 11:36 AM, "Mark"  wrote:

> Rahul Sitaram Johari wrote:
> 
> As far as I can see, there is probably only three ways to do this:
> 
> One: Make sure your dbase system contains unique primary key capability, and
> use it to avoid duplicates.
> Two: query for the row, if it isn't there insert it. (You'll have to deal
> with concurrency with locking or something)
> Three: Insert everything and remove duplicates later.
> 
>> Ave,
>> 
>> Let me explain what I¹m trying to do. Unfortunately it¹s not a very simple
>> Add/Update transaction.
>> Basically I gather records from multiple mySQL tables and add them to a
>> DBF
>> (dbase) database.  I wrote a code which was able to accomplish this
>> without any problems and the add_records goes very smooth.
>> 
>> However, I have to modify this program now so that only ³New² records,
>> i.e., records that have not yet been transferred, are added into the DBF.
>> In other words, any records that are being added, which already exist in
>> the DBF, should not be added.
>> 
>> If it were just adding records from one mySQL to another mySQL, I could
>> easily use INSERT IGNORE or the Unique Key fundamental ­ however, since
>> I¹m adding from multiple mySQL tables into DBF, I¹m not sure how to go
>> about doing this.
>> 
>> Here¹s my code that takes records from multiple mySQL tables and adds them
>> to a DBF.
>> 
>> // define the array with mySQL Table Names & Identifier
>> $tChoice = array(
>>"lodispo" => "VB",
>>"lodispo_osma" => "ATL",
>>"lodispo_osmh" => "HOU",
>>"lodispo_osmn" => "NSV",
>>"lodispo_osmp" => "PAA",
>>"lodispo_osmj" => "JAX",
>>"lodispo_osmt" => "TPA",
>>"lodispo_dmam" => "MET",
>>"lodispo_osmf" => "FTM",
>>"lodispo_hfglend" => "GLEND",
>>   "lodispo_hfmesa" => "MESA",
>>   "lodispo_hfphenx" => "PHENX",
>> );
>> 
>> 
>> // open DBF in read-write mode
>> $db2 = dbase_open($theDBFfile, 2);
>> if (!$db2) {
>>   echo "Fatal Error: Unable to open
>> database";
>>   exit;
>> }
>> 
>> else {
>> 
>> // Let's Run Array Loops!
>> foreach ($tChoice as $tblQ => $bxQ) {
>> 
>> // connect to mySQL tables one by one
>> mysql_select_db($database_imslead_transfer,
>> $imslead_transfer); $query_loDispo = "SELECT * FROM $tblQ";
>> $loDispo = mysql_query($query_loDispo, $imslead_transfer) or
>> die(mysql_error());
>> $row_loDispo = mysql_fetch_assoc($loDispo);
>> $totalRows_loDispo = mysql_num_rows($loDispo);
>>   
>> // write mySql data to Dbf
>> do {
>>  dbase_add_record($db2, array(
>>  $row_loDispo['phone'],
>>  $row_loDispo['comments'],
>>  $row_loDispo['starttime'],
>>  $row_loDispo['endtime'],
>>  $row_loDispo['dispo'],
>>  $row_loDispo['loanofficer'],
>>  $row_loDispo['verifier'],
>>  $bxQ));
>>  } while ($row_loDispo = mysql_fetch_assoc($loDispo));
>> }
>>  
>> dbase_close($db2);
>> }
>> 
>> Any suggestions would be highly appreciated.
>> 
>> Thanks,
>> 
>> ~~~
>> Rahul Sitaram Johari
>> CEO, Twenty Four Seventy Nine Inc.
>> 
>> W: http://www.rahulsjohari.com
>> E: [EMAIL PROTECTED]
>> 
>> ³I morti non sono piu soli ... The dead are no longer lonely²

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



RE: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Flavien CHANTELOT
In your function there is at the end before the return statement: 
$previewtext = $whowcatvar;
First $whowcatvar isn't defined. So it could be an answer.
And I think u need to delete this line.

-Message d'origine-
De : Dwayne Heronimo [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 23 mars 2007 16:55
À : php-general@lists.php.net
Objet : Re: [PHP] preview string with strlen PHP (help)

Dear all,

hmm.. sorry the $previewstext thing was a typo in my mail.

But yes it is working but it will only display the first record of the 
recordset. I have like a list for items with short text in a page and of 
course made a query to make the database variables available. Which where 
the variable $row_show_cat['text']; comes from.

This is why I thought that i may have to rewrite it into a function to 
display the $row_show_cat['text']; in a repeated reagion.


I have rewritten my function:

 235)
 {
  $len = 235;
 }
 else
 {
  $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

 $previewtext = $whowcatvar;

 return $previewtext;
}
?>

And to to show it later in the page:

but this still won't anywould display anything. :S

Please let me know.

""Tijnema !"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
>> Dear All,
>>
>> I am very new to programming. I want to make a preview text that would
>> display only a part of the text that is a text field in a database.
>>
>> //Begin Make preview string
>>
>>  $minitxt = $row_show_cat['text'];
>>  $len = strlen($minitxt);
>>
>>  if ($len > 235)
>>  {
>>  $len = 235;
>>  }
>>  else
>>  {
>>  $len = $len;
>>  }
>>
>>  $newstring = substr($minitxt,0,$len);
>>
>>  $previewtext = $newstring;
>>
>> //End Make preview string
>>
>> But if I want to display this somewhere in the page it will only display 
>> the
>> first record of at every text column row 
>>
>> Althought I am very new to php and programming. I thought maybe I should
>> rewrite it into a function. But my function won't work.
>>
>>
>> function previewString($showcatvar) {
>>
>>  $minitxt = $showcatvar;
>>  $len = strlen($minitxt);
>>
>>  if ($len > 235)
>>  {
>>  $len = 235;
>>  }
>>  else
>>  {
>>  $len = $len;
>>  }
>>
>>  $newstring = substr($minitxt,0,$len);
>>
>>  $previewtext = $newstring;
>>
>>  $previewtext = $whowcatvar;
>>
>> }
>>
>>
>> and to display it in the page:
>>
>> 
>>
>> IT displays notthing. But I think I am doing somthing wrong. I am 
>> assigning
>> the wrong variables to the $row_show_cat['text']) ???
>>
>> Please let me know
>
> I'm currently not sure why your first piece of code isn't working, but
> the second is quite simple. You aren't returning any variable in your
> function, and so it won't output anything. Add the following:
> return $previewtext;
> Just before the }
>
> Then it will return something, but i think not what you wanted to :(
>
> Tijnema
>>
>> --
>> 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] preview string with strlen PHP (help)

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 16.55-kor Dwayne Heronimo ezt írta:
> Dear all,
> 
> hmm.. sorry the $previewstext thing was a typo in my mail.
> 
> But yes it is working but it will only display the first record of the 
> recordset. I have like a list for items with short text in a page and of 
> course made a query to make the database variables available. Which where 
> the variable $row_show_cat['text']; comes from.
> 
> This is why I thought that i may have to rewrite it into a function to 
> display the $row_show_cat['text']; in a repeated reagion.
> 
> 
> I have rewritten my function:
> 
>   function previewString($showcatvar) {
> 
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
> 
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
> 
>  $newstring = substr($minitxt,0,$len);
> 
>  $previewtext = $newstring;
> 
>  $previewtext = $whowcatvar;

what is the meaning of the above line???
you are giving an undefined value (default NULL) to $previewtext, just
after you gave it the right value
delete that line and you might be well

greets
Zoltán Németh

> 
>  return $previewtext;
> }
> ?>
> 
> And to to show it later in the page:
> 
> but this still won't anywould display anything. :S
> 
> Please let me know.
> 
> ""Tijnema !"" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
> >> Dear All,
> >>
> >> I am very new to programming. I want to make a preview text that would
> >> display only a part of the text that is a text field in a database.
> >>
> >> //Begin Make preview string
> >>
> >>  $minitxt = $row_show_cat['text'];
> >>  $len = strlen($minitxt);
> >>
> >>  if ($len > 235)
> >>  {
> >>  $len = 235;
> >>  }
> >>  else
> >>  {
> >>  $len = $len;
> >>  }
> >>
> >>  $newstring = substr($minitxt,0,$len);
> >>
> >>  $previewtext = $newstring;
> >>
> >> //End Make preview string
> >>
> >> But if I want to display this somewhere in the page it will only display 
> >> the
> >> first record of at every text column row 
> >>
> >> Althought I am very new to php and programming. I thought maybe I should
> >> rewrite it into a function. But my function won't work.
> >>
> >>
> >> function previewString($showcatvar) {
> >>
> >>  $minitxt = $showcatvar;
> >>  $len = strlen($minitxt);
> >>
> >>  if ($len > 235)
> >>  {
> >>  $len = 235;
> >>  }
> >>  else
> >>  {
> >>  $len = $len;
> >>  }
> >>
> >>  $newstring = substr($minitxt,0,$len);
> >>
> >>  $previewtext = $newstring;
> >>
> >>  $previewtext = $whowcatvar;
> >>
> >> }
> >>
> >>
> >> and to display it in the page:
> >>
> >> 
> >>
> >> IT displays notthing. But I think I am doing somthing wrong. I am 
> >> assigning
> >> the wrong variables to the $row_show_cat['text']) ???
> >>
> >> Please let me know
> >
> > I'm currently not sure why your first piece of code isn't working, but
> > the second is quite simple. You aren't returning any variable in your
> > function, and so it won't output anything. Add the following:
> > return $previewtext;
> > Just before the }
> >
> > Then it will return something, but i think not what you wanted to :(
> >
> > Tijnema
> >>
> >> --
> >> 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] preview string with strlen PHP (help)

2007-03-23 Thread Dwayne Heronimo
Dear all,

hmm.. sorry the $previewstext thing was a typo in my mail.

But yes it is working but it will only display the first record of the 
recordset. I have like a list for items with short text in a page and of 
course made a query to make the database variables available. Which where 
the variable $row_show_cat['text']; comes from.

This is why I thought that i may have to rewrite it into a function to 
display the $row_show_cat['text']; in a repeated reagion.


I have rewritten my function:

 235)
 {
  $len = 235;
 }
 else
 {
  $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

 $previewtext = $whowcatvar;

 return $previewtext;
}
?>

And to to show it later in the page:

but this still won't anywould display anything. :S

Please let me know.

""Tijnema !"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
>> Dear All,
>>
>> I am very new to programming. I want to make a preview text that would
>> display only a part of the text that is a text field in a database.
>>
>> //Begin Make preview string
>>
>>  $minitxt = $row_show_cat['text'];
>>  $len = strlen($minitxt);
>>
>>  if ($len > 235)
>>  {
>>  $len = 235;
>>  }
>>  else
>>  {
>>  $len = $len;
>>  }
>>
>>  $newstring = substr($minitxt,0,$len);
>>
>>  $previewtext = $newstring;
>>
>> //End Make preview string
>>
>> But if I want to display this somewhere in the page it will only display 
>> the
>> first record of at every text column row 
>>
>> Althought I am very new to php and programming. I thought maybe I should
>> rewrite it into a function. But my function won't work.
>>
>>
>> function previewString($showcatvar) {
>>
>>  $minitxt = $showcatvar;
>>  $len = strlen($minitxt);
>>
>>  if ($len > 235)
>>  {
>>  $len = 235;
>>  }
>>  else
>>  {
>>  $len = $len;
>>  }
>>
>>  $newstring = substr($minitxt,0,$len);
>>
>>  $previewtext = $newstring;
>>
>>  $previewtext = $whowcatvar;
>>
>> }
>>
>>
>> and to display it in the page:
>>
>> 
>>
>> IT displays notthing. But I think I am doing somthing wrong. I am 
>> assigning
>> the wrong variables to the $row_show_cat['text']) ???
>>
>> Please let me know
>
> I'm currently not sure why your first piece of code isn't working, but
> the second is quite simple. You aren't returning any variable in your
> function, and so it won't output anything. Add the following:
> return $previewtext;
> Just before the }
>
> Then it will return something, but i think not what you wanted to :(
>
> Tijnema
>>
>> --
>> 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] Re: Keep the PHP list ON TOPIC!

2007-03-23 Thread Jochem Maas
Myron Turner wrote:
> Jochem Maas wrote:
>> Myron Turner wrote:
>>  
>>> Jochem Maas wrote:
>>>
 I would have made a similar comment - but I have soap stuck between my
 teeth atm :-P
 
>>> Just use a little of that saliva that you've been wasting on
>>> spitballs. ;-)
>>> 
>>
>> ok - I'm all soaped up now - I'll try a be nicer in future.
>>
>> the general point stands but the manner in which it was brought did leave
>> plenty of room for improvement, have a bad day is no excuse really!
>> anyway
>> I do my best to be more diplomatic when I try to tackle a misplaced
>> post/person/wotsit
>> in future.
>>
>> apologies to the OP is question for the tone.
>>
>>  
>>   
> 
> You are wonderfully good-humored for a grinch (you know--the guy who
> stole Christmas). 

I stole it and now I've misplaced it ;-/

>  Myself, I'm just a pretty old guy--like add sept to
> agenarian--

 don't quite follow that but I'll assume you have a couple more years
on the clock than I do ... hey somebody has to right? ;-)

> who does this for fun and the occasional cash and (at my age)
> sort of likes things peaceful.   I've only been using the list a short
> while, but it is very indebted to a small number of knowledgeable
> contributors, yourself included, who give a lot of their time. 

my/our debt to society ;-)
always nice to here when one's ramblings have been of use to others,
and for me it's not a one way thing by any means - I learn plenty for
other clever souls on this list :-)

> I really
> can understand your frustration with off topic posts, when you put so
> much into the list, but they seem impossible to stop.  

sometimes you just have an off day and then someone comes along
and posts something that's way out there (and seemingly blantantly
in the full knowledge that it's OT) and then they get earful ... I'm as
suseptable as the next man to losing his cool. that said there is also a
constant need to address newcomers to how to 'live' in this environment
(asking smart questions and asking in the right place, that sort of thing)
- the kind of advice I too needed when I was starting out :-)

onward and upward.

> Cheers,
> 
> Myron
> 
> 
> 

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



[PHP] High quality image resizing

2007-03-23 Thread Markus Fischer
Hi,

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with PHP4 and GD lib
2.0.33 and everything produces with them got rejected so far. I was also
going through the comments on php.net regarding self-written Bicubical
algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much better when
using the 'mogrify' tool from this package, yet not good enough for my
designers.

Of course, their expectations are very high because of their daily usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows library.
Using a commercial package would be completely fine for me, however I
just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.

thanks for any hints,
- Markus

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Jochem Maas
Dwayne Heronimo wrote:
> Dear All,
> 
> I am very new to programming. I want to make a preview text that would 
> display only a part of the text that is a text field in a database.
> 
> //Begin Make preview string
> 
>  $minitxt = $row_show_cat['text'];
>  $len = strlen($minitxt);
> 
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
> 
>  $newstring = substr($minitxt,0,$len);
> 
>  $previewtext = $newstring;
> 
> //End Make preview string
> 
> But if I want to display this somewhere in the page it will only display the 
> first record of at every text column row 
> 
> Althought I am very new to php and programming. I thought maybe I should 
> rewrite it into a function. But my function won't work.
> 
> 
> function previewString($showcatvar) {
> 
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
> 
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
> 
>  $newstring = substr($minitxt,0,$len);
> 
>  $previewtext = $newstring;

the above variable assignment is superfluous.

> 
>  $previewtext = $whowcatvar;

the above variable assignment is very wrong
(unless you intend to set $previewtext to NULL right after
you have just done the 'hard' work of creaating it).

> 

you have no return statement in your function so it will never give you
a value - some other languages implicitly return the value of the last 
expression
in a function (e.g. Ruby IIRC) but php requires that you explicitly
use 'return' to pass a variable back to the code that called the function.

note also that the variable named inside the function have nothing to do with
variables named outside the function - this is called variable scope ...
you can reference a variable in the global scope (i.e. one defined in
the outer most level of code by using the 'global' keyword), an example


> }

have a look at this:

function previewString($showcatvar)
{
// sanity check on the input
if (empty($showcatvar) || !is_string($showcatvar))
return "";

// get the string size
$len = strlen($showcatvar);

// long strings will be truncated to 235 chars
// BTW - this will really bite you in the ass if
// the string contains HTML (think about unclosed tags!)
if ($len > 235)
return substr($showcatvar, 0, 235);

// strings less than or equal to 235 in length
// are shown as is
return $showcatvar;
}

> 
> 
> and to display it in the page:
> 
> 
> 
> IT displays notthing. But I think I am doing somthing wrong. I am assigning 
> the wrong variables to the $row_show_cat['text']) ???
> 
> Please let me know 
> 

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



RE: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Edward Kay

> -Original Message-
> From: Dwayne Heronimo [mailto:[EMAIL PROTECTED]

> Dear All,
>
> I am very new to programming. I want to make a preview text that would
> display only a part of the text that is a text field in a database.
>
> //Begin Make preview string
>
>  $minitxt = $row_show_cat['text'];
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
> //End Make preview string
>
> But if I want to display this somewhere in the page it will only
> display the
> first record of at every text column row 
>
> Althought I am very new to php and programming. I thought maybe I should
> rewrite it into a function. But my function won't work.
>
>
> function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;
>
> }
>
>
> and to display it in the page:
>
> 
>
> IT displays notthing. But I think I am doing somthing wrong. I am
> assigning
> the wrong variables to the $row_show_cat['text']) ???
>
> Please let me know

Hi Dwayne,

Your function isn't working as you expect because you are not returning any
value. I would rewrite it as:

function previewString($strInput) {
// Max length allowed
// You could also store this in a config file or pass in as
// a second, possibly optional argument.
$intMaxLen = 235;

if (strlen($strInput) > $intMaxLen) {
// Too long so trucate it (and add ... to show
// it is truncated. I subtract 3 to allow for ...)
return substr($strInput, 0, ($intMaxLen-3)).'...'
}

// If we get here it is less than or equal to the allowed max so just
return it
return $strInput;
}

You would then call the function when you needed the truncated string, e.g.


If you are outputting this to a web page, you'll probably also want to pass
it through the htmlentities function: 

Good luck,
Edward

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



Re: [PHP] POST a variable

2007-03-23 Thread Satyam
Do a 'select @@identity', it will give you the last record id.  The gap in 
between steps 3 and 4, brief as it may seem, is enough to get you in 
trouble.


Satyam



- Original Message - 
From: "Dan Shirah" <[EMAIL PROTECTED]>

To: "Németh Zoltán" <[EMAIL PROTECTED]>
Cc: "php-general" 
Sent: Friday, March 23, 2007 4:07 PM
Subject: Re: [PHP] POST a variable


The reason I have to use it as I posted is because I am using Microsoft SQL
server instead of MySQL.  And I haven't found a php function for MSSQL that
works the same as mysql_insert_id()

So, to come out with a comparable function with pretty reliable results, I
follow this process:

1. User enters data into form
2. User submits form
3. Save page inserts info into the database
4. Directly after the insert statement is my SELECT MAX query
5. I assign the retrieved value to a hidden field
6. I pass this value to the next form

I figure the odds of another record being inserted inbetween the time it
takes to go from step 3 to step 4 are very, very minimal.  We're talking
about MAYBE a 2-3 millisecond gap?


On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote:


2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> Okay, I feel like the correct answer to this is about 2mm back in my
grey
> matter.
>
> 1. I have a query that pulls the last row number when a newly inserted
> record is added:
>
> $maximum="SELECT MAX(payment_id) FROM payment_request";
>   $max_result=mssql_query($maximum);
>   while($max=mssql_fetch_row($max_result)){
>   }
>   $max_id = $max[0];
>
> 2. I have multiple selections for the user to pick, but regardless of
what
> they choose I want the $max_id variable to be passed to the next page.
>
> 3.  Would I go about this by assigning $max_id to a hidden field like
below?
>
> " size="5"
> maxlength="10" name="max_id" />
>
> 4.  And then to retrieve this value on my next page just get it out of
> $_POST['max_id']  ??
>
> Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh









No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 22/03/2007 
7:44


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



RE: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Flavien CHANTELOT


-Message d'origine-
De : Tijnema ! [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 23 mars 2007 16:26
À : Dwayne Heronimo
Cc : php-general@lists.php.net
Objet : Re: [PHP] preview string with strlen PHP (help)

On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I am very new to programming. I want to make a preview text that would
> display only a part of the text that is a text field in a database.
>
> //Begin Make preview string
>
>  $minitxt = $row_show_cat['text'];
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>  $len = 235;
>  }
>  else
>  {
>  $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
> //End Make preview string
>
> But if I want to display this somewhere in the page it will only display the
> first record of at every text column row 
>
> Althought I am very new to php and programming. I thought maybe I should
> rewrite it into a function. But my function won't work.
>
>
> function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>  $len = 235;
>  }
>  else
>  {
>  $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;
>
> }
>
>
> and to display it in the page:
>
> 
>
> IT displays notthing. But I think I am doing somthing wrong. I am assigning
> the wrong variables to the $row_show_cat['text']) ???
>
> Please let me know

I'm currently not sure why your first piece of code isn't working, but
the second is quite simple. You aren't returning any variable in your
function, and so it won't output anything. Add the following:
return $previewtext;
Just before the }

Then it will return something, but i think not what you wanted to :(

The first piece of code isn't working cause : $previewtext != $previewstext
Tijnema
>
> --
> 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] Add New Records Only!

2007-03-23 Thread Mark
Rahul Sitaram Johari wrote:

As far as I can see, there is probably only three ways to do this:

One: Make sure your dbase system contains unique primary key capability, and
use it to avoid duplicates.
Two: query for the row, if it isn't there insert it. (You'll have to deal
with concurrency with locking or something)
Three: Insert everything and remove duplicates later.

> Ave,
> 
> Let me explain what I¹m trying to do. Unfortunately it¹s not a very simple
> Add/Update transaction.
> Basically I gather records from multiple mySQL tables and add them to a
> DBF
> (dbase) database.  I wrote a code which was able to accomplish this
> without any problems and the add_records goes very smooth.
> 
> However, I have to modify this program now so that only ³New² records,
> i.e., records that have not yet been transferred, are added into the DBF.
> In other words, any records that are being added, which already exist in
> the DBF, should not be added.
> 
> If it were just adding records from one mySQL to another mySQL, I could
> easily use INSERT IGNORE or the Unique Key fundamental ­ however, since
> I¹m adding from multiple mySQL tables into DBF, I¹m not sure how to go
> about doing this.
> 
> Here¹s my code that takes records from multiple mySQL tables and adds them
> to a DBF.
> 
> // define the array with mySQL Table Names & Identifier
> $tChoice = array(
>"lodispo" => "VB",
>"lodispo_osma" => "ATL",
>"lodispo_osmh" => "HOU",
>"lodispo_osmn" => "NSV",
>"lodispo_osmp" => "PAA",
>"lodispo_osmj" => "JAX",
>"lodispo_osmt" => "TPA",
>"lodispo_dmam" => "MET",
>"lodispo_osmf" => "FTM",
>"lodispo_hfglend" => "GLEND",
>   "lodispo_hfmesa" => "MESA",
>   "lodispo_hfphenx" => "PHENX",
> );
> 
>
> // open DBF in read-write mode
> $db2 = dbase_open($theDBFfile, 2);
> if (!$db2) {
>   echo "Fatal Error: Unable to open
> database";
>   exit;
> }
> 
> else {
> 
> // Let's Run Array Loops!
> foreach ($tChoice as $tblQ => $bxQ) {
> 
> // connect to mySQL tables one by one
> mysql_select_db($database_imslead_transfer,
> $imslead_transfer); $query_loDispo = "SELECT * FROM $tblQ";
> $loDispo = mysql_query($query_loDispo, $imslead_transfer) or
> die(mysql_error());
> $row_loDispo = mysql_fetch_assoc($loDispo);
> $totalRows_loDispo = mysql_num_rows($loDispo);
>   
> // write mySql data to Dbf
> do {
>  dbase_add_record($db2, array(
>  $row_loDispo['phone'],
>  $row_loDispo['comments'],
>  $row_loDispo['starttime'],
>  $row_loDispo['endtime'],
>  $row_loDispo['dispo'],
>  $row_loDispo['loanofficer'],
>  $row_loDispo['verifier'],
>  $bxQ));
>  } while ($row_loDispo = mysql_fetch_assoc($loDispo));
> }
>  
> dbase_close($db2);
> }
> 
> Any suggestions would be highly appreciated.
> 
> Thanks,
> 
> ~~~
> Rahul Sitaram Johari
> CEO, Twenty Four Seventy Nine Inc.
> 
> W: http://www.rahulsjohari.com
> E: [EMAIL PROTECTED]
> 
> ³I morti non sono piu soli ... The dead are no longer lonely²

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Tijnema !

On 3/23/07, Dwayne Heronimo <[EMAIL PROTECTED]> wrote:

Dear All,

I am very new to programming. I want to make a preview text that would
display only a part of the text that is a text field in a database.

//Begin Make preview string

 $minitxt = $row_show_cat['text'];
 $len = strlen($minitxt);

 if ($len > 235)
 {
 $len = 235;
 }
 else
 {
 $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

//End Make preview string

But if I want to display this somewhere in the page it will only display the
first record of at every text column row 

Althought I am very new to php and programming. I thought maybe I should
rewrite it into a function. But my function won't work.


function previewString($showcatvar) {

 $minitxt = $showcatvar;
 $len = strlen($minitxt);

 if ($len > 235)
 {
 $len = 235;
 }
 else
 {
 $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

 $previewtext = $whowcatvar;

}


and to display it in the page:



IT displays notthing. But I think I am doing somthing wrong. I am assigning
the wrong variables to the $row_show_cat['text']) ???

Please let me know


I'm currently not sure why your first piece of code isn't working, but
the second is quite simple. You aren't returning any variable in your
function, and so it won't output anything. Add the following:
return $previewtext;
Just before the }

Then it will return something, but i think not what you wanted to :(

Tijnema


--
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] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 11.07-kor Dan Shirah ezt írta:
> The reason I have to use it as I posted is because I am using
> Microsoft SQL server instead of MySQL.  And I haven't found a php
> function for MSSQL that works the same as mysql_insert_id()

you wrote something earlier as far as I can remember about a MSSQL
function scope_identity() which returns the last inserted id

why not use that?

greets
Zoltán Németh

>  
> So, to come out with a comparable function with pretty reliable
> results, I follow this process:
>  
> 1. User enters data into form
> 2. User submits form
> 3. Save page inserts info into the database
> 4. Directly after the insert statement is my SELECT MAX query
> 5. I assign the retrieved value to a hidden field
> 6. I pass this value to the next form
>  
> I figure the odds of another record being inserted inbetween the time
> it takes to go from step 3 to step 4 are very, very minimal.  We're
> talking about MAYBE a 2-3 millisecond gap?
> 
>  
> On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote: 
> 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt
> írta:
> > Okay, I feel like the correct answer to this is about 2mm
> back in my grey 
> > matter.
> >
> > 1. I have a query that pulls the last row number when a
> newly inserted
> > record is added:
> >
> > $maximum="SELECT MAX(payment_id) FROM payment_request";
> >   $max_result=mssql_query($maximum); 
> >   while($max=mssql_fetch_row($max_result)){
> >   }
> >   $max_id = $max[0];
> >
> > 2. I have multiple selections for the user to pick, but
> regardless of what
> > they choose I want the $max_id variable to be passed to the
> next page. 
> >
> > 3.  Would I go about this by assigning $max_id to a hidden
> field like below?
> >
> > "
> size="5" 
> > maxlength="10" name="max_id" />
> >
> > 4.  And then to retrieve this value on my next page just get
> it out of
> > $_POST['max_id']  ??
> >
> > Does that all sound correct? 
> 
> basically yes
> but if you want the id of the row you just inserted, using
> mysql_insert_id() is better because if another insert is
> happening at
> the same time, select max() may give you incorrect result
> 
> greets
> Zoltán Németh
> 
> 

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



[PHP] preview string with strlen PHP (help)

2007-03-23 Thread Dwayne Heronimo
Dear All,

I am very new to programming. I want to make a preview text that would 
display only a part of the text that is a text field in a database.

//Begin Make preview string

 $minitxt = $row_show_cat['text'];
 $len = strlen($minitxt);

 if ($len > 235)
 {
  $len = 235;
 }
 else
 {
  $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

//End Make preview string

But if I want to display this somewhere in the page it will only display the 
first record of at every text column row 

Althought I am very new to php and programming. I thought maybe I should 
rewrite it into a function. But my function won't work.


function previewString($showcatvar) {

 $minitxt = $showcatvar;
 $len = strlen($minitxt);

 if ($len > 235)
 {
  $len = 235;
 }
 else
 {
  $len = $len;
 }

 $newstring = substr($minitxt,0,$len);

 $previewtext = $newstring;

 $previewtext = $whowcatvar;

}


and to display it in the page:



IT displays notthing. But I think I am doing somthing wrong. I am assigning 
the wrong variables to the $row_show_cat['text']) ???

Please let me know 

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



[PHP] Re: close session when browser is closed

2007-03-23 Thread Colin Guthrie
Edward Vermillion wrote:
>> Personally I think this does make sense.  I fully expect the browser to
>> maintain cookies "Until it is closed" -- If I have closed one tab that
>> had set a cookie, re-opening that URL in a new window/tab should still
>> cause the browser to send in my cookie.
>>
> 
> Ouch! That doesn't make sense to me. I closed the tab/window, I expect
> that session to be done... period, without having to close down the
> whole application and restart it and open up all the other windows that
> I was working in. There are some things about FF that just really raise
> my hackles...
> 
> Oh well, that's good info to have anyway, and yet another reason *not*
> to use FF to check my bank balance.

This has always been my understanding of session cookies and has served
me well in the past. The problem I have is with browsers like IE which
never really "closed" per se (at least so you were confident) and as
such you were never really sure what it meant.

I've always wondered why banks etc. always say "for security reasons
please close this window" I always asked myself "why, what
difference does closing a window make???".

If you want my sessions to really end when you close the last window/tab
on a site in Firefox I'm sure there are extensions to do that.


Col

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



RE: [PHP] POST a variable

2007-03-23 Thread Edward Kay
> -Original Message-
> From: Németh Zoltán [mailto:[EMAIL PROTECTED]

> 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> > Okay, I feel like the correct answer to this is about 2mm back 
> in my grey
> > matter.
> > 
> > 1. I have a query that pulls the last row number when a newly inserted
> > record is added:
> > 
> > $maximum="SELECT MAX(payment_id) FROM payment_request";
> >   $max_result=mssql_query($maximum);
> >   while($max=mssql_fetch_row($max_result)){
> >   }
> >   $max_id = $max[0];
> > 
> > 2. I have multiple selections for the user to pick, but 
> regardless of what
> > they choose I want the $max_id variable to be passed to the next page.
> > 
> > 3.  Would I go about this by assigning $max_id to a hidden 
> field like below?
> > 
> > " size="5"
> > maxlength="10" name="max_id" />
> > 
> > 4.  And then to retrieve this value on my next page just get it out of
> > $_POST['max_id']  ??
> > 
> > Does that all sound correct?
> 
> basically yes

Personally, I'd put it in a session variable. This reduces the amount of data 
sent to/from the client and also stops anyone altering the value themselves. 

> but if you want the id of the row you just inserted, using
> mysql_insert_id() is better because if another insert is happening at
> the same time, select max() may give you incorrect result

This would be true if he was using MySQL. The code given uses MSSQL and there 
is no mssql_insert_id function (in my PHP manual).

Edward 

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



Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

The reason I have to use it as I posted is because I am using Microsoft SQL
server instead of MySQL.  And I haven't found a php function for MSSQL that
works the same as mysql_insert_id()

So, to come out with a comparable function with pretty reliable results, I
follow this process:

1. User enters data into form
2. User submits form
3. Save page inserts info into the database
4. Directly after the insert statement is my SELECT MAX query
5. I assign the retrieved value to a hidden field
6. I pass this value to the next form

I figure the odds of another record being inserted inbetween the time it
takes to go from step 3 to step 4 are very, very minimal.  We're talking
about MAYBE a 2-3 millisecond gap?


On 3/23/07, Németh Zoltán <[EMAIL PROTECTED]> wrote:


2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> Okay, I feel like the correct answer to this is about 2mm back in my
grey
> matter.
>
> 1. I have a query that pulls the last row number when a newly inserted
> record is added:
>
> $maximum="SELECT MAX(payment_id) FROM payment_request";
>   $max_result=mssql_query($maximum);
>   while($max=mssql_fetch_row($max_result)){
>   }
>   $max_id = $max[0];
>
> 2. I have multiple selections for the user to pick, but regardless of
what
> they choose I want the $max_id variable to be passed to the next page.
>
> 3.  Would I go about this by assigning $max_id to a hidden field like
below?
>
> " size="5"
> maxlength="10" name="max_id" />
>
> 4.  And then to retrieve this value on my next page just get it out of
> $_POST['max_id']  ??
>
> Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh




Re: [PHP] Add New Records Only!

2007-03-23 Thread clive
you could do a serialized md5 of sum of the more unique columns from 
your db abd use that as a unique identifier for the row. Then you would 
need to compare this 'key' before doing a insert.


Also keeping a log of the date and time of the last operation would help 
 as then you only need to select rows newer than that dates, thats 
provided of course your source data has a datetime column.


--
Regards,

Clive.

Real Time Travel Connections


{No electrons were harmed in the creation, transmission or reading of 
this email. However, many were excited and some may well have enjoyed 
the experience.}


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



Re: [PHP] Creating an FTP account on the fly from PHP

2007-03-23 Thread Tijnema !

On 3/23/07, Travis Doherty <[EMAIL PROTECTED]> wrote:

PHP Fusebox wrote:

> I built a CMS that lets a super user create and manage basic users
> (among lots of other things). I want basic users to get an FTP account
> that is automatically associated with their website user account, and
> managed from my add/edit user form. For example if I create a user
> named [EMAIL PROTECTED] for him to login to my web app, I want my
> users to be able to use their same login name and password to access
> their web folder via FTP.
>
> I am running on LAMP on a CPanel server with ProFTP as the FTP server
> software, but I have no clue how to get PHP to be able to create,
> edit, or delete an FTP account. Can someone point me in the right
> direction?
>
ProFTPd?  It can authenticate against MySQL tables...  It gets
authentication from your database.  We used to do this many many years
ago... It worked fine and was probably choke full of security problems.

Setting up ProFTPd for MySQL authentication was a pain, I'm sure its
easier today.  Once you have that setup, its just a simple matter of
CRUD SQL queries.

Travis Doherty

CPanel automatically installs server software, and also configures
them. So to let it work with the current system, you need to know how
it works now :)

Tijnema


--
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] Integer question

2007-03-23 Thread Tijnema !

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

On Thu, March 22, 2007 2:33 pm, Tijnema ! wrote:
>> > 2).  How do you handle numbers that large, while maintaining
>> precision.
>>
>> keep them as strings - and/or use a 64bit machine?
>
> a 64bit machine would make the number larger, not unlimited :)

Even GMP (or BC) isn't unlimited...

It's just limited to the number of bytes you have in RAM/swap. :-)


Yeah, well if you have a few TB of space, which you set up as swap,
the number would come really close to unlimited :) But of course it is
limited :P
So if you have 10 TB of swap(I believe current kernels can't handle
that, but that's another story) you could get a number as big as
2^87960930222081
Tell me any example where you would use a number larger than that :)

Tijnema



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




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



Re: [PHP] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> Okay, I feel like the correct answer to this is about 2mm back in my grey
> matter.
> 
> 1. I have a query that pulls the last row number when a newly inserted
> record is added:
> 
> $maximum="SELECT MAX(payment_id) FROM payment_request";
>   $max_result=mssql_query($maximum);
>   while($max=mssql_fetch_row($max_result)){
>   }
>   $max_id = $max[0];
> 
> 2. I have multiple selections for the user to pick, but regardless of what
> they choose I want the $max_id variable to be passed to the next page.
> 
> 3.  Would I go about this by assigning $max_id to a hidden field like below?
> 
> " size="5"
> maxlength="10" name="max_id" />
> 
> 4.  And then to retrieve this value on my next page just get it out of
> $_POST['max_id']  ??
> 
> Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh

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



Re: [PHP] Permissions issue on share

2007-03-23 Thread Tijnema !

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

Rahul Sitaram Johari wrote:
> Ave,
>
> I¹m not sure if anyone here is going to be able to help, but I¹ve run into a
> permissions snag.
> I have Apache Web Server running on Mac OS X with PHP. I have a folder on a
> windows machine mounted on my Mac OS X as a share using the ³mount ­t smbfs
> //[EMAIL PROTECTED]/ShareName Share².
> The ³user² has full read-write permission and physically I¹m able to do
> anything I want sitting on my Mac OS X in this share, like create, delete or
> modify files.
>
> The problem is, I don¹t think Apache Web Server (or PHP) has write access on
> this share. In PHP, I¹m able to read data from files on this share, but I¹m
> not able to write  data to any file on that share. I get access is denied.
>
> Is there anyway through PHP to give Apache or PHP write access to the files
> on this share?
> I don¹t see how I can provide Apache Web Server (installed on my Mac) Write
> Access through the Windows System that has the original folder. Windows is
> only able to provide the Mac User with Permissions, not Apache.
>
> Any help would be appreciated.
>
> Thanks
>
>
> ~~~
> Rahul Sitaram Johari
> CEO, Twenty Four Seventy Nine Inc.
>
> W: http://www.rahulsjohari.com
> E: [EMAIL PROTECTED]
>
> ³I morti non sono piu soli ... The dead are no longer lonely²
>
>
you could always change apache to run as the user/group that the mount
is set to.

Sorry you had to spend 6 hours hunting down a 2 second fix.  Not sure
why no one else suggested this.  If it is a local copy of Apache and not
used by anybody else, who cares about what permissions it runs as.

Jim


Running apache as root is quite hard... He was mounting his shares as
root so then apache would need to run as root. And that probably
requires recompiling of Apache. And i provided a quite secure way to
fix, but Mac OS X didn't understand that.

Tijnema


--
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] Performance: While or For loop

2007-03-23 Thread Tijnema !

On 3/23/07, Mario Guenterberg <[EMAIL PROTECTED]> wrote:

On Fri, Mar 23, 2007 at 12:24:45AM -0500, Travis Doherty wrote:
> After multiple runs I see that the for pre-increment loop is fastest.
> Note that the while loop with a post-increment runs once more than with
> a pre-increment.
>
> Everytime I run, the results are *very* different, though still fall
> within similar comparitive domains.

Hi...

I used your script and my results are different from yours.
The post-while increment is generally the fastest result on my
machine (Core 2 Duo, php 5.2.1 and apache 2.2.4).

I ran the script multiple times:

[schnipp ]

For pre-increment (10): 0.066
For post-increment (10): 0.066
While pre-increment (10): 0.028
While post-increment (11): 0.025

[schnipp ]

Greetings
Mario


Well, myh results are a little bit confusing again, if using
pre-increment, for shows up faster now. But while post-increment is
the fastest :) Is there any logic why we all have different results?
does it has to do something with the type of CPU, i'm using AMD
Athlon. 1800+ (clocked down from 133 to 100 * 11.5)

For pre-increment (10): 0.026
For post-increment (10): 0.030
While pre-increment (10): 0.029
While post-increment (11): 0.023

Tijnema

ps. @ Mario: Youre C2D got owned by a AMD 1.15Ghz :)




--
 -
| havelsoft.com - Ihr Service Partner für Open Source |
| Tel:  033876-21 966 |
| Notruf: 0173-277 33 60  |
| http://www.havelsoft.com|
| |
| Inhaber: Mario Günterberg   |
| Mützlitzer Strasse 19   |
| 14715 Märkisch Luch |
 -

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



  1   2   >