php-general Digest 19 Jan 2003 03:23:15 -0000 Issue 1831

Topics (messages 132094 through 132157):

Re: Select multiple boxes
        132094 by: Cal Evans
        132097 by: Gregory Chagnon
        132098 by: John W. Holmes
        132099 by: Cal Evans

Re: Ever complained about lousy PHP programmers?
        132095 by: michael kimsal

Re: Sessions or Cookies?
        132096 by: Chris Hewitt
        132102 by: Brad Pauly
        132125 by: Chris Shiflett

2 Qs: Passing current URL with session and how to avoid session timeout???
        132100 by: -<[ Rene Brehmer ]>-
        132101 by: Cal Evans
        132127 by: Chris Shiflett
        132137 by: John W. Holmes
        132147 by: Justin French

Can I use php to load a icon?????(.ico .exe .....)
        132103 by: hei
        132105 by: Cal Evans

Re: Converting accented characters or numeric equivalents to non-accented
        132104 by: -<[ Rene Brehmer ]>-
        132108 by: Chris Hewitt
        132113 by: Ian M. Evans
        132114 by: Ernest E Vogelsinger
        132115 by: Ernest E Vogelsinger
        132116 by: Ian M. Evans
        132118 by: Paul Roberts
        132124 by: Ian M. Evans

Does remote file(image) exist ?
        132106 by: Stephen of Blank Canvas
        132107 by: Andrew Brampton
        132110 by: pan

Re: Number Sign in String Variables
        132109 by: Joab Stieglitz
        132112 by: Brad Pauly
        132133 by: Joab Stieglitz
        132135 by: John W. Holmes
        132140 by: Steve Edberg
        132141 by: Joab Stieglitz

hyperlink and mySQL
        132111 by: M.E. Suliman
        132134 by: Bobby Patel

Logfile statistics - get words from position between other words
        132117 by: Svein O. Bennæs
        132119 by: Sean Burlington

passing variables to a sql statement
        132120 by: jennifer
        132123 by: Jason Wong
        132131 by: John W. Holmes
        132139 by: Bobby Patel
        132157 by: Tom Rogers

Multiple sizes for products
        132121 by: icaam.icaam.com.ar
        132130 by: John W. Holmes
        132143 by: Hugh Danaher

Auto Incrementing in PHP
        132122 by: Don Mc Nair
        132129 by: John W. Holmes
        132136 by: Bobby Patel
        132149 by: Justin French

Re: Check for start_sessoin without causing header problems
        132126 by: Chris Shiflett

PGP signing text from called from PHP
        132128 by: {R}ichard Ashton

File perms when dir already exists
        132132 by: rw.xend.net

Re: Number Sign in String Variables]
        132138 by: Brad Pauly

SQL+php
        132142 by: Paul Marinas
        132144 by: John W. Holmes
        132145 by: Sean Malloy
        132146 by: John W. Holmes
        132148 by: Paul Marinas
        132151 by: Sean Malloy
        132152 by: Paul Marinas
        132153 by: Justin French
        132154 by: Paul Marinas

Re: Free PHP Hosts?
        132150 by: David T-G

Changing order of just one array item?
        132155 by: Leif K-Brooks
        132156 by: Timothy Hitchens \(HiTCHO\)

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
whoops. Sorry, didn't read the question. Wrong answer. John gave the correct
answer.

=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-----Original Message-----
From: Cal Evans [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 18, 2003 8:41 AM
To: Gregory Chagnon; [EMAIL PROTECTED]
Subject: RE: [PHP] Select multiple boxes


use [] in your select box name. When it comes back in the $_POST array you
will have an array of options.  It breaks HTML standard therefore it is a
Bad Thing (tm) but it does work.

<SELECT name="mySelect[]" multi >
<option name='1'>Don't pick me</option>
<option name='2'>Pick me</option>
</select>

Selecting both results in:

$_POST['mySelect'][1] == "Don't pick me"
$_POST['mySelect'][2] == "Pick me"

HTH,
=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-----Original Message-----
From: Gregory Chagnon [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 17, 2003 11:14 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Select multiple boxes


Hi-
Is there any way to get all of the elements in a SELECT MULTIPLE box, not
just the ones that are selected?  Thanks!
-Greg



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


--- End Message ---
--- Begin Message ---
The problem is I have 2 seelect boxes...it's for creating a user and adding
them to a list of available groups...so I have one select box that is
initially empty called memberOf and another box that has all of the
available groups listed in it called availableGroups.  I have a script that
can move items back and forth and when the form is submitted I want to be
able to get all the items that are in the memberOf box..anyh ideas on how to
to this?  THanks.
-Greg


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
000501c2bf01$46464cc0$7c02a8c0@coconut">news:000501c2bf01$46464cc0$7c02a8c0@coconut...
> > Is there any way to get all of the elements in a SELECT MULTIPLE box,
> not
> > just the ones that are selected?  Thanks!
>
> No. You create the box, so you should know all of the possible values.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>


--- End Message ---
--- Begin Message ---
> The problem is I have 2 seelect boxes...it's for creating a user and
> adding
> them to a list of available groups...so I have one select box that is
> initially empty called memberOf and another box that has all of the
> available groups listed in it called availableGroups.  I have a script
> that
> can move items back and forth and when the form is submitted I want to
be
> able to get all the items that are in the memberOf box..anyh ideas on
how
> to
> to this?  THanks.

Well, you create the "memberOf" box, right? How do you do that? At the
same time, create a javascript or hidden variable that has its contents
to be passed along with the form. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
What you are describing is a "2 List Mover". PHP is a server-side language
and as such knows nothing about what is going on on the client. Therefore
you have limited options. My favorite is :

In your form's onSubmit() put code to load all the values into a hidden
field. (Assuming you have defined the hidden field)

<hidden name="StoreStuffhere">

in your JavaScript put things like

document.mainForm.storeStuffHere.value += "storeStuffHere[1]='Value1'";
document.mainForm.storeStuffHere.value += "storeStuffHere[2]='Value2'";
document.mainForm.storeStuffHere.value += "storeStuffHere[3]='Value3'";

Then, when the form is submitted use:

parse_str($_POST['storeStuffHere']);

This will create the array storeStuffHere with the 3 values.

HTH,
=C=
*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-----Original Message-----
From: Gregory Chagnon [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 18, 2003 9:31 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Select multiple boxes


The problem is I have 2 seelect boxes...it's for creating a user and adding
them to a list of available groups...so I have one select box that is
initially empty called memberOf and another box that has all of the
available groups listed in it called availableGroups.  I have a script that
can move items back and forth and when the form is submitted I want to be
able to get all the items that are in the memberOf box..anyh ideas on how to
to this?  THanks.
-Greg


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
000501c2bf01$46464cc0$7c02a8c0@coconut">news:000501c2bf01$46464cc0$7c02a8c0@coconut...
> > Is there any way to get all of the elements in a SELECT MULTIPLE box,
> not
> > just the ones that are selected?  Thanks!
>
> No. You create the box, so you should know all of the possible values.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>



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


--- End Message ---
--- Begin Message ---
Olinux wrote:
I prefer single quotes on stuff that doesn't need to
be parsed. In most cases this is more efficient,
though probably not noticed except on a large scale.
I also think it makes it easier to include html
strings (because double quotes don't need to be
escaped) and I find it easier to work my code in
Homesite.

echo '<p>'.$something.' '.$something_else.'</p>';
rather than echo "<p>$something $something_else</p>";


Both the zend accelerator (lower price for small businesses now)
and the ioncube system (free) optimize any minor
double-quote performance out after the first run, so it
should be a non-issue for more and more people.  Additionally,
as you mention, it's really only an issue on largescale
system (or systems under heavy load).

It's completely a comfortability issue - I personally
find the double-quoted version easier both to read and
to type.  It's not my favorite use of time to do extra
typing just to try to shave off 2 tenths of a millisecond
for the processor - computers are here to make life
easier (supposedly!)  :0

Michael Kimsal
LogiCreate
http://www.phpappserver.com
734-480-9961

--- End Message ---
--- Begin Message ---
Peter Janett wrote:

Sessions themselves use cookies, though, right?  So, if you want your app to
work for those who don't have cookies, you have to pass the session data in
the url string, at least that's my understanding.

With sessions, its only the session ID that is put in the cookie or url string. The session data stays on the server (usually in a file in /tmp). Its more secure than putting your data out to the client browser where it could be altered before being returned.

Regards

Chris

--- End Message ---
--- Begin Message ---
> Sessions themselves use cookies, though, right?  So, if you want your app to
> work for those who don't have cookies, you have to pass the session data in
> the url string, at least that's my understanding.

Cookies are used by default. However, if cookies are disabled in a
client, a session identifier will be passed via URL variable unless
session.use_only_cookies is enabled in php.ini.

Brad


--- End Message ---
--- Begin Message ---
--- Peter Janett <[EMAIL PROTECTED]> wrote:
> Sessions themselves use cookies, though, right?
> So, if you want your app to work for those who
> don't have cookies, you have to pass the session
> data in the url string, at least that's my
> understanding.

That's not quite right.

Session management requires an existing method of state
management. The default state management mechanism used by
PHP is indeed cookies, but that is not the only way. All
that is required for state management is that you assign
the Web client a unique identifier that it includes on
subsequent requests. Cookies make this easy and are
somewhat "automatic" in PHP, but GET and POST variables can
also be used.

For example, say you normally depend on a cookie to
identify the client. This will probably be something like
PHPSESSID=12345. The following link would send the same
unique identifier as a GET variable:

<a href="./example.php?PHPSESSID=12345">Click Here</a>

Unless you have PHP configured to only use cookies to
identify the client (which I think is not the default
setting anyway), it will use the PHPSESSID when sent on the
URL like this. In fact, you can configure PHP to append the
unique identifier to the URL automatically if the client
does not accept cookies. Just set session.use_trans_sid to
1 in your php.ini file if you compiled PHP with
--enable_trans_sid.

As I hope is clear, none of this requires that any client
data be passed on the URL, in cookies, or anything else.
The only data that should be sent by the client is data
necessary for client identification. All other data can
(and should in most cases) be stored on the server.

Chris
--- End Message ---
--- Begin Message ---
Hi gang

Been trying to figure out this session stuff, but since I was unable to
make the manual sample into something workable, I instead decided to
actually try and make the session do what I need it for: Passing the URL
of the caller page to the page that's being called.

1. Only I can't figure out if there's a function to just pull the current
URL and plop it into a session variable. The thing is that these pages are
all built by using a bunch of GET variables in the URL, so it would be
easiest to just do something like:

  $_SESSION['mother'] = $currentURL;

And then in the called, daughter, page do this:

<a href=<?php echo("\"$_SESSION['mother']\"") ?>>Get back to where you
came from</a>

As the only other way I've found is to have it use the string-functions
and re-build the current URL throughout the if-tree that builds the page.
I need to pass the mother URL to the daughter pages because there's two
main entry-points into the daugther pages, and one of them can have 10-15
different states...

But how do you pull the current url? ParseURL just smacks it into an
array, and I'll then have to rebuild it anyway ... which makes it about
just as simple as running it through the if-tree. Whether or not the
session-id is inside the URL is not essential to me, but dunno if php
cares about it.

2. Since the above is required to function at all times, I need to
override the expiration time. I can't do it in the ini file, 'cause I
can't modify the server where it's to run, and it's set to 0 there... (not
sure if that means it expires right away, or not at all)

Anyway to do this???

TIA

Rene
-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net
--- End Message ---
--- Begin Message ---
I guess I'm dense this morning. In response to 1:

$_SESSION['mother']=$_SERVER['PHP_SELF'];

and then

<a href="<?PHP echo $_SESSION['mother'];?>">Go Back</a>

or better yet...
<a href="<?PHP echo $_SERVER['PHP_SELF'];?>">Go Back</a>

as to #2:
I usually just pass this kind of info around on the URL.

http://mypage.com/mypage.php?prevURL=http://mypage.com/lastpage.php

if I have to pass a full query string then I urlencode() it first and
urldecode() it on the other side.

This survives sessions expiring.
=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-----Original Message-----
From: -<[ Rene Brehmer ]>- [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 18, 2003 10:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] 2 Qs: Passing current URL with session and how to avoid
session timeout???


Hi gang

Been trying to figure out this session stuff, but since I was unable to
make the manual sample into something workable, I instead decided to
actually try and make the session do what I need it for: Passing the URL
of the caller page to the page that's being called.

1. Only I can't figure out if there's a function to just pull the current
URL and plop it into a session variable. The thing is that these pages are
all built by using a bunch of GET variables in the URL, so it would be
easiest to just do something like:

  $_SESSION['mother'] = $currentURL;

And then in the called, daughter, page do this:

<a href=<?php echo("\"$_SESSION['mother']\"") ?>>Get back to where you
came from</a>

As the only other way I've found is to have it use the string-functions
and re-build the current URL throughout the if-tree that builds the page.
I need to pass the mother URL to the daughter pages because there's two
main entry-points into the daugther pages, and one of them can have 10-15
different states...

But how do you pull the current url? ParseURL just smacks it into an
array, and I'll then have to rebuild it anyway ... which makes it about
just as simple as running it through the if-tree. Whether or not the
session-id is inside the URL is not essential to me, but dunno if php
cares about it.

2. Since the above is required to function at all times, I need to
override the expiration time. I can't do it in the ini file, 'cause I
can't modify the server where it's to run, and it's set to 0 there... (not
sure if that means it expires right away, or not at all)

Anyway to do this???

TIA

Rene
--
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

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


--- End Message ---
--- Begin Message ---
--- Cal Evans <[EMAIL PROTECTED]> wrote:
> I usually just pass this kind of info around on the URL.
> 
>
http://mypage.com/mypage.php?prevURL=http://mypage.com/lastpage.php
> 
> if I have to pass a full query string then I urlencode()
> it first and urldecode() it on the other side.

Just as a bit of advice, you should always URL encode any
data you want to append to the URL like that. Also,
decoding it is superfluous, because the Web server will do
that for you (since URL data is supposed to be URL
encoded).

Chris
--- End Message ---
--- Begin Message ---
1. You can "create" the current page with a combination of PHP_SELF,
QUERY_STRING, etc... Take a look at a phpinfo() page to see all of the
variables. 

2. You can use ini_set() in your code to change the settings for your
sessions or an .htaccess file if your on *nix. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -----Original Message-----
> From: -<[ Rene Brehmer ]>- [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 18, 2003 11:04 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] 2 Qs: Passing current URL with session and how to avoid
> session timeout???
> 
> Hi gang
> 
> Been trying to figure out this session stuff, but since I was unable
to
> make the manual sample into something workable, I instead decided to
> actually try and make the session do what I need it for: Passing the
URL
> of the caller page to the page that's being called.
> 
> 1. Only I can't figure out if there's a function to just pull the
current
> URL and plop it into a session variable. The thing is that these pages
are
> all built by using a bunch of GET variables in the URL, so it would be
> easiest to just do something like:
> 
>   $_SESSION['mother'] = $currentURL;
> 
> And then in the called, daughter, page do this:
> 
> <a href=<?php echo("\"$_SESSION['mother']\"") ?>>Get back to where you
> came from</a>
> 
> As the only other way I've found is to have it use the
string-functions
> and re-build the current URL throughout the if-tree that builds the
page.
> I need to pass the mother URL to the daughter pages because there's
two
> main entry-points into the daugther pages, and one of them can have
10-15
> different states...
> 
> But how do you pull the current url? ParseURL just smacks it into an
> array, and I'll then have to rebuild it anyway ... which makes it
about
> just as simple as running it through the if-tree. Whether or not the
> session-id is inside the URL is not essential to me, but dunno if php
> cares about it.
> 
> 2. Since the above is required to function at all times, I need to
> override the expiration time. I can't do it in the ini file, 'cause I
> can't modify the server where it's to run, and it's set to 0 there...
(not
> sure if that means it expires right away, or not at all)
> 
> Anyway to do this???
> 
> TIA
> 
> Rene
> --
> Rene Brehmer
> 
> This message was written on 100% recycled spam.
> 
> Come see! My brand new site is now online!
> http://www.metalbunny.net
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
1. If you require the back button to work forever, then do not use sessions,
because they're not designed to be a forever thing.


2. I do this sort of stuff by building my own URL from $_SERVER components:

<?
$script = $_SERVER['PHP_SELF'];
$qs = $_SERVER['QUERY_STRING'];
$currentURL = base64_encode($script."?".$qs);
?>

The reason why I base64_encode() it is so that the vars=values of the
previous page don't affect the next page.

I the link to the second page might be something like:

<a href="page.php?ref=<?=$currentURL?>">click</a>

on page.php, to establish a back button:

<? $ref = base64_decode($ref) ?>
<a href="<?=$ref?>">go back</a>


3.  This way, the referring/mother URL is always attached to that URL... if
they bookmark it, of give it to a friend, it's always there... sessions
don't achieve this, and cookies usually can, apart from the usual cookie
problems.


CHeers,

Justin


on 19/01/03 3:03 AM, -<[ Rene Brehmer ]>- ([EMAIL PROTECTED]) wrote:

> Hi gang
> 
> Been trying to figure out this session stuff, but since I was unable to
> make the manual sample into something workable, I instead decided to
> actually try and make the session do what I need it for: Passing the URL
> of the caller page to the page that's being called.
> 
> 1. Only I can't figure out if there's a function to just pull the current
> URL and plop it into a session variable. The thing is that these pages are
> all built by using a bunch of GET variables in the URL, so it would be
> easiest to just do something like:
> 
> $_SESSION['mother'] = $currentURL;
> 
> And then in the called, daughter, page do this:
> 
> <a href=<?php echo("\"$_SESSION['mother']\"") ?>>Get back to where you
> came from</a>
> 
> As the only other way I've found is to have it use the string-functions
> and re-build the current URL throughout the if-tree that builds the page.
> I need to pass the mother URL to the daughter pages because there's two
> main entry-points into the daugther pages, and one of them can have 10-15
> different states...
> 
> But how do you pull the current url? ParseURL just smacks it into an
> array, and I'll then have to rebuild it anyway ... which makes it about
> just as simple as running it through the if-tree. Whether or not the
> session-id is inside the URL is not essential to me, but dunno if php
> cares about it.
> 
> 2. Since the above is required to function at all times, I need to
> override the expiration time. I can't do it in the ini file, 'cause I
> can't modify the server where it's to run, and it's set to 0 there... (not
> sure if that means it expires right away, or not at all)
> 
> Anyway to do this???
> 
> TIA
> 
> Rene

--- End Message ---
--- Begin Message ---
Can I use php to load a icon?????(.ico .exe .....)


--- End Message ---
--- Begin Message ---
exactly how do you "load" an icon?  What are you loading it into?

=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*
 

-----Original Message-----
From: hei [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 31, 2001 3:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Can I use php to load a icon?????(.ico .exe .....)


Can I use php to load a icon?????(.ico .exe .....)



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


--- End Message ---
--- Begin Message ---
Hi Ian M. Evans,

On Fri, 17 Jan 2003 14:04:15 -0500, you wrote about "[PHP] Converting
accented characters or numeric equivalents to non-accented" something that
looked like this:

>Does anyone have a quick PHP function for converting accented characters to
>their non-accented forms? It would really help a lot with Amazon searches,
>etc.

Not sure about quick, but the only way I've found that works with 100%
guarantee everytime is to take the string and check it character by
character, and if the ascii value is > 128, simply replace it with the
ascii value marker...

something like this (untested):

for ($i = 0; $i < strlen($string_to_parse); $i++) {
  $char = substr($string_to_parse, $i, 1);
  if (ord($char) > 128) {
    $output_string .= "&#".ord($char).";";
  }
  else {
    $output_string .= $char;
  }
}

You may need to test for value 127 ... not sure if it starts on 0 or 1
that is...

The above structure is what I use constantly to do this...

HTH

Rene

-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net
--- End Message ---
--- Begin Message ---
-<[ Rene Brehmer ]>- wrote:

something like this (untested):

for ($i = 0; $i < strlen($string_to_parse); $i++) {
 $char = substr($string_to_parse, $i, 1);
 if (ord($char) > 128) {
   $output_string .= "&#".ord($char).";";
 }
 else {
   $output_string .= $char;
 }
}

You may need to test for value 127 ... not sure if it starts on 0 or 1
that is...

127 is the last of the 7bit numbers (01111111), 128 has the 8th bit on (10000000), so perhaps you want to test for > 127 rather than > 128.

Regards

Chris

--- End Message ---
--- Begin Message ---
Rene:

Thanks for the response. I guess I wasn't too clear in my original post. I'm
not looking to turn an accented letter into its numeric equivalent, I'm
looking to strip the accent so that Renée Zellweger becomes Renee Zellweger.

Any thoughts there?

--- End Message ---
--- Begin Message ---
At 17:25 18.01.2003, -<[ Rene Brehmer ]>- said:
--------------------[snip]--------------------
>Not sure about quick, but the only way I've found that works with 100%
>guarantee everytime is to take the string and check it character by
>character, and if the ascii value is > 128, simply replace it with the
>ascii value marker...
>
>something like this (untested):
>
>for ($i = 0; $i < strlen($string_to_parse); $i++) {
>  $char = substr($string_to_parse, $i, 1);
>  if (ord($char) > 128) {
>    $output_string .= "&#".ord($char).";";
>  }
>  else {
>    $output_string .= $char;
>  }
>}
>
>You may need to test for value 127 ... not sure if it starts on 0 or 1
>that is...
--------------------[snip]-------------------- 

preg_replace('([\x80-\xff])/e', '&#'.ord('\1').';', $string_to_parse);



-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
At 19:11 18.01.2003, Ian M. Evans said:
--------------------[snip]--------------------
>Thanks for the response. I guess I wasn't too clear in my original post. I'm
>not looking to turn an accented letter into its numeric equivalent, I'm
>looking to strip the accent so that Renée Zellweger becomes Renee Zellweger.
--------------------[snip]-------------------- 

$chars_in = array('Á',''á','É','é');  // you get it
$chars_out = array('A','a','E','e');  // this too
preg_replace($chars_in, $chars_out, $string_to_parse);


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
Ernest E. Vogelsinger suggested:
>$chars_in = array('Á',''á','É','é');  // you get it
>$chars_out = array('A','a','E','e');  // this too
>preg_replace($chars_in, $chars_out, $string_to_parse);

I initially got a 'no ending delimiter' error but after adding /'s to the
$chars_in it was just what the doctor ordered.

I'm actually a little surprised that there isn't a built-in function, say,
strip_accent(). I'd assume a lot of people would need this at some time or
another.

--- End Message ---
--- Begin Message ---
another one for you

function removeaccents($string) {
   return strtr($string,
     "SOZsozY¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
     "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
}

Best Wishes & Happy New Year

Paul Roberts
[EMAIL PROTECTED]
++++++++++++++++++++++++
----- Original Message ----- 
From: "Ian M. Evans" <[EMAIL PROTECTED]>
To: "Ernest E Vogelsinger" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 6:41 PM
Subject: RE: [PHP] Converting accented characters or numeric equivalents to 
non-accented


Ernest E. Vogelsinger suggested:
>$chars_in = array('Á',''á','É','é');  // you get it
>$chars_out = array('A','a','E','e');  // this too
>preg_replace($chars_in, $chars_out, $string_to_parse);

I initially got a 'no ending delimiter' error but after adding /'s to the
$chars_in it was just what the doctor ordered.

I'm actually a little surprised that there isn't a built-in function, say,
strip_accent(). I'd assume a lot of people would need this at some time or
another.


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




--- End Message ---
--- Begin Message ---
>return strtr($string, "SOZsozY...

Just curious why the search starts with unaccented "SOZsozY"?
--- End Message ---
--- Begin Message ---
Hi Everyone,
 
Sorry I have no example code at all for this at all, I know some people
don't like that but I just do not know where to start so am asking for
help.
 
I have a system there users can put a picture of themselves by method of
URL in a MySQL field, however many of this image URL's do not work as
users type them in wrong.  So what I wanted to do was find a way to test
to see if the image can be accessed, then if not display a default
image.
 
Hope that makes sense, anyone already done something like this and want
to share code :-)
 
Stephen
--- End Message ---
--- Begin Message ---
If you looked at the usercomments for file_exists you would see it saying to
look at the fopen page for a example....
In the usercomments for fopen there is a post saying this:

jamie.watt at murchison.com.au
03-Feb-2000 01:39
To check if a file exists using http or ftp use the following:

<pre>
$fp = @fopen("http://www.someurl.com/testfile.php3","r";);
if ($fp)
{ print"The file exists!"; }
else
{ print"The file does not exist"; }
</pre>

Note: The "@" in front of fopen suppresses the error output of the function.

I hope this clears up some confusion.

There is your answer :)


----- Original Message -----
From: "Stephen of Blank Canvas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 4:42 PM
Subject: [PHP] Does remote file(image) exist ?


> Hi Everyone,
>
> Sorry I have no example code at all for this at all, I know some people
> don't like that but I just do not know where to start so am asking for
> help.
>
> I have a system there users can put a picture of themselves by method of
> URL in a MySQL field, however many of this image URL's do not work as
> users type them in wrong.  So what I wanted to do was find a way to test
> to see if the image can be accessed, then if not display a default
> image.
>
> Hope that makes sense, anyone already done something like this and want
> to share code :-)
>
> Stephen
>

--- End Message ---
--- Begin Message ---
reply to both mail list and O.P.

----- Original Message ----- 
From: "Stephen of Blank Canvas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 08:42
Subject: [PHP] Does remote file(image) exist ?


> Hi Everyone,
>  
> Sorry I have no example code at all for this at all, I know some people
> don't like that but I just do not know where to start so am asking for
> help.
>  
> I have a system there users can put a picture of themselves by method of
> URL in a MySQL field, however many of this image URL's do not work as
> users type them in wrong.  So what I wanted to do was find a way to test
> to see if the image can be accessed, then if not display a default
> image.
>  
> Hope that makes sense, anyone already done something like this and want
> to share code :-)
>  
> Stephen
> 

Use curl, 
or
write a script that executes a telnet session that issues
HEAD commands

The key command is the "HEAD path-to-resource HTTP/1.0"

Most servers are HTTP/1.1, but using 1.0 keeps backward compatibility.

The path-to-resource is whatever the path is that would appear after the
domain in the url.

You would want to split the submitted URL into domain and path.

You issue the telnet to $domain at port 80
"telnet $domain 80"

You issue the HEAD command
"HEAD /path-to-resource HTTP/1.0"

What follows is the servers response. I've included live
examples of both a 200 response (resource exists)
and a 404 response (resource does not exist).

Parse the responses and you will know that something
exists or not.

# telnet $domain 80
Trying {ip address}...
Connected to $domain
Escape character is '^]'.
HEAD /pov/box.png HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 18 Jan 2003 17:30:12 GMT
Server: Apache/1.3.27 (Unix) PHP/4.2.3
Last-Modified: Fri, 13 Dec 2002 23:29:56 GMT
ETag: "32e005-8c1d-3dfa6d74"
Accept-Ranges: bytes
Content-Length: 35869
Connection: close
Content-Type: image/png

Connection closed by foreign host.
# telnet $domain 80
Trying {ip address}...
Connected to $domain
Escape character is '^]'.
HEAD /pov/box1.png HTTP/1.0

HTTP/1.1 404 Not Found
Date: Sat, 18 Jan 2003 17:30:58 GMT
Server: Apache/1.3.27 (Unix) PHP/4.2.3
Connection: close
Content-Type: text/html; charset=iso-8859-1

Connection closed by foreign host.

--- End Message ---
--- Begin Message ---
OK.  I found the problem, and it isn't PHP or MySQL related.  It's an HTML
problem.  I'm passing the string from one script to another, and the # sign
is screwing up the URL.

For example, this URL:

add_to_cart.php?item_num=SOU3432410&quantity=1&sale_price=24.92&unit=BX
&short_desc=ENVELOPE,25%COT 24#,IY&wholesaler=US&cost=18.690

gets cut off at the # sign, so $wholesaler and $cost come out empty.

Any suggestions to get around this?


--- End Message ---
--- Begin Message ---
> For example, this URL:
> 
> add_to_cart.php?item_num=SOU3432410&quantity=1&sale_price=24.92&unit=BX
> &short_desc=ENVELOPE,25%COT 24#,IY&wholesaler=US&cost=18.690
> 
> gets cut off at the # sign, so $wholesaler and $cost come out empty.
> 
> Any suggestions to get around this?

You could use urlencode() and urldecode().

http://www.php.net/manual/en/function.urlencode.php
http://www.php.net/manual/en/function.urldecode.php

Brad


--- End Message ---
--- Begin Message ---
OK.  I urlencoded the URL and now the URL passes correctly...

add_to_cart.php%3Fitem_num%3DSTT32700%26quantity%3D1%26sale_price%3D52.78%26
unit%3DBX%26short_desc%3DENVELOPE%2C100%25COT%2024%23%2CGY%26wholesaler%3DUS
%26cost%3D37.700

... but I get the following error:

Forbidden
You don't have permission to access
/carmae/add_to_cart.php?item_num=STT32700&quantity=1&sale_price=52.78&unit=B
X&short_desc=ENVELOPE,100%COT 24#,GY&wholesaler=US&cost=37.700 on this
server.

I've never seen anything like this before.

Suggestions?

"Brad Pauly" <[EMAIL PROTECTED]> wrote in message
1042912825.15063.33.camel@earth">news:1042912825.15063.33.camel@earth...
> > For example, this URL:
> >
> > add_to_cart.php?item_num=SOU3432410&quantity=1&sale_price=24.92&unit=BX
> > &short_desc=ENVELOPE,25%COT 24#,IY&wholesaler=US&cost=18.690
> >
> > gets cut off at the # sign, so $wholesaler and $cost come out empty.
> >
> > Any suggestions to get around this?
>
> You could use urlencode() and urldecode().
>
> http://www.php.net/manual/en/function.urlencode.php
> http://www.php.net/manual/en/function.urldecode.php
>
> Brad
>
>


--- End Message ---
--- Begin Message ---
> OK.  I urlencoded the URL and now the URL passes correctly...
> 
>
add_to_cart.php%3Fitem_num%3DSTT32700%26quantity%3D1%26sale_price%3D52.7
8%
> 26
>
unit%3DBX%26short_desc%3DENVELOPE%2C100%25COT%2024%23%2CGY%26wholesaler%
3D
> US
> %26cost%3D37.700
> 
> ... but I get the following error:
> 
> Forbidden
> You don't have permission to access
>
/carmae/add_to_cart.php?item_num=STT32700&quantity=1&sale_price=52.78&un
it
> =B
> X&short_desc=ENVELOPE,100%COT 24#,GY&wholesaler=US&cost=37.700 on this
> server.
> 
> I've never seen anything like this before.

And the line you get that error looks like? It looks like you're trying
to fopen() a file that's made up of PHP_SELF and the QUERY_STRING.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message --- You need to urlencode() selectively; in this case, only the short_desc needs to be encoded, so you would have a statement something like

echo
"add_to_cart.php?item_num=$item_num&quantity=$quantity".
"&sale_price=$sale_price&unit=$unit&short_desc=".
url_encode($short_desc)."&wholesaler=$wholesaler&cost=$cost"
;

You need to encode any parameter (everything to the right of that first '?') that might include the '?', '&'. '#' or space characters, since those all mean something special in a URL. To be safe, it's best to encode everything - or at least all strings. However, you have to encode them individually, since you need the UNencoded '&' between them to delimit parameters, and you need that '?' there to indicate the start of the parameters.

I don't know the details of your program design, but there may be no reason to pass all the item details (description, sale price, etc.) in the URL anyway. Can't you just look them up in the add_to_card.php page, based on the item_num? Thus, all you need to pass are the quantity & item_number:

echo "add_to_cart.php?item_num=$item_num&quantity=$quantity";

For one thing, that would eliminated the possibility of someone trying to get everything for free by manually typing a URL like

add_to_cart.php?item_num=SOU3432410&quantity=1&sale_price=0&unit=...

-steve


At 6:29 PM -0500 1/18/03, Joab Stieglitz wrote:
OK.  I urlencoded the URL and now the URL passes correctly...

add_to_cart.php%3Fitem_num%3DSTT32700%26quantity%3D1%26sale_price%3D52.78%26
unit%3DBX%26short_desc%3DENVELOPE%2C100%25COT%2024%23%2CGY%26wholesaler%3DUS
%26cost%3D37.700

... but I get the following error:

Forbidden
You don't have permission to access
/carmae/add_to_cart.php?item_num=STT32700&quantity=1&sale_price=52.78&unit=B
X&short_desc=ENVELOPE,100%COT 24#,GY&wholesaler=US&cost=37.700 on this
server.

I've never seen anything like this before.

Suggestions?

"Brad Pauly" <[EMAIL PROTECTED]> wrote in message
1042912825.15063.33.camel@earth">news:1042912825.15063.33.camel@earth...
 > For example, this URL:
 >
 > > add_to_cart.php?item_num=SOU3432410&quantity=1&sale_price=24.92&unit=BX
 > > &short_desc=ENVELOPE,25%COT 24#,IY&wholesaler=US&cost=18.690
 >
 > gets cut off at the # sign, so $wholesaler and $cost come out empty.
 >
 > Any suggestions to get around this?

 You could use urlencode() and urldecode().

 http://www.php.net/manual/en/function.urlencode.php
 http://www.php.net/manual/en/function.urldecode.php

 Brad




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

--
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| SETI@Home: 1001 Work units on 23 oct 2002                              |
| 3.152 years CPU time, 3.142 years SETI user... and STILL no aliens...  |
+------------------------------------------------------------------------+
--- End Message ---
--- Begin Message ---
All I'm doing is making a hyperlink that sends the selected item from the
catalog to the add to shopping cart script.  The code now looks like this...

  $value = rawurlencode("add_to_cart.php?item_num=" . $item_num .
    "&quantity=1&sale_price=" . $our_price .
    "&unit=" . $unit .
    "&short_desc=" . $short_desc .
    "&wholesaler=" . $wholesaler .
    "&cost=" . $cost);

  echo "</td><td><a href=\"" . $value .
           "\" <img src=\"cart.jpg\">Add</a>\n</td></tr>";

... and executes the link when the user clicks on the shopping cart icon.

"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
002301c2bf4b$bc44c0b0$7c02a8c0@coconut">news:002301c2bf4b$bc44c0b0$7c02a8c0@coconut...

> And the line you get that error looks like? It looks like you're trying
> to fopen() a file that's made up of PHP_SELF and the QUERY_STRING.
>
> ---John W. Holmes...


--- End Message ---
--- Begin Message ---
Hi

I have created a simple script that pulls the three latest news entries from
a mySQL database and displays it on a webpage.   At the end of the preview
paragraph of the news story there is a hyperlink to access the full text
specific to that preview.  How would I do this?  Any ideas would be
appreciated.

Mohamed

--- End Message ---
--- Begin Message ---
I have done something similar:
write a script that takes an Article ID, and displays the text. So to
displat article #3, you would call it like getArticle.php?id=3.
Skelton for getArticle.php
- take id and store in $id
- Select FullBody from Articles where ID = $id
- $body = query['FullBody']
- then echo $body

That's the basic idea, if you have any problems email me and post to the
list.




"M.E. Suliman" <[EMAIL PROTECTED]> wrote in message
000f01c2bf1b$e95fff40$4abe1fc4@b1s0n2">news:000f01c2bf1b$e95fff40$4abe1fc4@b1s0n2...
> Hi
>
> I have created a simple script that pulls the three latest news entries
from
> a mySQL database and displays it on a webpage.   At the end of the preview
> paragraph of the news story there is a hyperlink to access the full text
> specific to that preview.  How would I do this?  Any ideas would be
> appreciated.
>
> Mohamed
>


--- End Message ---
--- Begin Message ---
I'm trying to write a script that extracts some search-queries from a
logfile, but I'm having problems finding the right function to solve this
problem.

Below you'll find 4 lines from the log - the words I'm trying to extract are
(for now) written in capital letters, and they are always found between the
expression "query=" and "&hits=".

Straightforward; I am trying to get everything between "query=" and "&hits="
on each line, and output statistics on different search queries on a web
page. Probably an easy thing to do, but I'm kinda stuck on this one...

*****

192.168.0.1 - - [20/Dec/2002:12:19:24 +0100] "GET
/cgi-bin/search?query=WORD&hits=10&offset=0&clustering=yes&type=all&version=
3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:25 +0100] "GET
/cgi-bin/search?query=ANOTHERWORD&hits=10&offset=0&clustering=yes&type=all&v
ersion=3.1.0 HTTP/1.1" 200 917 ""0.0150 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:27 +0100] "GET
/cgi-bin/search?query=YETANOTHERWORD&hits=10&offset=0&clustering=yes&type=al
l&version=3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:53 +0100] "GET
/cgi-bin/search?query=AGAINWITHTHEWORD&hits=10&offset=0&qtf_lemmatize=true&r
pf_clustering:enabled=1&rpf_clustering:root=%2A&clustering=yes&type=all&vers
ion=3.1.0 HTTP/1.1" 200 980 ""0.0310 0.0000 0.0000 0

*****

TIA

[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
Svein O. Bennæs wrote:
I'm trying to write a script that extracts some search-queries from a
logfile, but I'm having problems finding the right function to solve this
problem.

Below you'll find 4 lines from the log - the words I'm trying to extract are
(for now) written in capital letters, and they are always found between the
expression "query=" and "&hits=".

Straightforward; I am trying to get everything between "query=" and "&hits="
on each line, and output statistics on different search queries on a web
page. Probably an easy thing to do, but I'm kinda stuck on this one...

*****

192.168.0.1 - - [20/Dec/2002:12:19:24 +0100] "GET
/cgi-bin/search?query=WORD&hits=10&offset=0&clustering=yes&type=all&version=
3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:25 +0100] "GET
/cgi-bin/search?query=ANOTHERWORD&hits=10&offset=0&clustering=yes&type=all&v
ersion=3.1.0 HTTP/1.1" 200 917 ""0.0150 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:27 +0100] "GET
/cgi-bin/search?query=YETANOTHERWORD&hits=10&offset=0&clustering=yes&type=al
l&version=3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0

192.168.0.1 - - [20/Dec/2002:12:19:53 +0100] "GET
/cgi-bin/search?query=AGAINWITHTHEWORD&hits=10&offset=0&qtf_lemmatize=true&r
pf_clustering:enabled=1&rpf_clustering:root=%2A&clustering=yes&type=all&vers
ion=3.1.0 HTTP/1.1" 200 980 ""0.0310 0.0000 0.0000 0

*****
try this

<?

$line = '192.168.0.1 - - [20/Dec/2002:12:19:27 +0100] "GET/cgi-bin/search?query=YETANOTHERWORD&hits=10&offset=0&clustering=yes&type=all&version=3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0';
preg_match("/query=([^&]*)/", $line, $matches);

echo $matches[1];

?>




--- End Message ---
--- Begin Message ---
hi, i'm hoping someone can help me out here - im trying to pass a variable from a 
string in the href tag, however my sql breaks when i put a var in the statment.
when i replace $foo with a number, the page works fine. can someone please tell me 
what im doing wrong?

here is the error i get:

Warning: Supplied argument is not a valid MySQL result resource in 
/home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php on line 11



here is my code:

<?php
$hostName="localhost";
$userName="xxxx";
$password="xxxx";
$database= "projects";
$tableName="project_descrip";

$descripQuery = "SELECT descrip from project_descrip where rowid=$foo";
mysql_connect($hostName, $userName, $password);
$descripResult = mysql_db_query($database,$descripQuery);
   while($row = mysql_fetch_object($descripResult)){

$foo = $row->descrip;

echo("<font face=verdana size=1>");
echo("<a href='projects_descrip.php?rowid=$foobar'>" . "$foo</a>" . " | ");
echo("</font>");

  }


?>

thanks in advance, 
jennifer
--- End Message ---
--- Begin Message ---
On Sunday 19 January 2003 03:50, jennifer wrote:
> hi, i'm hoping someone can help me out here - im trying to pass a variable
> from a string in the href tag, however my sql breaks when i put a var in
> the statment. when i replace $foo with a number, the page works fine. can
> someone please tell me what im doing wrong?

Do you mean $foo or $foobar? In the URL below it seems as if you really mean 
$foobar?

And please give an example of where $foo (or $foobar) passed in the URL 
doesn't work.

> here is the error i get:
>
> Warning: Supplied argument is not a valid MySQL result resource in

Search the archives to find out the common causes of this error (it's an 
__extremely__ FAQ).

Read up on the uses of mysql_error().


> here is my code:
>
> <?php
> $hostName="localhost";
> $userName="xxxx";
> $password="xxxx";
> $database= "projects";
> $tableName="project_descrip";
>
> $descripQuery = "SELECT descrip from project_descrip where rowid=$foo";
> mysql_connect($hostName, $userName, $password);
> $descripResult = mysql_db_query($database,$descripQuery);
>    while($row = mysql_fetch_object($descripResult)){
>
> $foo = $row->descrip;
>
> echo("<font face=verdana size=1>");
> echo("<a href='projects_descrip.php?rowid=$foobar'>" . "$foo</a>" . " | ");
> echo("</font>");
>
>   }
>
>
> ?>

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
There is something in the pang of change
More than the heart can bear,
Unhappiness remembering happiness.
                -- Euripides
*/

--- End Message ---
--- Begin Message ---
> hi, i'm hoping someone can help me out here - im trying to pass a
variable
> from a string in the href tag, however my sql breaks when i put a var
in
> the statment.
> when i replace $foo with a number, the page works fine. can someone
please
> tell me what im doing wrong?
> 
> here is the error i get:
> 
> Warning: Supplied argument is not a valid MySQL result resource in
>
/home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php
> on line 11

That means your query failed. Use mysql_error() to find out why. 
 
> here is my code:
> 
> <?php
> $hostName="localhost";
> $userName="xxxx";
> $password="xxxx";
> $database= "projects";
> $tableName="project_descrip";
> 
> $descripQuery = "SELECT descrip from project_descrip where
rowid=$foo";
> mysql_connect($hostName, $userName, $password);
> $descripResult = mysql_db_query($database,$descripQuery);
>    while($row = mysql_fetch_object($descripResult)){

You shouldn't be using mysql_db_query() for one, it's depreciated. Use
mysql_select_db() along with mysql_query().

If rowid is an integer, then you don't need quotes around $foo,
otherwise, if it's a string, then you do.

where rowid='$foo'

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
It seems that error is from an ill-formed MySql statement. Try this,
$descripQuery = "SELECT descrip from project_descrip where rowid=$foo";
echo $descripQuery ; // put in this echo after the query.
$descripResult = mysql_query($descripQuery);
echo mysql_error(); file://put this echo after query execution

Now, run it and see on screen what query is actually executed.

"Jennifer" <[EMAIL PROTECTED]> wrote in message
003401c2bf2b$0a042d20$8101a8c0@fvcrx01">news:003401c2bf2b$0a042d20$8101a8c0@fvcrx01...
> hi, i'm hoping someone can help me out here - im trying to pass a variable
from a string in the href tag, however my sql breaks when i put a var in the
statment.
> when i replace $foo with a number, the page works fine. can someone please
tell me what im doing wrong?
>
> here is the error i get:
>
> Warning: Supplied argument is not a valid MySQL result resource in
/home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php on
line 11
>
>
>
> here is my code:
>
> <?php
> $hostName="localhost";
> $userName="xxxx";
> $password="xxxx";
> $database= "projects";
> $tableName="project_descrip";
>
> $descripQuery = "SELECT descrip from project_descrip where rowid=$foo";
> mysql_connect($hostName, $userName, $password);
> $descripResult = mysql_db_query($database,$descripQuery);
>    while($row = mysql_fetch_object($descripResult)){
>
> $foo = $row->descrip;
>
> echo("<font face=verdana size=1>");
> echo("<a href='projects_descrip.php?rowid=$foobar'>" . "$foo</a>" . " |
");
> echo("</font>");
>
>   }
>
>
> ?>
>
> thanks in advance,
> jennifer
>


--- End Message ---
--- Begin Message ---
Hi,

Sunday, January 19, 2003, 5:50:51 AM, you wrote:
j> hi, i'm hoping someone can help me out here - im trying to pass a variable from a 
string in the href tag, however my sql breaks when i put a var in the statment.
j> when i replace $foo with a number, the page works fine. can someone please tell me 
what im doing wrong?

j> here is the error i get:

j> Warning: Supplied argument is not a valid MySQL result resource in 
/home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php on line 11



j> here is my code:

j> <?php
j> $hostName="localhost";
j> $userName="xxxx";
j> $password="xxxx";
j> $database= "projects";
j> $tableName="project_descrip";

j> $descripQuery = "SELECT descrip from project_descrip where rowid=$foo";
j> mysql_connect($hostName, $userName, $password);
j> $descripResult = mysql_db_query($database,$descripQuery);
j>    while($row = mysql_fetch_object($descripResult)){

$foo = $row->>descrip;

j> echo("<font face=verdana size=1>");
j> echo("<a href='projects_descrip.php?rowid=$foobar'>" . "$foo</a>" . " | ");
j> echo("</font>");

j>   }


?>>

j> thanks in advance, 
j> jennifer

You need to put $foo in quotes like

     $descripQuery = "SELECT descrip from project_descrip where rowid='$foo'";

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
Hi all,

I'm making this web site, where the owner or administrator will be able to
upload new products and these products come in different sizes. Now, I made
a table in MySQL o store the products but only with a VARCHAR field where
the administrator will store the sizes like "12, 14, 16 and 18".

I would like to store the sizes for each product in a different table, but
my question refers on how to do this... one product per row with all the
different sizes (which will leave too many blank fields in every row) or
one size per row, making several rows per product.

Thanks in advance,

Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


--- End Message ---
--- Begin Message ---
> I'm making this web site, where the owner or administrator will be
able to
> upload new products and these products come in different sizes. Now, I
> made
> a table in MySQL o store the products but only with a VARCHAR field
where
> the administrator will store the sizes like "12, 14, 16 and 18".
> 
> I would like to store the sizes for each product in a different table,
but
> my question refers on how to do this... one product per row with all
the
> different sizes (which will leave too many blank fields in every row)
or
> one size per row, making several rows per product.

Sounds like you want a SET column, where you can define the different
values it can contain and it can contain any of those values.

So, if you have a SET(12,14,16,18) column, it can have values like
'12,18' and '14,16,18' and '12', etc...

You can then use functions such as FIND_IN_SET to quickly look for
specific values. Note that this would be quicker than using a plain
VARCHAR column to store a comma separated string. 

Or, you could have a 'size' table where you store the Item_ID and a
size. So you'd have rows like this:

+------+------+
| Item | Size |
+------+------+
|     1|    12|
|     1|    14|
|     2|    14|
|     3|    16|
|     3|    18|
+------+------+

And do JOINs to find your relevant data.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
If your customer views these items as different products then store them as
separate records in the same table.
My $0.02
Hugh
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 11:55 AM
Subject: [PHP] Multiple sizes for products


Hi all,

I'm making this web site, where the owner or administrator will be able to
upload new products and these products come in different sizes. Now, I made
a table in MySQL o store the products but only with a VARCHAR field where
the administrator will store the sizes like "12, 14, 16 and 18".

I would like to store the sizes for each product in a different table, but
my question refers on how to do this... one product per row with all the
different sizes (which will leave too many blank fields in every row) or
one size per row, making several rows per product.

Thanks in advance,

Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



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


--- End Message ---
--- Begin Message ---
Hi

Is there a way for a php page to automatically increment a number and store
it every time the page is loaded.

I want to generate an invoice number that goes up 1 everytime the HTML form
is sent to it.

Thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.435 / Virus Database: 244 - Release Date: 01/01/2003


--- End Message ---
--- Begin Message ---
> Is there a way for a php page to automatically increment a number and
> store
> it every time the page is loaded.
> 
> I want to generate an invoice number that goes up 1 everytime the HTML
> form
> is sent to it.

I assume you're talking about incrementing for everyone that accesses
your site. For that you need a database to keep track of the number for
all users. You'd be replicating an "Application Variable" that other
languages have.

If you're talking about incrementing on a per user basis, i.e. each time
a specific user goes to the form, increment their number, then use
sessions to keep a count.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
One quick note, if you DO NOT have access to a database, you could store
that incremented number to a file. And open and retrieve, and increment
every time you need. If you need to take this approach checkout php.net and
search for "fopen".



"Don Mc Nair" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi
>
> Is there a way for a php page to automatically increment a number and
store
> it every time the page is loaded.
>
> I want to generate an invoice number that goes up 1 everytime the HTML
form
> is sent to it.
>
> Thanks
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.435 / Virus Database: 244 - Release Date: 01/01/2003
>
>


--- End Message ---
--- Begin Message ---
on 19/01/03 9:59 AM, John W. Holmes ([EMAIL PROTECTED]) wrote:

>> Is there a way for a php page to automatically increment a number and
>> store
>> it every time the page is loaded.
>> 
>> I want to generate an invoice number that goes up 1 everytime the HTML
>> form
>> is sent to it.
> 
> I assume you're talking about incrementing for everyone that accesses
> your site. For that you need a database to keep track of the number for
> all users. 

Or use a file-based counter.  There are 1000's of counter scripts out there
both file based and database based.


Justin

--- End Message ---
--- Begin Message ---
--- [EMAIL PROTECTED] wrote:
> how can I call a register session from within a
> class and make sure that the session is allready
> active and if not just print a warning.

This is closely related; you can check to see whether
headers have already been sent:

http://www.php.net/manual/en/function.headers-sent.php

If they have not, it does not matter if you start the
session or use an existing one.

You can probably use session_name() to check for an
existing session. It is worth experimenting with anyway.

Chris
--- End Message ---
--- Begin Message ---
Using PHP 4.1.2  I need to PGP sign a piece of text and detached the signature. I have 
read a lot in the archives and and about the better exec() calls in 4.3.

However I cannot find a reference that indicates the best way to pass a set of 
arguments out of a PHP script to PGP.

I need to use pgp2.6.3i the pgp command line looks like a bit this

pgp -sabf -u "pgpuser"  "pgppassphrase"  <"text"   >"pgpsignature" 

This has to be given to the Bash Shell with whatever works exec() system() or 
passthrough(), any output can be retrieved later . 

It is possible, if anyone knows how, to set ENV variable in the shell to preload the 
passphrase and the pgpuser into ENV variables.

Has anyone cracked this? Any pointers to archived messages I have missed.

Any suggestions at all would be most welcome.

{R}


--- End Message ---
--- Begin Message ---
Hello all!

I have a number of scripts that upload 5 files at a time each.
The first one creates the dir using umask(000)and mkdir($dir,0777)
which gives the first five files perms 777, which is what I want.

I have the subsequent scripts check if the dir exists and if not does the same
thing with umask and mkdir.  The problem is the uploaded files in scripts 2
through 5 do not inherit the perms 777.

The script:

if (!is_dir("/mnt/ls6/17/169/00000000/htdocs/2003/uploads/$mls")){
umask(000);
mkdir($dir,0777)or die("couldn't create directory");
}
$path1=$dir . "/1.jpg";                                 
        move_uploaded_file( $upload1, $path1)or die("couldn't upload photo");   
        $sql = (" UPDATE gallery SET img1 = '1' WHERE mls = '$mls';"); 

Is there a parameter I can include in move_uploaded_file() to set the perms on
the remaining files?

Any help is greatly appreciated.

RW
--- End Message ---
--- Begin Message ---
Oops...

-----Forwarded Message-----

From: Brad Pauly <[EMAIL PROTECTED]>
To: Joab Stieglitz <[EMAIL PROTECTED]>
Subject: Re: [PHP] Number Sign in String Variables
Date: 18 Jan 2003 16:40:40 -0700

> OK.  I urlencoded the URL and now the URL passes correctly...
> 
> add_to_cart.php%3Fitem_num%3DSTT32700%26quantity%3D1%26sale_price%3D52.78%26
> unit%3DBX%26short_desc%3DENVELOPE%2C100%25COT%2024%23%2CGY%26wholesaler%3DUS
> %26cost%3D37.700
> 
> ... but I get the following error:
> 
> Forbidden
> You don't have permission to access
> /carmae/add_to_cart.php?item_num=STT32700&quantity=1&sale_price=52.78&unit=B
> X&short_desc=ENVELOPE,100%COT 24#,GY&wholesaler=US&cost=37.700 on this
> server.

Your web server is trying to find a directory with that long name. If
you encode the entire string, you need to pass it in a new variable,
then break it apart again.
 
> Suggestions?

Sorry, I gave some bad advice the first time. All you need to do is
urlencode each of the variables individually. Something like this:

$item_num_encoded = urlencode($item_num);
[...]

Then your link will be something like this:

add_to_cart.php?item_num=$item_num_encoded


Brad






--- End Message ---
--- Begin Message ---
        Dose anyone know how to search and replace a string in a
mysql_query output.

Thanks, Paul
--- End Message ---
--- Begin Message ---
>       Dose anyone know how to search and replace a string in a
> mysql_query output.

Yes. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
I see a lot of these type of answers on the list at the moment.

I'm sick of receiving smart ass answers from people. It wastes my time, and
my bandwidth.

Either answer the fucking question, even if it hasn't been asked correctly,
or don't reply at all.

Given you are a 'PHP Professional' John, I would expect a little more from
you.

-----Original Message-----
From: John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 19 January 2003 11:42 AM
To: 'Paul Marinas'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] SQL+php


>       Dose anyone know how to search and replace a string in a
> mysql_query output.

Yes.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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

--- End Message ---
--- Begin Message ---
How about you describe exactly what you're trying to do and why and then
someone can help you. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -----Original Message-----
> From: Paul Marinas [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 18, 2003 7:46 PM
> To: John W. Holmes
> Subject: RE: [PHP] SQL+php
> 
> 
> what number? .. i really need that .
> On Sat, 18 Jan 2003, John W. Holmes wrote:
> 
> > >   Dose anyone know how to search and replace a string in a
> > > mysql_query output.
> >
> > Yes.
> >
> > ---John W. Holmes...
> >
> > PHP Architect - A monthly magazine for PHP Professionals. Get your
copy
> > today. http://www.phparch.com/
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >


--- End Message ---
--- Begin Message ---
i am trying to select some fields form a database but in there the data is
something like "172.10.192.22:100", not very frendly, and instad of those
numbers i whant to display on my web page something like  "july"...that's
it ..:)

On Sat, 18 Jan 2003, John W. Holmes wrote:

> How about you describe exactly what you're trying to do and why and then
> someone can help you.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
> > -----Original Message-----
> > From: Paul Marinas [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 18, 2003 7:46 PM
> > To: John W. Holmes
> > Subject: RE: [PHP] SQL+php
> >
> >
> > what number? .. i really need that .
> > On Sat, 18 Jan 2003, John W. Holmes wrote:
> >
> > > >         Dose anyone know how to search and replace a string in a
> > > > mysql_query output.
> > >
> > > Yes.
> > >
> > > ---John W. Holmes...
> > >
> > > PHP Architect - A monthly magazine for PHP Professionals. Get your
> copy
> > > today. http://www.phparch.com/
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
>
>
--- End Message ---
--- Begin Message ---
If you want to do it within the query itself, take a look at the mysql
replace command

REPLACE(str,from_str,to_str)

SELECT REPLACE(<field>,<from>,<to>) FROM table

or you can do it using PHP once the query has executed, on a record by
record basis, within a while/for loop or whatever.

-----Original Message-----
From: Paul Marinas [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 19 January 2003 11:07 AM
Cc: [EMAIL PROTECTED]
Subject: [PHP] SQL+php


        Dose anyone know how to search and replace a string in a
mysql_query output.

Thanks, Paul

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

--- End Message ---
--- Begin Message ---
something like that only i don't whant to alter the database, the fields
in the database must remains unchanged, only, on page i  whant to display
diferent data.

 On Sun, 19 Jan 2003, Sean Malloy wrote:

> If you want to do it within the query itself, take a look at the mysql
> replace command
>
> REPLACE(str,from_str,to_str)
>
> SELECT REPLACE(<field>,<from>,<to>) FROM table
>
> or you can do it using PHP once the query has executed, on a record by
> record basis, within a while/for loop or whatever.
>
> -----Original Message-----
> From: Paul Marinas [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 19 January 2003 11:07 AM
> Cc: [EMAIL PROTECTED]
> Subject: [PHP] SQL+php
>
>
>       Dose anyone know how to search and replace a string in a
> mysql_query output.
>
> Thanks, Paul
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
where the F*** are you getting july from???  which number do you want to
convert to a month, or am i totally missing it?

you need to be DESCRIPTIVE in what you want to acheive.

we're not a mind readers!


Justin


on 19/01/03 11:59 AM, Paul Marinas ([EMAIL PROTECTED]) wrote:

> i am trying to select some fields form a database but in there the data is
> something like "172.10.192.22:100", not very frendly, and instad of those
> numbers i whant to display on my web page something like  "july"...that's
> it ..:)
> 
> On Sat, 18 Jan 2003, John W. Holmes wrote:
> 
>> How about you describe exactly what you're trying to do and why and then
>> someone can help you.
>> 
>> ---John W. Holmes...
>> 
>> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
>> today. http://www.phparch.com/
>> 
>>> -----Original Message-----
>>> From: Paul Marinas [mailto:[EMAIL PROTECTED]]
>>> Sent: Saturday, January 18, 2003 7:46 PM
>>> To: John W. Holmes
>>> Subject: RE: [PHP] SQL+php
>>> 
>>> 
>>> what number? .. i really need that .
>>> On Sat, 18 Jan 2003, John W. Holmes wrote:
>>> 
>>>>> Dose anyone know how to search and replace a string in a
>>>>> mysql_query output.
>>>> 
>>>> Yes.
>>>> 
>>>> ---John W. Holmes...
>>>> 
>>>> PHP Architect - A monthly magazine for PHP Professionals. Get your
>> copy
>>>> today. http://www.phparch.com/
>>>> 
>>>> 
>>>> 
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>> 
>> 
>> 

--- End Message ---
--- Begin Message ---
:)))
.....it's an log for a VoIp network, evrey voip has an ip and i whant
that instad of the VoIp's IP to put his name, instad of "1.1.1.1:xxx" must
be "jhon doe form yyy city", it's easier to read for the people who that
follow the logs. .. that's it ...

 On Sun, 19 Jan 2003, Justin French wrote:

> where the F*** are you getting july from???  which number do you want to
> convert to a month, or am i totally missing it?
>
> you need to be DESCRIPTIVE in what you want to acheive.
>
> we're not a mind readers!
>
>
> Justin
>
>
> on 19/01/03 11:59 AM, Paul Marinas ([EMAIL PROTECTED]) wrote:
>
> > i am trying to select some fields form a database but in there the data is
> > something like "172.10.192.22:100", not very frendly, and instad of those
> > numbers i whant to display on my web page something like  "july"...that's
> > it ..:)
> >
> > On Sat, 18 Jan 2003, John W. Holmes wrote:
> >
> >> How about you describe exactly what you're trying to do and why and then
> >> someone can help you.
> >>
> >> ---John W. Holmes...
> >>
> >> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> >> today. http://www.phparch.com/
> >>
> >>> -----Original Message-----
> >>> From: Paul Marinas [mailto:[EMAIL PROTECTED]]
> >>> Sent: Saturday, January 18, 2003 7:46 PM
> >>> To: John W. Holmes
> >>> Subject: RE: [PHP] SQL+php
> >>>
> >>>
> >>> what number? .. i really need that .
> >>> On Sat, 18 Jan 2003, John W. Holmes wrote:
> >>>
> >>>>> Dose anyone know how to search and replace a string in a
> >>>>> mysql_query output.
> >>>>
> >>>> Yes.
> >>>>
> >>>> ---John W. Holmes...
> >>>>
> >>>> PHP Architect - A monthly magazine for PHP Professionals. Get your
> >> copy
> >>>> today. http://www.phparch.com/
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> PHP General Mailing List (http://www.php.net/)
> >>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>>
> >>
> >>
>
--- End Message ---
--- Begin Message ---
JJ --

...and then JJ Harrison said...
% 
...
% Does anyone know of a free php webhost? (Banners, poop-ups etc are
% exceptable).

You should ask google first:

  Advanced Search    Preferences    Language Tools    Search Tips
  free web hosting php___________ Google Search
  ...
  Searched the web for free web hosting php.  Results 1 - 10 of about
  1,520,000. Search took 0.18 seconds.

Doesn't seem too difficult...


% --
% ---
% JJ Harrison
% [EMAIL PROTECTED]


HTH & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: msg93498/pgp00000.pgp
Description: PGP signature

--- End Message ---
--- Begin Message --- I need to change where one item is ordered in an array. I know how to sory an array, but I need to move one item up/down in the array. Example:
$array is:
0 => "element one"
1 => "element two"
2 => "element three"
3 => "element four"
I call array_order_up($array[1]) and $array is now:
0 => "element one"
2 => "element three"
1 => "element two"
3 => "element four"

If there aren't any native functions to do this, can anyone think of a way to make my own function to do this?

--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.


--- End Message ---
--- Begin Message ---
This would do it:

<?php

$first[] = 'hello';
$first[] = 'bye';

function swap(&$list, $first, $second)
{
        $tempOne = $list[$first];
        $list[$first] = $list[$second];
        $list[$second] = $tempOne;      
}

swap($first, 0, 1);

print_r($first);

?>


Timothy Hitchens (HiTCHO)
Open Source Consulting
e-mail: [EMAIL PROTECTED]

> -----Original Message-----
> From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, 19 January 2003 12:36 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Changing order of just one array item?
> 
> 
> I need to change where one item is ordered in an array.  I 
> know how to 
> sory an array, but I need to move one item up/down in the 
> array.  Example: $array is: 0 => "element one" 1 => "element 
> two" 2 => "element three" 3 => "element four" I call 
> array_order_up($array[1]) and $array is now: 0 => "element 
> one" 2 => "element three" 1 => "element two" 3 => "element four"
> 
> If there aren't any native functions to do this, can anyone 
> think of a 
> way to make my own function to do this?
> 
> -- 
> The above message is encrypted with double rot13 encoding.  
> Any unauthorized attempt to decrypt it will be prosecuted to 
> the full extent of the law.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---

Reply via email to