Re: [PHP] PHP Applications?

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 1:50 pm, Greg Donald said:
> On 5/17/05, Brent Baisley <[EMAIL PROTECTED]> wrote:
>> Zend sells a compiler to speed up your PHP code. Since it's compiled,
>> it also does not contain the source code in readable form. You should
>> visit the Zend website.
>
> Did you have a link for this 'compiler' ?  All I see in the site menu
> is a link to the encoder.  Sorry if I'm just not seeing it.

He probably meant the encoder.

Zend has a lot of products, though, and there maybe might be one designed
just to secure your PHP source...  I kinda lost track lately, with all the
options out there.

Err, anyway, I just really wanted to say that virtually every Zend product
has been so routinely mis-represented by what it does that the amount of
mis-information out there is probably larger than the amount of correct
info.

Read Zend's website product descriptions first, and ignore forum/mailing
list comments until you're clear on what the product does, and doesn't do.

That will help you separate the patent falsehoods from useful info, and
winnow down your reading by a factor of 3.

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

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



[PHP] Re: Secure delivery

2005-05-17 Thread lopopizarro

Please authenticate the secure message.


+++ Attachment: No Virus found
+++ Bitdefender AntiVirus - www.bitdefender.com


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

Re: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 2:24 pm, Robert Meyer said:
> Hello,
>
> Scenario:
> 1) User is presented a blank form.

with an MD5 hash which is stored in the database as "fresh"

> 2) User fills in form.
> 3) User submits form.
> 4) Record is added to database.

That particular MD5 has is marked as "used"

> 5) Back to 1).
> All is fine to here.
> 6) User clicks refresh.
> 7) Another record is added, same data except auto-increment field.
> How do I prevent these last two steps, or at least prevent a record
> from being added when refresh is clicked?

The used MD5 hash tells you they are re-submitting the exact same form.

Now, if the real problem is that the user has a fresh new form, and fills
in the same data again by hand, then there are only two possibilities:

1. In the real world, they actually NEED two of the "same" thing in the
database, and your application should allow it.

2. In the real world, users are likely to lose track of where they are in
their data entry, and you need to provide them the context to help avoid
that. When you go back to 1) present a message like "added blah blah blah"
at the top of the screen.  Now they *KNOW* they just did blah blah blah,
and can move on to blah blah bleh.  Data entry is a sucky job.  Make it
nicer for them, eh?  You STILL need to code for the dual entry, and do
something intelligent when they mess up, but you can improve efficiency
and decrease errors (where 2 not-quite-the-same-but-really-are-the-same
entries pass your tests) if you make your application nicer to the user.

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

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



Re: [PHP] Mail function

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 3:53 pm, [EMAIL PROTECTED] said:
> I have a script which send emails using mail() function. I have 100 email
> addresses and i set up the script to send 1 email every 10 seconds. So, it
> will take 1000 seconds
> to send all 100 emails.
>
> My question is: If I stop the script after,let's say 12 seconds, it will
> send only 1 email or all 100?I mean it is possible that the server to
> cache all emails and send them  if i stop the script? I must say that the
> script is run through a web browser.

If you stop the script before PHP executes the instruction to send the
email,  then the email ain't gonna go out.  Period.

Your best bet would be to use PHP to QUEUE the emails up, and let your
mail sending software (sendmail, qmail, elvenmail) worry about load and
timing.

You may also want to consider having the web-based application simply set
a flag/indicator somewhere which tells PHP that it's time to queue up all
100 emails.  Then the end user won't even have to wait for 100 emails to
get queued up in line.  They only have to wait for the flag to get set
which should take, like, less than one second.

There are also innumerable PHP mail classes "out there" to make sending
email easier. http://phpclasses.org has some, I'm betting PEAR has some,
and you could Google and find a thousand more.

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

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



Re: [PHP] libxml_set_streams_context

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 9:03 pm, Bill Hoffman said:
> I'm trying to use libxml_set_streams_context() to load a remote xml
> file via HTTP conditional GET with DOMDocument::load() by stuffing an
> 'If-Modified-Since: --- " HTTP header into the stream, but no matter
> how I try it I always get an HTTP 200 response when I know the last-
> modified date is well before my if-modified date string.
>
> I've confirmed via curl -H on the command line that I can do it
> properly and get an HTTP 304 as expected, but I don't know what I'm
> not doing right with libxml_set_streams_context(). Here's my code:
>
> $opts = array('http'=>array('method'=>"GET", 'header'=>"If-Modified-
> Since: Wed, 18 May 2005 23:55:29 GMT\r\n"));
> $context = stream_context_create($opts);
> libxml_set_streams_context($context);
> $doc->load('http://www.somewhere.com/somefile.xml');
> echo $doc->saveXML();

Where is your error checking?

I don't know much about that fancy new stream stuff, or the XML crap, but
you've got zero (0) lines of code in there to do anything useful when the
functions fail.

If you ask the functions nicely, they almost always tell you EXACTLY what
went wrong.

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

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



Re: [PHP] PHP Applications?

2005-05-17 Thread Chris Shiflett
Danny Brow wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled,
> it also does not contain the source code in readable form. You should
> visit the Zend website.
Any free ones?
http://pecl.php.net/package/APC
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] libxml_set_streams_context

2005-05-17 Thread Bill Hoffman
I'm trying to use libxml_set_streams_context() to load a remote xml  
file via HTTP conditional GET with DOMDocument::load() by stuffing an  
'If-Modified-Since: --- " HTTP header into the stream, but no matter  
how I try it I always get an HTTP 200 response when I know the last- 
modified date is well before my if-modified date string.

I've confirmed via curl -H on the command line that I can do it  
properly and get an HTTP 304 as expected, but I don't know what I'm  
not doing right with libxml_set_streams_context(). Here's my code:

$opts = array('http'=>array('method'=>"GET", 'header'=>"If-Modified- 
Since: Wed, 18 May 2005 23:55:29 GMT\r\n"));
$context = stream_context_create($opts);
libxml_set_streams_context($context);
$doc->load('http://www.somewhere.com/somefile.xml');
echo $doc->saveXML();

using the same $context resource, this also produces the same result,  
when I expect it should work.

file_get_contents('http://www.somewhere.com/somefile.xml', false,  
$context);

I have php 5.0.4 compiled with libxml2 (2.6.16) on Mac OS X 10.4. I  
imagine I'm not doing something correctly, but can't figure out what  
it is.

Any help?
--
Bill Hoffman
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Robert Meyer
As a last resort, I may have to do that, but that is by no means the 
preferred method.  I want to keep database access to a minimum.

I thought by this time this problem would have had a standard solution.  It 
would be nice if PHP had a function like refreshed() so one could do ... if 
(!refreshed()) { ... } ..., but I guess not.

Thanks for your input.

Regards,

Robert

"Marcus Joyce" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Why dont you check that data isnt being duplicated?
>
> $query = "SELECT auto_col FROM table where col1 = $var1 & col2 = $var 
> 3.";
> $call_query = mysql_query($query,...
> $query_data = mysql_assoc($call_query);
>
> if(!$query_data) { do form }
>
> else echo "information already exists in database";
>
>
> Pierce
>
> Robert Meyer wrote:
>
>>Hello,
>>
>>Scenario:
>>1) User is presented a blank form.
>>2) User fills in form.
>>3) User submits form.
>>4) Record is added to database.
>>5) Back to 1).
>>All is fine to here.
>>6) User clicks refresh.
>>7) Another record is added, same data except auto-increment field.
>>How do I prevent these last two steps, or at least prevent a record
>>from being added when refresh is clicked?
>>
>>Regards,
>>
>>Robert
>> 

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



Re: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Robert Meyer

"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Robert Meyer wrote:
>> Hello,
>>
>> Scenario:
>> 1) User is presented a blank form.
>> 2) User fills in form.
>> 3) User submits form.
>> 4) Record is added to database.
>> 5) Back to 1).
>
> Go really back to 1) - use redirect. After the record is added to the 
> database, use something like:
> header('Location: http://yourserver.com/form.php');
> exit;

Does this work for all browsers?

>> All is fine to here.
>> 6) User clicks refresh.
>> 7) Another record is added, same data except auto-increment field.
>> How do I prevent these last two steps, or at least prevent a record
>> from being added when refresh is clicked?
>
> You should see a message from your browser that data is being reposted.

I looked for such a message and the only thing I can find is as follows:

1) _SERVER['HTTP_ACCEPT'] and _ENV['HTTP_ACCEPT'] and change to "*/*", but I 
don't know if that is the case for all browsers, do you know?

2) _SERVER['REDIRECT_UNIQUE_ID'] and _ENV['REDIRECT_UNIQUE_ID'], 
_SERVER['REMOTE_PORT'] and _ENV['REMOTE_PORT'], _SERVER['UNIQUE_ID'] and 
_ENV['UNIQUE_ID'] change, but I don't think the values are predictable, 
especially between browsers.

Do you know of a specific message to look for and is that message the same 
for all browsers? 

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



RE: [PHP] array, trouble updating - SOLVED

2005-05-17 Thread mayo
Yikes,

Who would have thought something so easy would be such a pain in the
butt.

I solved it with embedded if-else clauses.

Thx all



-Original Message-
From: mayo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 9:19 AM
To: 'php'
Subject: [PHP] array, trouble updating

I usually work with cold fusion and took on a little project to get my
feet wet in php and am spinning my wheels.  What I thought might be
difficult was easy and what I thought would be a piece of cake has
caused me much grief over the last few days.
 
I'm making a little shopping basket, writing the results to a file,
ftping the file to a distributor and sending the CC data to merchant
services company.
 
Write to file - easy
FTP file to distributor - easy
Updating the array in the shopping basket -- not so easy !!??!!
 
A shopping basket should be able to add and delete items (done)
You should be able to delete the whole basket (done)
Now I need to be able to update quantity - I've spent at least 5 or 6
hours on this and have gotten nowhere!!! This learning exercise is
getting to be a major time drag.
 
Any hints would be good. 
 
The code is below:
 
 
 -1) 
{ 
array_splice ($ses_basket_name,
$ses_basket_items, 1); 
array_splice ($ses_basket_amount,
$ses_basket_items, 1); 
array_splice ($ses_basket_price,
$ses_basket_items, 1); 
array_splice ($ses_basket_id,
$ses_basket_items, 1); 
$ses_basket_items--; 
} 
} 
 
if ($action2 == "deleteItem") 
{ 
array_splice ($ses_basket_name, $position, 1); 
array_splice ($ses_basket_amount, $position, 1);

array_splice ($ses_basket_price, $position, 1); 
array_splice ($ses_basket_id, $position, 1); 
$ses_basket_items--;
} 
 
?>
0){ 
foreach ($_SESSION['ses_basket_name'] as $basket_item){ 
if ($basket_item==$_GET['basket']){ 
$double=1; 
$subtract=1;
$basket_position=$basket_position_counter; 
 
} 
$basket_position_counter++; 
} 
} 
 
if ($double==1){ 

$oldamount=$_SESSION['ses_basket_amount'][$basket_position];

$_SESSION['ses_basket_amount'][$basket_position]++; 
$amount=$_SESSION['ses_basket_amount'][$basket_position]; 
$oldprice=$_SESSION['ses_basket_price'][$basket_position]; 
$newprice=($oldprice/$oldamount)*$amount; 
$_SESSION['ses_basket_price'][$basket_position]=$newprice; 
 
}else{ 
$_SESSION['ses_basket_name'][]=$_GET['basket']; 
$_SESSION['ses_basket_amount'][]=1; 
$_SESSION['ses_basket_price'][]=$_GET['price']; 
$_SESSION['ses_basket_id'][]=$_GET['id']; 
$_SESSION['ses_basket_items']++; 
} 
}else{ 
 
$_SESSION['ses_basket_items']=1; 
$_SESSION['ses_basket_name'][0]=$_GET['basket']; 
$_SESSION['ses_basket_amount'][0]=1; 
$_SESSION['ses_basket_price'][0]=$_GET['price']; 
$_SESSION['ses_basket_id'][0]=$_GET['id']; 
session_register("ses_basket_items"); 
session_register("ses_basket_name"); 
session_register("ses_basket_amount"); 
session_register("ses_basket_price"); 
session_register("ses_basket_id"); 
} 
} 
 

if ($_SESSION['ses_basket_items']>0){ 
 
for
($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket
_counter++){ 
// basket output 
$price=sprintf("%01.2f",$_SESSION['ses_basket_price'][$basket_counter]);

$amount=$_SESSION['ses_basket_amount'][$basket_counter]; 
$name=$_SESSION['ses_basket_name'][$basket_counter]; 
$aaa=$basket_counter;
 
echo "$amount $name $price";
echo "DEL";
echo "-sub";
echo "$aaa";
 
echo "\n"; 
} 
} else { 
 
$_SESSION['ses_basket_items']=0; 
unset($_SESSION['ses_basket_name']); 
unset($_SESSION['ses_basket_amount']); 
unset($_SESSION['ses_basket_price']); 
unset($_SESSION['ses_basket_id']); 
} 
 
?>
 

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



RE: [PHP] array, trouble updating

2005-05-17 Thread mayo

Jason,

Thx. Even though I have what I need for the client (I finally got things
to work as desired), I'll rework it and update the client version.

I knew I was doing things poorly and it degenerated into simply "get the
damn thing to work."

Thx, Mayo



-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 5:56 PM
To: php-general@lists.php.net
Subject: Re: [PHP] array, trouble updating

On Tuesday 17 May 2005 21:18, mayo wrote:
> I usually work with cold fusion and took on a little project to get my
> feet wet in php and am spinning my wheels.  What I thought might be
> difficult was easy and what I thought would be a piece of cake has
> caused me much grief over the last few days.

It appears that your overall problem is a misunderstanding of how arrays

work in PHP and how easy it is to manipulate them.

First:

> if (session_is_registered('ses_basket_items')){

In general, for practical purposes (if PHP is installed using the 
recommended default setup, ie register_globals disabled), 
session_is_registered() is deprecated and should not be used. Use:

  if (isset($_SESSION['ses_basket_items'])) { ... };


Second:

> if ($action == "empty")
> {
> while ($ses_basket_items > -1)
> {
> array_splice ($ses_basket_name,
> $ses_basket_items, 1);
> array_splice ($ses_basket_amount,
> $ses_basket_items, 1);
> array_splice ($ses_basket_price,
> $ses_basket_items, 1);
> array_splice ($ses_basket_id,
> $ses_basket_items, 1);
> $ses_basket_items--;
> }
> }

You seem to be using multiple single dimension arrays to store your
basket 
details. That is not the optimal way of doing things. You should have a 
*single* multi dimension array, there are many ways to do this, here's a

couple:

1)
  $basket[1] = array('name' => 'name of product',
 'id' => 'product id',
 'price' => 'price of product',
 'amount' => 'quantity required');
  $basket[2] = array('name' => 'name of product',
 'id' => 'product id',
 'price' => 'price of product',
 'amount' => 'quantity required');

2)
  $basket['a_product_id'] = array('name' => 'name of product',
  'price' => 'price of product',
  'amount' => 'quantity required');

  $basket['another_product_id'] = array('name' => 'name of product',
'price' => 'price of product',
'amount' => 'quantity
required');


OK, so how do you operate on them? In the examples below 2 forms will be

given corresponding to how you defined the arrays as per above.

To remove an item:

1) unset($basket[n]); // where n is an integer 
2) unset($basket['product_id']; // if product_id is an integer
// then you don't need the single-quotes
// note that also applies when first
// define the array, ie:
// $basket[product_id] = array(...);

To change an attribute, eg the amount:

1) $basket[n]['amount'] = 5;
2) $basket['product_id'] = 10;


To display an attribute, eg price:

1) echo $basket[n]['price'];
2) echo $basket['product_id']['price'];


When playing around with arrays, print_r() is your friend, use it 
liberally.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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

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



Re: [PHP] Re: hey dip shit

2005-05-17 Thread Ryan A
Or why sometimes its ok to punch a friend in the mouth...


On 5/18/2005 1:42:30 AM, Mary-Anne Nayler ([EMAIL PROTECTED]) wrote:
> This is a perfect example of the reason why you should lock your screen
> when you are away from your desk!!
> 
> Jason Motes wrote, On 18/05/05 07:53 AM:
> 
> > Sorry for this post.  A coworker was messing around with my computer
> > and sent it.
> >
> > Please direct all flames to [EMAIL PROTECTED]
> >
> > Sorry!!
> >
> > Jason Motes wrote:
> >
> >> HAH
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.12 - Release Date: 5/17/2005

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



[PHP] Curious bug and crash

2005-05-17 Thread Dave Lists
Hi,
 Tonight I installed a new php5 instance. 
php5.0.4/apache-1.3.33/mysql-4.1.10. I was getting "\Wed May 18 01:59:42 
2005] [notice] child pid 1621 exit signal Segmentation fault (11)" error 
whenever I accessed a PHP enable page. I recompiled a few times and 
removed unnecessary modules. Still the same problem. So in order to get 
a debug output, I recompiled with --enable-debug. The curious thing is, 
now the error doesn't occur. Anyone any ideas?

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


Re: [PHP] PHP Applications?

2005-05-17 Thread Danny Brow
On Tue, 2005-05-17 at 15:34 -0400, Brent Baisley wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled, 
> it also does not contain the source code in readable form. You should 
> visit the Zend website.
> 

Any free ones?

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



[PHP] Re: PHP Complex Data Structures

2005-05-17 Thread Matthew Weier O'Phinney
* Zzapper <[EMAIL PROTECTED]>:
> I seem to remember that you access/use PHP data in the same/similar
> way to Perl data and that you can create complex data structures ie
> arrays of arrays, arrays of records etc.
>
> For once Google let me down so can any one point at any doc info.

Did you try building any complex data structures? You could have whipped
out something to test pretty quickly. The quick answer is, 'Yes'. 

The longer answer is: cut-and-past the following into a script and see
what you get:

$cds = array(
'element1' => array(
'string1',
'string2',
'string3'
),
'element2' => true,
'element3' => array(
'subelement1' => array(
array(1, 2, 3),
2,
3
)
)
);
var_dump($cds);

You can create any complexity you want using nested arrays. Arrays in
PHP are ordered (also called indexed) unless string keys are used (in
which case they're called associative) -- and you can mix and match
styles as needed.

Additionally, you can use these structures within objects, and define
object properties on the fly.

Read through the manual about variable types if you need more
information -- and don't be afraid to experiment.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



[PHP] Re: PHP Applications?

2005-05-17 Thread Manuel Lemos
Hello,
on 05/17/2005 11:27 AM Brian Dunning said the following:
My background is mostly with Lasso. One cool feature is the ability  to 
make "LassoApps" - single file applications that are secure and  can be 
sold & distributed without providing access to the source.  Does PHP 
offer any such capability?
You may want to try this class that generates a PHP script that self 
installs packages with many application files.

http://www.phpclasses.org/php2install
Then you can use a PHP compiler like RoadSend to generate executable 
binaries to protect the code.

http://www.roadsend.com/
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: hey dip shit

2005-05-17 Thread Mary-Anne Nayler
This is a perfect example of the reason why you should lock your screen 
when you are away from your desk!!

Jason Motes wrote, On 18/05/05 07:53 AM:
Sorry for this post.  A coworker was messing around with my computer 
and sent it.

Please direct all flames to [EMAIL PROTECTED]
Sorry!!
Jason Motes wrote:
HAH

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


Re: [PHP] Re: hey dip shit

2005-05-17 Thread Ryan A
Well, I guess he was just talking to himself.

Please forward this to your pal at [EMAIL PROTECTED]

Cheers!


On 5/17/2005 11:53:20 PM, Jason Motes ([EMAIL PROTECTED]) wrote:
> Sorry for this post.  A coworker was messing around with my computer and
> sent it.
> 
> Please direct all flames to [EMAIL PROTECTED]
> 
> Sorry!!
> 
> Jason Motes wrote:
> > HAH
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.12 - Release Date: 5/17/2005

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



Re: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Marcus Joyce
Why dont you check that data isnt being duplicated?
$query = "SELECT auto_col FROM table where col1 = $var1 & col2 = $var 
3.";
$call_query = mysql_query($query,...
$query_data = mysql_assoc($call_query);

if(!$query_data) { do form }
else echo "information already exists in database";
Pierce
Robert Meyer wrote:
Hello,
Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).
All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?
Regards,
Robert 

 

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


[PHP] Mail function

2005-05-17 Thread virtualsoftware

Hi,

I have a script which send emails using mail() function. I have 100 email 
addresses and i set up the script to send 1 email every 10 seconds. So, it will 
take 1000 seconds
to send all 100 emails.

My question is: If I stop the script after,let's say 12 seconds, it will send 
only 1 email or all 100?I mean it is possible that the server to cache all 
emails and send them  if i stop the script? I must say that the script is run 
through a web browser.


Thanks in advance for your help 

Re: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Marek Kilimajer
Robert Meyer wrote:
Hello,
Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).
Go really back to 1) - use redirect. After the record is added to the 
database, use something like:
header('Location: http://yourserver.com/form.php');
exit;

All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?
You should see a message from your browser that data is being reposted.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] hey dip shit

2005-05-17 Thread John Nichel
Jason Motes wrote:
HAH
This list could really use an active moderator.
--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Jay Blanchard
[snip]
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?
[/snip]

Test for the existence (SELECT statement with the variables therein) of
the record even on the first try, if it exists, do not add (ever again),
if it does not exist do the insert

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



[PHP] Re: hey dip shit

2005-05-17 Thread Jason Motes
Sorry for this post.  A coworker was messing around with my computer and 
sent it.

Please direct all flames to [EMAIL PROTECTED]
Sorry!!
Jason Motes wrote:
HAH
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] array, trouble updating

2005-05-17 Thread Jason Wong
On Tuesday 17 May 2005 21:18, mayo wrote:
> I usually work with cold fusion and took on a little project to get my
> feet wet in php and am spinning my wheels.  What I thought might be
> difficult was easy and what I thought would be a piece of cake has
> caused me much grief over the last few days.

It appears that your overall problem is a misunderstanding of how arrays 
work in PHP and how easy it is to manipulate them.

First:

> if (session_is_registered('ses_basket_items')){

In general, for practical purposes (if PHP is installed using the 
recommended default setup, ie register_globals disabled), 
session_is_registered() is deprecated and should not be used. Use:

  if (isset($_SESSION['ses_basket_items'])) { ... };


Second:

> if ($action == "empty")
> {
> while ($ses_basket_items > -1)
> {
> array_splice ($ses_basket_name,
> $ses_basket_items, 1);
> array_splice ($ses_basket_amount,
> $ses_basket_items, 1);
> array_splice ($ses_basket_price,
> $ses_basket_items, 1);
> array_splice ($ses_basket_id,
> $ses_basket_items, 1);
> $ses_basket_items--;
> }
> }

You seem to be using multiple single dimension arrays to store your basket 
details. That is not the optimal way of doing things. You should have a 
*single* multi dimension array, there are many ways to do this, here's a 
couple:

1)
  $basket[1] = array('name' => 'name of product',
 'id' => 'product id',
 'price' => 'price of product',
 'amount' => 'quantity required');
  $basket[2] = array('name' => 'name of product',
 'id' => 'product id',
 'price' => 'price of product',
 'amount' => 'quantity required');

2)
  $basket['a_product_id'] = array('name' => 'name of product',
  'price' => 'price of product',
  'amount' => 'quantity required');

  $basket['another_product_id'] = array('name' => 'name of product',
'price' => 'price of product',
'amount' => 'quantity required');


OK, so how do you operate on them? In the examples below 2 forms will be 
given corresponding to how you defined the arrays as per above.

To remove an item:

1) unset($basket[n]); // where n is an integer 
2) unset($basket['product_id']; // if product_id is an integer
// then you don't need the single-quotes
// note that also applies when first
// define the array, ie:
// $basket[product_id] = array(...);

To change an attribute, eg the amount:

1) $basket[n]['amount'] = 5;
2) $basket['product_id'] = 10;


To display an attribute, eg price:

1) echo $basket[n]['price'];
2) echo $basket['product_id']['price'];


When playing around with arrays, print_r() is your friend, use it 
liberally.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Brian V Bonini
On Tue, 2005-05-17 at 15:58, Richard Lynch wrote:
> > On Tuesday 17 May 2005 21:01, Brian V Bonini wrote:
> >
> >> Still no go... Other changes in php.ini DO take effect, just not
> >> this I'm at a loss
> 
> Does phpinfo() show trans_sid as "on" or "off"?

Shows it as 0 or 1 depending on how I set it at that moment...
http://gfx.gfx-design.com/php_info.php


-- 

s/:-[(/]/:-)/g


BrianGnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

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



RE: [PHP] PHP Complex Data Structures

2005-05-17 Thread Jay Blanchard
[snip]
I seem to remember that you access/use PHP data in the same/similar way
to Perl data and that you
can create complex data structures ie
arrays of arrays, arrays of records etc.

For once Google let me down so can any one point at any doc info.
[/snip]

Start with http://www.php.net/array

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



[PHP] Refresh (F5) adds another SQL record.

2005-05-17 Thread Robert Meyer
Hello,

Scenario:
1) User is presented a blank form.
2) User fills in form.
3) User submits form.
4) Record is added to database.
5) Back to 1).
All is fine to here.
6) User clicks refresh.
7) Another record is added, same data except auto-increment field.
How do I prevent these last two steps, or at least prevent a record
from being added when refresh is clicked?

Regards,

Robert 

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



[PHP] Re: PHP Complex Data Structures

2005-05-17 Thread Jason Barnett
Zzapper wrote:
Hi,
I seem to remember that you access/use PHP data in the same/similar way to Perl 
data and that you
can create complex data structures ie
arrays of arrays, arrays of records etc.
For once Google let me down so can any one point at any doc info.


class A { }
/** Initialize the array with values */
$stack = array(1,2,3);
/** Push an array on the stack */
$stack[] = array('a', '2nd dimension of array');
/** Now we show that we can push an object onto the array */
$obj = new A();
/** The & might be recommended if you're using PHP4 */
$stack[] = &$obj;
$obj->testvar = TRUE;
/** Now we look at the stack */
echo '';
var_dump($stack);
echo '';
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] hey dip shit

2005-05-17 Thread Jason Motes
HAH
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Applications?

2005-05-17 Thread Greg Donald
On 5/17/05, Brent Baisley <[EMAIL PROTECTED]> wrote:
> Zend sells a compiler to speed up your PHP code. Since it's compiled,
> it also does not contain the source code in readable form. You should
> visit the Zend website.

Did you have a link for this 'compiler' ?  All I see in the site menu
is a link to the encoder.  Sorry if I'm just not seeing it.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] PHP Complex Data Structures

2005-05-17 Thread zzapper
Hi,
I seem to remember that you access/use PHP data in the same/similar way to Perl 
data and that you
can create complex data structures ie
arrays of arrays, arrays of records etc.

For once Google let me down so can any one point at any doc info.


-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips

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



Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Richard Lynch
> On Tuesday 17 May 2005 21:01, Brian V Bonini wrote:
>
>> Still no go... Other changes in php.ini DO take effect, just not
>> this I'm at a loss

Does phpinfo() show trans_sid as "on" or "off"?

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

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



Re: [PHP] php file list with forced download

2005-05-17 Thread Richard Lynch
On Mon, May 16, 2005 5:49 pm, Miguel Vaz said:
>   Was coding a directory listing for several dirs on a client's server 
> that
> would list the files and allow users to download them. The question is, is
> there a way to force download of all files, regardless of their types?
> i.e., if the list constains a .jpg, the browser will show it instead of
> asking the user to download. Also for .html, gifs, etc.



Any browser that doesn't force a download for application/octet-stream is
in violation of every HTTP protocol version ever published.

Even *MICROSOFT* hasn't screwed this one up.  Yet...

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

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



Re: [PHP] Blank page in browser

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 1:41 am, Nayeem said:
> I'm new to PHP programming and I just try to display small information
> from
> database on web page but its shows blank page. So my code is mention below
> and let me know what's wrong in it but when I execute same program on
> command prompt then its shows all result correctly with HTML Tags

You logged in as you.
The PHP user runs as somebody else.

That other user does not have the same permissions/rights as you, and not
the same environment variables ($PATH in shell) and not even the same
shell.

If you can 'su' to that other user and run it, you may find out why it
fails.  You should also check error logs as suggested, and use "View
Source" in your browser to see if the "blank" page is really blank, or
just buried inside an unfinished HTML tag.

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

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



Re: [PHP] PHP Applications?

2005-05-17 Thread Richard Lynch
On Tue, May 17, 2005 7:27 am, Brian Dunning said:
> My background is mostly with Lasso. One cool feature is the ability
> to make "LassoApps" - single file applications that are secure and
> can be sold & distributed without providing access to the source.
> Does PHP offer any such capability?

No.

Third-party hacks to do things kinda sorta like what you describe can be
acquired for varying amounts of money.

Zend has one, I think, and road[mumble] and there are several others.

Google for "PHP compiler" and you should find most of them.

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

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



Re: [PHP] regex question

2005-05-17 Thread Al
Murry's solution here is ideal since it only captures the single occurrence. 
Since I want to use it for a preg_replace(), it is perfect.

A couple of folks sent this pattern [EMAIL PROTECTED]@[EMAIL PROTECTED]; but, it doesn't work because I 
then have to remove the unwanted caracters on either side.

All it says is [not  @[EMAIL PROTECTED]@] but, it captures the 2 characters on 
each side.
Murry's solution (?
Thanks everyone


Murray @ PlanetThoughtful wrote:
What pattern can I use to match ONLY single occurrences of a character in
a string.
e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.
I only want the two occurrences with a single occurrence of "@".
@{1} doesn't work; there are 4 matches.
Thanks

Please ignore my last email re: your question. I realized that the negation
of the range containing the "@" would end up capturing unwanted characters.
As an alternative, try the following:
preg_match_all('/(?
$thing, PREG_OFFSET_CAPTURE); 

print_r($thing);
Hope that's a little more relevant to your question.
Regards,
Murray
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Applications?

2005-05-17 Thread Brent Baisley
Zend sells a compiler to speed up your PHP code. Since it's compiled, 
it also does not contain the source code in readable form. You should 
visit the Zend website.

On May 17, 2005, at 10:27 AM, Brian Dunning wrote:
Hi all -
My background is mostly with Lasso. One cool feature is the ability to 
make "LassoApps" - single file applications that are secure and can be 
sold & distributed without providing access to the source. Does PHP 
offer any such capability?

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

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Jason Wong
On Tuesday 17 May 2005 21:01, Brian V Bonini wrote:

> Still no go... Other changes in php.ini DO take effect, just not
> this I'm at a loss

What version of PHP are you using? In older versions (have a look at the 
changelog) you had to configure with --enable-trans-sid, in newer 
versions this is the default.

Summary: you have to compile PHP with --enable-trans-sid, AND enable it in 
php.ini.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Jason Wong
On Tuesday 17 May 2005 18:00, Merlin wrote:

> I am trying to find a way to count the number of times (if any) words
> are inside a string.

  explode()
  array_count_values()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] RE: regex question

2005-05-17 Thread Carl Furst
I think there maybe a few ways to do this... One is

[EMAIL PROTECTED]@[EMAIL PROTECTED]

That basically says "find me the pattern where one non-at symbol is followed
by an at symbol followed by another non-at symbol"

So if you do 



numMatch: 3
Array
(
[0] => Array
(
[0] =>  @ 
[1] => i@ 
[2] => [EMAIL PROTECTED]
)

[1] => Array
(
[0] => @
[1] => @
[2] => @
)

)

Well, where that fails is when you have @'s at the beginning or end of the
string and that's easy enough to do.. So that would mean three searches...
There's probably a way to integrate them into one without loosing integrity,
but it depends on what kind of regexp libs you have, I reckon. It also
depends on what you really are trying to do with this search. Consider
str_replace, strpos and strtr as well.

Thanks,


Carl
-Original Message-
From: Al [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 16, 2005 3:54 PM
To: php-general@lists.php.net
Subject: regex question

What pattern can I use to match ONLY single occurrences of a character in a
string.

e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.

I only want the two occurrences with a single occurrence of "@".

@{1} doesn't work; there are 4 matches.

Thanks

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



Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Brian V Bonini
On Tue, 2005-05-17 at 09:53, Jason Barnett wrote:
> Brian V Bonini wrote:
> ...
> > 
> > Still no go... Other changes in php.ini DO take effect, just not
> > this I'm at a loss
> > 
> > 
> 
> By any chance are you changing PHP values through Apache's conf file?

I am, in ANOTHER virtual hosts container block but not any values
related to sessions. What are you getting at?

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



[PHP] Upload Files

2005-05-17 Thread Stuart Nielson
I have a few interpretive questions on uploading files.  There is the
max_input_time, and the max_execution_time.  I am uploading files and
they continue to time out after a few minutes.  Looking at the php.ini
file from phpinfo() shows max_input_time set to -1 and
max_execution_time set to 60.

Does the max_execution_time have anything to do with the timeout, or is
it all in the max_input_time?  And does the "-1" value mean run
indefinitely (until the file is uploaded)?  Is there any function that
will change that value?

Any clarifications on this would be helpful.

Stuart


[PHP] php addslashes etc

2005-05-17 Thread Pieter Breed
Hi,

First of, sorry for the attachment. It is a screenshot of the output of the 
following code. It also shows the contents of the array data in question.

I have the following piece of actual code:


// $arrayData is the data in an array form
$arrayData = ArrayIzeDbResult( $db2 ) ;

// we want to capture the printed output
ob_start();
$data = addslashes( serialize( $arrayData ) );
print $testdata;
$printeddata = ob_get_contents();

// this next line does not work since the results of unserialize 
// is bool(false)
ob_end_flush();
print "\nNumber, the first\n";
print_r( unserialize( stripslashes( $printeddata ) ) );

// however, this next line DOES work
print "\nNumber, the second\n";
print_r( unserialize( stripslashes( addslashes( serialize( $arrayData ) ) ) ) );


I am trying to store the serialized array into a database (mysql) but on 
reading it out again, it cannot unserialize. This piece of code, even though 
it doesn't use the db, shows the problem perfectly.

The other funny thing is that not all arrays break when I am doing this. I 
have quite a lot of similar arrays that work find when you do this. This one 
however needs to work too ;)

Regards,
Pieter Breed


 

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

Re: [PHP] PHP Phone Number Validation

2005-05-17 Thread Paul Fierro
On 05/16/2005 7:48 PM, IMEX Research <[EMAIL PROTECTED]> wrote:

> OK, I know this has probably gone aruond the list a few times, but how do I
> validate a phone number that is in the format ddd-ddd- ??  I can't figure
> out how.

I try to not restrict the way your users enter phone numbers or other types
of structured data. I wouldn't bother validating against ddd-ddd- unless
you also plan on validating (ddd) ddd-, ddd.ddd., +1 ddd ddd ddd or
any number of variations. Your best bet is to make sure that the number
contains 10 (or 11) digits:

$phone = preg_replace('/[^0-9]/', '', $phone); # remove non-numbers

if (preg_match('/^1?[0-9]{10}$/', $phone)) {
echo 'Valid';
}

To answer your original question:

if (preg_match('/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/', $phone)) {
echo 'Valid';
}

Paul

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



Re: [PHP] PHP and COM+ prob

2005-05-17 Thread Jochem Maas
bob pilly wrote:
Hi all!
I am trying to start word using com and php and having
problems. I am running php 5.04 and apache 2.054 on
windows. I have used a simple example from the php
site but cant get it working.
|Version}\n";
//bring it to front
$word->Visible = 1;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
//closing word
$word->Quit();
//free the object
$word = null;
?>
i have called this page testcom.php but when i try and
view it with a clients browser i get this error:
[client xxx.xxx.xxx.xxx] PHP Fatal error:  Uncaught
exception 'com_exception' with message 'Failed to
create COM object `Word.application': Invalid
syntax\r\n' in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php:3\nStack
trace:\n#0 C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php(3):
com->com('Word.applicatio...')\n#1 {main}\n  thrown in
C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php on line 3
|
Has anyone seen this error before or know what it
means? Or if possible does anyone know of any good
docs on using com with php?
this is not a COM specific error, you're trying to create
a new COM object and that fails - rather than return something
that evaluates to false the constructor for the COM object (
or something it is trying to call) is throwing a Exception...
('throwing' of) exceptions (and logically also the 'catching'
of them) are new concepts in PHP5.
try like it this and see whether something more useful error msg
is output:

// this is PHP5 only!
try {
// starting word
$word = new COM("word.application");
echo "Loaded Word, version {$word->Version}\n";
//bring it to front
$word->Visible = 1;
//open an empty document
$word->Documents->Add();

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
//closing word
$word->Quit();
//free the object
$word = null;
}
catch (com_exception $e) {
echo "something bad happened with COM:", $e->__toString(); 
}
catch (Exception $e) {
echo "something bad happened:", $e->__toString();
}
?>
lookup 'try'/'catch'/'throw', 'exception' in the manual (php5 specific
areas).
Thanks in advance for any help!!
Cheers
Bob 

	
	
		
___ 
Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com

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


Re: [PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread disguised.jedi
> I want to write a string to a variable and use $_POST or $_GET to retrieve
> it on another page.
> 
> I keep gettting an undefined index errror. Can someone show me how this is
> done?
/*
How are you trying to accomplish this?  Are you setting the $_GET in
the page code, or using a hidden form?  (If you are using the form,
you can skip this part.  If you aren't, or don't know what I mean,
read on!)  For example:

This code (page1.php):


With this code (page2.php):

Will not return an error, but the second page won't echo anything. 
However, if you access page2.php with the URL like this:
http://localhost/page2.php?myvalue=This is MY GET VALUE

The first line will output: "This is MY GET VALUE"

To get the second line to work, you will need to use this:
(page1.php)





When the button is clicked, page2.php, which is the same as before,
will load, and the second line will cause the output of "This is MY
POST VALUE".  You can make both lines of page2.php work by
changing the action attribute of the form to "page2.php?myvalue=This
is MY GET VALUE".  That way, they will both work.
*/
> Do I have to use session_start() ?
/*
This would be better.  You can use sessions the way I think you are
trying to use $_GET and $_POST.  Just start the session on the first
page, and set an element in $_SESSION and on the next page you can
start the session again and read the value out of the array.  Like
this:

(page1.php)


(page2.php)


The page, page2.php, will show "test value" if you run page1.php
first.  $_SESSION is probably the easiest of all the superglobals to
use.

Try those, and if I'm completely off-base, and not even helping, try
posting some code, which is ALWAYS a good thing to do.  A big post
asking for help never hurt anyone.  Most people almost never read the
short ones.

Happy coding!!!
*/

-- 
[EMAIL PROTECTED]

PHP rocks!
"Knowledge is Power.  Power Corrupts.  Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

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



[PHP] PHP Applications?

2005-05-17 Thread Brian Dunning
Hi all -
My background is mostly with Lasso. One cool feature is the ability  
to make "LassoApps" - single file applications that are secure and  
can be sold & distributed without providing access to the source.  
Does PHP offer any such capability?

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


Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Brian V Bonini
On Tue, 2005-05-17 at 06:00, Merlin wrote:
> Hi there,
> 
> I am trying to find a way to count the number of times (if any) words are 
> inside 
> a string. So I played around with ereg, preg_match_all and so on, but could 
> not 
> put together a working code.

Maybe something like this?

';

foreach($words as $word) {
echo 'word = ' .$word;
echo ' (' . substr_count($str, $word). ")\n";
}

echo '';

?>

Although you'll run into a problem if your words array contains for
example 'air' which will match both 'air' and 'fair',

-- 

s/:-[(/]/:-)/g


BrianGnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

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



Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Jason Barnett
Brian V Bonini wrote:
...
Still no go... Other changes in php.ini DO take effect, just not
this I'm at a loss

By any chance are you changing PHP values through Apache's conf file?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Phone Number Validation

2005-05-17 Thread John Nichel
IMEX Research wrote:
OK, I know this has probably gone aruond the list a few times, but how do I validate a phone number that is in the format ddd-ddd- ??  I can't figure out how.
preg_match ( "/^\d{3}-\d{3}-\d{4}$/", $phnumber )
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: why are session only working with cookies?

2005-05-17 Thread Brian V Bonini
On Mon, 2005-05-16 at 22:10, Richard Lynch wrote:
> Does  show the same /path/to/php.ini as the one you edit?
> 

Yup

> To be 100% certain, use 'stop' to stop Apache and then do:
> ps aux | grep httpd
> 
> You should see only the "grep httpd" output, or no output at all.

Did that...


> Then start Apache, and triple check  shows the php.ini
> file being read from the same directory you edited php.ini
> 

Yup

Still no go... Other changes in php.ini DO take effect, just not
this I'm at a loss


-- 

s/:-[(/]/:-)/g


BrianGnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

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



[PHP] array, trouble updating

2005-05-17 Thread mayo
I usually work with cold fusion and took on a little project to get my
feet wet in php and am spinning my wheels.  What I thought might be
difficult was easy and what I thought would be a piece of cake has
caused me much grief over the last few days.
 
I'm making a little shopping basket, writing the results to a file,
ftping the file to a distributor and sending the CC data to merchant
services company.
 
Write to file - easy
FTP file to distributor - easy
Updating the array in the shopping basket -- not so easy !!??!!
 
A shopping basket should be able to add and delete items (done)
You should be able to delete the whole basket (done)
Now I need to be able to update quantity - I've spent at least 5 or 6
hours on this and have gotten nowhere!!! This learning exercise is
getting to be a major time drag.
 
Any hints would be good. 
 
The code is below:
 
 
 -1) 
{ 
array_splice ($ses_basket_name,
$ses_basket_items, 1); 
array_splice ($ses_basket_amount,
$ses_basket_items, 1); 
array_splice ($ses_basket_price,
$ses_basket_items, 1); 
array_splice ($ses_basket_id,
$ses_basket_items, 1); 
$ses_basket_items--; 
} 
} 
 
if ($action2 == "deleteItem") 
{ 
array_splice ($ses_basket_name, $position, 1); 
array_splice ($ses_basket_amount, $position, 1);

array_splice ($ses_basket_price, $position, 1); 
array_splice ($ses_basket_id, $position, 1); 
$ses_basket_items--;
} 
 
?>
0){ 
foreach ($_SESSION['ses_basket_name'] as $basket_item){ 
if ($basket_item==$_GET['basket']){ 
$double=1; 
$subtract=1;
$basket_position=$basket_position_counter; 
 
} 
$basket_position_counter++; 
} 
} 
 
if ($double==1){ 

$oldamount=$_SESSION['ses_basket_amount'][$basket_position];

$_SESSION['ses_basket_amount'][$basket_position]++; 
$amount=$_SESSION['ses_basket_amount'][$basket_position]; 
$oldprice=$_SESSION['ses_basket_price'][$basket_position]; 
$newprice=($oldprice/$oldamount)*$amount; 
$_SESSION['ses_basket_price'][$basket_position]=$newprice; 
 
}else{ 
$_SESSION['ses_basket_name'][]=$_GET['basket']; 
$_SESSION['ses_basket_amount'][]=1; 
$_SESSION['ses_basket_price'][]=$_GET['price']; 
$_SESSION['ses_basket_id'][]=$_GET['id']; 
$_SESSION['ses_basket_items']++; 
} 
}else{ 
 
$_SESSION['ses_basket_items']=1; 
$_SESSION['ses_basket_name'][0]=$_GET['basket']; 
$_SESSION['ses_basket_amount'][0]=1; 
$_SESSION['ses_basket_price'][0]=$_GET['price']; 
$_SESSION['ses_basket_id'][0]=$_GET['id']; 
session_register("ses_basket_items"); 
session_register("ses_basket_name"); 
session_register("ses_basket_amount"); 
session_register("ses_basket_price"); 
session_register("ses_basket_id"); 
} 
} 
 

if ($_SESSION['ses_basket_items']>0){ 
 
for
($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket
_counter++){ 
// basket output 
$price=sprintf("%01.2f",$_SESSION['ses_basket_price'][$basket_counter]);

$amount=$_SESSION['ses_basket_amount'][$basket_counter]; 
$name=$_SESSION['ses_basket_name'][$basket_counter]; 
$aaa=$basket_counter;
 
echo "$amount $name $price";
echo "DEL";
echo "-sub";
echo "$aaa";
 
echo "\n"; 
} 
} else { 
 
$_SESSION['ses_basket_items']=0; 
unset($_SESSION['ses_basket_name']); 
unset($_SESSION['ses_basket_amount']); 
unset($_SESSION['ses_basket_price']); 
unset($_SESSION['ses_basket_id']); 
} 
 
?>
 


Re: [PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread Burhan Khalid
Ross wrote:
I want to write a string to a variable and use $_POST or $_GET to retrieve 
it on another page.

I keep gettting an undefined index errror. Can someone show me how this is 
done?

Do I have to use session_start() ?
This would be ideal.
Have checked the documentation, can't find a really basic example.
Well you didn't post any code, so I can't give you specifics, but a 
crude example is :

Read the string';
?>

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


Re: [PHP] PHP 5.0 and mysql

2005-05-17 Thread Burhan Khalid
Jay Blanchard wrote:
[snip]
This is going to a very naive question, but how do I make mysql work
with
PHP 5? I run PHP on IIS on Windows 2000. Help!
[/snip]
Read the instructions http://us4.php.net/mysql
Also See > http://www.php.net/manual/en/install.windows.extensions.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re-initiating an autostarted session

2005-05-17 Thread Ville Mattila
[EMAIL PROTECTED] wrote:
Look in the user contributed notes in the session-destroy page.  There
is a function to wipe out the session and has worked nicely for me!
http://www.php.net/session_destroy
Thank you for a message. Anyway, I could not get it working (the code 
follows) - I do still have exactly the same session id. I'm not sure if you 
meant that note as you spoke about a function. Anyway, I couldn't find any 
function that handles the cookies (only one about wiping out a session file 
from the server but it doesn't do anything for the cookie at the client's side).

$CookieInfo = session_get_cookie_params();
if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) 
{
setcookie(session_name(), '', time()-3600, $CookieInfo['path']);
} elseif (empty($CookieInfo['secure'])) {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'], 
$CookieInfo['domain']);
} else {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'], 
$CookieInfo['domain'], $CookieInfo['secure']);
}
unset($_COOKIE[session_name()]);
session_destroy();
session_write_close();
Header("Location: ...");
exit;
Very mysterous... =/
Ville
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Cache

2005-05-17 Thread Rory Browne
> Probably, but not serializing at all, and stuffing the data directly into
> shared memory would perhaps be faster, at least as I vaguely understood
> the results of a thread on serialization on this very forum from a month
> or two ago.  (Check archives for "serialize" "shared memory" and "Rasmus
> Lerdorf" who weighed in with a succinct explanation of how to avoid
> serialization if that performance hit was really a problem (unlikely as
> that was))

You're looking for this topic:

From: Josh Whiting <[EMAIL PROTECTED]>
To: php-general@lists.php.net
Date: Jan 3, 2005 5:28 PM
Subject: [PHP] Persistent PHP web application?

and this response by Rasmus:

From: Rasmus Lerdorf <[EMAIL PROTECTED]>
To: Josh Whiting <[EMAIL PROTECTED]>
Cc: php-general@lists.php.net
Date: Jan 4, 2005 6:40 PM
Subject: Re: [PHP] Persistent PHP web application?

The important functions were apc_fetch(), and apc_store() IIRC.
> 
> --
> Like Music?
> http://l-i-e.com/artists.htm
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] Re: I have some upload questions.

2005-05-17 Thread Lee Chen

"James E Hicks III" <[EMAIL PROTECTED]>
???:[EMAIL PROTECTED]
> Lee Chen wrote:
>
> >Thanks
> >I check the phpinfo, and my safe_mode is off.
> >This is my phpinfo
> >http://homepage.ntu.edu.tw/~b91401010/phpinfo().htm
> >It is just a copy, not on the server.(so it's html file, not a php
file)
> >
> >Thanks.
> >
> >
> Looks like you need to check this in your php.ini file. Could be your
> problem!
>
> max_input_time integer
>
>  This sets the maximum time in seconds a script is allowed to receive
> input data, like POST, GET and file uploads.
>
>
>
> James Hicks

Thanks for your anwsering.

I still have some questions   that if I put the same php file   on the OTHER
server whose settings are like this:
http://homepage.ntu.edu.tw/~b91401010/phpinfo()1.htm

With the samemax_input_time value "60"  ,   I can upload a file of 30MB
successfully and I'm very sure that  the duration of uploading files
was exceeding "5 minutes"without seeing any message like :Fatal error:
Maximum execution time of 0 seconds exceeded in justtest.php on
line 2

I don't know what's the difference between the two servers about some
settings.
With almost the same settings, but it made different results.
I'm confused.

Please help me solve this problem.   Did I have some settings
wrong?
Thanks.

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



RE: [PHP] Blank page in browser

2005-05-17 Thread Leila Lappin
Blank page usually means there was an error during parsing of PHP.  The
error will be in the error.log file under apache.  Find that file and check
it, it'll show you what happened.



-Original Message-
From: Nayeem [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 17, 2005 4:42 AM
To: php-general@lists.php.net
Subject: [PHP] Blank page in browser


Dear All,

I'm new to PHP programming and I just try to display small information from
database on web page but its shows blank page. So my code is mention below
and let me know what's wrong in it but when I execute same program on
command prompt then its shows all result correctly with HTML Tags

\n";

   echo "\n";
   echo "\n";
   echo "Name\n";
   echo "Salary\n";
   echo "\n";

   for ($i = 0; $i < $nrows; $i++ ) {
 echo "\n";
 echo "" . $results["ENAME"][$i] . "";
 echo "$ " . number_format($results["SAL"][$i], 2). "";
 echo "\n";
   }

   echo "\n";

   ?>

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

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



Re: [PHP] counting ocuring words in a string

2005-05-17 Thread Petar Nedyalkov
On Tuesday 17 May 2005 13:00, Merlin wrote:
> Hi there,
>
> I am trying to find a way to count the number of times (if any) words are
> inside a string. So I played around with ereg, preg_match_all and so on,
> but could not put together a working code.
>
> Can anybody help me on that?
>
> This is the current code:
> function count_words($str, $words) {
>if(is_array($words)) {
> foreach($words as $k => $word) {
>   $pattern[$k] = "/\b($word)\b/is";
> }
>}
>else {
> $pattern = "/\b($words)\b/is";
>}
>return ereg( $pattern, $str);
> }
> $words = 'php language';
> $str = 'One language which is great is php. PHP works great!';
> $num_hits = count_words($str, $word);
> echo $num_hits;
>
> I would like to get an case insensitive result. In this example: 3

http://www.php.net/manual/en/function.substr-count.php

Try this.

>
> I am a bit lost on this one. Thank you for any help.
>
> Merlin

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

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


pgpvE9fqC9aji.pgp
Description: PGP signature


RE: [PHP] PHP 5.0 and mysql

2005-05-17 Thread Jay Blanchard
[snip]
This is going to a very naive question, but how do I make mysql work
with
PHP 5? I run PHP on IIS on Windows 2000. Help!
[/snip]

Read the instructions http://us4.php.net/mysql

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



[PHP] PHP 5.0 and mysql

2005-05-17 Thread Eustace
This is going to a very naive question, but how do I make mysql work with
PHP 5? I run PHP on IIS on Windows 2000. Help!


[PHP] counting ocuring words in a string

2005-05-17 Thread Merlin
Hi there,
I am trying to find a way to count the number of times (if any) words are inside 
a string. So I played around with ereg, preg_match_all and so on, but could not 
put together a working code.

Can anybody help me on that?
This is the current code:
function count_words($str, $words) {
  if(is_array($words)) {
   foreach($words as $k => $word) {
 $pattern[$k] = "/\b($word)\b/is";
   }
  }
  else {
   $pattern = "/\b($words)\b/is";
  }
  return ereg( $pattern, $str);
}
$words = 'php language';
$str = 'One language which is great is php. PHP works great!';
$num_hits = count_words($str, $word);
echo $num_hits;
I would like to get an case insensitive result. In this example: 3
I am a bit lost on this one. Thank you for any help.
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Syntax Coloring

2005-05-17 Thread Burhan Khalid
hima wrote:
Hi all,
I am trying to apply syntax coloring to my source code
as I type it in unix shell. I work on a mac machine. 
How do I achieve this.
In the php.ini file I see these following lines
commented out.

; Colors for Syntax Highlighting mode.  Anything
that's acceptable in
;  would work.
;highlight.string  = #DD
;highlight.comment = #FF9900
;highlight.keyword = #007700
;highlight.bg  = #FF
;highlight.default = #BB
;highlight.html= #00
Should I uncomment  the above lines?
These lines are to set up custom colors for the highlight_* functions 
and for the automatic highlighting of .phps files.

For your console needs, you would need to find an editor that supports 
PHP highlighting.  Almost all unix based editors do.  For example, vim 
does PHP syntax highlighting, as I'm sure Emacs has a mode that does 
this too (I don't use emacs).

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


RE: [PHP] JavaScript+Html+PH

2005-05-17 Thread Richard Sitompul
Of course, why not, or you can use smarty template engine.
http://smarty.php.net/


Thanks,
Richard Sitompul


-Original Message-
From: ÃÃÂÃÃÃ [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 12:26
To: php-general@lists.php.net
Subject: [PHP] JavaScript+Html+PH

Hiï

Can  I  use  JavaScript+Html+PHP in  a  file?

 

 





Function sort(){

Sort_asc();

}



 







 

E-mail/MSN: [EMAIL PROTECTED]

 

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



[PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread Ross
I want to write a string to a variable and use $_POST or $_GET to retrieve 
it on another page.

I keep gettting an undefined index errror. Can someone show me how this is 
done?

Do I have to use session_start() ?

Have checked the documentation, can't find a really basic example.

R. 

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



[PHP] PHP and COM+ prob

2005-05-17 Thread bob pilly
Hi all!

I am trying to start word using com and php and having
problems. I am running php 5.04 and apache 2.054 on
windows. I have used a simple example from the php
site but cant get it working.

|Version}\n";

//bring it to front
$word->Visible = 1;

//open an empty document
$word->Documents->Add();

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");

//closing word
$word->Quit();

//free the object
$word = null;
?>

i have called this page testcom.php but when i try and
view it with a clients browser i get this error:

[client xxx.xxx.xxx.xxx] PHP Fatal error:  Uncaught
exception 'com_exception' with message 'Failed to
create COM object `Word.application': Invalid
syntax\r\n' in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php:3\nStack
trace:\n#0 C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php(3):
com->com('Word.applicatio...')\n#1 {main}\n  thrown in
C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\testcom.php on line 3

|
Has anyone seen this error before or know what it
means? Or if possible does anyone know of any good
docs on using com with php?

Thanks in advance for any help!!

Cheers

Bob 





___ 
Yahoo! Messenger - want a free and easy way to contact your friends online? 
http://uk.messenger.yahoo.com

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



[PHP] Blank page in browser

2005-05-17 Thread Nayeem
Dear All,

I'm new to PHP programming and I just try to display small information from
database on web page but its shows blank page. So my code is mention below
and let me know what's wrong in it but when I execute same program on
command prompt then its shows all result correctly with HTML Tags 

\n";

   echo "\n";
   echo "\n";
   echo "Name\n";
   echo "Salary\n";
   echo "\n";

   for ($i = 0; $i < $nrows; $i++ ) {
 echo "\n";
 echo "" . $results["ENAME"][$i] . "";
 echo "$ " . number_format($results["SAL"][$i], 2). "";
 echo "\n";
   }

   echo "\n";

   ?>

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



RE: [PHP] PHP Phone Number Validation

2005-05-17 Thread Kim Madsen

> -Original Message-
> From: IMEX Research [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 17, 2005 2:49 AM
> To: php-general@lists.php.net
> Subject: [PHP] PHP Phone Number Validation
> 
> OK, I know this has probably gone aruond the list a few times, but how
do
> I validate a phone number that is in the format ddd-ddd- ??  I
can't
> figure out how.

With regular expressions: 

http://dk.php.net/manual/en/function.ereg.php
http://dk.php.net/manual/en/function.preg-match.php

I expect You wanna match 555-666-0606? (Angelina Jolies number ;-)

This will match the number from start to end:

^[0-9]{3}-[0-9]{3}-[0-9]{5}$

^ means the start of the string
$ means the end of the string
[0-9] means any number from 0 to 9
{3} means _exactly_ 3 occurences, no more no less (can also be {2,4} if
You world allow from 2 to 4 occurences or {2,} if You want at least 2
digits)

So this line says _start_ with 3 digits followed by a - then 3 digits,
then another - and end with 4 digits

Example:

$number = "555-666-0606";

if(ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", $number)) {
  echo "valid phonenumber";
}
else {
  echo "invalid phonenumber";
}

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

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



Re: [PHP] JavaScript+Html+PH

2005-05-17 Thread fabien champel
no




javascript won't call a php function. you'll need to open another page
or do it in javascript

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



[PHP] php and com

2005-05-17 Thread Bob Pilly
I am trying to start word using com and php. I am running php 5.04 and 
apache 2.054 on windows. I have used a simple example from the php site 
but cant get it working.

|Version}\n";
//bring it to front
$word->Visible = 1;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
//closing word
$word->Quit();
//free the object
$word = null;
?>
i have called this page testcom.php but when i try and view it with a 
clients browser i get this error:

[client xxx.xxx.xxx.xxx] PHP Fatal error:  Uncaught exception 
'com_exception' with message 'Failed to create COM object 
`Word.application': Invalid syntax\r\n' in C:\\Program Files\\Apache 
Group\\Apache2\\htdocs\\testcom.php:3\nStack trace:\n#0 C:\\Program 
Files\\Apache Group\\Apache2\\htdocs\\testcom.php(3): 
com->com('Word.applicatio...')\n#1 {main}\n  thrown in C:\\Program 
Files\\Apache Group\\Apache2\\htdocs\\testcom.php on line 3

|
Has anyone seen this error before or know what it means? Or if possible 
does anyone know of any good docs on using com with php?

Thanks in advance for any help!!
Cheers
Bob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mysql + addslashes + stripslashes

2005-05-17 Thread Milen Yordanov
Thank you VERY much for you detailed reply.
Especially that part:
"
MySQL "sees" the \' and "knows" that is an embedded apostrophe and saves
your data as "Joe's Grill" down in the guts of MySQL files.  Note that
MySQL does *NOT* *NOT* *NOT* store \' as part of the data.  The \ is
simply a marker that the MySQL engine "eats" once it understands that it
means: "The following character is DATA, nor part of my SQL begin/end
marker"
"
It was very informative and I almost knew everything except that part that I
quoted you.

After a little thinking I think that it is a good idea to check if
magic_quotes_runtime is set to On  for incoming MySQL data and if the data
will be "slashed" :).


Milen



- Original Message -
From: "Richard Lynch" <[EMAIL PROTECTED]>
Newsgroups: php.general
To: "Pieter Breed" <[EMAIL PROTECTED]>
Cc: "Petzo" <[EMAIL PROTECTED]>; 
Sent: Tuesday, May 17, 2005 5:00 AM
Subject: Re: [PHP] mysql + addslashes + stripslashes


> On Mon, May 16, 2005 5:16 am, Pieter Breed said:
> > My problem is that I have a large array (without any funnies like
> > self-referencing) getting serialized. There are some funnies in the
string
> > fields though (like `'`s etc). After making a roundtrip to the mysql
> > database, things start to get bad on me since I cannot unserialize the
> > text
> > anymore. This only happens for some of the arrays that I have. Other
> > arrays
> > with similar data can get serialized and unserialized just fine.
> >
> > I do suspect though, that the problem lies with how I am using
addslashes
> > and how I am not using it. Any definitive help would be much
appreciated.
> >
> > On 5/16/05, Petzo <[EMAIL PROTECTED]> wrote:
> >> My question is about the norlmal behaviour of PHP and MYSQL but I cant
> >> explain it without a simple example. Thank you for reading:
> >>
> >> I have the following code:
> >> 
> >>  >> print $t = $_POST['txt'];
> >> print $t = addslashes($t);
>
> For the Record:
>
> If you have Magic Quotes "ON" then Magic Quotes has ALREADY called
> addslashes() on all your $_POST elements, including 'txt'
>
> If you then call addslashes() on that data, you are escaping the escape
> characters, which are then interpreted and stored by MySQL as data.
>
> And while extra extra cherries might be Good; extra extra addslashes is
> very  Not Good.
>
> Consider this example:
>
> 
>
> Magic Quotes ON  |  Magic Quotes OFF
>   |  
> Joe\'s Grill |  Joe's Grill
>  | (same code)
>  |  
> Joe\\\'s Grill   |  Joe\'s Grill
> /* insert into MySQL */
>
> Now, the MySQL engine will INTERPRET the data you hand it:
>
> If there was NO addslashes at all (not shown above) with NO Magic Quotes
> and without you calling addslahes(), your query would look like:
>
> INSERT INTO something VALUES ('Joe's Grill')
>
> That is a SYNTAX ERROR because the ' inside of Joe's looks like the END
> MARKER for the string.
>
> If you had *ONLY* Magic Quotes or *ONLY* addslashes your query is Good:
>
> INSERT INTO something VALUES ('Joe\'s Grill')
>
> MySQL "sees" the \' and "knows" that is an embedded apostrophe and saves
> your data as "Joe's Grill" down in the guts of MySQL files.  Note that
> MySQL does *NOT* *NOT* *NOT* store \' as part of the data.  The \ is
> simply a marker that the MySQL engine "eats" once it understands that it
> means: "The following character is DATA, nor part of my SQL begin/end
> marker"
>
> Now, finally, if you have *BOTH* Magic Quotes *AND* addslashes() you get:
>
> INSERT INTO something VALUES ('Joe\\\'s Grill')
>
> Because Magic Quotes called addslashes, then *you* ALSO called addslashes,
> so *YOUR* addslashes escaped the escape characters that Magic Quotes had
> already added.
>
> MySQL then believes that both the \ and the ' inside of Joes are DATA and
> not part of your SQL end markers, and MySQL then stores: "Joe\'s Grill"
> which is *NOT* what you want in your data.
>
> You've got to check if Magic Quotes is ON, and if it is ON do *NOT* call
> addslashes() on your data.
>
> If you want the new-fangled Improved Way, you would detect that Magic
> Quotes is ON, use stripslashes() to un-do Magic Quotes' addslashes(),
> validate and scrub the data to be *SURE* it's kosher, and then call
> mysql_real_escape_string on the data to put back in the escape characters
> that Magic Quotes was putting in for you.
>
> ALSO:
> Note that if you take the data *AFTER* Magic Quotes, or addslashes() or
> mysql_real_escape_string, and then you put that data into a FORM or a
> HIDDEN INPUT or even a GET (URL with a ? in it) then you are going to get
> all messed up.  Because you'll end up having Magic Quotes and/or
> addslashes and/or mysql_escape_real_string being called on it AGAIN which
> is pretty much the exact same problem outlined above.
>
> Data that has been escaped by Magic Quotes, or addslashes, or
> mysql_escape_real_string was intended to be put into MySQL. 

RE: [PHP] JavaScript+Html+PH

2005-05-17 Thread YaronKh
yes

-Original Message-
From: çæä [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 17, 2005 7:26 AM
To: php-general@lists.php.net
Subject: [PHP] JavaScript+Html+PH

Hiï

Can  I  use  JavaScript+Html+PHP in  a  file?

 

 





Function sort(){

Sort_asc();

}



 







 

E-mail/MSN: [EMAIL PROTECTED]

 



Re: [PHP] regex question

2005-05-17 Thread Petar Nedyalkov
On Monday 16 May 2005 22:53, Al wrote:
> What pattern can I use to match ONLY single occurrences of a character in a
> string.
>
> e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.

Use the following:

/(^@)(@{1})(^@)/

This way you'll be sure the regexp will match only single occurences ot hte 
'@' symbol.
Please take in mind that if you have this symbol in the beginning of the 
string or at the end - you have to modify this.

>
> I only want the two occurrences with a single occurrence of "@".
>
> @{1} doesn't work; there are 4 matches.
>
> Thanks

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

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


pgpWSAkSaWAeD.pgp
Description: PGP signature