Re: [PHP] Does JavaScript not work in php web file?

2007-08-26 Thread Patrik Hasibuan
Dear Sanjeev,

you're right. I am sorry for my carelessness. I corrected my code and than try 
it again. But again, it does not work as I expect.

I even put << prompt("this function is being called"); >> in the jsopsi() but 
again the prompt does not come out. Pffuih... I am desperate only because of 
this small thing.

Please keep telling me what's wrong with my code. Do I have to write the 
JavaScript in another way if the javascript is placed in php file?
==
//This is my current code:




  

  guru.com - Menu for new customer


function jsopsi(){
prompt("This prompt comes out if this function is really being called");
if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){
document.formulir.opsistate.options[5].selected=true;
}
}



";
}
?>






3. Country:





getkoneksi("survey",$sqlnya);
if ( mysql_num_rows($klas) > 0 ) {
while( list($negara) = mysql_fetch_row($klas) ) {
echo "$negara";
}
} else {
echo 'No results found';
}
?>





4. State:





getkoneksi("survey",$sqlnya);
if ( mysql_num_rows($klas) > 0 ) {
echo "";
while( list($state,$statename) = mysql_fetch_row($klas) ) {
echo "$statename 
($state)";
}
} else {
echo 'No results found';
}
?>








==
On Sat, 25 Aug 2007 22:26:49 +0530
"Sanjeev N" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> JavaScript codes works in php files. Yours code is also fine. 
> But check your calling function and defined functions. Calling function is
> jsopsi and defined function is opsi. Please check. Other than this
> everything is ok
> 
> Warm Regards,
> Sanjeev
> http://www.sanchanworld.com/
> http://webdirectory.sanchanworld.com - Submit your website URL
> http://webhosting.sanchanworld.com - Choose your best web hosting plan
> -Original Message-
> From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, August 25, 2007 9:17 PM
> To: php-general@lists.php.net
> Subject: [PHP] Does JavaScript not work in php web file?
> 
> Dear my friends...
> 
> I am confused to implement JavaScript code in php web file.
> 
> I want my JavaScript change the "selected" item of  tag based on the
> "selected" item of previous  in same php page.
> 
> Please help me tell my where is my mistake.
> 
> ===
> Here is my code pelangganbaru.php
> ===
> 
> 
> 
> 
>   
> 
>   guru.com - Menu for new customer
> 
> 
> function opsi(){
> if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){
>   document.formulir.opsistate.options[0].selected=true;
> }
> }
> 
> 
> 
>  if (isset($pid)){
>   $idproduk=$_GET['pid'];
>   echo "Produk ID: $idproduk";
> }
> ?>
> 
> 
>  width=400>
>  name="formulir">
> 
>   
>   3. Country:
>   
>   
>   
>   
>   
>  include_once "koneksi.php";
>   $sqlnya="select country from countries";
>   $kelas=new koneksi();
>   $klas=$kelas->getkoneksi("survey",$sqlnya);
>   if ( mysql_num_rows($klas) > 0 ) {
>   while( list($negara) = mysql_fetch_row($klas) ) {
>   echo " value=\"$negara\">$negara";
>   }
>   } else {
>   echo 'No results found';
>   }
>   ?>
>   
>   
> 
> 
>   
>   4. State:
>   
>   
>   
>   
>   
>  include_once "koneksi.php";
>   $sqlnya="select state,statename from states";
>   $kelas=new koneksi();
>   $klas=$kelas->getkoneksi("survey",$sqlnya);
>   if ( mysql_num_rows($klas) > 0 ) {
>   echo "";
>   if ($negara=="Virgin Islands (US)"){
>   echo "Non
> USA";
>   }else{
>   echo "Non
> USA";
>   }
>   while( list($state,$statename) = mysql_fetch_row($klas) ) {
>   echo "$statename
> ($state)";
>   }
>   } else {
>   echo 'No results found';
>   }
>   ?>
>   
>   
> 
> 
>   
>   
>   
>   
>   
>   
>   
>   
> 
> 
> 
> 
> 
> 
> -- 
> Patrik Hasibuan <[EMAIL PROTECTED]>
> Junior Programmer
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


-- 
Patrik Hasibuan <[EMAIL PROTECTED]>
Junior Programmer

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



[PHP] help with session

2007-08-26 Thread Jason Cartledge

Hi, this is my first post to this newsgroup. Does this code look ok or is there 
a more clean way of doing this? I am learning. Thank you for reading.
Jason

   if ( !empty($_REQUEST['gender']) )
  {
$registrationGender=$_REQUEST['gender'];
  }
  else {
 if (session_is_registered('registrationGender'))
  {
   $registrationGender=$_SESSION['registrationGender'];
   print "you are preregistered as a $registrationGender";
  }
  else
  {
   print "your gender is unknown, youare assumed to be a male";
   $registrationGender="male";
  }
   }

$_SESSION['registrationGender']=$registrationGender;

_
100’s of Music vouchers to be won with MSN Music
https://www.musicmashup.co.uk/index.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with session

2007-08-26 Thread mike
On 8/26/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:

I would replace $_REQUEST with $_GET or $_POST (as appropriate)

>   if ( !empty($_REQUEST['gender']) )
>  {
>$registrationGender=$_REQUEST['gender'];
>  }
>  else {

Personally I would use if(isset($_SESSION['registrationGender'])) here

> if (session_is_registered('registrationGender'))
>  {
>   $registrationGender=$_SESSION['registrationGender'];
>   print "you are preregistered as a $registrationGender";
>  }
>  else
>  {
>   print "your gender is unknown, youare assumed to be a male";

$_SESSION['registrationGender']='male';

I would change it to assign it here. No need to assign it a second
time below, since you are just printing the session variable if it is
already set

>  }
>   }
>

Those are a couple quick things my tired bloodshot eyes thought of.

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



Re: [PHP] help with session

2007-08-26 Thread Wouter van Vliet / Interpotential
I would go for:

if (isset($_REQUEST['gender'])) $_SESSION['registrationGender'] =
$_REQUEST['gender'];
print isset($_SESSION['registrationGender']) ? "You are registered as
gender: ".$_SESSION['registrationGender'] : "Your gender is unknown";

And make no assumptions about a gender when you don't know any ;-)

On 26/08/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:
>
>
> Hi, this is my first post to this newsgroup. Does this code look ok or is
> there a more clean way of doing this? I am learning. Thank you for reading.
> Jason
>
>if ( !empty($_REQUEST['gender']) )
>   {
> $registrationGender=$_REQUEST['gender'];
>   }
>   else {
>  if (session_is_registered('registrationGender'))
>   {
>$registrationGender=$_SESSION['registrationGender'];
>print "you are preregistered as a $registrationGender";
>   }
>   else
>   {
>print "your gender is unknown, youare assumed to be a
> male";
>$registrationGender="male";
>   }
>}
>
> $_SESSION['registrationGender']=$registrationGender;
>
> _
> 100's of Music vouchers to be won with MSN Music
> https://www.musicmashup.co.uk/index.html
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Interpotential.com
Phone: +31615397471


[PHP] text to HTML

2007-08-26 Thread Ron Piggott

Is there a PHP command that turns text into HTML?

EXAMPLE:

"before"

Hi.

How are you doing?

"after"

Hi.

How are you doing?



[PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen

Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.
I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.
I do not know where else to look for an answer to this question
at present.
Any knowledgeable response appreciated.
Thanks in advance:
Jeff K.

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



RE: [PHP] text to HTML

2007-08-26 Thread Bastien Koert

the closest is nl2br() which converts line breaks to  tags. Other than that, 
you would need to look at regex manipulation to make those changes.

Bastien





> From: [EMAIL PROTECTED]
> To: php-general@lists.php.net
> Date: Sun, 26 Aug 2007 10:36:06 -0400
> Subject: [PHP] text to HTML
> 
> 
> Is there a PHP command that turns text into HTML?
> 
> EXAMPLE:
> 
> "before"
> 
> Hi.
> 
> How are you doing?
> 
> "after"
> 
> Hi.
> 
> How are you doing?
> 

_
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread brian

jekillen wrote:

Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.


No, the best solution is for your application to grab the path to that 
particular user's directory and assign a unique name to the uploaded 
file, then move it from the temp dir:


move_uploaded_file($_FILES['upload_file']['tmp_name'], $upload_path);

where 'upload_file' is the name of your upload form field.

http://www.php.net/manual/en/function.move-uploaded-file.php


I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.


That's unlikely to occur. In fact, i'd be surprised if it were possible 
that PHP would assign a temp name that already existed.


brian

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



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread Ludovic André

Hi,

that's not a problem to specify where the uploaded file has to be moved 
after upload.  As you specify for each user a personal directory in the 
system, you just need to use a function like move_uploaded_file() to 
move the uploaded file to this directory.  Each uploaded file goes to, 
let's say, /tmp (the directory specified in your php config), and 
inherits from a unique filename.  This filename is contained in the 
$_FILES array available in the script which handles the upload. So if 
you have a form containing a file upload field called "file", you can 
retrieve the filename of the newly uploaded file using: 
$_FILES['file']['tmp_name'] (if the upload went successfully).

You can then simply use:
move_uploaded_file( $_FILES['file']['tmp_name'], 
'/path/to/user/personal/dir');


This will work even if multiple users are uploading a file at the same 
time, as the $_FILES array will contain the info related to a single user.


I hope I've been clear enough...

Ludo

Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.
I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.
I do not know where else to look for an answer to this question
at present.
Any knowledgeable response appreciated.
Thanks in advance:
Jeff K.



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



[PHP] How do I delete a composite key?

2007-08-26 Thread nitrox .
Im trying to delete a composite key but cannot figure out the proper format. 
Would somebody tell me where im messing up? I have an url that is supposed 
to send the member id and game id to a delete query. And the delete query is 
supposed to grab the id's based on type.




This is the link:

href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME 
REMOVAL]\n";




This is the code that recieves the link information:

case "remove":
 switch ($_GET['type']) {
   case "Member":
 if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
 
   Are you sure you want to delete this ?
   yes
   or Index
 
  WHERE Member_id = '" . mysql_real_escape_string((int)$_GET['id']) 
. " .

AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) . "'";
   }
 }

_
Messenger Café — open for fun 24/7. Hot games, cool activities served daily. 
Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline


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



RE: [PHP] Does JavaScript not work in php web file?

2007-08-26 Thread Sanjeev N
Hi,

 

I tried this code by removing PHP codes and made as HTML. As you said prompt
dint come to me also. When I checked JavaScript errors then I saw that
prompt function had some errors (like ; in wrong place). I have corrected
the errors in script.

 



function jsopsi(){

prompt("This prompt comes out if this function is really being called"); 

if(document.formulir.opsinegara.value!="Virgina Islands (USA)"){

  document.formulir.opsistate.options[5].selected=true;

}

}



 

And the complete code after converting to HTML is as follows.



 





  

 

  guru.com - Menu for new customer

 



function jsopsi(){

prompt("This prompt comes out if this function is really being called"); 

if(document.formulir.opsinegara.value!="Virgina Islands (USA)"){

  document.formulir.opsistate.options[5].selected=true;

}

}







";

}

?>

 


  

  

  3. Country:

  

  

  

  

  

negara1

negara2

negara3

negara4

negara5

  

  





  

  4. State:

  

  

  

  

   

  1

  4

  3

  

  













 

You please check with PHP codes included (also I suggest you check the
javascript errors if it don't works). 

 

Warm Regards,

Sanjeev

http://www.sanchanworld.com/

http://webdirectory.sanchanworld.com - Submit your website URL

http://webhosting.sanchanworld.com - Choose your best web hosting plan

-Original Message-
From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 26, 2007 3:12 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Does JavaScript not work in php web file?

 

Dear Sanjeev,

 

you're right. I am sorry for my carelessness. I corrected my code and than
try it again. But again, it does not work as I expect.

 

I even put << prompt("this function is being called"); >> in the jsopsi()
but again the prompt does not come out. Pffuih... I am desperate only
because of this small thing.

 

Please keep telling me what's wrong with my code. Do I have to write the
JavaScript in another way if the javascript is placed in php file?

==

//This is my current code:



 





  

 

  guru.com - Menu for new customer

 



function jsopsi(){

prompt("This prompt comes out if this function is really being called");

if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){

  document.formulir.opsistate.options[5].selected=true;

}

}







";

}

?>

 









  

  3. Country:

  

  

  

  

  

  getkoneksi("survey",$sqlnya);

  if ( mysql_num_rows($klas) > 0 ) {

  while( list($negara) = mysql_fetch_row($klas) ) {

echo "$negara";

  }

  } else {

echo 'No results found';

  }

  ?>

  

  





  

  4. State:

  

  

  

  

  

  getkoneksi("survey",$sqlnya);

  if ( mysql_num_rows($klas) > 0 ) {

  echo "";

  while( list($state,$statename) = mysql_fetch_row($klas) ) {

echo "$statename
($state)";

  }

  } else {

echo 'No results found';

  }

  ?>

  

  













==

On Sat, 25 Aug 2007 22:26:49 +0530

"Sanjeev N" <[EMAIL PROTECTED]> wrote:

 

> Hi,

> 

> JavaScript codes works in php files. Yours code is also fine. 

> But check your calling function and defined functions. Calling function is

> jsopsi and defined function is opsi. Please check. Other than this

> everything is ok

> 

> Warm Regards,

> Sanjeev

> http://www.sanchanworld.com/

> http://webdirectory.sanchanworld.com - Submit your website URL

> http://webhosting.sanchanworld.com - Choose your best web hosting plan

> -Original Message-

> From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 

> Sent: Saturday, August 25, 2007 9:17 PM

> To: php-general@lists.php.net

> Subject: [PHP] Does JavaScript not work in php web file?

> 

> Dear my friends...

> 

> I am confused to implement JavaScript code in php web file.

> 

> I want my JavaScript change the "selected" item of  tag based on
the

> "selected" item of previous  in same php page.

> 

> Please help me tell my where is my mistake.

> 

> ===

> Here is my code pelangganbaru.php

> ===

> 

> 

> 

> 

>   

> 

>   guru.com - Menu for new customer

> 

> 

> function opsi(){

> if (document.formulir.opsinegara.value!="Virgina Islands (USA)";){

> document.formulir.opsistate.options[0].selected=true;

> }

> }

> 

> 

> 

>  if (isset($pid)){

> $idproduk=$_GET['pid'];

> echo "Produk ID: $idproduk";

> }

> ?>

> 

> 

>  width=400>

>  name="formulir">

> 

> 

> 3. Country:

> 

> 

> 

> 

> 

>  include_once "koneksi.php";

> $sqlnya="select country from countries";

> $kelas=new koneksi();

> $klas=$kelas->getkoneksi("survey",$sqlnya);

> if ( mysql_num_rows($klas) > 0 ) {

> while( list($negara

Re: [PHP] PHP4 vs PHP5 Performance?

2007-08-26 Thread Stut

Nathan Nobbe wrote:

look at C++, Java, and PHP.  these languages are all written in C;


Just wanted to pick you up on this. PHP is the only language you've 
listed that only has a single implementation. There are implementations 
of C++ compilers that are writting in other languages. I can't speak for 
Java since I have little experience but I'd be surprised if all 
implementations are written in C.


PHP could easily (although lengthily) be re-implemented in another 
language, including PHP itself if you were sufficiently mad.



they are high level, and although php allows you to write proceedrual
code, i think it is best used from an oop paradigm.


This would be a personal choice. Just like C++ "allows you to write 
procedural code" there are times when OOP makes sense and times when 
procedural is "better". It's a choice that should be left up to the 
developer, and the argument over whether OOP is better than procedural 
is not winnable. It's in the same league as PHP vs Python.


-Stut

--
http://stut.net/

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



Re: [PHP] How do I delete a composite key?

2007-08-26 Thread Stut

nitrox . wrote:
Im trying to delete a composite key but cannot figure out the proper 
format. Would somebody tell me where im messing up? I have an url that 
is supposed to send the member id and game id to a delete query. And the 
delete query is supposed to grab the id's based on type.


This is the link:

href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME 
REMOVAL]\n";



   $sql = "DELETE
  FROM xsm_membergames
  WHERE Member_id = '" . 
mysql_real_escape_string((int)$_GET['id']) . " .

AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) . "'";


Your URL contains 2 instances of a GET variable named, which you then 
use in the SQL query. In this instance $_GET['id'] will contain just the 
Game_id. Change the name of one or both IDs and you should be ok.


-Stut

--
http://stut.net/

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



[PHP] How do I get Apache 1.3.36 to use PHP 5

2007-08-26 Thread Beauford
Not to sound like a total nob, but how do I get Apache 1.3.36 to use PHP5. I
have both 4 and 5 installed, but it still uses 4. I never had a problem with
4.

I read the followed the INSTALL file for PHP5, below. I reinstall Apache as
well and nothing - step 11.

I tried putting LoadModule php5_module /usr/local/apache/libphp5.so in my
http.conf, but it doesn't exist.

Any help is appreciated.

   Example 2-2. Installation Instructions (Static Module Installation for
   Apache) for PHP
1.  gunzip -c apache_1.3.x.tar.gz | tar xf -
2.  cd apache_1.3.x
3.  ./configure
4.  cd ..

5.  gunzip -c php-5.x.y.tar.gz | tar xf -
6.  cd php-5.x.y
7.  ./configure --with-mysql --with-apache=../apache_1.3.x
8.  make
9.  make install

10. cd ../apache_1.3.x

11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a
(The above line is correct! Yes, we know libphp5.a does not exist at
this
stage. It isn't supposed to. It will be created.)

12. make
(you should now have an httpd binary which you can copy to your Apache
bin d
ir if
it is your first install then you need to "make install" as well)

13. cd ../php-5.x.y
14. cp php.ini-dist /usr/local/lib/php.ini 

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



[PHP] Adding text before last paragraph

2007-08-26 Thread Dotan Cohen
I have a string with some HTML paragraphs, like so:
$text="First paragraph\nMore text\nSome more
text\nEnd of story";

I'd like to add an image before the last paragraph. I know that
preg_replace can replace only the first n occurrences of a string, but
how can I replace the _last_ occurrence of a string? My initial idea
was to do this:
1) Count how many  times "\n" occurs as $n
2) Replace them all with  "\n\n"
3) Replace $n-1 replacements back to "\n"

Is there a cleaner way? Thanks in advance.

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

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



Re: [PHP] Adding text before last paragraph

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 3:41 pm, Dotan Cohen wrote:
> I have a string with some HTML paragraphs, like so:
> $text="First paragraph\nMore text\nSome more
> text\nEnd of story";
>
> I'd like to add an image before the last paragraph. I know that
> preg_replace can replace only the first n occurrences of a string, but
> how can I replace the _last_ occurrence of a string? My initial idea
> was to do this:
> 1) Count how many  times "\n" occurs as $n
> 2) Replace them all with  "\n\n"
> 3) Replace $n-1 replacements back to "\n"
>
> Is there a cleaner way? Thanks in advance.

If the string really really ENDS on that LAST "", then you can key
off of that:

$story = preg_replace("|(.*\$|Umsi",
"$new_paragraph\n\\1", $story;

You may have to fiddle with the DOT_ALL setting to only match the true
end of string and not just any old "\n" within the string...
http://php.net/pcre

-- 
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] How do I delete a composite key?

2007-08-26 Thread Richard Lynch


On Sun, August 26, 2007 2:05 pm, Stut wrote:
> nitrox . wrote:
>> Im trying to delete a composite key but cannot figure out the proper
>> format. Would somebody tell me where im messing up? I have an url
>> that
>> is supposed to send the member id and game id to a delete query. And
>> the
>> delete query is supposed to grab the id's based on type.
>>
>> This is the link:
>>
>> > href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME
>> REMOVAL]\n";
> 
>>$sql = "DELETE
>>   FROM xsm_membergames
>>   WHERE Member_id = '" .
>> mysql_real_escape_string((int)$_GET['id']) . " .
>> AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) .
>> "'";
>
> Your URL contains 2 instances of a GET variable named, which you then
> use in the SQL query. In this instance $_GET['id'] will contain just
> the
> Game_id. Change the name of one or both IDs and you should be ok.

Another possiblity, if you are trying to write this more generically,
would be to use:

?id[game]=$record->Game_id&id[Member]=$record->Member_id

$_GET['id'] will then be an array that looks something like this:
array('game' => 42, 'member' => 17);

You would then iterate through $_GET['id'] and show all the factors
that are going into the query/delete.

-- 
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] upload temp dir in vhost env.

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 10:34 am, jekillen wrote:
> I have been working on a project that has registered users, each
> having
> a user space portion of the web site file system. I want them to be
> able to upload images and such and have the stuff transfered to their
> own user spaces. With one up load temp dir designated, how do I
> insure that the uploaded files get to the correct destination?

http://php.net/move_uploaded_file

And, BEFORE you move it, you should Validate the uploaded file as many
ways as practical for your web application.

> I am using Apache on unix based host and am aware that php
> assigns a temp name to files that are uploaded, but if different
> users are uploading files concurrently, there could be a confusion
> as to where each file should be transfered to.

The user uploading the file is probably logged in, and you probably
have some kind of user_id or Profile and can decide where to move the
file based on that user's identity.

-- 
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] text to HTML

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 9:36 am, Ron Piggott wrote:
>
> Is there a PHP command that turns text into HTML?
>
> EXAMPLE:
>
> "before"
>
> Hi.
>
> How are you doing?
>
> "after"
>
> Hi.
>
> How are you doing?

http://php.net/nl2br

You could also do:
echo "", str_replace("\n", "\n", $text), "\n";

Another option, if the text is more pre-formatted or ASCII-art like,
is to wrap it in  tags -- or style it with CSS as, errr,
whatever, instead of  tags.

-- 
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] determine which string is longer and then what is different in that string

2007-08-26 Thread Richard Lynch


On Sun, August 26, 2007 1:11 am, Richard Kurth wrote:
> I am trying to find out which string is the longest and then find out
> what
> is different between the two string. Sometimes String 2 is longer than
> String 1 The script below works sometimes but not all the time.
> Is there a better way to do this or tell me what is wrong with the
> script I
> am using
>
> $string1 = "1,2,3,4,5,6,7,8";
> $string2 = "1,2,3,4,6,7,8";

I didn't follow your code, but I think your answer lies in here
somewhere:

$array1 = explode(',', $string1);
$array2 = explode(',', $string2);
$diff1 = array_diff($array1, $array2);
$diff2 = array_diff($array2, $array1);
$diff = array_merge($diff1, $diff2);
var_dump($diff1);
var_dump($diff2);
var_dump($diff);

-- 
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] Calling functions which names are inside a variable

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 12:46 am, Robert Keizer wrote:
> I am currently working on a module testing class, I can't seem to find
> the
> correct syntax. Here is an example of the problem:
>
> function foo( $var ){
>   include $var.'.php';
>   return $var(); // 

Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-26 Thread Richard Lynch
On Fri, August 24, 2007 11:03 am, Jason Pruim wrote:
> Hi Everyone,
>
> I'm attempting to figure out the proper way to use sessions to log
> someone into my system. The idea being, if they arn't logged in all
> they can see is the login form, and if they are logged in, they and
> have access to a database of addresses.
>
> I think I understand how to start sessions, and store variables such
> as some sort of login identifier to say they have access to the
> database, what I'm running into  and have been googling about all
> morning so far, is how would I get the system to say they are logged
> in? Is it as simple as:
>
> $sql = "SELECT loginid FROM table where username="$username" and
> password="$password";
>
> and then setting session_register("loginid")
>
> and then checking to see if the variable exists? Or am I missing like
> huge chunks of info?

No, that's pretty much it.

Except you should get with the times and use:
$_SESSION['loginid'] = $loginid;
and then:
isset($_SESSION['loginid']);


-- 
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] PHP4 vs PHP5 Performance?

2007-08-26 Thread Richard Lynch
On Fri, August 24, 2007 10:11 am, Steve Brown wrote:

> 
> 
>   PHP Web Server Test
> 
> 
> 
> 
> 

phpinfo(), which should never be called in a production setting, is
quite possibly the worst benchmark function you could choose. :-) :-)
:-)

> I ran ab in a loop 12 times with 10,000 connections and a concurrency
> of 10. Then I threw out the highest result and the lowest result and
> averaged the remaining values.   Both PHP4 (v 4.4.7) and PHP5 (v
> 5.2.3) were built as Apache modules, and I simply changed Apache's
> config file to swap modules.
>
> The results were somewhat surprising to me: on average, PHP4
> significantly outperformed PHP5. Over our LAN PHP5 handled roughly
> 1,200 requests / sec while PHP4 handled over 1,800 requests / sec.
> Since everything I have heard/read is that PHP5 is much faster than
> PHP4, I expected the opposite to be true, but the numbers are what
> they are.  Also PHP on Apache1 was much faster than on Apache2.
>
> The only difference I can figure is that PHP5 was the packaged version
> that comes with Ubuntu and I had to compile PHP4 from source since
> there is no package for it in Feisty. But I wouldn't expect a 50%
> increase as a result of that.  Any thoughts on this?

Which PHP on Apache1 vs Apache2 did you try?

PHP5 is probably "faster" for OOP code more than anything, as that's
where most of the development work went.

Well, that and some good XML processing.

-- 
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] PHP4 vs PHP5 Performance?

2007-08-26 Thread Richard Lynch
On Sat, August 25, 2007 9:45 am, Robert Cummings wrote:
> PHP4 AND PHP5 developers don't even use OOP. Tell me what is
> compelling
> in PHP5 that doesn't rely on you being an OOP developer?

The XML stuff, if you need to parse XML a lot, which is not exactly a
niche market, but not everybody needs it either.

That said:

PHP 4 end of shelf life is just that.

It's software that you're simply going to see less and less of as
fewer and fewer hosts/distros use it.

If you analyze the situation more carefully, I think you'll find that
the statistics about PHP 4 versus PHP 5 adoption are pretty skewed by
large-scale webhosts that are offering PHP 5 now, but aren't pushing
their clients to move to a new box with PHP 5, nor upgrading to PHP 5
on the box they are using.

Will they start pushing their clients or upgrading PHP out from under
them?

Probably some of both.

Will PHP 4 suddenly disappear from the face of the Earth in December?

Or course not.

Should you jump through hoops to write new code that works in both 4
and 5?

Probably not, as PHP 5 is readily available to anybody.

Should your old code that runs on 4 be made to run on 5?

Maybe not today, or even tomorrow, but unless you want to co-lo your
own box with software for which even Security updates aren't available
after Aug 8, 2008 (I think that's the date), then, yeah, you probably
should re-write any code that won't run on 5.  Of which there probably
won't be very much at all.

-- 
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] PHP4 vs PHP5 Performance?

2007-08-26 Thread Richard Lynch
On Sat, August 25, 2007 11:56 am, Nathan Nobbe wrote:
> so we would really have to
> dig deeper for a definition of 'basic oop' / 'true oop' etc.

I'll consider PHP true OOP when PECL has a Lisp extension for me to
write REAL oop code
:-)

Actually, that could be a kind of fun extension to write...

Does anybody else here remember the days of old when PHP 4 OOP was
"real" OOP and PHP 3 OOP was just glorified structs with functions
attached?

Ah, the joys of sitting through endless silly threads on PHP-General. 
I'm so glad we don't have those anymore...
:-)

-- 
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: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink

2007-08-26 Thread Richard Lynch
On Fri, August 24, 2007 3:20 am, Goltsios Theodore wrote:

>> Please do not encourage the use of $_REQUEST.
>>
>> You might as well just tell people to enable register_globals again.

This is *SO* not correct at all!

$_REQUEST[] is merely array_merge($_GET, $_POST, $_COOKIE);

It is *NOT* in any way, shape, or form, polluting the global namespace
of all your variables, which is what register_globals is.

Don't use http://php.net/extract on $_REQUEST would be the same as
enabling register_globals again.

There is no real difference from a SECURITY stand-point between GET or
POST or COOKIE.  They are all equally trivial to inject any data the
user chooses.

Using $_GET versus $_POST (versus $_COOKIE) is an issue of code
clarity -- You know that the data is expected to come from the URL or
the POST data.  It is not, repeat not, an issue of Security.

There could easily be a script written which is expected to respond to
GET or POST data in the same way, particularly a simplistic
web-service that doesn't really care if the web "Designers" prefer to
have buttons or links or CSS links that look like buttons or CSS
buttons that look like links or rabid squirrels that send the GET
and/or POST data to make the HTTP request.

So the blanket statement to never use $_REQUEST is probably ill-advised.

Use $_POST when you expect the data to always be in POST data.

Use $_GET when you expect the data to alwasy be in GET data.

If you actually want to accept HTTP requests of either kind for
flexibility to an external user, by all means use REQUEST.

You must, of course, also factor in that you should never ever use
POST for a non-idempotent operation.  Or, in layman's terms, if the
script *changes* data, use POST and not GET.  That is a totally
separate reason to choose POST over GET or vice versa.

ymmv
naiaa
ianal

-- 
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: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink

2007-08-26 Thread Richard Lynch
On Fri, August 24, 2007 6:34 am, Suamya Srivastava wrote:

> by doing this can i disable the register_globals?

You can disable register_globals by using these:

$_GET['foo']
$_POST['foo']
$_REQUEST['foo'];
$_COOKIES['foo'];
$_SESSION['foo'];
$_ENV['foo'];
$_SERVER['foo'];

and never, ever, ever, use just plain old $foo for data that was
supposed to come from GET/POST/COOKIE/REQUEST/SESSION/...

register_globals has absolutely nothing to do with whether the session
data is getting passed along or not by either Cookie or TransId.

register_globals has everything to do with whether you know that you
are getting external data or internal data.

You, and others on this list in response to you, have conflated two
very distinct and different issues into one giant snarled knot.

Don't do that. :-)

-- 
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: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink

2007-08-26 Thread mike
On 8/26/07, Richard Lynch <[EMAIL PROTECTED]> wrote:

> This is *SO* not correct at all!
>
> $_REQUEST[] is merely array_merge($_GET, $_POST, $_COOKIE);

Yes and it mimics being lazy - allowing overriding values from $_POST
vs. $_GET vs. $_COOKIE depending on what the programmer wants to
"trust"

It encourages poor practices. There is no reason to not name the
proper source of data - i.e. "i want it from POST not GET"

> It is *NOT* in any way, shape, or form, polluting the global namespace
> of all your variables, which is what register_globals is.

That is why I said it was *one* reason register_globals was disabled -
global namespace was probably the biggest reason, but also variable
overriding and sloppyness allowing for exploits was probably up there
too.

> There could easily be a script written which is expected to respond to
> GET or POST data in the same way, particularly a simplistic
> web-service that doesn't really care if the web "Designers" prefer to
> have buttons or links or CSS links that look like buttons or CSS
> buttons that look like links or rabid squirrels that send the GET
> and/or POST data to make the HTTP request.

Yes, there could. But part of that would rely on a *very* motivated
end-user (or we'll call them "hacker") - they would probably find a
way in or do what they want either way.

There's no reason to make it easier just because "well they can hack
something up to do that anyway" - that's a Microsoft approach to
security. Whatever happened to people at least trying to discourage
abuse or issues.

I have never used $_REQUEST and my applications don't seem to have any
issues. Obviously someone could have tried to switch POST/GET on me,
but I still ensure proper bounds checking/sanity checking/type
checking/etc. But I would not allow someone to issue a GET variable to
override a cookie value without having to make the extra effort (and
furthermore understand how the variables work on the server side to
make it actually work how they want.)

> Use $_POST when you expect the data to always be in POST data.

correct.

> Use $_GET when you expect the data to alwasy be in GET data.

correct.

> If you actually want to accept HTTP requests of either kind for
> flexibility to an external user, by all means use REQUEST.

In my opinion a properly coded web application shouldn't be lazy and
should know the source of data. So I consider this incorrect.

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



Re: [PHP] Re: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 6:37 pm, mike wrote:
> On 8/26/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> It is *NOT* in any way, shape, or form, polluting the global
>> namespace
>> of all your variables, which is what register_globals is.
>
> That is why I said it was *one* reason register_globals was disabled -
> global namespace was probably the biggest reason, but also variable
> overriding and sloppyness allowing for exploits was probably up there
> too.

I'll say it again:

regsiter_globals has *NOTHING* to do with $_REQUEST.

Zero.
Zilch.
Nada.
Zip.

>> There could easily be a script written which is expected to respond
>> to
>> GET or POST data in the same way, particularly a simplistic
>> web-service that doesn't really care if the web "Designers" prefer
>> to
>> have buttons or links or CSS links that look like buttons or CSS
>> buttons that look like links or rabid squirrels that send the GET
>> and/or POST data to make the HTTP request.
>
> Yes, there could. But part of that would rely on a *very* motivated
> end-user (or we'll call them "hacker") - they would probably find a
> way in or do what they want either way.

No, it only relies on one "Designer" who wants their request to look
like a FORM and another "Designer" who wants their request to look
like a link.

And I don't really *CARE* if the search terms (or whatever input it
its) comes from GET versus POST as there is NO Security difference
whatsoever.

They need equal filtration.

> There's no reason to make it easier just because "well they can hack
> something up to do that anyway" - that's a Microsoft approach to
> security. Whatever happened to people at least trying to discourage
> abuse or issues.

The point is not that they can hack something up to use GET instead of
POST and make it work.

The point is that GET and/or POST are equally tainted data, and that I
wish to provide the same services to either kind of request, and there
is NO DIFFERENCE between them for this service.

> I have never used $_REQUEST and my applications don't seem to have any
> issues. Obviously someone could have tried to switch POST/GET on me,
> but I still ensure proper bounds checking/sanity checking/type
> checking/etc. But I would not allow someone to issue a GET variable to
> override a cookie value without having to make the extra effort (and
> furthermore understand how the variables work on the server side to
> make it actually work how they want.)

You're still not getting the point.

There *ARE* valid reasons for allowing GET and POST to be used
inter-changably.

Consider a stupid simple web "service" that lets you look up
Longitude, Latitude by zip code from their own website.

Do you really CARE if they use a link or a form to REQUEST the
long/lat with the zip input?

No.  You don't.  So go ahead and use REQUEST.

And register_globals should be off, and using REQUEST does not "undo"
*anything* that was done by register_globals being turned off.

>> Use $_POST when you expect the data to always be in POST data.
>
> correct.
>
>> Use $_GET when you expect the data to alwasy be in GET data.
>
> correct.
>
>> If you actually want to accept HTTP requests of either kind for
>> flexibility to an external user, by all means use REQUEST.
>
> In my opinion a properly coded web application shouldn't be lazy and
> should know the source of data. So I consider this incorrect.

I'm sorry you feel that way.

But please do NOT spread mis-information that using $_REQUEST un-does
what turning register_globals off does.  Because that is simply not
factually correct, no matter how you feel about $_REQUEST.

-- 
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 and SOAP calls

2007-08-26 Thread Richard Lynch


On Fri, August 24, 2007 12:55 am, Angelo Zanetti wrote:
> Dear All
>
> I have been using nusoap to development a client that makes SOAP calls
> to a server. I have however been stuck on a  small issue but can't
> seem
> to solve it and therefore I need to relook at using another package to
> get a solution.
>
> So I have read that PEAR also has a package that makes SOAP calls
> (PEAR::SOAP). And there is PHP-SOAP.
>
> Now Im running PHP 4.4xxx and I need to get this up and running ASAP.
> What would you suggest I use as the package to make the client calls?
>
> I have read that the PEAR::SOAP thing is fairly easy to use?
>
> Does anyone have suggestions or recommendations or what not to use and
> why?

I have fought with SOAP in PHP 5, and PHP 4, and I think maybe even
PHP 3 (shudder).

I've used nuSoap, and I think I used PEAR::SOAP once.  I also tried to
use some other SOAP package once, I think, that failed miserably.

My recommendations:

#1
If you can move to PHP 5 and use the built-in SOAP there, do it ASAP.
It's like night and day.

#2
If you are stuck in PHP 4, try the PEAR::SOAP.
I believe it will handle the whatsit tag namespace-y thingie you are
getting with that  business better than nuSoap, as I recall.  I
won't swear to it in court, though, as I only use PEAR::SOAP once
before I moved to PHP 5 and my SOAP life was way way way cleaner.
-- 
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] [mssql_connect error] Changed database context to..

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 6:26 pm, Liz Kim wrote:
> Did anyone else run into this problem?
>
> PHP fails to connect to MSSQL7 with mssql_connect with the message:
> Changed database context to ''.
>
> I've been searching around but did not find a good solution for PHP.
> I did find this link:
> http://support.microsoft.com/default.aspx?scid=KB;EN-US;197459
>
> But is not too helpful..
>
> I've tried:
> setting the severity value higher with
> mssql_min_error_severity(4);
> mssql_min_message_severity(4);
> but these did not work either..
>
> Any ideas?

Perhaps the connection is fine and you just need to ignore those
particular messages?

You may also want to just try out the Sybase driver...

I've generally found it to be better/faster/simple than the MS driver,
on the (thankfully) few occasions I had to use SQL Server.

-- 
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] Spam Post Defense / ID spam form posts

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 2:49 pm, Instruct ICC wrote:
> Can server1 receive a web page form post from remoteAttacker,
> identify it as spam (or a DoS or DDoS attack),
> hand off the socket to multiple threads on multiple servers owned by
> server1's owner,
> return multiple responses to remoteAttacker which normally would have
> been a
> single response returned by server1,
> so that server1 is not busy responding to remoteAttacker and is able
> to
> handle legitimate requests?
>
> Technically?

You could always just 301 them, but you're just tying up more of your
servers...

Unless you 301 them back to their own box...

But that might not even really be their box, as it could be a zombie,
so you just are making life (more) miserable for some other victim.

> Legally?

No comment.

> The boss doesn't want to use a CAPTCHA on the form but wants us to
> identify
> it without additional user input.

Might I suggest a CAPTCHA and an optional "accessible" link/form which
gets human-reviewed before posting?

> Also, can a form post be run through an email spam filter to identify
> it as
> spam?

I'm 100% sure you could manage that somehow.

> Do you have any ideas to detect spam form posts?

Most spam posts are a) very long and b) have a very high HTML to data
content ratio.

 $spam_factor)
die('spammer.');
?>

> I'm tracking the spam posts in an attempt to find a pattern I can use
> to
> detect them.

It would probably be smarter to run them through spam assasin and not
re-invent that particular wheel.

It would make a VERY nice PECL project, actually, I should think...

-- 
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] Spam Post Defense / ID spam form posts

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 4:46 pm, Stut wrote:
> Instruct ICC wrote:
>>> Wow, that's for that egg-sucking lesson. I would think it was clear
>>> from my answer that I know what a socket is.
>> Sorry.  You understood the concept but it wasn't clear to me that
>> you
>> understood about the socket.  Save me a google search and define
>> "egg-sucking", although I get your point.
>
> To "teach someone how to suck eggs" means to explain something to them
> when they already know it.
> http://www.google.co.uk/search?q=teach+someone+how+to+suck+eggs

I always wondered where that phrase came from, and just how common is
egg-sucking anyway?

I mean, sure, I've eaten eggs.

I've even eaten hard-boiled eggs, which can sometimes require sort of
sucking them in.

But, really, who sucks on an egg in the first place?

I Googled and Wikipediad a bit and came up with a lot of un-sourced
junk that's probably about as correct as some of today's posts on this
list :-)

Anybody happen to have this book:
http://www.orionbooks.co.uk/PB-24584/Cassell's-Dictionary-of-Word-and-Phrase-Origins.htm
whose blurb makes it seem like it might have the answer?...

-- 
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] ignore-user-abort and connection-handling

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 12:04 pm, Jason Pruim wrote:
> One of these days someone is going to get sick of hearing from me,
> but until that day comes I have another question :)
>
> I asked on a MySQL list about wether it's better to have 1 database
> with many tables, or many databases with 1 table for my address list
> application I'm writing.
>
> One of the people there asked me about "terminating the TCP
> connections and ensuring that each PHP script runs to completion" to
> keep the database in good condition.
>
> He recommened looking at the ignore-user-abort and connection-
> handling functions in php...
>
> So now the question, Do I have to worry if a user hits the stop
> button in their browser before the script finishes? Will It corrupt
> the database or causing undo havoc to my system?
>
> This is far past my knowledge, so references to how I would use
> something like that properly would be greatly appreciated! :)

It won't corrupt your data.

It could tie up MySQL connections and make your server slower, I suppose.

I'm not sure that ignore_user_abort is actually going to help,
however...  Start reading, I guess.

-- 
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] Re: determine which string is longer and then what is different in that string

2007-08-26 Thread Bill Guion

At 11:11 PM -0700 8/25/07, Richard Kurth wrote:


I am trying to find out which string is the longest and then find out what
is different between the two string. Sometimes String 2 is longer than
String 1 The script below works sometimes but not all the time.
Is there a better way to do this or tell me what is wrong with the script I
am using

$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8";


Can you give us an example of two strings where the comparison fails? 
I suspect you are looking for the number of "entries" in the string, 
rather than the length of the string. For example:

$string1 = "1,2,3,4,5,6,9";
$string2 = "1,2,3,10,11,12";

number of entries in $string1 is 7, number of entries in $string2 is 
6, but length($string1) = 13, while length($string2) = 14. Is this 
the problem you are seeing?


 -= Bill =-


--

The greatest calamity is not to have failed,
but to have failed to try.
  


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



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen


On Aug 26, 2007, at 9:15 AM, brian wrote:


jekillen wrote:

Hello again;
I have a question about  upload temp dir as defined in php.ini;
I have been working on a project that has registered users, each 
having

a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.


No, the best solution is for your application to grab the path to that 
particular user's directory and assign a unique name to the uploaded 
file, then move it from the temp dir:


move_uploaded_file($_FILES['upload_file']['tmp_name'], $upload_path);

where 'upload_file' is the name of your upload form field.

http://www.php.net/manual/en/function.move-uploaded-file.php


I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.


That's unlikely to occur. In fact, i'd be surprised if it were 
possible that PHP would assign a temp name that already existed.


brian



Thanks thats all I need to know.
Jeff K

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



[PHP] RE: determine which string is longer and then what is different in that string

2007-08-26 Thread Richard Kurth
 
> 
> >I am trying to find out which string is the longest and then 
> find out 
> >what is different between the two string. Sometimes String 2 
> is longer 
> >than String 1 The script below works sometimes but not all the time.
> >Is there a better way to do this or tell me what is wrong with the 
> >script I am using
> >
> >$string1 = "1,2,3,4,5,6,7,8";
> >$string2 = "1,2,3,4,6,7,8";
> >
> >
> Can you give us an example of two strings where the comparison fails? 
> I suspect you are looking for the number of "entries" in the 
> string, rather than the length of the string. For example:
> $string1 = "1,2,3,4,5,6,9";
> $string2 = "1,2,3,10,11,12";
> 
> number of entries in $string1 is 7, number of entries in 
> $string2 is 6, but length($string1) = 13, while 
> length($string2) = 14. Is this the problem you are seeing?
> 
Yes that is the problem $string2 is what is saved in the database and
string1 is coming from a form. The form has every thing that is in the
database but could have some items added and some removed. I need to know
what is different so I can add to or remove from a separate table so both
tables are the same. 

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



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen


On Aug 26, 2007, at 2:56 PM, Richard Lynch wrote:


On Sun, August 26, 2007 10:34 am, jekillen wrote:

I have been working on a project that has registered users, each
having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?


http://php.net/move_uploaded_file

And, BEFORE you move it, you should Validate the uploaded file as many
ways as practical for your web application.


Yes, I agree, I want to completely decontaminate all uploaded files but 
I

am not sure of a system that will do that.
like embedding scripts in image files, binary files, encrypted images
(I forgot the term for that, stegonography or something), shell
escape chars, incompatible files, viruses, erroneous mime or file types,
you name it, I want to check it out before it is a problem.
JK



I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.


The user uploading the file is probably logged in, and you probably
have some kind of user_id or Profile and can decide where to move the
file based on that user's identity.


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



Re: [PHP] Re: Recompiling PHP with mssql

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 9:45 am, Colin Guthrie wrote:
> Dan Shirah wrote:
>> You shouldn't need to recompile PHP.
>>
>> Just go into your PHP.ini file and uncomment the line:
>> ;extension=php_mssql.dll
>>
>> After that you can go to the [MSSQL] section of the .ini file and
>> change the
>> rest of the settings however you want them. IE. Allow persistent
>> connections, timeouts etc.
>>
>> Then, just use the mssql_ functions to create, connect, query SQL
>> Server.
>
> That completely depends on how the original PHP was compiled.
>
> If the original was not compiled with mssql support then it wont work.

If the OP was actually on Windows, this would actually work.

The DLL in question *is* the compilation of mssql support, assuming it
is the same version as the php.exe (or php .dll for modules)

> Also I reckon the windows .dlls will not work on the OP's redhat
> server..

Correct.

The OP could use rpm and/or up2date to just get the php-mssql package
if they installed from rpm to start with.

If they compiled from source, they should be able to go back to the
source and ./configure --with-mssql=shared, and then make and then
copy the php-mssql.so file into their extensions dir.

However, it is probably easier to just do:
./config --with-mssql
make
make install
if you compiled from source in the first place.

-- 
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] Table shows even when if () is false

2007-08-26 Thread Richard Lynch
The definition of 'empty' changed several times in the life of PHP.

I think an empty array was always empty though...

Still, if it's giving you grief, just use http://php.net/count

On Wed, August 22, 2007 4:06 pm, Dan Shirah wrote:
> From my understanding, if $result_deferred_comments is empty, than
> none of
> the code below the if should be executed, correct?
>
> The actualy rows/columns that would contain the data do not appear,
> but I am
> still seeing the "DEFERRED PAYMENT REQUEST COMMENTS" table. Is the
> only way
> to block out EVERYTHING from being displayed if
> $result_deferred_comments is
> empty to use " " around all of the HTML and not exit out of the PHP
> tags?
> Or am I doing something else wrong?
>
> Or, is it a problem with (!empty())?  Since the value is an array,
> will it
> never be parsed as empty even if there is no data retrieved?
>
> Below is my code:
>
>  $credit_card_id = $_GET['credit_card_id'];
>
> $deferred_comments= "SELECT * FROM comments WHERE credit_card_id =
> '$credit_card_id' AND request_type = 'D'";
> $result_deferred_comments = mssql_query($deferred_comments) or
> die(mssql_error());
>
> if(!empty($result_deferred_comments)) {
> ?>
> 
>   
> 
> DEFERRED PAYMENT REQUEST
> COMMENTS
>   
> 
> 
>  while ($row_deferred_comments =
> mssql_fetch_array($result_deferred_comments)) {
>$id_deferred_comment = $row_deferred_comments['request_id'];
>$dateTime_deferred = $row_deferred_comments['comment_date'];
>$deferred_comments = $row_deferred_comments['comments'];
>$deferred_wrap_comments = wordwrap($deferred_comments, 60, " />\n");
> ?>
> 
>  class='tblcell'>
>?>
>  class='tblcell'>
>?>
>  class='tblcell'>
> 
> 
> 
> 
> 
>
> Thanks,
> Dan
>


-- 
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] Override parent class constants

2007-08-26 Thread Richard Lynch
On Wed, August 22, 2007 3:04 pm, James Ausmus wrote:
> Hello - I'm trying to find a (sane) way to, in an extended class,
> override the parent class's constants, something like the following
> (which doesn't actually work):

Call me crazy, but if you're over-riding it, then it's not a constant,
so don't make it a constant...

Make it a var.

-- 
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] using disable_functions silently

2007-08-26 Thread Richard Lynch
You could change the PHP source to not emit an error when a function
doesn't exist and matches the list in disable_functions...

But since a whole heck of a lot of scripts would NOT "just work"
without exec, that would probably not be such a Good Idea...

On Thu, August 23, 2007 12:25 am, Samuel Vogel wrote:
> Unfortunately we would need a solution without changing the PHP code
> of
> our users.
> No way to do that?
>
> Regards,
> Samy
>
> Chris schrieb:
>> Samuel Vogel wrote:
>>> I would like to know, if there is any way, to use disable_functions
>>> silently.
>>> We are running an shared hosting environment and therefore forbid
>>> the
>>> use of exec() etc.
>>>
>>> Many of our users, just seem to be to dumb to comment out exec() in
>>> phpBB etc.
>>> Since removing the exec()-calls works fine, is there any way to
>>> just
>>> omit them silently from the server side?
>>
>> Don't think so. The code just needs to handle it better. I do it
>> like
>> this:
>>
>> $disabled_functions = explode(',', str_replace(' ', '',
>> ini_get('disable_functions')));
>>
>> if (!in_array('set_time_limit', $disabled_functions)) {
>> set_time_limit(0);
>> }
>>
>> Works every time :)
>>
>
> --
> 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



[PHP] RE: determine which string is longer and then what is different in that string

2007-08-26 Thread Bill Guion

At 6:00 PM -0700 8/26/07, Richard Kurth wrote:





 >I am trying to find out which string is the longest and then
 find out
 >what is different between the two string. Sometimes String 2
 is longer
 >than String 1 The script below works sometimes but not all the time.
 >Is there a better way to do this or tell me what is wrong with the
 >script I am using
 >
 >$string1 = "1,2,3,4,5,6,7,8";
 >$string2 = "1,2,3,4,6,7,8";
 >
 >
 Can you give us an example of two strings where the comparison fails?
 I suspect you are looking for the number of "entries" in the
 string, rather than the length of the string. For example:
 $string1 = "1,2,3,4,5,6,9";
 $string2 = "1,2,3,10,11,12";

 number of entries in $string1 is 7, number of entries in
 $string2 is 6, but length($string1) = 13, while
 length($string2) = 14. Is this the problem you are seeing?


Yes that is the problem $string2 is what is saved in the database and
string1 is coming from a form. The form has every thing that is in the
database but could have some items added and some removed. I need to know
what is different so I can add to or remove from a separate table so both
tables are the same.


How about something like

$array_string1 = explode(',' , $string1);
$array_string2 = explode(',' , $string2);
$len_string1 = count($array_string1);
$len_string2 = count($array_string2);

Now you can compare the number of elements in $string1 ($len_string1) 
vs. the number of elements in $string2 ($len_string2). And the two 
arrays can be compared to see what the differences are.


You haven't really provided enough information about what is really 
going on (nor is it necessary to do so), but is it possible that the 
two strings could be different but have the same number of elements? 
If so, then the lenght of the strings is not particularly relevant, 
and you might just want to compare the specific elements of both 
strings with each other.


 -= Bill =-
--

If you're living on the edge, make sure you're wearing your seat belt.
  


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



Re: [PHP] How do I get Apache 1.3.36 to use PHP 5

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 3:03 pm, Beauford wrote:

> I tried putting LoadModule php5_module /usr/local/apache/libphp5.so in
> my
> http.conf, but it doesn't exist.

>Example 2-2. Installation Instructions (Static Module Installation
> for
>Apache) for PHP

I think "static module installation" means you've compiled PHP *in* to
Apache, and it's not a libphp5.so file -- It's just part of httpd
binary.

> 8.  make
> 9.  make install

This step should tell you if it's copying libphp5.so into the Apache dir.

> 10. cd ../apache_1.3.x
>
> 11. ./configure --prefix=/www
> --activate-module=src/modules/php5/libphp5.a
> (The above line is correct! Yes, we know libphp5.a does not exist
> at
> this
> stage. It isn't supposed to. It will be created.)

Yup, this is where you are compiling php INTO the httpd binary.


If you want to end up with a libphp5.so, you have to follow the
instructions that involve apxs and not the "Static" instructions.

-- 
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] Database includes

2007-08-26 Thread Bruce Cowin
I'm curious as to how everyone organises and includes their classes in
PHP5.  Let's take a simple example that has 3 classes: customer, order,
and database.  The database class has a base sql db class (I know there
is PDO and other things but this class is already written and working)
and classes that inherit from the base class for dev, test, and prod,
passing the associated logins.  The customer and order will both use the
appropriate database class depending on which environment its in (e.g.,
SalesDevDB, SalesTestDB, SalesProdDB).

I don't want to have to go into the customer and order class code and
change which db class it uses when I move it from dev to test and from
test to prod.  What's the proper way to handle this?  Or am I way off
base?

Thanks.

Regards,

Bruce

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



Re: [PHP] Re: Announcement: Releasing CORE GRASP for PHP. An open source, dynamic web application protection system.

2007-08-26 Thread Richard Lynch
On Wed, August 22, 2007 3:31 pm, mike wrote:
>> I thing a good FAQ entry would be how this patch fits in with
>> Suhosin
>> and what are the comparable/conflicting concepts, are they
>> compatible
>> with each other etc.
>>
>> http://www.hardened-php.net/suhosin/a_feature_list.html
>>
>>
>> Both systems are liable to appeal to the same sort of people so it
>> makes
>>  sense to cover this.
>
> What I do not understand is why don't these patches get put instantly
> back into the core PHP distribution? So patches against 5.2.3 perhaps
> would be in 5.2.4, etc?
>
> IMHO there shouldn't be a hardened PHP project. Their patches should
> be put in whenever possible, perhaps during an RCx before a gold build
> or something. Any loss of functionality due to them should be a
> configuration option to turn on/off but otherwise everyone would
> benefit from security, memory leak, and other patches...

You'd really have to take that up with Steffan Esser and the Core PHP
Dev Team...

They had differences of opinion about where to draw the line in the
sand on some PHP Security issues which led to Steffan starting Suhosin
and eventually withdrawing from the team.

Steffan still contributes many security patches/suggestions, and many
of those are put into the stock PHP distribution.

Apologies in advance to all involved in my gross over-simplification
and probably mis-representation of "history". :-)

-- 
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] Re: Database includes

2007-08-26 Thread Gregory Beaver
Bruce Cowin wrote:
> I'm curious as to how everyone organises and includes their classes in
> PHP5.  Let's take a simple example that has 3 classes: customer, order,
> and database.  The database class has a base sql db class (I know there
> is PDO and other things but this class is already written and working)
> and classes that inherit from the base class for dev, test, and prod,
> passing the associated logins.  The customer and order will both use the
> appropriate database class depending on which environment its in (e.g.,
> SalesDevDB, SalesTestDB, SalesProdDB).
> 
> I don't want to have to go into the customer and order class code and
> change which db class it uses when I move it from dev to test and from
> test to prod.  What's the proper way to handle this?  Or am I way off
> base?

Hi Bruce,

Use a factory or singleton pattern to instantiate your database objects,
and you can centralize the choice.

public $production = 'Dev'; // or 'Test' or 'Prod'
static function factory($dbname, $args)
{
if (!class_exists($dname . self::$production . 'DB')) {
require 'However/You/Find/It.php';
}
$db = $dname . self::$production . 'DB';
return new $db($args);
}

Singleton would simply return a pre-instantiated object if it exists for
that class type but is otherwise the same.

Greg

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



Re: [PHP] Database includes

2007-08-26 Thread Larry Garfield
On Sunday 26 August 2007, Bruce Cowin wrote:
> I'm curious as to how everyone organises and includes their classes in
> PHP5.  Let's take a simple example that has 3 classes: customer, order,
> and database.  The database class has a base sql db class (I know there
> is PDO and other things but this class is already written and working)
> and classes that inherit from the base class for dev, test, and prod,
> passing the associated logins.  The customer and order will both use the
> appropriate database class depending on which environment its in (e.g.,
> SalesDevDB, SalesTestDB, SalesProdDB).
>
> I don't want to have to go into the customer and order class code and
> change which db class it uses when I move it from dev to test and from
> test to prod.  What's the proper way to handle this?  Or am I way off
> base?

The best way to handle that is to not use 3 separate classes.  You should have 
one and only one code base that works on all installations.

Then have a config file of some sort in which you specify your DB credentials.  
There's a variety of ways to do that (ini file, a PHP file with a database 
url, a PHP file that just has a couple of variables in it, or constants 
instead, etc.).  Pick one you like.  Then have your DB connection class read 
that file's data one way or another and connect as appropriate.  

If you have to modify anything other than a single config file in order to 
move your site/app from one server to another, then you have a design flaw.  
(I'd say that applies for moving the site to a subdirectory on a server too, 
but that takes a bit more effort.)

Cheers.

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

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

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



Re: [PHP] RE: determine which string is longer and then what is different in that string

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 8:00 pm, Richard Kurth wrote:
>> >I am trying to find out which string is the longest and then
>> find out
>> >what is different between the two string. Sometimes String 2
>> is longer
>> >than String 1 The script below works sometimes but not all the
>> time.
>> >Is there a better way to do this or tell me what is wrong with the
>> >script I am using
>> >
>> >$string1 = "1,2,3,4,5,6,7,8";
>> >$string2 = "1,2,3,4,6,7,8";
>> >
>> >
>> Can you give us an example of two strings where the comparison
>> fails?
>> I suspect you are looking for the number of "entries" in the
>> string, rather than the length of the string. For example:
>> $string1 = "1,2,3,4,5,6,9";
>> $string2 = "1,2,3,10,11,12";
>>
>> number of entries in $string1 is 7, number of entries in
>> $string2 is 6, but length($string1) = 13, while
>> length($string2) = 14. Is this the problem you are seeing?
>>
> Yes that is the problem $string2 is what is saved in the database and
> string1 is coming from a form. The form has every thing that is in the
> database but could have some items added and some removed. I need to
> know
> what is different so I can add to or remove from a separate table so
> both
> tables are the same.

A lot of times it's easier to just delete all the old rows and insert
all the new ones.

It may even be FASTER than using PHP logic to work out what is different.

That said, the array_diff function should tell you want got deleted,
and what got added if you call it as I posted earlier.

-- 
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] using disable_functions silently

2007-08-26 Thread Richard Lynch
On Thu, August 23, 2007 12:58 pm, Samuel Vogel wrote:
> That'd be at least some kind of a solution.
> I'm thinking of overwriting the functions I want to block with one,
> that
> just returns true and does nothing.
> How would I do that?

E.  You don't.

Well, okay, you *COULD* install the "Run-Kit" extension and then you
can over-ride whatever you want, I think.

Maybe not language constructs like 'if' and 'echo' and 'include' but
any function.

Note that "Run-Kit" on a production server is probably NOT a Good Idea
in a very big way, as any user who knows you have it installed could
do things way way way worse than running 'exec'...  Like the could
re-defined 'exec' after you defined it, and define it to whatever they
want.  I think.

-- 
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] Database includes

2007-08-26 Thread Chris

Bruce Cowin wrote:

I'm curious as to how everyone organises and includes their classes in
PHP5.  Let's take a simple example that has 3 classes: customer, order,
and database.  The database class has a base sql db class (I know there
is PDO and other things but this class is already written and working)
and classes that inherit from the base class for dev, test, and prod,
passing the associated logins.  The customer and order will both use the
appropriate database class depending on which environment its in (e.g.,
SalesDevDB, SalesTestDB, SalesProdDB).

I don't want to have to go into the customer and order class code and
change which db class it uses when I move it from dev to test and from
test to prod.  What's the proper way to handle this?  Or am I way off
base?


Could you just have 3 config files and use the appropriate one in each 
environment?


The settings are in 'config.php'. When it's in dev:

cp dev.php config.php

when it's in test:

cp test.php config.php

:)

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

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



Re: [PHP] export data of html table

2007-08-26 Thread Richard Lynch
On Wed, August 22, 2007 1:09 am, Vanessa Vega wrote:
> i have a table generated using PHP & javascript...the data on that
> table
> came from a form where several
> data was inputted... I want
> to let them see a preview of the data they entered, so i put a link or
> button that when clicked, will display all the data in the table and
> they
> will also have an option to
> print them.
>
> Is there a way to easily do this? does it really need exporting data
> to
> another
> application like excel in order to print it?
>  please give me some advice...thanks

Depending on the size of the table and your HTML and CSS, you could
make the browser itself print decent.

You could also explore using libpdf http://php.net/pdf

Excel would be the LAST thing I'd try... :-v

-- 
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 to generate java-script

2007-08-26 Thread Richard Lynch
If you want to capture the output of your current script, toss
ob_start() at the top and $data = ob_get_content() at the bottom and
then munge it as you will.

Though I also think you'd be better off putting the JS validation
in-line with the  Anyone have a good method of grabbing the current page and reading
> data
> from it?
>
> For example:
>   // find all form fields for current page
>  function FindFormFields( $page ) {
>   if( empty( $page ) ) {
>$data = -1;
>   } else {
>if( ( $fh = @fopen( $page, "r" ) ) === FALSE ) {
> $data = -1;
>} else {
> while( !feof( $fh ) ) {
>  $line = fgets( $fh, 512 );
>  if( eregi( "   $data[] = $line;
>  }
> }
> fclose( $fh );
>}
>   }
>   return $data;
>  }
>
>  echo FindFormFields( "http://php.net"; );
> ?>
>
> The above code would output the following:
> Array
> (
> [0] => accesskey="s" />
>
> [1] =>
> )
>
> Now for the problem I am having and a description of what I am trying
> to
> accomplish:
>
> I want to dynamically generate a form and in doing so I would like to
> dynamically generate the following javascript features for said page
>   - javascript form validation
>   - javascript form field focus
>
> The problem is if I call the current page that is being generated such
> as
>  echo FindFormFields( "http://"; . $_SERVER['SERVER_NAME'] .
> $_SERVER['REQUEST_URI'] );
> ?>
>
> Not only does it take a helluva long time to load the page but it also
> creates a nested array with duplicate values.
>
> My best guess is that the order in which the page is being generated
> has
> something to do with the lag as well as the nested array with
> duplicate
> values.
>
> Could anyone help me or point me in a better direction for performing
> these actions?
>
> Thanks in advance,
> Jas
>
> --
> 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] Server error

2007-08-26 Thread Richard Lynch


On Tue, August 21, 2007 6:14 am, Humani Power wrote:
> Hi everybody. I have a Fedora Core 7 with php 5, and I want to upload
> an
> image.
> The funniest thing is that my script works fine in other computer but
> not in
> this one.
> I look for the error in /var/log/httpd/error.log and I found this
>
> [Tue Aug 21 15:52:46 2007] [notice] caught SIGTERM, shutting down
> [Tue Aug 21 15:55:32 2007] [notice] suEXEC mechanism enabled (wrapper:
> /usr/sbin/suexec)
> [Tue Aug 21 15:55:32 2007] [notice] Digest: generating secret for
> digest
> authentication ...
> [Tue Aug 21 15:55:32 2007] [notice] Digest: done
> [Tue Aug 21 15:55:33 2007] [notice] mod_python: Creating 4 session
> mutexes
> based on 256 max processes and 0 max threads.
> [Tue Aug 21 15:55:33 2007] [notice] mod_python: using mutex_directory
> /tmp
> [Tue Aug 21 15:55:34 2007] [notice] Apache/2.2.4 (Unix) DAV/2
> PHP/5.2.2
> mod_python/3.3.1 Python/2.5 mod_ssl/2.2.4 OpenSSL/0.9.8b
> mod_perl/2.0.3
> Perl/v5.8.8 configured -- resuming normal operations
>
> I know that this is PHP forum, but dont know if it is related.
> Thanks for your help

It's POSSIBLE you've found some kind of issue in PHP that is causing
Apache to sigterm...

Can you get that same info in your log by uploading another image?

Does it happen at the right time to be a direct result of the upload?

-- 
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: [PHP-DB] Re: [PHP] Passing variables to a PHP script on clicking a hyperlink

2007-08-26 Thread mike
> I'll say it again:
>
> regsiter_globals has *NOTHING* to do with $_REQUEST.
>
> Zero.
> Zilch.
> Nada.
> Zip.

To me it allows for the same [lazy] behavior. Period. I've had other
people agree. Say what you want about it.

> No, it only relies on one "Designer" who wants their request to look
> like a FORM and another "Designer" who wants their request to look
> like a link.

I've never had to write an app where I allow GET and POST. Either way
can be created using a form, a button, a link, etc. Pick one and stick
with it.

> And I don't really *CARE* if the search terms (or whatever input it
> its) comes from GET versus POST as there is NO Security difference
> whatsoever.
>
> They need equal filtration.

Agreed

> The point is that GET and/or POST are equally tainted data, and that I
> wish to provide the same services to either kind of request, and there
> is NO DIFFERENCE between them for this service.

I disagree with that approach to a web application.

> You're still not getting the point.

No, I get it. I was too vague in my original message. To me newbies
picked up PHP easily because "hey, this query string variable is $foo
just like when I do a post variable of $foo!" and $_REQUEST to them is
their way to get around a register_globals = off installation. I've
seen it many times with people just learning PHP. I associate the use
of $_REQUEST with people new to PHP, because I've seen it many times.
Also when told about $_GET, $_POST, $_COOKIE, etc... they realized how
much cleaner that is and adjust appropriately.

> There *ARE* valid reasons for allowing GET and POST to be used
> inter-changably.
>
> Consider a stupid simple web "service" that lets you look up
> Longitude, Latitude by zip code from their own website.

> Do you really CARE if they use a link or a form to REQUEST the
> long/lat with the zip input?
>
> No.  You don't.

You're right - I don't. But I tell them to use GET or POST and they
prepare their client-side code appropriately. Both ways can be done. I
don't make my applications lazy and then allow two interfaces to them
when one is perfectly fine and allows for one consistent interaction
method.

> But please do NOT spread mis-information that using $_REQUEST un-does
> what turning register_globals off does.  Because that is simply not
> factually correct, no matter how you feel about $_REQUEST.

Eh, you call it mis-information. I call it advising on how to code a
tighter web application.

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



Re: [PHP] Best Practices for calling 'setup' classes that extend 'parent' classes?

2007-08-26 Thread Richard Lynch
Put all your classes into a single directory structure.

Use http://php.net/set_include_path (or php.ini or .htaccess) to
provide the FULL PATH to that directory.

PHP now knows where to "start" its search, and essentially prepends
that directory when it does an include.

Assume this directory structure:

/path/to/your/includes
   parent_class.php
   /child
  some_child_class.php

This works:


Do not under any circumstances try to use './' or '../' in your
include statements.  You will only make yourself miserable in the long
run.

On Mon, August 20, 2007 1:52 pm, Graham Anderson wrote:
> What is the best practice for correctly targeting  'include' paths
> when using Initialization/Setup classes that extend Parent classes?
>
> In my extend_parent_class.php file, I have to provide an incorrect
> relative path. Apparently, the path (that does work) is relative to
> php file that calls the initialization/setup class
> (call_the_extend_parent_class.php).  Is there a less confusing way to
> correctly target include paths when creating initialization classes?
>
> Should I be using absolute paths instead?
>
> many thanks in advance
>
>
>
> extend_parent_class.php:
>
> include_once('./path/to/parent_class.php'); # Works with 'incorrect'
> relative path
> //include_once('../path/to/parent_class.php'); # Fatal Error with
> 'correct' relative path
>
> class Initialize_Parent_Class extends Parent_Class {
>
> function Initialize_Parent_Class()
>   {
> $this->Parent_Class();
> echo "This was successful and does not result in a fatal 'class not
> found' error";
> }
>
> }
>
>
>
> Call the initialization class.
> call_the_extend_parent_class.php:
> 
> require('./includes/extend_parent_class.php'); # initialize Parent
> Class
>
> $parent_class = new Initialize_Parent_Class();
> // prints 'This was successful and does not result in a fatal 'class
> not found' error'
>
> ?>
>
> File structure:
>
> php
> ++call_the_extend_parent_class.php
> ++ includes directory
> extend_parent_class.php
> ++ classes directory
>  parent_class.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] for/foreach speed

2007-08-26 Thread Richard Lynch
On Mon, August 20, 2007 11:50 am, Sascha Braun, CEO @ fit-o-matic wrote:
> could somebody please explain me, what loop construct is
> faster? The for, while or foreach.

If you are doing anything where the speed of for/while/foreach
matters, you shouldn't have done that in PHP in the first place, but
should have put it into a custom PHP extension. :-)


-- 
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 eval() fatal error

2007-08-26 Thread Richard Lynch
On Mon, August 20, 2007 8:54 am, Maarten Balliauw wrote:
> Here's the thing: I'm trying to do some dynamic code compilation
> within
> PHP using eval(). The code I'm trying to compile raises an E_ERROR
> (Fatal).
>
> Here's a simple example:
>
>  $code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
> $returnValue = 0;
>
> eval($code);
> ?>
>
> Now, I'd like to catch the error made by eval:
>
> // ...
> try {
>eval($code);
> } catch (Exception $ex) {
>var_dump($ex);
> }
> // ...
>
> Problem persists: a fatal error occurs.
> Using set_error_handler() and set_exception_handler() is not working
> either...
>
> Is there any way to gracefully catch this error?

I would expect that you need to wrap the try catch block *IN* the code
to be eval'd...

You sound like you know what you're doing, but I'm still gonna say it:

If eval is the solution, you probably didn't understand the problem. :-)

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

2007-08-26 Thread Richard Lynch
On Mon, August 20, 2007 12:41 am, Augusto Morais wrote:
> Hi,
>
>
> I want create a variable based in another variable. Example:
>
>
> $foo  (a simple variable);
>
> $myvar_foo
>
>
> Does it possible?

"variable variables" will do it.

But 99.% of the time, you're better off just using an array.

-- 
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] Delete row in a lookup table

2007-08-26 Thread Richard Lynch
On Sat, August 18, 2007 6:31 pm, nitrox . wrote:
> Is it not considered good practice to have a primary key on a lookup
> table for a database?
> I have 3 tables setup, games, memberleagues and members. The
> memberleagues table holds the id of the games table and members table.
> The problem I have is that Im not sure how to delete a row from the
> memberleagues table without a primary key. If its not considered bad
> practice I could add a primary key to the memberleagues table and be
> done. Anybody have any tutorials on how to write the php for this?

You can add the primary key, no problem.

However, it might be kind of silly...

For a lookup table, you probably have:

member_id   |game_id

1   | 1
1   | 3
1   | 17
2   | 1
2   | 5
.
.
.


USUALLY you can just have the unique key be the composite key of
member_id, game_id and you just delete "where member_id = $m and
game_id = $g"

The data itself is the key, so to speak, because there can only be one
of each member/game combo, and it's unique all by itself.

Using an extra field for a key is only a "problem" if you have a
zillion members/games to the point where the "extra" space matters on
your hard drive.  In this day and age, you'd have to have a LOT of
members and games for an INT or even BIGINT to make that much
difference on the hard drive.

-- 
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] Database includes

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 9:16 pm, Bruce Cowin wrote:
> I'm curious as to how everyone organises and includes their classes in
> PHP5.  Let's take a simple example that has 3 classes: customer,
> order,
> and database.  The database class has a base sql db class (I know
> there
> is PDO and other things but this class is already written and working)
> and classes that inherit from the base class for dev, test, and prod,
> passing the associated logins.  The customer and order will both use
> the
> appropriate database class depending on which environment its in
> (e.g.,
> SalesDevDB, SalesTestDB, SalesProdDB).

I personally wouldn't make up a whole new class just to pass in a
different username/password/host/database...

> I don't want to have to go into the customer and order class code and
> change which db class it uses when I move it from dev to test and from
> test to prod.  What's the proper way to handle this?  Or am I way off
> base?

Once you don't have sub-classes for the 3 environments, you don't
change anything in the customer nor order class.

-- 
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] Pass $_GET to php cli.

2007-08-26 Thread Richard Lynch
On Tue, August 21, 2007 3:08 am, Per Jessen wrote:
> N0K wrote:
>
>> But if it run in the browser, i think it have to run in cli, dont
>> you
>> think ?
>
> No, certainly not by default. They are very different environments, as
> you have already found out.

If you want to force it to work, you could hack up a CGI SAPI sort of
thing...

Or just toss it into a web-server somewhere and use wget from the
command line to access it, which would be much easier.

-- 
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] apache/php with sybase12.5

2007-08-26 Thread Richard Lynch
Are you sure it's not --with-apxs2 instead of --with-apx2 ???

On Fri, August 17, 2007 8:00 am, ROUKOS Michel wrote:
> Hi,
>
> I am integrating httpd-2.0.59 with php-5.2.1 and Sybase 12.5 on a
> solaris 8 machine. I followed these steps:
> Install apache:
>
> ./configure --prefix=/usr/local/apache2 --enable-so
> make
> make install
>
>
> PHP configuration:
>
>
> I edited this file php-5.2.1/ext/sybase_ct/ php_sybase_ct.h and
> changed
> this line:
> #define CTLIB_VERSION CS_VERSION_100
> ...to...
> #define CTLIB_VERSION CS_VERSION_125
>
> Then:
> ./configure --with-apx2=/usr/local/apache2/bin/apxs
> --with-sybase-ct=/opt/sybase/oc12.5-EBF11486/OCS-12_5/ --enable-bcmath
> --enable-calendar --enable-ctype --enable-exif --enable-ftp
> --enable-trans-sid --enable-shmop --enable-sockets --enable-sysvsem
> --enable-sysvshm --enable-wddx
> make
> make install
>
>
> then added these 2 lines in httpd.conf:
> AddType application/x-httpd-php .php .phtml
> AddType application/x-httpd-php-source .phps
>
>
> When I access test.php, I am asked to download the file - meaning php
> is
> not working well. I also don't see libphp5.so under modules/
> directory.
>
> test.php is locate under htdocs/ and has this content:
>
> 
>
>
> Could you please point to me why libphp5.so was not generated? Also
> why
> php is not working well with apache and sybase?
>
> ***
> This e-mail contains information for the intended recipient only.  It
> may contain proprietary material or confidential information.  If you
> are not the intended recipient you are not authorised to distribute,
> copy or use this e-mail or any attachment to it.  Murex cannot
> guarantee that it is virus free and accepts no responsibility for any
> loss or damage arising from its use.  If you have received this e-mail
> in error please notify immediately the sender and delete the original
> email received, any attachments and all copies from your system.
>
> --
> 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



[PHP] Re: PHP eval() fatal error

2007-08-26 Thread Maarten Balliauw
When re-writing this example to a form of "create_function", the same 
problem occurs:


	$temporaryCalculationFunction = @create_function('', $code); // E_ERROR 
here

if ($temporaryCalculationFunction === FALSE) {
$returnValue = '#N/A';
} else {
   		$returnValue = call_user_func_array($temporaryCalculationFunction, 
array());

}
} catch (Exception $ex) {
$returnValue = '#N/A';
}
?>

Now I would expect that when I feed "create_function" invalid code 
(syntax), the function returns false. It doesn't!


E_ERROR is thrown right away. In my opinion, this should return FALSE, 
and only throw an E_ERROR when the created function is executed...


Before telling me to read the manual: I did over a hundred times, on 
both eval and create_function: create_function is not documented to 
throw E_ERROR right away, instead returning FALSE on error... Exactly 
what I was thinking using the above code.


Now let's repeat my question: is there any way to gracefully evaluate 
specific code, eventually catch an error and respond to that, without 
using parsekit() or launching another process to get this done?


Regards,
Maarten

PS: Eval/create_function is in place in my code, I don't see any other 
method to execute (filtered, of course !!!) PHP code that is embedded in 
a string.



Maarten Balliauw wrote:
Here's the thing: I'm trying to do some dynamic code compilation within 
PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).


Here's a simple example:



Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working 
either...


Is there any way to gracefully catch this error?

Regards,
Maarten


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



Re: [PHP] Adding text before last paragraph

2007-08-26 Thread Dotan Cohen
On 27/08/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Sun, August 26, 2007 3:41 pm, Dotan Cohen wrote:
> > I have a string with some HTML paragraphs, like so:
> > $text="First paragraph\nMore text\nSome more
> > text\nEnd of story";
> >
> > I'd like to add an image before the last paragraph. I know that
> > preg_replace can replace only the first n occurrences of a string, but
> > how can I replace the _last_ occurrence of a string? My initial idea
> > was to do this:
> > 1) Count how many  times "\n" occurs as $n
> > 2) Replace them all with  "\n\n"
> > 3) Replace $n-1 replacements back to "\n"
> >
> > Is there a cleaner way? Thanks in advance.
>
> If the string really really ENDS on that LAST "", then you can key
> off of that:
>
> $story = preg_replace("|(.*\$|Umsi",
> "$new_paragraph\n\\1", $story;
>
> You may have to fiddle with the DOT_ALL setting to only match the true
> end of string and not just any old "\n" within the string...
> http://php.net/pcre
>

Thanks, Richard, I was also trying to use a regex with pre_replace and
getting nowhere. In the manual page for strrpos, there is a
user-comment function for finding the last occurrence of a string:
http://il2.php.net/manual/en/function.strrpos.php#56735

However, I am unable to piece 2 and 2 together.

Note that I'm adding a paragraph before the last paragraph, so I'm
searching for the last instance of "\n".

This is what I've done to your code, but I'm unable to get much further:
$text = preg_replace("|(\n)\$|Umsi", "\nTest\n", $text);

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

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