[PHP] HTTP ERRORS Boolean

2006-06-07 Thread Rodrigo de Oliveira Costa

Guys is there a way that I can call the func file(www.url.com) and
get a result true if there is a page and false if the page doesnt
exists (error 404)? the thing is I'm trying to retrieve a page but I
cant be sure that it exists so I need my script to try to access it
and if it cant access it then he should write something else.

Thanks,
Rodrigo

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



Re: [PHP] Getting totals

2006-06-07 Thread Rabin Vincent

On 6/7/06, Rob W. [EMAIL PROTECTED] wrote:

I got the fix, strstr didnt work right because it was relaying more than
just what I was thinking.

Here is the fix.

$value=array(strstr($block, $address));
foreach ($value as $var) {
  $block_total_ip++;
 }


How can this work? $value will have 1 element no matter what,
so $block_total_ip will always be incremented once. The above
code is equivalent to just:

$block_total_ip++;

Rabin

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



Re: [PHP] Getting totals

2006-06-07 Thread Rob W.
Yeah, it counts how many times block is in $address, so if there's 254 ip's 
listed in the database, it will incriment it 254 times and display that.


- Original Message - 
From: Rabin Vincent [EMAIL PROTECTED]

To: Rob W. [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Wednesday, June 07, 2006 2:03 AM
Subject: Re: [PHP] Getting totals



On 6/7/06, Rob W. [EMAIL PROTECTED] wrote:

I got the fix, strstr didnt work right because it was relaying more than
just what I was thinking.

Here is the fix.

$value=array(strstr($block, $address));
foreach ($value as $var) {
  $block_total_ip++;
 }


How can this work? $value will have 1 element no matter what,
so $block_total_ip will always be incremented once. The above
code is equivalent to just:

$block_total_ip++;

Rabin

--
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] Getting totals

2006-06-07 Thread Rabin Vincent

On 6/7/06, Rob W. [EMAIL PROTECTED] wrote:

Yeah, it counts how many times block is in $address, so if there's 254 ip's
listed in the database, it will incriment it 254 times and display that.


Well, the code snippet you've shown does NOT do any
kind of checking to see if $block is in $address. It simply
increments the counter.

If your script is working properly for you, it must be due
to the way the rest of the script functions.

Rabin

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



Re: [PHP] HTTP ERRORS Boolean

2006-06-07 Thread Rabin Vincent

On 6/7/06, Rodrigo de Oliveira Costa [EMAIL PROTECTED] wrote:

Guys is there a way that I can call the func file(www.url.com) and
get a result true if there is a page and false if the page doesnt
exists (error 404)?


This would work, but will not specifically check for a 404:

$page = file('..');
if (!$page) {
 // does not exist or some other error
}

Rabin

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



[PHP] how to compare value between 2 arrays

2006-06-07 Thread weetat

Hi all,

 I am using php 4.3.2 in Red hat enterprise.
 Have some issue which need some advice from php experts here.

 I need to compare value between 2 arrays .
 The arrays data are populated by data from the database resultset.
 The database resultset fields are the same type and name.

 for example ,
   serial_no is PK field.

  in resultset 1 , have field serial_no = '123456' country = 'England' 
and city = 'London'
  in resultset 2 , have field serial_no = '123456' country = 'England' 
and city = 'Manchester


   As you can see , the city value is different between the 2 resultset.
   So i will update status fields in the resultset 1 to 'Update'.If the 
same is 'New' ,and so on.


Thanks
-weetat

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



Re: [PHP] how to compare value between 2 arrays

2006-06-07 Thread Chris

weetat wrote:

Hi all,

 I am using php 4.3.2 in Red hat enterprise.
 Have some issue which need some advice from php experts here.

 I need to compare value between 2 arrays .
 The arrays data are populated by data from the database resultset.
 The database resultset fields are the same type and name.

 for example ,
   serial_no is PK field.

  in resultset 1 , have field serial_no = '123456' country = 'England' 
and city = 'London'
  in resultset 2 , have field serial_no = '123456' country = 'England' 
and city = 'Manchester


   As you can see , the city value is different between the 2 resultset.
   So i will update status fields in the resultset 1 to 'Update'.If the 
same is 'New' ,and so on.


http://www.php.net/array_diff will do it for you.

--
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] how to compare value between 2 arrays

2006-06-07 Thread Peter Lauri
Weetat,

Can you be clearer, and then I might be able to help. Do you just want to
perform updates towards the database? What is the status field?

/Peter

-Original Message-
From: weetat [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 07, 2006 2:36 PM
To: php-general@lists.php.net
Subject: [PHP] how to compare value between 2 arrays

Hi all,

  I am using php 4.3.2 in Red hat enterprise.
  Have some issue which need some advice from php experts here.

  I need to compare value between 2 arrays .
  The arrays data are populated by data from the database resultset.
  The database resultset fields are the same type and name.

  for example ,
serial_no is PK field.

   in resultset 1 , have field serial_no = '123456' country = 'England' 
and city = 'London'
   in resultset 2 , have field serial_no = '123456' country = 'England' 
and city = 'Manchester

As you can see , the city value is different between the 2 resultset.
So i will update status fields in the resultset 1 to 'Update'.If the 
same is 'New' ,and so on.

Thanks
-weetat

-- 
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] Replacing text of a DOM text node

2006-06-07 Thread Frank Arensmeier

Jochem, thank you for your input!

So, right now I am able to access all text nodes by e.g.

$nodeElement - parentNode - childNodes - item(0); - returns  
Lenght, Width and so on

$nodeElement - parentNode - childNodes - item(1); - is empty
$nodeElement - parentNode - childNodes - item(2); - returns mm,  
kg ...


and so on. Or is there an easier way? When trying to acces the items by

($nodeElement containing text nodes)

$nodeElemtent - item(0);

I get the following error message:  Call to undefined method  
DOMText::item()...


BTW, is there an easy way to get the total amount of items in a  
curent node? count ( $nodeElement - parentNode - childNodes )  
always returns 1. For now the only solution I know of is looping  
through the nodeElements (e.g. foreach ( $nodeElement as $value ) and  
have a counter inside the loop.


Thank you so far.
/frank

ps. I am desperately looking for some good sites covering the PHP DOM  
functions. On www.php.net/dom there are barely some examples. And on  
www.zend.com I only found one article with very, very basic examples.  
Any ideas/suggestions are more than welcome. ds.


7 jun 2006 kl. 00.54 skrev Jochem Maas:


Frank Arensmeier wrote:

Hello!

Basically, I am working on a script that is supposed to convert table
data from metric to imperial data. I want to pare XHTML pages
(containing up to three different tables) with the PHP DOM  
functions in
order to be able to access and manipulate the tables one by one.  
Parsing
and retrieving table headers and cells is not the problem. The  
problem

right now is how to replace data in the headers.

Here is a rather simplified  example of a table I want to convert:

Header contains: Product | Lenght br /  mm | Width br /mm |  
Weight

br / kg

As you can see, table headers can contain one or more words and a
(optional) line break. Currently, I am able to get all headers as  
a list
of nodes from where I can access all  headers one by one. But when  
I try

to replace some content like this:

# $nodeElement contains the current text node from a header


not all of it - because the 'current' text is actual a series of
text and xml nodes (each br / and the text between being a  
seperate node)




$str = some new content;
$new_header_element = $doc - createTextNode ( $str );
$nodeElement - parentNode - replaceChild ( $new_element,  
$nodeElement );


you'll need to remove all children of parentNode and then append  
the new node
(for arguments sake - you could do it another way but the result  
would/should be
the same) because the contents of the 'Header' (the parentNode) is  
actually a

set of nodes:

i.e. this:
Product | Lenght br /  mm | Width br /mm | Weight

ammounts to this (pseudo markup):

textNode/xmlNode/textNode/xmlNode/textNode/

and you are currently replacing only the first [text]node

hth



.. I am able to replace e.g. Product, Length or Width. I am not
able to access / replace anything after the line-break. Why? I have
already tested to get to this content with $nodeElement -  
childNodes;

but this will throw an error.

Hopefully, I was able to explain my problem to you... OOP and  
especially

working with the DOM functions are still very new to me, so please be
patient with me.

If anyone has an idea, I would love to hear about it. Otherwise,  
there
might be someone how can point me to some good on-line  
documentation /

tutorials regarding PHP DOM functions.

Thank you and good night.
/frank

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



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




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



[PHP] Re: HTTP ERRORS Boolean

2006-06-07 Thread Barry

Rodrigo de Oliveira Costa schrieb:

Guys is there a way that I can call the func file(www.url.com) and
get a result true if there is a page and false if the page doesnt
exists (error 404)? the thing is I'm trying to retrieve a page but I
cant be sure that it exists so I need my script to try to access it
and if it cant access it then he should write something else.

Thanks,
Rodrigo

Read the comments of file, fopen, filegetcontents.

There might be a function already written i think i saw one there giving 
you the error.


Best way to handle would be to go over sockets and catch the 
headerinformation.

since 200 is OK and 404 would be GONE and so on.

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] File downloads

2006-06-07 Thread kartikay malhotra

Dear All,

I have a HTTP server + MySQL database. Everytime a file is requested for
download, my PHP script loads the content from the database into a temporary
file (on the server). I then pass a URL to the client, with a link to this
file. The client can thus download the file at any time.

However, I can foresee many problems with this approach. One is, when to
delete the temporary file? Also with more than one client, this approach
would have to be refined. Security is also an issue: One user may read
another's files.

Can anyone kindly give me an alternative approach?

I reiterate, I cannot supply static URLs as the downloadable file is
generated on-demand.

Thanks  Regards
KM


[PHP] Re: File downloads

2006-06-07 Thread Barry

kartikay malhotra schrieb:

Dear All,

I have a HTTP server + MySQL database. Everytime a file is requested for
download, my PHP script loads the content from the database into a 
temporary

file (on the server). I then pass a URL to the client, with a link to this
file. The client can thus download the file at any time.

However, I can foresee many problems with this approach. One is, when to
delete the temporary file? Also with more than one client, this approach
would have to be refined. Security is also an issue: One user may read
another's files.

Can anyone kindly give me an alternative approach?

I reiterate, I cannot supply static URLs as the downloadable file is
generated on-demand.

Thanks  Regards
KM

Code a page that passes the appropriate headers for the file to the user 
and passthrough the file to the user.

That way no file is been generated and therefore nothing can be stolen.

I would do it like that

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] HTML mailing list

2006-06-07 Thread Barry

Anyone know any good HTML mailing list?

Sorry for OT but google don't give me any good lists, and probably 
somone here has a list which is good :)


My Problem:
I want to use mailto:; in one of my pages but i have to use umlauts 
(uuml;).
Thunderbird just works fine and is displaying me the bodytext as it 
should. But Outlook express isn't working.

It looks like it encodes it to URL like internally.
Hexadezimal numbers with a leading %

Any help or a mailing list would be nice :)

Thanks

Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] ADODB store session to database

2006-06-07 Thread weetat

Hi all ,

  I am having problem in store session in the database . Below is the 
example code from code.


The issue is that the code run ok , however the expireref fields is not 
updated in the sessions table, below is the sessions schema :


CREATE TABLE `sessions` (
  `sesskey` varchar(32) NOT NULL default '',
  `expiry` int(11) unsigned NOT NULL default '0',
  `expireref` varchar(64) default '',
  `data` longtext,
  PRIMARY KEY  (`sesskey`),
  KEY `expiry` (`expiry`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |


Anybody have ideas why all fields are updated except expireref field ?


?php

function NotifyExpire($ref,$key)
{
print pbNotify Expiring=$ref, sessionkey=$key/b/p;
}

$ADODB_SESSION_DRIVER='mysql';
$ADODB_SESSION_CONNECT='';
$ADODB_SESSION_USER ='';
$ADODB_SESSION_PWD ='';
$ADODB_SESSION_DB ='';

$ADODB_SESS_DEBUG = 99;
session_start();
$userdata = new User();
$_SESSION['USER_NAME'] = $userdata-getUsername();
$ADODB_SESSION_EXPIRE_NOTIFY =array('USER_NAME','NotifyExpire');


ob_start();
include('./library/adodb/session/adodb-cryptsession.php');

adodb_session_regenerate_id();

$_SESSION['MONKEY'] = array('1','abc',44.41);
if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;



?

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



Re: [PHP] Replacing text of a DOM text node

2006-06-07 Thread Rob Richards

Hi Frank,

Frank Arensmeier wrote:
 Jochem, thank you for your input!

 So, right now I am able to access all text nodes by e.g.

 $nodeElement - parentNode - childNodes - item(0); - returns Lenght,
 Width and so on
 $nodeElement - parentNode - childNodes - item(1); - is empty
 $nodeElement - parentNode - childNodes - item(2); - returns mm, 
kg ...


 and so on. Or is there an easier way? When trying to acces the items by

 ($nodeElement containing text nodes)

 $nodeElemtent - item(0);

 I get the following error message:  Call to undefined method
 DOMText::item()...

Only a nodelist and namenodemap has the item() method.

You could also do something like the following - note that manually 
walking the tree is much faster than iterating a nodelist - (there are 
also many different variations of this code depending upon what you need 
to do with the subtree):


$node = $nodeElement-parentNode-firstChild;
while ($node) {
   /* only process text or element nodes here */
   if ($node-nodeType == XML_TEXT_NODE) {
  $node-nodeValue = 'New text content'; /* modify text content */
   } else if ($node-nodeType == XML_ELEMENT_NODE) {
  /* node is element - process its subtree or move on i.e.: */
  if ($node-hasChildNodes()) {
 foreach ($node-childNodes AS $child) {
/* process child nodes here */
 }
  }
   }
   $node = $node-nextSibling;
}


 BTW, is there an easy way to get the total amount of items in a curent
 node? count ( $nodeElement - parentNode - childNodes ) always returns
 1. For now the only solution I know of is looping through the
 nodeElements (e.g. foreach ( $nodeElement as $value ) and have a counter
 inside the loop.

$count = $nodeElement-parentNode-childNodes-length;
This property is only available from a nodelist or namednodemap.


 Thank you so far.
 /frank

 ps. I am desperately looking for some good sites covering the PHP DOM
 functions. On www.php.net/dom there are barely some examples. And on
 www.zend.com I only found one article with very, very basic examples.
 Any ideas/suggestions are more than welcome. ds.

You can pretty much search for examples from any DOM implementation 
since its a standard (not too difficult to go from one language to 
another when using DOM). For PHP specific ones, there are a number of 
tests in the CVS repository that demonstrate much of the functionality:

http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/tests/
One particular test that uses a good amount of the API (though the basic 
functions) is dom001.phpt:

http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/tests/dom001.phpt?view=markuprev=1.4

Rob

--
[EMAIL PROTECTED]
author of Pro PHP XML and Web Services from Apress

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



[PHP] Control GET data ( not php related )

2006-06-07 Thread Thomas Munz
Thats not PHP related. Its normal HTML/JS

2 Ways:

1) Make form to use 1 field:;

form method=GET action=file.php 
input name=name type=text /
/form

2) Use JS to manipulate the target url dynamicaly

on Wednesday 07 June 2006 21:20, Steffen Mazanek wrote:
 Hello,

 I want to provide two input text fields lastname and firstname and if the
 user pushes the submit button the generated url should be
 ...?name=firstname_lastname.

 Is this possible and how?

 Thank you for helping a php newbie.

 Steffen Mazanek

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



Re: [PHP] Replacing text of a DOM text node

2006-06-07 Thread Frank Arensmeier

Hello Rob.

Thank you very much indeed! Since this DOM thing is very new to me  
(well, maybe not the DOM concept but working with DOM function in  
PHP), I appreciate especially the links you provided.


Right now I am able to loop through all text nodes, replace certain  
characters and mark a column for translation so to say. And this is  
pretty much everything I needed to know in order to go on. One  
problem I definitely see coming up will be dealing with headers that  
have attributes like colspan or rowspan. But that's another story.


/frank


7 jun 2006 kl. 12.26 skrev Rob Richards:


Hi Frank,

Frank Arensmeier wrote:
 Jochem, thank you for your input!

 So, right now I am able to access all text nodes by e.g.

 $nodeElement - parentNode - childNodes - item(0); - returns  
Lenght,

 Width and so on
 $nodeElement - parentNode - childNodes - item(1); - is empty
 $nodeElement - parentNode - childNodes - item(2); - returns  
mm, kg ...


 and so on. Or is there an easier way? When trying to acces the  
items by


 ($nodeElement containing text nodes)

 $nodeElemtent - item(0);

 I get the following error message:  Call to undefined method
 DOMText::item()...

Only a nodelist and namenodemap has the item() method.

You could also do something like the following - note that manually  
walking the tree is much faster than iterating a nodelist - (there  
are also many different variations of this code depending upon what  
you need to do with the subtree):


$node = $nodeElement-parentNode-firstChild;
while ($node) {
   /* only process text or element nodes here */
   if ($node-nodeType == XML_TEXT_NODE) {
  $node-nodeValue = 'New text content'; /* modify text content */
   } else if ($node-nodeType == XML_ELEMENT_NODE) {
  /* node is element - process its subtree or move on i.e.: */
  if ($node-hasChildNodes()) {
 foreach ($node-childNodes AS $child) {
/* process child nodes here */
 }
  }
   }
   $node = $node-nextSibling;
}


 BTW, is there an easy way to get the total amount of items in a  
curent
 node? count ( $nodeElement - parentNode - childNodes ) always  
returns

 1. For now the only solution I know of is looping through the
 nodeElements (e.g. foreach ( $nodeElement as $value ) and have a  
counter

 inside the loop.

$count = $nodeElement-parentNode-childNodes-length;
This property is only available from a nodelist or namednodemap.


 Thank you so far.
 /frank

 ps. I am desperately looking for some good sites covering the PHP  
DOM

 functions. On www.php.net/dom there are barely some examples. And on
 www.zend.com I only found one article with very, very basic  
examples.

 Any ideas/suggestions are more than welcome. ds.

You can pretty much search for examples from any DOM implementation  
since its a standard (not too difficult to go from one language to  
another when using DOM). For PHP specific ones, there are a number  
of tests in the CVS repository that demonstrate much of the  
functionality:

http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/tests/
One particular test that uses a good amount of the API (though the  
basic functions) is dom001.phpt:
http://cvs.php.net/viewcvs.cgi/php-src/ext/dom/tests/dom001.phpt? 
view=markuprev=1.4


Rob

--
[EMAIL PROTECTED]
author of Pro PHP XML and Web Services from Apress

--
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] When is z != z ?

2006-06-07 Thread tedd
At 11:45 PM -0400 6/6/06, Robert Cummings wrote:
On Tue, 2006-06-06 at 22:53, Rasmus Lerdorf wrote:
 Richard Lynch wrote:

 Or we try to do something a bit more creative which always runs the risk
 of surprising people.  In this case a2++ becomes a3 and c9++
 becomes d0.  If we have a character that doesn't infer any sort of
 logical sequence, like  then the ++ does nothing.  So ++ stays at
 .  However 3 becomes 4 and b++ becomes c.  99z++
 becomes 100a and

Funky stuff.

  1z9z9z++ becomes 2a0a0a and yes, of course z++

Good thing Tedd didn't come across the above one by accident *lol*.

Cheers,
Rob.

Well... now that you mentioned it :-)

Good discussion all.

Thanks for everyone's input, learned a lot -- and hopefully didn't annoy too 
many.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] If value is odd or not

2006-06-07 Thread Dimiter Ivanov

On 6/5/06, Adam Zey [EMAIL PROTECTED] wrote:

Let's make it even more compact and confusing :)

echo $variable is .($variable % 2 ?'even':'odd').br /\n;

I'm not sure if you can nuke the whitespace in the modulus area or not.



Yes you can,in  php whitespaces inside expressions does not have
special meaning.

echo $variable is .($variable%2?'even':'odd').br /\n;

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



Re: [PHP] How do I make a HTML tree for a set of nodes?

2006-06-07 Thread Niels
Hi,

On Tuesday 06 June 2006 21:05, Jochem Maas wrote:

[snip]
 I might be late to the party but have you thought of trying the YAHOO UI
 lib (treeview widget) it even allows you to dynamically load subbranches
 as they are expanded (AJAX lovelyness):
 
 http://developer.yahoo.com/yui/treeview/
 
Thanks, that's a nice library. But it is really what I'm looking for, and it
has many features I won't be using.


 I have used (and extended) the treeview code with great success (ok so I'm
 biased ;-) - if nothing else the guys at YAHOO have done a great job in
 showing how one can use prototyping (more or less the javascript
 equivalent to classes) to build [very] robust javascript libraries.
 
 testament to=YAHOO JS Lib being rather good
 I have made the YAHOO javascript lib(s) part of my core [reusable] js
 codebase - the only downside is that its a bit embarrassing hwo the YAHOO
 stuff has made alot of my own js code redundant :-P
 testament
There are just sooo many libraries and code snippets and paradigms these
days...  


 disclaimerI have nothing to do with YAHOO apart from occasionally
 harassing one of their system architects (sorry Rasmus) about things not
 related to YAHOO/disclaimer
Hands off Rasmus! He's a good guy!


Thank you for your answer,
Niels

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



Re: [PHP] ADODB store session to database

2006-06-07 Thread chris smith

On 6/7/06, weetat [EMAIL PROTECTED] wrote:

Hi all ,

   I am having problem in store session in the database . Below is the
example code from code.


Ask the adodb guys.

http://adodb.sourceforge.net/#mail

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

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



[PHP] better way to create custom text file from query results?

2006-06-07 Thread Ben Liu

Hello All,

I've written a clunky script that presents a form to a user with 30  
checkboxes on it to match 30 fields in a table. The user checks off  
each field they want to appear in a text file produced by the script.  
The script I wrote captures each checkbox response to a separate  
variable:


$fieldname1=$_POST['fieldname1'];
$fieldname2=$_POST['fieldname2'];

etc...

I then build a custom query based on those variables using 30 logic  
statements like such:


if ($fieldname1) $query .=fieldname1, ;
if ($fieldname2) $query .=fieldname2, ;

etc...

I then query the DB and iterate over the results, shoving the data  
into an output variable like this (again 30 logic statements):


if ($fieldname1) $output.=$row[fieldname1]\t;
if ($fieldname2) $output.=$row[fieldname2]\t;

then I print the contents of $output to a text file.

It seems that there has to be a better way of doing this. Can the  
$_POST superglobal be manipulated in this way:


foreach ($_POST as $fieldname) ?

Thanks for any help and guidance.

- Ben

smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] better way to create custom text file from query results?

2006-06-07 Thread chris smith

On 6/7/06, Ben Liu [EMAIL PROTECTED] wrote:

Hello All,


snip


It seems that there has to be a better way of doing this. Can the
$_POST superglobal be manipulated in this way:

foreach ($_POST as $fieldname) ?


Yes, that will work.

If in doubt give something a try. :)

--
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] Replacing text of a DOM text node

2006-06-07 Thread tedd
BTW, is there an easy way to get the total amount of items in a curent node? 
count ( $nodeElement - parentNode - childNodes ) always returns 1. For now 
the only solution I know of is looping through the nodeElements (e.g. foreach 
( $nodeElement as $value ) and have a counter inside the loop.

The way I did this (unfortunately in another language) was to write a recursive 
function that traveled to the end counting along the way and then returned the 
count.

hth's

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] better way to create custom text file from query results?

2006-06-07 Thread tedd
At 8:21 AM -0400 6/7/06, Ben Liu wrote:
Hello All,

I've written a clunky script that presents a form to a user with 30 checkboxes 
on it to match 30 fields in a table. The user checks off each field they want 
to appear in a text file produced by the script. The script I wrote captures 
each checkbox response to a separate variable:

$fieldname1=$_POST['fieldname1'];
$fieldname2=$_POST['fieldname2'];

etc...

I then build a custom query based on those variables using 30 logic statements 
like such:

if ($fieldname1) $query .=fieldname1, ;
if ($fieldname2) $query .=fieldname2, ;

etc...

I then query the DB and iterate over the results, shoving the data into an 
output variable like this (again 30 logic statements):

if ($fieldname1) $output.=$row[fieldname1]\t;
if ($fieldname2) $output.=$row[fieldname2]\t;

then I print the contents of $output to a text file.

It seems that there has to be a better way of doing this.

Ben:

What you did doesn't look bad to me. If you understand it, it's obvious, and it 
works...

But, if it was my code, I might take steps one and two and combine them, and 
run the process through a loop, like so:

for ($i = 1; $=30; $I)
   {
   if ($_POST['$i']) $query .=$i, ;
   }

And then assemble the data the same way.

for ($i = 1; $=30; $I)
   {
   if ($i) $output.=$row[$i]\t;
   }

This is written on the fly, so it may not work as I expect, but I'm sure you 
get the idea.

hth's

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] better way to create custom text file from query results?

2006-06-07 Thread Ben Liu

I guess I was just talking the problem out. :-)
Writing that post helped me think of iterating through $_POST. Now  
I've come to this problem:


Before I did this and it works:

while ([EMAIL PROTECTED]($result)) {
if ($fieldname1) $output.=$row[fieldname1]\t;
if ($fieldname2) $output.=$row[fieldname2]\t;
}

Trying to tighten up as discussed with this, but doesn't work:

while ([EMAIL PROTECTED]($result)) {
foreach ($_POST as $key = $data)
if ($data) {$output.=$row[ . $key . ]\t;
} // foreach
} // end while $row

The above throws a Parse error: parse error, expecting `T_STRING' or  
`T_VARIABLE' or `T_NUM_STRING' in error.


This substitution:

if ($data) {$output.=$row[$key]\t;

eliminates the aforementioned error, but does not produce the desired  
results.


On Jun 7, 2006, at 8:26 AM, chris smith wrote:


If in doubt give something a try. :)





smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] File downloads

2006-06-07 Thread tedd
At 8:42 AM + 6/7/06, kartikay malhotra wrote:
Dear All,

I have a HTTP server + MySQL database. Everytime a file is requested for
download, my PHP script loads the content from the database into a temporary
file (on the server). I then pass a URL to the client, with a link to this
file. The client can thus download the file at any time.

However, I can foresee many problems with this approach. One is, when to
delete the temporary file? Also with more than one client, this approach
would have to be refined. Security is also an issue: One user may read
another's files.

Can anyone kindly give me an alternative approach?

I reiterate, I cannot supply static URLs as the downloadable file is
generated on-demand.

Thanks  Regards
KM

KM:

Thinking off the top of my head (not always the best for me) -- why not give 
the user a static url AND a key?

The static url would have a php program sitting there waiting for a user to 
come along and provide the correct key. After which, your program would then 
create the file (in a random named folder); provide the user with a link; and 
clean-up after he's done.

That way you have the control over what's happening. The key approach handles 
security and when to clean-up.

hth's

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] better way to create custom text file from query results?

2006-06-07 Thread Ben Liu

Nevermind, got it to work with this:

while ([EMAIL PROTECTED]($result)) {
foreach ($_POST as $key = $data) {
if ($data) $output.=$row[$key]\t;
} // foreach $_POST
}// while $row

Had a poorly positioned statement throwing off the data output.

Thanks for all suggestions...
--Ben

smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] Re: Pear DB and memcached

2006-06-07 Thread Ruben Rubio Rey

Ben Ramsey wrote:


On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:


Im having a trouble using memcached with pear db.

When im using memcache to store and retrieve an string, all works fine.
When Im using memcache to store a pear db resulset, it does not work!!

This retrieves data but pear::db does not understand it.
I really dont know



This is because $db-query returns a resource, which is a reference to 
the data and not the data itself.


For example, let's say you're using the MySQL driver for PEAR::DB, 
then when you call $db-query(), it uses mysql_query(). This function 
will return a resource. When you store the resource to the memcache 
server and then later retrieve it, it no longer maintains its 
reference to the data.


If you want to store the data to the cache, I suggest you use getAll() 
to retrieve an array of data and then store that to the memcache server:


$db-setFetchMode(DB_FETCHMODE_ASSOC);
$data = $db-getAll($sSQL);
memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10);

Now, your result set is stored properly on the memcache server.


Seems its working. Thaks a lot!

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



[PHP] Cant work HTML echo loop

2006-06-07 Thread Rodrigo de Oliveira Costa

Hi guys Im here again, now I got this problem with a loop. The script
is at the end of the message so you guys can review it. Now to the
problem: I have a script that go to a site and try to access an url
like www.domain.com/story/variable/ it should do the following:

Try to open the page if it doesnt exist return false for the boolean check,

If not should echo the page and add to the variable to be like:

www.domain.com/story/1/
www.domain.com/story/2/
www.domain.com/story/3/
etc...

I'm trying to echo all the pages in one html adding it after echoing
it. It just return some strange values like z or a pund signal...

Anyone off you guys up to the task?

Thanks a lot...
Rodrigo

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



[PHP] Cant work HTML echo loop

2006-06-07 Thread Rodrigo de Oliveira Costa

i guys Im here again, now I got this problem with a loop. The script
is at the end of the message so you guys can review it. Now to the
problem: I have a script that go to a site and try to access an url
like www.domain.com/story/variable/ it should do the following:

Try to open the page if it doesnt exist return false for the boolean check,

If not should echo the page and add to the variable to be like:

www.domain.com/story/1/
www.domain.com/story/2/
www.domain.com/story/3/
etc...

I'm trying to echo all the pages in one html adding it after echoing
it. It just return some strange values like z or a pund signal...

Anyone off you guys up to the task?

Thanks a lot...
Rodrigo

?


$urlChapter = 1;//'/'.$_POST[chapter].'/';

$urlStory = '/s/'.$_POST[story];

$urlMain = http://www.domain.com;;

$url = $urlMain.$urlStory.$urlChapter;

$texto = file($url);

$result2 = count($texto);

$i = 0;

while ($i  $result2)
{
 echo $texto[$i];
 $i++;

}







while (@fopen(http://www.domain.com/s/$urlStory/$urlChapter/,r;)!=null)
{

   $pega = @fopen($urlMain.$urlStory.$urlChapter,r);

$pega =  strip_tags($pega, 'p/pbr');

   echo $pega;

   $urlChapter++;

}

?

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



[PHP] generating/transforming HTML so that it 'works' in a flash file

2006-06-07 Thread Jochem Maas
hi people,

I've been STFW till I'm blue in the face (so lack of oxygen might be
problem atm) but can't find any [decent] info on generating/transforming 
existing
HTML so thats it's compatible with the subset of tags that are supported
by Flash (apparently Flash has the ability to show something that resembles
HTML in certain visual controls - I don't flash, I'm just responsible for
supplying XML feeds that the flash site/file in question can consume).

so the question does any know of a reliable resource on this subject and/or
some code nugget that is capable of generating/transforming (x)HTML into
the cruft that Flash is capable of displaying?

any feedback is welcome (apart from 'STFW' - I'm already doing that :-P)

rgds,
Jochem

ps - my server side stuff is all php (so I need to have an HTML 'converter'
written in php too [preferably]) before someone hits me with the 'what does
this has to do with php' response.

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



[PHP] Introductory message

2006-06-07 Thread JF Simard

Hi all,

I am attempting to send my first post to the list. Been reading and using  
PHP with passion for the past year on our website and want to learn more  
and more, and contribute if I can.


--
JF Simard
  creative + code + logistics //
  Feed your eyes - http://netdiver.net/

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



Re: [PHP] generating/transforming HTML so that it 'works' in a flash file

2006-06-07 Thread Martin Alterisio

2006/6/7, Jochem Maas [EMAIL PROTECTED]:


hi people,

I've been STFW till I'm blue in the face (so lack of oxygen might be
problem atm) but can't find any [decent] info on generating/transforming
existing
HTML so thats it's compatible with the subset of tags that are supported
by Flash (apparently Flash has the ability to show something that
resembles
HTML in certain visual controls - I don't flash, I'm just responsible for
supplying XML feeds that the flash site/file in question can consume).

so the question does any know of a reliable resource on this subject
and/or
some code nugget that is capable of generating/transforming (x)HTML into
the cruft that Flash is capable of displaying?

any feedback is welcome (apart from 'STFW' - I'm already doing that :-P)

rgds,
Jochem

ps - my server side stuff is all php (so I need to have an HTML
'converter'
written in php too [preferably]) before someone hits me with the 'what
does
this has to do with php' response.

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



Have you read the following?
http://livedocs.macromedia.com/flash/mx2004/main_7_2/1027.html
http://livedocs.macromedia.com/flash/mx2004/main_7_2/1014.html


[PHP] question on getting PDO to output final assembled query from prepared statements?

2006-06-07 Thread Rick Harding
I am working on some code that I am moving to use PDO in order to  
play with it a bit. I used to use ADODB, but want to try out the
performance of using PDO and just skipping some of the portability of  
the db code. The one thing I find myself missing is the ADODB debug  
and sql values where you can get out the last query executed (with  
$dbh-sql) and a dump of queries as they are executed (with $dhb- 
debug = true). Can anyone suggest how I can get this functionality  
into my code with PDO? I want to be able to just set a debug flag in  
a config file for the project and get a dump of all SQL queries  
executed output to the page as it loads. I'm not sure what the best  
method to extend/wrap PDO calls to do this as I don't see any way in  
the PDO functionality to do it now.


Thanks for the tips/help

Rick

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



RE: [PHP] Introductory message

2006-06-07 Thread Jay Blanchard
[snip]
I am attempting to send my first post to the list. Been reading and
using  
PHP with passion for the past year on our website and want to learn more

and more, and contribute if I can.
[/snip]

Your attempt was successful, some suggested reading;

http://zirzow.dyndns.org/php-general/NEWBIE

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



[PHP] question on getting PDO to output final assembled query from the prepared statements

2006-06-07 Thread Rick Harding
I am working on some code that I am moving to use PDO in order to  
play with it a bit. I used to use ADODB, but want to try out the
performance of using PDO and just skipping some of the portability of  
the db code. The one thing I find myself missing is the ADODB debug  
and sql values where you can get out the last query executed (with  
$dbh-sql) and a dump of queries as they are executed (with $dhb- 
debug = true). Can anyone suggest how I can get this functionality  
into my code with PDO? I want to be able to just set a debug flag in  
a config file for the project and get a dump of all SQL queries  
executed output to the page as it loads. I'm not sure what the best  
method to extend/wrap PDO calls to do this as I don't see any way in  
the PDO functionality to do it now.


Thanks for the tips/help

Rick

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



[PHP] file( ) function

2006-06-07 Thread Mayank Maheshwary

Hi,

I am facing some trouble with the file( ) function. I understand that it
returns the contents of the file in an array. Also, I am able to print the
lines using the echo function. However, whenever I try to compare the
contents of an array using strcmp, or ==, the page simply keeps 'loading',
instead of printing results.

The following is the code that I try:

$name = $_POST[filename];
$lines = file($name);
$i = 0;
$len = sizeof($lines);
//echo $i;
while($i  $len) {
 //echo $lines[$i];
 $temp = $lines[$i];
 $temp = trim($temp);
 //echo $temp;
 if($temp1 == '--') {
   echo $i;
   return $i;
 }
 else
   $i++;
}

I think that the way the lines of the file are stored in the array may be
the problem, but I do not know what I am supposed to change. Any help would
be appreciated.

Thanks.

MM.


Re: [PHP] file( ) function

2006-06-07 Thread Rabin Vincent

On 6/8/06, Mayank Maheshwary [EMAIL PROTECTED] wrote:

$name = $_POST[filename];
$lines = file($name);
$i = 0;
$len = sizeof($lines);
//echo $i;
while($i  $len) {
  //echo $lines[$i];
  $temp = $lines[$i];
  $temp = trim($temp);
  //echo $temp;
  if($temp1 == '--') {


This should be $temp, shoudn't it?


echo $i;
return $i;
  }
  else
$i++;
}


Rabin

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



Re: [PHP] file( ) function

2006-06-07 Thread Jo�o C�ndido de Souza Neto

Rabin Vincent [EMAIL PROTECTED] escreveu na mensagem 
news:[EMAIL PROTECTED]
 On 6/8/06, Mayank Maheshwary [EMAIL PROTECTED] wrote:
 $name = $_POST[filename];
 $lines = file($name);
 $i = 0;
 $len = sizeof($lines);
 //echo $i;
 while($i  $len) {
   //echo $lines[$i];
   $temp = $lines[$i];
   $temp = trim($temp);
   //echo $temp;
   if($temp1 == '--') {

 This should be $temp, shoudn't it?

 echo $i;
 return $i;
   }
   else
 Else here´s putting you in loop.
 $i++;
 }

 Rabin 

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



Re: [PHP] file( ) function

2006-06-07 Thread Mayank Maheshwary

Yes, that is actually $temp, not $temp1. However, my problem still remains
the same.

Several lines in the file contain the exact same string as the one I am
comparing. I need their positions in the array so that I can operate on
other lines in the file. That is why I am using file( ) instead of other
file reader functions.

Thanks.

MM.




 $name = $_POST[filename];
 $lines = file($name);
 $i = 0;
 $len = sizeof($lines);
 //echo $i;
 while($i  $len) {
   //echo $lines[$i];
   $temp = $lines[$i];
   $temp = trim($temp);
   //echo $temp;
   if($temp1 == '--') {

This should be $temp, shoudn't it?

 echo $i;
 return $i;
   }
   else
 $i++;
 }



[PHP] php sessions and Google

2006-06-07 Thread tedd
Hi gang:

I've read that php sessions can create problems for Google bots. For example, 
the following was taken from a Google Web Master Help Center:

-- Quote --
Allow search bots to crawl your sites without session IDs or arguments that 
track their path through the site. These techniques are useful for tracking 
individual user behavior, but the access pattern of bots is entirely different. 
Using these techniques may result in incomplete indexing of your site, as bots 
may not be able to eliminate URLs that look different but actually point to the 
same page.
-- Un-quote --

http://www.google.com/support/webmasters/bin/answer.py?answer=35770

I've also seen a comment here:

http://www.weberdev.com/get_example-3431.html

But, I'm not following what's happening.

Can someone shed some light on this for me? How can one do sessions and make 
Google bots happy?

Thanks in advance for any comments or suggestions.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] SSL support for pgsql module in Windows binary distribution

2006-06-07 Thread Peter Kuma
Hi
Is there any reason why SSL support for pgsql module is disabled by
default in binary distribution for Windows (PHP 5.1.4 zip package)?
I thing it'd be very useful if this feauture were compiled in.

I sent this question to php-windows a few days ago with no response.

Regards
Peter Kuma

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



[PHP] odbc remote

2006-06-07 Thread Benjamin Adams

how do I do a remote connection for odbc?
Everything that I see is on the local machine.
Can you do an odbc to a remote database?


Benjamin Adams / Lord of the Root / Ambrosia Software, Inc. -- http:// 
www.AmbrosiaSW.com


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



Re: [PHP] generating/transforming HTML so that it 'works' in a flash file

2006-06-07 Thread Jochem Maas
Martin Alterisio wrote:
 2006/6/7, Jochem Maas [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]:
 

...

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Have you read the following?
 http://livedocs.macromedia.com/flash/mx2004/main_7_2/1027.html
 http://livedocs.macromedia.com/flash/mx2004/main_7_2/1014.html

yes I found those already and read them (but thanks for pointing them out):

1. I'm trying to find something flash version agnostic so my XML output
routines can be reused by different flash files (made by different people,
with different reqs, etc)

2. the apparent lack of tag support is a major bummer when trying to
map fullblown (x)HTML to something flash will display sensibly... writing a
fullblown robust converter from scratch is something I don't really have the
time for (and the gains are not really worth it) - I mean where do you start
when TABLE is not even supported :-/

rather a downer all in all - I guess I have to start tweaking tinyMCE to
only produce the bare minimum of markup, seems like the path of least 
resistance.

 

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



[PHP] Re: odbc remote

2006-06-07 Thread Peter Kuma
Benjamin Adams wrote:
 how do I do a remote connection for odbc?
 Everything that I see is on the local machine.
 Can you do an odbc to a remote database?
As far as I know ODBC can be used only locally. Although some kind of
forwarding utilities might exist. Maybe it could be accomplished by
windows sharing (eg if your database is MS Access).
Peter Kuma

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



[PHP] Re: SSL support for pgsql module in Windows binary distribution

2006-06-07 Thread M. Sokolewicz

Peter Kuma wrote:

Hi
Is there any reason why SSL support for pgsql module is disabled by
default in binary distribution for Windows (PHP 5.1.4 zip package)?
I thing it'd be very useful if this feauture were compiled in.

I sent this question to php-windows a few days ago with no response.

Regards
Peter Kuma


probably because it relies on openssl which is disabled by default (and 
built as shared), as such you wouldn't be able to use pgsql if openssl 
was disabled... well, that's my first guess anyway... I don't really know.


- tul

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



RE: [PHP] Re: odbc remote

2006-06-07 Thread Warren Vail
I use odbc to connect to mainframe databases, and they are definitely remote
from my web server, and to access the mainframe database, the mainframe
needed to support tcp/ip on the database end and I needed a special driver
on the ODBC end.  Perhaps the odbc driver routine is the key (check your
odbc manager utility, if you have one, and try adding the datasource,
looking for host name provisions). 

Hope this helps,

Warren Vail

-Original Message-
From: Peter Kuma [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 07, 2006 2:51 PM
To: php-general@lists.php.net
Subject: [PHP] Re: odbc remote

Benjamin Adams wrote:
 how do I do a remote connection for odbc?
 Everything that I see is on the local machine.
 Can you do an odbc to a remote database?
As far as I know ODBC can be used only locally. Although some kind of
forwarding utilities might exist. Maybe it could be accomplished by windows
sharing (eg if your database is MS Access).
Peter Kuma

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

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



[PHP] file from database work local, but not on server

2006-06-07 Thread Peter Lauri
Best group member,

This code works fine on my local machine:

$Query = sprintf(SELECT * FROM filestorage WHERE id=%s LIMIT 1,
$_GET['fileid']);
$Result = mysql_query($Query);
if (mysql_num_rows ($Result)0) {
  $Row = @mysql_fetch_array ($Result);
  $file_type = $Row[filetype];
  $file = $Row[filedata];
  header (Content-type: $file_type);
  header(Content-Disposition: attachment;
filename=fil.substr($Row['filename'], strrpos($Row['filename'], '.')));
'.')).'
  print $file;
}

But when I run it on my server it does not start the download, and the file
name is the location of the script instead of what I state as file name.

Is this a server issue? I run Linux server with Plesk. Is there anyone with
the same problems?

Best regards,
Peter Lauri

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



Re: [PHP] Introductory message

2006-06-07 Thread Ligaya Turmelle

Jay Blanchard wrote:

[snip]
I am attempting to send my first post to the list. Been reading and
using  
PHP with passion for the past year on our website and want to learn more


and more, and contribute if I can.
[/snip]

Your attempt was successful, some suggested reading;

http://zirzow.dyndns.org/php-general/NEWBIE

Thought we were going to add the Security subsection to the Where to 
Find More Information section of the NEWBIE email.  Wasn't it supposed 
to include a link to the manuals security area as well as the phpsec site?


--

life is a game... so have fun.

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

Re: [PHP] Getting totals

2006-06-07 Thread Rafael
	I really doubt you need to use strstr() here, since it will return a 
string (_if_ the 'needle' is found in the 'haystack')[1], I guess you're 
looking for strpos() or something similar.


	Now, you said that you have this IPs on your database, so why don't you 
count the IPs directly on your database?  If the examples you gave are 
real and the first 3 segments of each IP are the same, then you could 
group your records, clasify and count them.  For example, if you were 
using MySQL, you can count them with something like


  SELECT
SUBSTRING(ip, 1, 11) AS ip
COUNT(1) AS counter
  FROM table
  GROUP BY ip
  ORDER BY ip ASC
*NOT tested

which should give you something like
  ip  | counter
 -+-
  192.168.100 |   1
  192.168.101 |   2
  ··· |   ···
  192.168.110 |  11

[1] http://php.net/strstr

Rob W. wrote:
Sorry for the miss understanding, That's the way the viarable will look, 
i'm putting it in as a viariable.


if (strstr($block,$address)) {
 $inc++;
}

- Original Message - From: Richard Lynch [EMAIL PROTECTED]
To: Rob W. [EMAIL PROTECTED]
Sent: Tuesday, June 06, 2006 8:58 PM
Subject: Re: [PHP] Getting totals




Put quotes or apostrophes on the strings...
if (strstr('192.168.100','192.168.100.10')) {

On Tue, June 6, 2006 8:46 pm, Rob W. wrote:


if (strstr(192.168.100,192.168.100.10)) {
  $inc++;
}
echo $inc;

That returns nothing. What am i still doing wrong?

- Original Message -
From: Rabin Vincent [EMAIL PROTECTED]
To: Rob W. [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, June 06, 2006 1:36 PM
Subject: Re: [PHP] Getting totals



On 6/6/06, Rob W. [EMAIL PROTECTED] wrote:


So far what I have gotten is a stristr match but it's not working
correctly. I have a variable that basically weed's out the last
digits of
the ip it's self from help previously

So my code so far is:

if (stristr($block,$address)) {
   $count_ip++;
}



You've got the parameters mixed up. strstr is (haystack,
needle) so you need strstr($address, $block). php.net/stristr.

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



Re: [PHP] php sessions and Google

2006-06-07 Thread Chris

tedd wrote:

Hi gang:

I've read that php sessions can create problems for Google bots. For example, the 
following was taken from a Google Web Master Help Center:

-- Quote --
Allow search bots to crawl your sites without session IDs or arguments that 
track their path through the site. These techniques are useful for tracking 
individual user behavior, but the access pattern of bots is entirely different. 
Using these techniques may result in incomplete indexing of your site, as bots 
may not be able to eliminate URLs that look different but actually point to the 
same page.
-- Un-quote --

http://www.google.com/support/webmasters/bin/answer.py?answer=35770

I've also seen a comment here:

http://www.weberdev.com/get_example-3431.html

But, I'm not following what's happening.

Can someone shed some light on this for me? How can one do sessions and make 
Google bots happy?


use_trans_sid (I think) will append the sessionid to all pages, so 
instead of:


/page.php

it will become

/page.php?PHPSESSID=x

much the same as if you do:

?php
echo '/page.php?' . SID;
?

Bots don't like that, so where possible turn use_trans_sid off (check 
manual about when/how you can do this).


--
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] file from database work local, but not on server

2006-06-07 Thread Chris

Peter Lauri wrote:

Best group member,

This code works fine on my local machine:

$Query = sprintf(SELECT * FROM filestorage WHERE id=%s LIMIT 1,
$_GET['fileid']);
$Result = mysql_query($Query);
if (mysql_num_rows ($Result)0) {
  $Row = @mysql_fetch_array ($Result);
  $file_type = $Row[filetype];
  $file = $Row[filedata];
  header (Content-type: $file_type);
  header(Content-Disposition: attachment;
filename=fil.substr($Row['filename'], strrpos($Row['filename'], '.')));
'.')).'
  print $file;
}

But when I run it on my server it does not start the download, and the file
name is the location of the script instead of what I state as file name.



The first thing you should do is read this site:

http://www.phpsec.org

I could pass all sorts of bad things to $_GET['fileid'] and it will ruin 
your database.


At least make it:

(int)$_GET['fileid'];

so if it's non-numeric, it will get converted to 0.

Can we assume the database is exactly the same and it's not that 
$row['filename'] has the wrong data in it?


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

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



[PHP] Re: file( ) function

2006-06-07 Thread David Robley
Mayank Maheshwary wrote:

 Hi,
 
 I am facing some trouble with the file( ) function. I understand that it
 returns the contents of the file in an array. Also, I am able to print the
 lines using the echo function. However, whenever I try to compare the
 contents of an array using strcmp, or ==, the page simply keeps 'loading',
 instead of printing results.
 
 The following is the code that I try:
 
 $name = $_POST[filename];
 $lines = file($name);
 $i = 0;
 $len = sizeof($lines);
 //echo $i;
 while($i  $len) {
   //echo $lines[$i];
   $temp = $lines[$i];
   $temp = trim($temp);
   //echo $temp;
   if($temp1 == '--') {
 echo $i;
 return $i;
   }
   else
 $i++;
 }
 
 I think that the way the lines of the file are stored in the array may be
 the problem, but I do not know what I am supposed to change. Any help
 would be appreciated.
 
 Thanks.
 
 MM.

You seem to be aware of the fact that each line of the file is loaded into
an arry element with the newline still attached as you are using trim() to
clear white space from the start/end of the array element. For a second
test, maybe do a strlen on the array element and see if that tells you
anything.



Cheers
-- 
David Robley

Memory is a thing we forget with.
Today is Prickle-Prickle, the 13rd day of Confusion in the YOLD 3172. 

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



Re: [PHP] php sessions and Google

2006-06-07 Thread tedd
At 10:56 AM +1000 6/8/06, Chris wrote:
tedd wrote:
Hi gang:

I've read that php sessions can create problems for Google bots. For example, 
the following was taken from a Google Web Master Help Center:

-- Quote --
Allow search bots to crawl your sites without session IDs or arguments that 
track their path through the site. These techniques are useful for tracking 
individual user behavior, but the access pattern of bots is entirely 
different. Using these techniques may result in incomplete indexing of your 
site, as bots may not be able to eliminate URLs that look different but 
actually point to the same page.
-- Un-quote --

http://www.google.com/support/webmasters/bin/answer.py?answer=35770

I've also seen a comment here:

http://www.weberdev.com/get_example-3431.html

But, I'm not following what's happening.

Can someone shed some light on this for me? How can one do sessions and make 
Google bots happy?

use_trans_sid (I think) will append the sessionid to all pages, so instead of:

/page.php

it will become

/page.php?PHPSESSID=x

much the same as if you do:

?php
echo '/page.php?' . SID;
?

Bots don't like that, so where possible turn use_trans_sid off (check manual 
about when/how you can do this).


Chris:

Thanks -- after your lead, I found that my site's session.use_trans_sid was 
turned off by default.

So, it wasn't the problem I thought it might have been.

Thanks again.

tedd
 
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php sessions and Google

2006-06-07 Thread Chris

tedd wrote:

At 10:56 AM +1000 6/8/06, Chris wrote:

tedd wrote:

Hi gang:

I've read that php sessions can create problems for Google bots. For example, the 
following was taken from a Google Web Master Help Center:

-- Quote --
Allow search bots to crawl your sites without session IDs or arguments that 
track their path through the site. These techniques are useful for tracking 
individual user behavior, but the access pattern of bots is entirely different. 
Using these techniques may result in incomplete indexing of your site, as bots 
may not be able to eliminate URLs that look different but actually point to the 
same page.
-- Un-quote --

http://www.google.com/support/webmasters/bin/answer.py?answer=35770

I've also seen a comment here:

http://www.weberdev.com/get_example-3431.html

But, I'm not following what's happening.

Can someone shed some light on this for me? How can one do sessions and make 
Google bots happy?

use_trans_sid (I think) will append the sessionid to all pages, so instead of:

/page.php

it will become

/page.php?PHPSESSID=x

much the same as if you do:

?php
echo '/page.php?' . SID;
?

Bots don't like that, so where possible turn use_trans_sid off (check manual 
about when/how you can do this).



Chris:

Thanks -- after your lead, I found that my site's session.use_trans_sid was 
turned off by default.

So, it wasn't the problem I thought it might have been.


So your page urls don't automatically append the session id to the end? 
I might have the wrong variable name so if you're still seeing them, I 
obviously have it wrong...


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

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



[PHP] Pear Pager

2006-06-07 Thread weetat

Hi all ,

  Thanks all in this newsgroup for your help.

  I have question regarding PEAR Pager .

  The PEAR pager is working ok , however , the PEAR Pager always display
  totalItems: display and value 1 on my web page.
  How to make the totalItems: and the value 1 not to display on 
webpage?


  I am using MYSQL database and PHP 4.3.2

Thanks
-weetat

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