OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 9 Aug 2005 17:33:36 -0000 Issue 3615

php-general-digest-helplists.php.net
Date: Tue Aug 09 2005 - 12:33:36 CDT


php-general Digest 9 Aug 2005 17:33:36 -0000 Issue 3615

Topics (messages 220270 through 220291):

Re: Generating a 404 status message with header()
        220270 by: Paul Waring
        220287 by: Eric Gorr
        220289 by: Sebastian

Re: parallel execution of php code?
        220271 by: Marcus Bointon
        220288 by: Martin van den Berg

Session-problem? Simple counter won't work
        220272 by: Sabine
        220290 by: Jochem Maas

download snippet
        220273 by: Roger Thomas
        220274 by: Burhan Khalid

Re: Class / app for reading web pages and storing in a mySQL DB
        220275 by: Burhan Khalid

Re: parallel execution of code
        220276 by: hope
        220277 by: hope
        220278 by: hope

N/A
        220279 by: R. Ragunathan
        220280 by: Jay Blanchard

How to search products on my site
        220281 by: virtualsoftware.gmail.com
        220282 by: Jay Blanchard
        220283 by: Miles Thompson
        220284 by: Jim Moseby

rename an uploaded file.
        220285 by: Bosky, Dave
        220286 by: Stut

How to add .zip or gzip compression to the php module
        220291 by: Mauricio Pellegrini

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote:
> Should it? Is it possible to write a doesexists.php script which would
> cause the 404 directive to be triggered?
>
> I also tried: header("Status: 404 Not Found"); but this did not work either.

Try searching the archives for this list, I'm sure this question, or one
very similar to it, was asked and answered fairly recently.

Paul

--
Rogue Tory
http://www.roguetory.org.uk

attached mail follows:


Paul Waring wrote:
> On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote:
>
>>Should it? Is it possible to write a doesexists.php script which would
>>cause the 404 directive to be triggered?
>>
>>I also tried: header("Status: 404 Not Found"); but this did not work either.
>
>
> Try searching the archives for this list, I'm sure this question, or one
> very similar to it, was asked and answered fairly recently.

I believe I found the thread you were referring to, but it does not
provide the answer that I found actually works.

Since my goal is _strictly_ and _only_ to get the 404 directive
triggered and _absolutely_ nothing more, the solution I found was for
doesexists.php to use the Location directive to redirect to a page which
I know does not exist.

This, obviously, triggers the 404 directive as I wanted.

Problem solved.

--
== Eric Gorr =============================== http://www.ericgorr.net ===
"Those who would sacrifice a little freedom for temporal safety
deserve neither to be safe or free." - Benjamin Franklin
== Insults, like violence, are the last refuge of the incompetent... ===

attached mail follows:


Paul Waring wrote:

>On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote:
>
>
>>Should it? Is it possible to write a doesexists.php script which would
>>cause the 404 directive to be triggered?
>>
>>I also tried: header("Status: 404 Not Found"); but this did not work either.
>>
>>
>
>Try searching the archives for this list, I'm sure this question, or one
>very similar to it, was asked and answered fairly recently.
>
>Paul
>
>
header('HTTP/1.0 404 Not Found');

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005

attached mail follows:


On 8 Aug 2005, at 16:07, Martin van den Berg wrote:

> $query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";
> $rows = execute( $query )
> if ( $rows == 0 )
> {
> /* some more processing */
> $query = "INSERT INTO mytable ...... etc etc
> execute( $query )
> }

I have lots of places where I used to do this. Since MySQL 4.1 I've
changed it to something like:

"INSERT INTO mytable SET id = 123, bla = '$x' ON DUPLICATE KEY UPDATE
bla='$x'"

This saves you a query, and makes it easier to isolate the insert/
update as it will play nicely with autocommit.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcussynchromedia.co.uk | http://www.synchromedia.co.uk

attached mail follows:


> I have lots of places where I used to do this. Since MySQL 4.1 I've
> changed it to something like:
>
> "INSERT INTO mytable SET id = 123, bla = '$x' ON DUPLICATE KEY UPDATE
> bla='$x'"
>
> This saves you a query, and makes it easier to isolate the insert/
> update as it will play nicely with autocommit.
>

Neat construction but in my case, id is an auto-increment field... so
I guess your example won't work since I never get a duplicate key.

attached mail follows:


Hello to all,

I'm working on a server where even a simple counter-script won't work.

session_start();
if (isset($HTTP_SESSION_VARS['counter'])) {
    $HTTP_SESSION_VARS['counter']++;
} else {
    $HTTP_SESSION_VARS['counter']=1;
}

On every refresh the counter is set to 1.

I dont' know, where to search for the reasons.
The server is a normal service providers server. My customers site is
using sessions and they are working on his site.
My script lays in a subdirectory of my costumers site, protected with a
.htaccess.:
The PHP-Version is 4.0.6.
The values for the session-parameters are, as far as I see, standard:
session.save_handler: files
session.save_path: /tmp

Register-globals is set to on.

Has anybody an idea where the problem lays?
Is it possible that I don' have the right to write into the /tmp-directory?

It would be very nice of you to give me some tips. I don't want to ask
my customer silly questions.

Thanks in advance
Sabine

attached mail follows:


Sabine wrote:
> Hello to all,
>
> I'm working on a server where even a simple counter-script won't work.
>
> session_start();
> if (isset($HTTP_SESSION_VARS['counter'])) {
> $HTTP_SESSION_VARS['counter']++;
> } else {
> $HTTP_SESSION_VARS['counter']=1;
> }
>
> On every refresh the counter is set to 1.
>

I take it this is not inside a function? have you tried using var_dump()
to output $HTTP_SESSION_VARS?

you may be stuck with doing things the old session_register() way rather than
using $HTTP_SESSION_VARS (or preferably $_SESSION - if you had a version of php at
your disposal that had that.)

> I dont' know, where to search for the reasons.
> The server is a normal service providers server. My customers site is
> using sessions and they are working on his site.

I would suggest that you go thru his code line by line to figure out
how it works.

also check out this page:
http://php.net/manual/en/function.session-set-cookie-params.php

given that you want your own session on a specific subpath you will have to
do some more owkr than just start the session.

> My script lays in a subdirectory of my costumers site, protected with a
> .htaccess.:
> The PHP-Version is 4.0.6.

which idiot is setting 4.0.6 as a requirement - its old, has lots of bugs that
have been fixed in more recent versions and is full _known_ security issues
(which have also been fixed) ... upgrade is the sane thing to do.

if there is one other person on this list using 4.0.6 you'll be lucky. all
this means that your going to have a hard time getting things done - bottom line
this costs your customer more (you are passing on the cost right?)

> The values for the session-parameters are, as far as I see, standard:
> session.save_handler: files
> session.save_path: /tmp
>
> Register-globals is set to on.
>
> Has anybody an idea where the problem lays?
> Is it possible that I don' have the right to write into the /tmp-directory?

possible but unlikely, given that the main site works. try writing a file to /tmp.

>
> It would be very nice of you to give me some tips. I don't want to ask
> my customer silly questions.

your customer is requiring 4.0.6 - nothing you can ask could be sillier than that ;-)
(other than maybe asking to downgrade to php3)

>
> Thanks in advance
> Sabine
>

attached mail follows:


Am looking for code snippet to download file. It should be able to detect mime-types. Thanks.

--
Roger

---------------------------------------------------
Sign Up for free Email at http://ureg.home.net.my/
---------------------------------------------------

attached mail follows:


Roger Thomas wrote:
> Am looking for code snippet to download file. It should be able to detect mime-types. Thanks.

http://www.php.net/manual/en/function.header.php

attached mail follows:


Alan Milnes wrote:
> I'm interested in extracting a series of web pages from a Yahoo forum
> and storing them in a MySQL database so I can generate things like most
> number of posts etc. I've searched on Google but most of the links seem
> to be for email harversters!
>
> Anyone have any tips for where to look?

Well, you'd need something like cURL, HTTP_Client or Snoopy to get you
started at fetching files from the web.

Then its a matter of extracting the information (parsing out the tags).
Snoopy has this function that returns the plain text version of a page,
or you can use regular expressions or strip_tags.

 From here on out, its just normal PHP tasks of connecting to the
database, running your queries, etc.

Oh, Snoopy is snoopy.sf.net. HTTP_Client is in PEAR. cURL is at
php.net/curl

Regards,
Burhan

attached mail follows:


U might try omthing like this::

$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";

$result = mysql_query($query, $cnn) or die(mysql_error());
                                        
$totalRows_result = mysql_num_rows($result);
                                                
if($totalRows_result>0)
                                                
{

       //display error tht id already exists
}
else
{

   //insert code goes here
}

attached mail follows:


U might try omthing like this::

$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";

$result = mysql_query($query, $cnn) or die(mysql_error());
                                        
$totalRows_result = mysql_num_rows($result);
                                                
if($totalRows_result>0)
                                                
{

       //display error tht id already exists
}
else
{

   //insert code goes here
}

attached mail follows:


U might try omthing like this::

$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";

$result = mysql_query($query, $cnn) or die(mysql_error());
                                        
$totalRows_result = mysql_num_rows($result);
                                                
if($totalRows_result>0)
                                                
{

       //display error tht id already exists
}
else
{

   //insert code goes here
}

attached mail follows:


hi,

  can we implement postgres transactions with php.
if anyone knows the solution please reply back.

attached mail follows:


[snip]
  can we implement postgres transactions with php.
if anyone knows the solution please reply back.
[/snip]

Have you read http://www.php.net/postgres ?

attached mail follows:


Hi,

I have a site with some phone products. I want to search for a specific products. I use this:

SELECT product_id, product_name FROM products WHERE product_name LIKE '%$search_string%'

It works fine if the search string counts 1 word. But if the search string id counts 2 or 3 or more words it's not working.. How can i do this kind of search. I do not want a boolean search or a fulltext search.

Thabks for any help!

attached mail follows:


[snip]
I have a site with some phone products. I want to search for a specific
products. I use this:

SELECT product_id, product_name FROM products WHERE product_name LIKE
'%$search_string%'

It works fine if the search string counts 1 word. But if the search
string id counts 2 or 3 or more words it's not working.. How can i do
this kind of search. I do not want a boolean search or a fulltext
search.
[/snip]

If you don't want to do fulltext or boolean then you may have to
construct your query with several OR statements based on the number of
words entered into the search criteria.

attached mail follows:


At 08:54 AM 8/9/2005, virtualsoftwaregmail.com wrote:
>Hi,
>
>I have a site with some phone products. I want to search for a specific
>products. I use this:
>
>SELECT product_id, product_name FROM products WHERE product_name LIKE
>'%$search_string%'
>
>It works fine if the search string counts 1 word. But if the search string
>id counts 2 or 3 or more words it's not working.. How can i do this kind
>of search. I do not want a boolean search or a fulltext search.
>
>Thabks for any help!

A lot of this depends on how your site is constructed and the kind of
products you're offering.

split() the string, strip out any noise words, then use the array
processing features of PHP to build the WHERE condition so you end up with
     WHERE product_name LIKE 'arrSearch[1]' OR product_name LIKE
'arrSeach[2]' ... and so forth

I think that would be deadly slow -- you're essentially abandoning any
indexes and doing a sequential read of the database. If MySQL, does it have
string search functions - InString() or InArray()

You might also reconsider your search criteria - offer a series of combo
boxes from which user makes a selection. Then you can construct the query
from the combo box choices.

If the database is MySQL, and you have general description fields, what's
wrong with indexed text search? It's pretty fast.

Or abandon search altogether, and present groups of products, user clicks
on a group which opens up the sub-group with more detailed choices -
usually specific products. See http://www.leevalley.com . The advantage of
this is it exposes the user to associated products.

By the way - how is a search not Boolean? Except for fairly sophisticated
fuzzy logic applications you're either found something or not. (How about
search with three levels? Teenage child - goes out, thrashes around, comes
back with something close, or nothing; Father - more purposeful, but unless
the item is where he last laid it down no hope of retrieval; Mother- here
it is.)

Of semi-fuzzy - you asked for gray, but here's the same thing in a
wonderful orange.

Cheers - Miles

attached mail follows:


>
> I have a site with some phone products. I want to search for
> a specific products. I use this:
>
> SELECT product_id, product_name FROM products WHERE
> product_name LIKE '%$search_string%'
>
> It works fine if the search string counts 1 word. But if the
> search string id counts 2 or 3 or more words it's not
> working.. How can i do this kind of search. I do not want a
> boolean search or a fulltext search.

If you have decided to abandon MySQL's search functions, you will probably
need to do something like this:

$searchtype = "OR"; // Ask the user for preference 'AND' or 'OR'
$pieces=explode(' ',$searchstring);
$sql="select * from inventory where ";
foreach($pieces as $thispiece){
  $sql .= "description like '%".$thispiece."%' ".$searchtype;
}

...to build a query string. Of course you will probably want to look at the
search terms for unnecessary words and definately protect yourself from SQL
injection, but this is the general idea.

>
> Thabks for any help!

Thabk you for askibg! ;-)

JM

 

attached mail follows:


I seem to be having some trouble renaming a file after uploading it.

It always returns a warning message indicating I have an invalid
attribute in my rename statement.

 

Thanks,

Dave

 

-------------------

Example:

 

$old = 'C:\\homedirectory\uploadedfiles\\newfile.gif';

$new = 'C:\\homedirectory\\uploadedfiles\\2005-08-05-09:00:00.gif';

move_uploaded_file(temp fileuploaded, $old);

rename($old,$new);

 

 

 

 

 

 

HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.

attached mail follows:


Bosky, Dave wrote:
> I seem to be having some trouble renaming a file after uploading it.
>
> It always returns a warning message indicating I have an invalid
> attribute in my rename statement.
<snip>
> $old = 'C:\\homedirectory\uploadedfiles\\newfile.gif';
>
> $new = 'C:\\homedirectory\\uploadedfiles\\2005-08-05-09:00:00.gif';
>
> move_uploaded_file(temp fileuploaded, $old);
>
> rename($old,$new);

Colons (:) are not allowed in Windows filenames.

Also, you don't need to escape the backslashes when using single quotes.

-Stuart

attached mail follows:


Hi ,

This time I'm trying to add support for compressed files
into the PHP module version 4.3.4 running with Apache 1.3.29

I remember adding dbase and mysql support with the following command

> './configure' '--with-mysql' '--with-apxs=/usr/local/apache/bin/apxs'
> '-enable-dbase'

Now I need to be able to create .zip files from within my php scripts,so
my questions are:

1 ) Which command should I use when recompiling ?

2 ) Is it possible to save my actual compiled module just in case the
new one has any problem?

Thanks a lot
Mauricio