RE: [PHP] case ?

2001-01-10 Thread Steve Edberg

At 2:29 PM +0900 1/11/01, Maxim Maletsky wrote:
here we go, from Zeev:

  As of PHP 4.0.3, the implementation of require() no longer behaves that
  way, and processes the file 'just in time'.  That means that in the 1st
  example, the file will be processed a hundred times, and in the 2nd
  example, it won't be processed at all.  That's the way include() behaves
  (in all versions of PHP) as well.

November 14-th ...


Cheers,
Maxim Maletsky



Aah; so I leaned something new today :)

My production systems are still PHP3; PHP4.0.4 is still on my test system.

- steve



-Original Message-
From: Maxim Maletsky
Sent: Thursday, January 11, 2001 2:26 PM
To: 'Steve Edberg'; Jon Rosenberg; PHP List .
Subject: RE: [PHP] case ?



 'require' ALWAYS includes the file; 'include' is what you want here.

not since v4.0.2(?) came out ...
I heard from Zeev that require() and include() behave now just about the
same.
Read our posting regarding this topic of 1-2 month ago..

Cheers,
Maxim Maletsky

 The tradeoff is that include is slightly slower. For more info, see

  http://www.php.net/manual/function.include.php
 and
  http://www.php.net/manual/function.require.php

-steve

+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] regex

2001-01-12 Thread Steve Edberg

At 02:54 PM 1/12/01 , Jerry Lake wrote:
is it possible with regex to
change one or more text characters
followed by a space into the same
characters followed by a tab?

Jerry Lake


For example -

 $NewString = ereg_replace("([[:alpha:]]+) ", "\\1".chr(9), $String);

This will convert a sequence of one or more alphabetic characters followed 
by one space to the same set of characters followed by a tab (that's the 
chr(9) part).

If you want to match only a specific set of text characters - say, a, e, i, 
o and u - then you can use

 $NewString = eregi_replace("([aeiou]+) ", "\\1".chr(9), $String);

Notice i used eregi_replace() instead of ereg_replace(); the 'i' means case 
INsensitive.

Of course, there are other ways of doing this with preg_replace and 
str_replace, both of which are faster than ereg_replace (str_replace is the 
fastest); I happen to use ereg becaouse I'm most familiar with it, since it 
came along before the preg_ functions. As always, you can check out the docs:

 http://www.php.net/ereg_replace
 http://www.php.net/eregi_replace
 http://www.php.net/str_replace
 http://www.php.net/preg_replace


 -steve

(The usual off-the-top-of-my-head-untested-code-snippet caveats apply)



+----+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED] (530)754-9127 |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] changing strings to float vars

2001-01-15 Thread Steve Edberg

At 4:28 PM -0500 1/15/01, bill wrote:
Sometimes clients put a dollar sign "$" in a form that only needs a
number (like "1.50").

Is there a way to take a post variable and automatically convert it to a
float value, stripping off any non-numeric characters?

I tried doubleval() without success and I can't use intval() because it
has decimals.

kind regards,


$SanitizedNumber = ereg_replace('[^0-9.]', '', $NumberString);

If you really need to make this a float variable, then you can add

$Number = (float)$SanitizedNumber;

although in most cases PHP handles type conversion correctly on-the-fly.

- steve

+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] non-php related question.

2001-01-23 Thread Steve Edberg

Try wget

http://sunsite.dk/wget/index.html


At 12:05 PM -0500 1/23/01, Jason Jacobs wrote:
Hey guys and gals!  I have my personal site on go.com, and I wanna move it.
The problem is I don't have it all backed up on my machine (I think I only
have some of the images), but I want to move it to my server at work.  Does
anyone know of a script of some sort that will go to my site, copy all the
files to a specified folder, and follow my internal links?  Thanks for the
info.


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help w/ quotes/html and data from MySQL

2001-01-23 Thread Steve Edberg

At 4:47 PM -0500 1/23/01, Shane McBride wrote:
I have a field in MySQL that holds data that may look like this:

bRose Painting/b"Looks really nice, blah, blah"b25.00/b

Now, I want to pull that data back into a form textarea to edit. 
Here's how I have unsuccessfully been doing it:

?
 beginning code
tdDescription:/td
tdtextarea name=\"description\" value='$description' cols=\"50\" 
rows=\"5\"/textarea/td
...ending code
?

I looks like that the embedded html in the MySQL data is actually 
being "rendered" (for the lack of a better term).
How can I get the whole chunk of data back into the form?



Well, if you're using PHP:

echo
'tdDescription:/td',
'tdtextarea name="description" cols="50" rows="5"',
htmlentities($description),
'/textarea/td'
;

Presumably, other web development languages have an equivalent 
construct to PHP's htmlentities().

Also, the value of a textarea tag is not put in a 'value' attribute 
within the tag as with the INPUT tag; it is put in the textarea 
'container' - that is, between the textarea and /textarea tags.

- steve


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Form data is not remembered

2001-01-24 Thread Steve Edberg

At 2:41 AM -0800 1/24/01, Klepto wrote:
Try the "GET" method in the form.

Jaks
- Original Message -
From: Alain Fontaine [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 2:11 AM
Subject: [PHP] Form data is not "remembered"


  Hi,

  I have a page with a couple of form fields that are being POSTed to a
  processing PHP script. The page that contains these form fields is itself
a
  PHP page that uses sessions and so on.

  I have to make "server-side data validation" on the fields because of
their
  complexity. When the user hits submit and comes to the result page, if
there
  was any error I ask the user to go back to the form and correct the
  mistakes, using either his browser BACK button or by clicking on a link
that
  does a javascript:history.back().

  The problem is, when the user gets back to the form page, all of the
values
  he had typed in are gone, and he has to start all over again. Does anyone
  have an idea why this is so, and how to circumvent it without saving the
  user data into a session variable and then setting it back again once the
  user hits the form page again ? I have seen many pages where your previous
  data would stay in the form after you make a "Back" operation, but here,
it
   disappears.
  


Some browsers will save the entered info when you hit the BACK 
button, some won't; it also depends on your HTTP header settings 
(no-cache, must-revalidate, etc.). Probably bad idea to rely on that.

In a nutshell, if your validation fails, don't tell the user to hit 
the back button. Instead, redisplay the form with the data fields 
already filled in.

I usually write my form display  process programs something like 
this (assuming $Submit is the name attribute of the submit button):


...

if ($Submit = 'Enter your data') {

$ErrorList = validate_form_data();

if (is_array($ErrorList)) {
show_form($ErrorList);
} else {
process_data();
}

} else {

show_form();

}

...


Where:

validate_form_data is a function that returns an array of 
error messages like $ErrorList[form field name] = error message, 
or FALSE if all tests passed. If there are errors, I redisplay the 
form with entered data (from $HTTP_POST_VARS or wherever), and error 
messages displayed alongside the appropriate form fields.

show_form displays the entry form, with any existing data 
(from HTTP_POST_VARS, etc.) filled in and error messages, if any, 
displayed. Basically, the FORM tag action attribute refers to the 
same program as displayed the form - that is, $PHP_SELF.


Hope this is clear...I getting  tired, and I don't even think an 
intravenous drip of concentrated Mountain Dew syrup will help.

- steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Editors, again (was Re: [PHP] Beginner in php!)

2001-01-24 Thread Steve Edberg

At 4:40 PM +0600 1/24/01, Tshering Norbu wrote:
Here is collection I got from this list;

www.editplus.com
www.codecharge.com
www.phpedit.com
www.ultraedit.com



See this list:

http://www.itworks.demon.co.uk/phpeditors.htm

Some of the comments are a bit out of date - for instance, BBEdit 6.0 
(Macintosh) now has PHP syntax highlighting - but it's a got starting 
point.

- steve



- Original Message -
From: kaab kaoutar [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 4:28 PM
Subject: [PHP] Beginner in php!


  Hi guys!

  I'm working on an NT workstation, i used to work with asp, but i heard a
lot
  about php! that i decided to start working with it !
  so i'm using PWS4 and i'm wondering which free php editor is more suitible
  for me ? and also what links to get free more tutorials, i got one of
phpnet
  but still 

  Regards
  _
   Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: AW: [PHP] eval() to string???

2001-01-24 Thread Steve Edberg

-Ursprngliche Nachricht-
Von: Robert S. White [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 16:20
An: [EMAIL PROTECTED]
Betreff: Re: [PHP] eval() to string???


How is this going to help me?

I want to evaluate the code in $php_code to *another* string...



From

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

"A return statement will terminate the evaluation of the string
immediatley. In PHP 4 you may use return to return a value that will
become the result of the eval() function while in PHP 3 eval() was of
type void and did never return anything."

So, if you're using PHP4, just ensure that there is a return
in$php_code that returns the desired value:

$thing = eval($php_code);

It's helpful to read the notes at the above URL - escaping things
correctly for eval() can be tricky...


- steve


- Original Message -
From: Thomas Weber 
To: Php-General 
Sent: Wednesday, January 24, 2001 10:14 AM
Subject: AW: [PHP] eval() to string???


  try

  eval("\$php_code;");

  -Ursprngliche Nachricht-
  Von: [ rswfire ] [mailto:[EMAIL PROTECTED]]
  Gesendet: Mittwoch, 24. Januar 2001 15:36
  An: [EMAIL PROTECTED]
  Betreff: [PHP] eval() to string???


  I want to evaluate some PHP code to a string.  How can I do this?

  $php_code = "echo 'hello';"

  I would like to evaluate the code to "hello" in another string...


   --

--
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Loop Through all Querystring Variables

2001-01-24 Thread Steve Edberg

At 3:07 PM -0700 1/24/01, Karl J. Stubsjoen wrote:
What is the simplest way to set up a procedure to loop through all passed
querystring values and/or form values?

I'm very new to PHP, and don't know how to set up loops at all.


reset($HTTP_GET_VARS);
while (list($VariableName, $VariableValue) = each($HTTP_GET_VARS))
{
echo "GET variable $VariableName was set to $VariableValuebr\n";
}

Of course, you would want to do your own processing in place of the echo.

If you want to use POSTed or cookie variables, replace the _GET_ in 
the above snippet with _POST_ or _COOKIE_, respectively.

The reset(), by the way, resets the array pointer to the beginning of 
the array. It's not always needed, but I tend to do it anyway. It IS 
necessary, however, ig you use the above snippet within an enclosing 
loop.


- steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" ------+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] finding the difference

2001-01-25 Thread Steve Edberg

At 3:16 AM -0500 1/25/01, [EMAIL PROTECTED] wrote:
I have a date and time stored in the following format:

day:month:year:hour:minutes

Example 27:01:2001:08:13

I want to work out the difference between that and the current time on my
server, but I can`t find any math functions in the PHP manual that allows you
to work out the diference. In the end I hope to be able to display '2 days 23
hours and 55 minutes' type results, similar to the way in which eLance.com
shows the time remaining on a project. Anyone have any suggestion if it is at
all possible?

Thanks
Ade



Take a look under date/time functions:

http://www.php.net/manual/en/ref.datetime.php

You want to convert your stored time into a Unix timestamp (that is, 
seconds since midnight 1 jan 1970), subtract the unix timestamp of 
the current time, and then display the result in your desired format:

$Deadline = ' 27:01:2001:08:13';
$Bits = explode(':', $Deadline);

$TimeDiff =
mktime($Bits[3],$Bits[4],$Bits[5],$Bits[1],$Bits[0],$Bits[2])
- time();

# $TimeDiff is now the time difference, expressed in seconds.
# Now, use modulo operator repeatedly to get day, hour  minute values.
# BTW, there are 86400 seconds/day, 3600 seconds/hour.

$NDays = $TimeDiff % 86400;
$R = $TimeDiff - ($NDays * 86400);
$NHours = $R % 3600;
$R = $R - ($NHours * 3600);
$NMinutes = round($R/60);

echo "You have $NDays days, $NHours hours and $NMinutes left!";

If you're feeling obfuscatory, you could compact the calculations 
into (I think):

$NHours = ($R = $TimeDiff - (($NDays = $TimeDiff % 86400) * 
86400)) % 3600;
$NMinutes = round(($R - ($NHours * 3600))/60);

Why you would _want_ to do this, I don't know. I suppose if you're an 
ex-FORTRAN programmer frustrated by the lack of assigned and computed 
GOTOs and want to take it out on others, maybe. OK, now I'm rambling. 
And showing my age...

- steve

Usual untested, off-top-of-head, no-warranty code caveats apply.

-- 
+--- "They've got a cherry pie there, that'll kill ya" ------+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How do I see the data in list()?

2001-01-25 Thread Steve Edberg

At 11:33 AM -0500 1/25/01, Scott Fletcher wrote:
Hi!

 When I use the echo to see what is inside the list().  Instead I got the
message on screen saying "ArrayArray".

 The array are being assigned first then then list come second.  ie.

 $test = array();
 $test1 = array()

 list($test,$test1);

---
 When I do "echo list($test,$test1);", it doesn't work.

 What are the better way to see the data in the array?



Are these actual program snippets? If they are then

(1) '$test1 = array()' line is missing a trailing ';'

(2) The statement 'list($test,$test1);', to the best of my knowledge, 
does nothing in this context.

(3) From your echo statement, you should see the output 
'list(Array,Array)' - functions and language constructs aren't 
evaluated in double-quoted strings; only variables.

It would make more sense to me to have something like

$test = array('bean', 'noodle', 'wednesday');
$test1 = array('a'='apple', 'b'='banana', 'c'='carrot');

$foo = array($test, $test1);

Then you could display these values like so:

If you have PHP4, use print_r() or var_dump():

echo print_r($foo);

See
http://www.php.net/manual/en/function.print-r.php
http://www.php.net/manual/en/function.var-dump.php

I haven't used either of these functions, so I don't know exactly 
what the output looks like. It says var_dump() was available in PHP 3 
after 3.0.5, but I'm not entirely sure that's true. If it is, it must 
have been undocumented for a while.

An alternative display method would be something like (a little more 
cumbersome, but works in PHP3  4):

for ($i=0; $icount($foo); $i++)
{
while(list($Key,$Val) = each($foo[$i]))
{
echo "foo[$i][$Key] = $Valbr\n";
}
}

Also, instead of the

$test = array('bean', 'noodle', 'wednesday');
$test1 = array('a'='apple', 'b'='banana', 'c'='carrot');

$foo = array($test, $test1);

way of declaring the $foo array, you could also say

$foo = array(
array('bean', 'noodle', 'wednesday'),
array('a'='apple', 'b'='banana', 'c'='carrot')
)

or
$foo[0] = array('bean', 'noodle', 'wednesday');
$foo[1] = array('a'='apple', 'b'='banana', 'c'='carrot');

See

http://www.php.net/manual/en/language.types.array.php

for more information.

- steve


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using a variable to select what variable to use...???

2001-01-26 Thread Steve Edberg

At 9:32 AM -0800 1/26/01, Brandon Orther wrote:
Hello,

I am doing a do loop and I want it to change what variable to use each
run...

First time use: $run1

Second time use: $run2

Third time use: $run2

I hope you can understand what I am saying.



'Variable variables'; see

http://www.php.net/manual/en/language.variables.variable.php

If you meant $run3 on the third time line, then you can use

for ($i=1; $i$SomeNumber; $i++)
{
$SomeValue = some_function(${run$i});
}

Or, use could say

for ($i=1; $i$SomeNumber; $i++)
{
$VarName = "run$i";
$SomeValue = some_function($$VarName);
}

If you actually _wanted_ to use '$run2' on the third time, I'm 
interpreting that to mean you want to limit the maximum value of the 
digit to 2. If so, you could do

for ($i=1; $i$SomeNumber; $i++)
{
$VarName = 'run'.max($i, 2);
$SomeValue = some_function($$VarName);
}


-Steve



Brandon Orther
WebIntellects Design/Development Manager
[EMAIL PROTECTED]
800-994-6364
www.webintellects.com



-- 
+--- "They've got a cherry pie there, that'll kill ya" ------+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] VAR and variables

2001-01-29 Thread Steve Edberg

At 10:50 AM + 1/29/01, Tim Ward wrote:
   -Original Message-
  From: Steve Edberg [mailto:[EMAIL PROTECTED]]
  Sent: 25 January 2001 22:02
  To: Matt; [EMAIL PROTECTED]
  Subject: Re: [PHP] VAR and variables


  At 3:00 PM -0600 1/25/01, Matt wrote:
  I have a question that may seem kind of silly, but I'm curious...
  
  When using PHP why would one use "var" to define a variable as
  opposed to just regularly creating it?


  Because that's the way it is ;).

  The var is part of the syntax of a class definition; it isn't used
  anywhere else. I don't know the actual deep reason for having it, as
  far as the parser is concerned, but it does make it clear - at least
  to me - what the class variables are.

class definitions are the fundamental building blocks of object orientated
programming. They define an object type which your object is an example of.
The defined variables should be regarded as properties of the class rather
than variables in the usual sense. If you're going to be strict about it you
should not even refer to them directly outside the class definition but use
methods to access and change them.


Yes --- I was referring to the use of the keyword 'var' here (as 
opposed to nothing, or some _other_ construct), which I think was the 
original question.



  
  You can also initialize the variable here, too:

  var $a = 5;


not any more you can't ... use the constructor


According to the docs, you can still use a _constant_ initializer in 
PHP4 (I use them in 4.0.4), just not a variable one. From 
http://www.php.net/manual/en/language.oop.php:

Note: In PHP 4, only constant initializers for var variables 
are allowed. Use constructors for non-constant initializers.


Of course, this might not be the official OOP usage, but this is 
PHP's way (I'd call it Pseudo-OOP, but the acronym for that isn't all 
that pleasant ;)

- steve


-- 
+--- "They've got a cherry pie there, that'll kill ya" ------+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Server VS Client script validation

2001-01-29 Thread Steve Edberg

At 11:27 AM + 1/29/01, kaab kaoutar wrote:
Hi!
What's best ? using client script while validating form 
inputs(javasript or vbscript) or using php for validating!
with the first way, i can trigger alert ! however with the second 
one, i have to show up a whole page for just saying that there are 
errors, go back to the form !
any ideas ?
thanks


Best way is to do it both ways:

JavaScript to make a more user-friendly page, and server-side 
validation in case  JavaScript is disabled AND to catch programs that 
simulate posts by writing directly to a socket. It's really easy to 
do that  - via telnet to port 80, for example, or via PHP (see the 
posttohost function at one of the code libraries - see px.sklar.com, 
or phpbuilder.com, or on of the other resources).

- steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Select list with PHP

2001-02-03 Thread Steve Edberg

At 3:24 PM -0700 2/3/01, Gerry wrote:
Hello:

I'm trying to create dinamic color SELECT lists with php. I have my
database set up as follows:

Paint = good
bucket = good
weight = 100kg
Colors = green, blue, red

and here is my php:

while ($row = mysql_fetch_array($sql_result)) {
echo"trtd";
echo $row["paint"];
echo"/tdtd";
echo $row["bucket"];
echo"/tdtd";
echo"form action=\"http://www.\" method=\"POST\"";

Replace this line:

$Color  = $row["Color"];

with this:

$option = '';
$ColorArray = split(',' $row['Colors']);
while (list(, $Color) = each($ColorArray)) {
# yes, the comma in the list() should be there!

if ($Color == $Color) {
$option .= "OPTION value=\"$Color\" selected$Color/OPTION";
} else {
$option .= "OPTION value=\"$Color\"$Color/OPTION";
}

and add this here:

}


echo"select name=\"Colors\"";
echo "$option";
echo"/select";

For more information, see

http://www.php.net/split

Oh - and just in case the 'Colors' column is empty, you might want to 
do the while statement like -

while (is_array($ColorArray)  (list(, $Color) = each($ColorArray))) {

- since split() won't return an array if there's nothing to split.

- steve



as you can see I end up with a select menu with this "green, blue, red"
as the only option.

is there a way I can tell php3 to break it down at "," so I can actually
have a drop down menu

Thanks ahead:
Gerry Figueroa
------
Modern Confucius:
Man who run in front of car get tired.
--


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is this a missing feature?

2001-02-04 Thread Steve Edberg

At 8:40 PM +0200 2/4/01, Teodor Cimpoesu wrote:
Lux wrote:

  Where do I make a formal request for a feature?  In Perl or Ruby, I
  could have said:

  foo ({ 'var1' = 'value', 'var2' = 'value'});

  and it is so much more elegant than having to say:

  $hash = array (
 'var1' = 'value',
 'var2' = 'value'
  );
  foo ($hash);

  elegance is everything, man.

  lux
lux in latin means 'light' right? :) let me enlighten then :-P
   foo ($hash = array('var1'='value', 'var2'='value'));
should work.


And just to turn up the wattage a little further (hey, I work for the 
University of California whose motto is 'Fiat Lux', menaing either 
Lux drives an Italian car or 'Let there be light')...

You don't need the $hash in that function call unless you need to use 
it later on in your main program, so you can just say:

foo (array('var1'='value', 'var2'='value'));

which is basically the same as the Perl or Ruby (??? never heard of 
that...) call above, with the addition of array(...). I use the

function(array('param1'='value', ...))

syntax a lot instead of individual parameters in function calls. I 
don't have to remember function argument order that way.

- steve




Now, I don't undestand why exactly do you need references. By default
everything is passed in a referenced manner, if I undestood correct the
explanation Zeev wrote right after 4.0 was out, or so.

Don't take references like something that will boost your skript speed
to 200%.
Use them only when you need them, and to find out when you actually need
them
check out an article on references at zend.com.

Now, let me tell you that somehow I agreed with you :) cause I love
Python way
of dealing with arrays, but we are in PHP, so we have to figure PHP way,
not
your-fav-lang way.

ciao

-- teodor


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Stripping HTML selectively?

2001-03-04 Thread Steve Edberg

At 09:43 PM 3/3/01 , Erick Papadakis wrote:
Thanks Brian, I have tried the allowable tags, but I need to remove the
ATTRIBUTES of a tag, not the tag itself. STRIP_TAGS totally removes the tag,
and ALLOWABLE_TAGS lets the tag be. WHat I wish to do is let the main tag be
but remove its attributes, as follows:

 Original text:
 font class="something" style=""Hi!/font

 Parsed text:
 fontHi!/font

Thanks/erick

Well, in this case, you'd have to use regular expressions. One way to do it 
would be:

 $SanitizedString = 
ereg_replace('[[:space:]]*([[:alnum:]]+)[^]*', "\\1", $String);

this _should_  work (haven't tested it). If you wanted to remove some tags 
entirely, and then remove the attributes of the remaining tags, you could 
(1) use strip_tags() with a list of allowable tags, then (2) run the regexp 
above. Incidentally, the above regexp also removes leading spaces from the 
tag. Eg,font style="unreadable" becomes font. If you don't want, 
that user the regexp

 '([[:space:]]*[[:alnum:]]+)[^]*'

instead.

 - steve


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.230 / Virus Database: 111 - Release Date: 25-Jan-01



+----+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED] (530)754-9127 |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] session in php3

2001-03-07 Thread Steve Edberg

At 3:28 PM -0600 3/7/01, Jacky wrote:
Hi people
I got problem of how to assign session value in php3. As far as I 
know, all syntax in manual talks about php4 syntax only. How am I 
going to do that?
best


In PHP3, you'll have to create your own session functions, or use a 
library like PHPLIB (phplib.netuse.de).

-steve


Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for yourself"

-- 
+--- "They've got a cherry pie there, that'll kill ya" ------+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ASP vs PHP

2001-03-11 Thread Steve Edberg

At 11:48 PM -0500 3/11/01, Rick St Jean wrote:
I was told by someone that it is possible with apache.  You can have 
something parse
the page once then be parsed by something else.  I don't know how 
and I have never seen
it but I have been told that it is possible.

Rick


That would be 'stacked request handlers'...not possible, AFAIK, with 
any of the 1.x versions, but supposedly Apache 2.0 can do it. Check 
out httpd.apache.org; v2.0 is still alpha.

- steve



At 11:28 PM 3/11/01 -0500, Michael Kimsal wrote:
You're comparing a framework to a language.

ASP is a technology which allows code for different languages to be 
embedded in a file
parsed by a webserver (IIS).  To accomplish this, different 
languages need to be written
as modules for that webserver.  MS has VBScript (default language), 
JScript and PerlScript
(anyone know of any more?).  If someone was to write PHP to be an 
ASP/IIS module
that could be executed under the ASP framework, then yes.  Until 
then, no.  I also
don't think it's a likely scenario, but I've been wrong many times 
before in my life.  :)



Chris Anderson wrote:

  This is going to sound like heresy, but is there any way to use 
ASP and PHP in the same fle/page? Seperated of course.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

##
#  Rick St Jean,
#  [EMAIL PROTECTED]
#  President of Design Shark,
#  http://www.designshark.com/
#  Quick Contact:  http://www.designshark.com/messaging.ihtml
#  Tel: 905-684-2952
##



-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Question: Number of Characters

2001-04-01 Thread Steve Edberg

At 4:16 PM -0700 4/1/01, Marcus Ouimet wrote:
   How can i determine the number of characters in a string? I 
am using substr
to cut off the last 4 characters of a string. Which is working great. But I
want to replace the 3 charcters with "..." only if there are over 20
charcters . I tried substr_replace but it appears on everything no matter
how many characters. I am trying to do this is simple terms:


Use strlen(). For example:

$String = 'hi my name is';
if (strlen($String)  20) {
$String = substr($String, 0, 17).'...';
}

In PHP4, you can use the substr_replace() function to replace the 
third line in the example above:

$String = 'hi my name is';
if (strlen($String)  20) {
$String = substr_replace($String, '...', 17);
}

For more information, see

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

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

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

-steve


if the string was:

hi my name is

it is returned shortened to:

hi ...

   Any help appreciated.


-- 
+--- 12 April 2001: Forty years of manned spaceflight ---+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- www.yurisnight.net --+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] $PHP_SELF not working -please help

2001-12-19 Thread Steve Edberg

Is the code below in a function? If so, you'll have to globalize $PHP_SELF:

function your_function() {
global $PHP_SELF;

...
echo $PHP_SELF;
..
}

alternatively, you could do

function your_function() {

...
echo $GLOBALS['PHP_SELF'];
..
}

To the best of my knowledge, PHP_SELF is set regardless of the 
register_globals configuration setting, but I'm not 100% sure.

-steve



At 11:13 AM + 12/19/01, Caleb Carvalho wrote:
Hi there,

I have created a script that is suppose to get some input from
user and display back, and i have the following method

FORM METHOD=POST ACTION=? echo $PHP_SELF ? 

so i have a script that if login fails it will ask the user
to register,


if(!$username) {
  session_unregister(userid);
  session_uregister(userpassword);
  echo Authorisation Failed. .
   you must enter a valid credentials..
   try again.BR\n;
echo A HREF=\$PHP_SELF\Login/ABR;
echo If you're not a member please regsiter.BR\n;
echo A HREF=\$register_script\Membership/A;
exit;
}
else echo welcome, $username!;


Now for some strange reasons it tries to access my web direcorty 
that does not contain any file, and i get the 404 page not found 
error.

any help would do,

Thanks

Caleb



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP3 NOT being parsed for SSI!! HELP!!

2001-12-20 Thread Steve Edberg

If you're using PHP as an Apache module, you can use virtual() -

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

- to include the dynamic parts; vcstatic includes could be handled by 
virtual() or just a normal PHP include()/require().

- steve



At 11:09 PM -0800 12/19/01, Thomas Edison Jr. wrote:
Folks,

I have a serious problem and i don't know what to do.

We have a fixed  template  for  each intranet page.
Now the template consists of a header, a left
navigation and a footer. The body would contain
my pages content.

What we are doing at present is that the header, the
left navigation and the footer is included in the page
using SSI.  The header is a static include file.
However the footer and the left navigation are
customizable, and hence are dynamic pages (cgi
scripts) which generate the appropriate code depending
on the command line parameters.

Now the problem is that php3 pages are not being
parsed for SSI. I looked up on the web , and
found that only one of two can be used at the same
time.

Can anyone suggest a Possible Solution? We are running
a Solaris machine!

Thanks,
T. Edison Jr.

=
Rahul S. Johari (Director)
**
Abraxas Technologies Inc.
Homepage : http://www.abraxastech.com
Email : [EMAIL PROTECTED]
Tel : 91-4546512/4522124
***



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Number Format

2001-12-20 Thread Steve Edberg

Or
 http://www.php.net/manual/en/function.sprintf.php
or
 http://www.php.net/manual/en/function.printf.php



At 04:45 PM 12/20/01 , Bogdan Stancescu [EMAIL PROTECTED] wrote:
if ($i10) { $i=0.$i } ? :-)

phantom [EMAIL PROTECTED] wrote:

  I would like to format numbers to be a fixed width.
 
  I want all numbers to be 2 characters in width to the left of the
  decimal point.
 
  1 should be 01
  2 should be 02
  3 should be 03
 
  How can I do this?
 


++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] INI file parsing

2002-01-02 Thread Steve Edberg

AFAIK, it will reread the .ini file every time only if you're running PHP 
as a CGI, as opposed to an Apache module (or ISAPI or NSAPI module, but I 
don't think either of those are industrial strength yet). SO, yes, the .ini 
file will be reread each time PHP is called by IIS.

-steve

At 01:02 PM 1/2/02 , Joe Webster wrote:
If so that would be totally shitty (in the respects of effecienty)


Charlesk [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I am running IIS 5.0 Windows 2000 Server.  Changes made to the ini take
effect immediately.  So it seems that php in Windows and IIS reloads the ini
every time a page is requested?
 
  Charles Killmer
 
  -- Original Message --
  From: Joe Webster [EMAIL PROTECTED]
  Date: Wed, 2 Jan 2002 15:46:32 -0500
 
  no you need to restart apache to change an in setting. So it loads the
  settings once per server start (at least with apache).
 
  Charlesk [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]...
   Does PHP parse the ini file every time a file is requested?  I am trying
  to track down a problem on various pages where the timelimit will expire.
  These are not complex pages and when I go to them they work fine.
   I have used the same browser that the user eses when the timeout occurs.
  Nothing strange for me.
   I have looked at the line that the error log specifies and it is just
  random lines.  sometimes it is a '}'.  As if the script just ran out of
time
  on that line.  BTW '}' is the closing of an if statement so it isnt stuck
in
  a loop.  And when I go to the page I make sure to use the same querystring
  that the user sent.
  
   Another thought, is the php engine slowed by users with a slow
connection?
  
   Charles Killmer
   NetgainTechnology.com
 
 

++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] string to array??

2002-01-17 Thread Steve Edberg

Actually, you can treat a string as an array without any further processing:

$Globbot = 'dribcot';
echo $Globbot[0];   # echoes 'd'
echo $Globbot[6];   # echoes 't'

Check out 'String access by character' about halfway down the page at

http://www.php.net/manual/en/language.types.string.php

(or, in Portuguese,

http://www.php.net/manual/pt_BR/language.types.string.php

).

Actually, using the [] syntax is deprecated - using {} is the new way 
- but I'm a creature of habit...

-steve



At 11:57 AM +0100 1/17/02, Nick Wilson [EMAIL PROTECTED] wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* On 17-01-02 at 11:46
* Sandeep Murphy said

  hi,

  can i convert a string to an array?? if so how shud the syntax read??

  Thnx,

  sands


Check out explode()
www.php.net/manual/en/function.explode.php

- --

Nick Wilson

Tel:   +45 3325 0688
Fax:   +45 3325 0677
Web:   www.explodingnet.com



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] string to array??

2002-01-17 Thread Steve Edberg

Sorry if I was less than totally clear; I was referring to this part 
of the page:


Characters within strings may be accessed by specifying the 
zero-based offset of the desired character after the string in curly 
braces.

Note: For backwards compatibility, you can still use the 
array-braces. However, this syntax is deprecated as of PHP 4.

Example 6-3. Some string examples

SNIP

/* Get the first character of a string  */
$str = 'This is a test.'
$first = $str{0};


...and that was the first I'd noticed that myself; I assume that the 
{} syntax is only being used to refer to arrays as strings, to avoid 
confusion with an array of strings -

$str = array('string 1', 'thing 2');
echo $str[0]; # produces 'string 1'

- and a scalar string variable being treated as an array of 
characters. So I'm guessing (too lazy to test right at the moment) 
that you would get

$str = array(array('bork','fubar'), 'snafu');
echo $str[0][1]; # produces 'fubar'
echo $str[1][1]; # produces null
echo $str[1]{1}; # produces 'n'

Again, that's just what I'm assuming from the docs. A quick test 
would clear it up, but it doesn't affect me right now, and I'm 
feeling lazy ;)

Hope that clears up my statement...

-steve


At 12:11 PM -0500 1/17/02, Erik Price wrote:
I didn't know that either.  Does this apply only when accessing 
strings by character?  Or are all conventional uses of brackets 
deprecated for the purposes of arrays?

It doesn't say on that page 
(http://www.php.net/manual/en/language.types.string.php , a bit more 
than halfway down).


Erik


Actually, using the [] syntax is deprecated - using {} is the new way
- but I'm a creature of habit...





-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Any Ideas

2002-01-26 Thread Steve Edberg

Or do it all in one line:

$string = ereg_replace('[!@#$%^*()_+=-';:/.,?]', '', $string);

If you want to remove non-alphanumeric characters from a string, you can do:

$string = ereg_replace('[^[:alnum:]]', '', $string);

Perl-compatible regular expressions would work as well, and be 
slightly faster. For more info, see:

http://www.php.net/manual/en/function.ereg.php
http://www.php.net/manual/en/ref.regex.php
http://www.php.net/manual/en/ref.pcre.php

-steve


At 12:21 PM -0800 1/26/02, qartis [EMAIL PROTECTED] wrote:
I'm guessing something along the lines of:

--
$string=str_replace(!,,$string);
$string=str_replace(@,,$string);
$string=str_replace(#,,$string);
$string=str_replace($,,$string);
$string=str_replace(%,,$string);
$string=str_replace(^,,$string);
--

etc.

Philip J. Newman [EMAIL PROTECTED] wrote in message
003d01c1a6a5$fa7d60e0$0401a8c0@philip">news:003d01c1a6a5$fa7d60e0$0401a8c0@philip...
Any Ideas how I can remove   !@#$%^*()_+=-';:/.,? charactors from a
string?

Philip J. Newman
Philip's Domain - Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]
Phone: +64 25 6144012


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Ports

2002-02-04 Thread Steve Edberg

Well, a quick google -

 http://www.google.com/search?hl=enq=tcp+ports

- gave me:

 http://www.networkice.com/advice/Exploits/Ports/
and
 http://www.iana.org/assignments/port-numbers

 This would presumably be the authoritative source; the answer to 
your questions is at the top of this (very long) page.

 -steve


At 04:20 PM 2/4/02 , Liam MacKenzie wrote:
Just a quick question...
What is the highest port possible?

I want to make a PHP port scanner, but need to know the portrange.

Thanks




++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] Using a mysql data base and cookie to log a person in

2002-02-20 Thread Steve Edberg

Have you considered PHPLIB?

http://phplib.sourceforge.net/

http://sourceforge.net/projects/phplib

http://www.sanisoft.com/phplib/manual/

The docs'll give you an idea of how they did it. The code is pretty 
complex, though, but it does a lot. I'd suggest using this as a base, 
if PHP4's session handling isn't sufficient. I use it, with my own 
hacks for my authorization needs.

-steve


At 8:38 AM -0800 2/20/02, Brandon Orther wrote:
Hello,

I loosely understand how I can have a person login to a system by giving
them a cookie with a certain amount of time with a encrypted code.  And
save that same encrypted code in the database for a certain amount of
time.  I am looking for a tutorial on how to do this so I can wrap my
mind around it a little better.

If anyone knows a good tutorial on how to log people into your site
using a userser database please hook me upZ wiT da Inf0z

Brandon Orther
WebIntellects Design/Development Manager [EMAIL PROTECTED]
800-994-6364
www.webintellects.com




-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

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




Re: [PHP] running commands as root from a script

2002-03-28 Thread Steve Edberg

I have done a similar thing by executing another script via sudo using the 
PHP command passthru() (or you could use exec(), system(), whatever's 
appropriate). See

 http://www.courtesan.com/sudo/

for more info. The whole setup was (and is) a bit of a kluge, but the 
script didn't need to be run often so it doesn't impact server performance any.

 -steve

At 09:37 AM 3/28/02 , Ken Nagorski wrote:
Hi there,

I have a little problem. I need to run a few commands for Courier from a
script. What I have is a php based application that makes it easy to create
and manage virtual domains and the addresses for them from the web. However
when You Apply the changes everything is written to /tmp dir and the a
little perl script parses the file and moves things where they need to go
and then runs couriers makealiases command. Now you can't run a perl script
SUID so I wrote a C program that just calls system() and runs the script and
it is SUID. This doens't work however. No matter what I do. It is like
Courier ignores this.

I can't imagine there isn't anyone who has not run into the problem of
automating things via PHP and not had to run a system command as root at
some point in time. I am wondering what the different approaches to this
problem are.

Thanks
Ken




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

++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+


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




RE: [PHP] Re: Automatic user login under NT

2002-06-12 Thread Steve Edberg

At 01:39 PM 6/12/02 , Barajas, Arturo wrote:
  From: Lazor, Ed [mailto:[EMAIL PROTECTED]]

Hi, Ed.

  and I'm pretty sure I'm not the only one he's helped.  That
  garners even more respect - IMHO.

I'm new on the list, so I really don't know Rasmus, or what he does. As 
far as I've read messages, he seems to be really appreciated and 
respected, one way or another.


You can check out this bit from the PHP archives, written by Rasmus:

 http://www.php.net/manual/phpfi2.php#history

and take a look through the credits

 http://www.php.net/credits.php

and count how many times his name appears. In short, PHP sprang from his 
brain. Now, it springs from many brains.

 -steve


++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] Usiing FOREACH to loop through Array

2002-06-29 Thread Steve Edberg

At 3:27 PM -0700 6/29/02, Brad Melendy wrote:
Hi All,
I've stumped myself here.  In a nutshell, I have a function that returns my
array based on a SQL query and here's the code:

-begin code---
function getCourses($UID)
  {
  global $link;
  $result = mysql_query( SELECT C.CourseName FROM tblcourses C, tblusers U,
tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
$UID, $link );
  if ( ! $result )
   die ( getRow fatal error: .mysql_error() );
  return mysql_fetch_array( $result );
  }
end code 

I call this from a PHP page with the following code:

begin code--
$myCourses = getCourses($session[id]);
foreach ($myCourses as $value)
  {
  print br$value;
  }
end code---

Now, when I test the SQL from my function directly on the database, it
returns just want I want it to return but it isn't working that way on my
PHP page. For results where there is a single entry, I am getting the same
entry TWICE and for records with more than a single entry I am getting ONLY
the FIRST entry TWICE.

Now I know my SQL code is correct (I am testing it against a MySQL database
using MySQL-Front) so I suspect I'm doing something stupid in my foreach
loop.


I think your problem lies in a misunderstanding of the 
mysql_fetch_array() function. It doesn't return the entire result set 
in an array - just one record at a time. You can fix this in one of 
two ways:

(1) Loop though the entire result set in your function:

function getCourses($UID)
 {
  global $link;

  $ResultSet = array();

  $result = mysql_query( SELECT C.CourseName FROM tblcourses C, tblusers U,
   tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
   $UID, $link );

  if ( ! $result )
   die ( getRow fatal error: .mysql_error() );

  while ($Row = mysql_fetch_array( $result ))
  {
   $ResultSet[] = $Row['C.CourseName'];
  }

  return $ResultSet;
 }

...

$myCourses = getCourses($session[id]);
foreach ($myCourses as $value)
 {
 print br$value;
 }

or (2) set a flag in getCourses() so that the query is only executed 
once, otherwise returning a result line - something like:

function getCourses($UID)
 global $link;
 static $result = false;

 if (!$result)
  {
$result = mysql_query( SELECT C.CourseName FROM tblcourses C, 
tblusers U,
 tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
 $UID, $link );
if ( ! $result )
 die ( getRow fatal error: .mysql_error() );
  }
 {
 return mysql_fetch_array( $result );
 }

...

while ($Row = getCourses($session[id]) as $value)
 {
 print br, $Row['C.CourseName'];
 }

(standard caveats about off-top-of-head, untested code apply)

The reason you are getting the first record TWICE is becaouse of the 
default behaviour of the mysql_fetch_array() function. It returns 
both an associative array - ie, elements of the form field-name = 
value - and a numerically indexed array (0, 1, 2, etc.). You can 
alter this behaviour by the second parameter of the function: see

http://www.php.net/manual/en/function.mysql-fetch-array.php

-steve


I'm hoping someone will spot my dumb mistake.  Thanks very much for any help
at all on this.

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/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Usiing FOREACH to loop through Array

2002-06-29 Thread Steve Edberg

Oops! It's hot, it's Saturday, brain not functioning at 100%, made 
cut'n'paste error:

SNIP

or (2) set a flag in getCourses() so that the query is only executed 
once, otherwise returning a result line - something like:

function getCourses($UID)
 global $link;
 static $result = false;

 if (!$result)
  {
$result = mysql_query( SELECT C.CourseName FROM tblcourses C, 
tblusers U,
 tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
 $UID, $link );
if ( ! $result )
 die ( getRow fatal error: .mysql_error() );
  }
 {
 return mysql_fetch_array( $result );
 }

...

while ($Row = getCourses($session[id]) as $value)
 {
 print br, $Row['C.CourseName'];
 }

SNIP

This last block of code should be

while ($Row = getCourses($session[id]))
 {
 print br, $Row['C.CourseName'];
 }

-steve
-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Usiing FOREACH to loop through Array

2002-06-29 Thread Steve Edberg

At 7:35 PM -0700 6/29/02, Brad Melendy wrote:
Steve,
Thanks very much.


You're welcome!


This make total sense to me.  Now, I was pretty sure that
I was getting an array back from mysql_fetch_array because when I do a
'print $myCourses' without specifying any value, I just get 'array' which I
believe I am supposed to, IF it is truly an array.  Anyway, I'm going to
revisit the mysql_fetch_array function right now.  Thanks for your help, it
is greatly appreciated.

...Brad


Just to clarify a bit - mysql_fetch_array() DOES return an array - 
thus the name - but it is an array containing one record from the 
result set. For instance, if the result of the statement

SELECT C.CourseName
FROM tblcourses C, tblusers U, tblEnrollment E
WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID = 1

through the MySQL commandline was

+-+
| C.CourseName|
+-+
| Basketweaving   |
| Noodle twirling |
| Poodle furling  |
| Puddle curling  |
+-+

then the first use of mysql_fetch_array($result) through PHP would 
retrieve the array

'C.CourseName' = 'Basketweaving',
0 = 'Basketweaving'

the second call would retrieve

'C.CourseName' = ' Noodle twirling',
0 = ' Noodle twirling'

and so on. If you had two columns in the result set:

+-++
| C.CourseName| C.CourseNo |
+-++
| Basketweaving   | 12 |
| Noodle twirling | 23 |
| Poodle furling  | 24 |
| Puddle curling  | 25 |
+-++

you would get results like

'C.CourseName' = 'Basketweaving',
0 = 'Basketweaving',
'C.CourseNo' = 12,
1 = 12

and so on. The reason you get the doubled keys (associative  
numeric) is for historical compatibility; to turn off the feature, 
and retrieve only the associated indexes (the behavior you normally 
want), you can use

mysql_fetch_array($result, MYSQL_ASSOC);

Incidentally, I just learned something here myself; there's a 
relatively new (= version 4.0.3) function mysql_fetch_assoc() which 
does what you want...return ONLY the associated indexes. See:

http://www.php.net/manual/en/function.mysql-fetch-assoc.php


-steve



Steve Edberg [EMAIL PROTECTED] wrote in message
news:p05100300b943f2a7feef@[168.150.239.37]...
  At 3:27 PM -0700 6/29/02, Brad Melendy wrote:
  Hi All,
  I've stumped myself here.  In a nutshell, I have a function that returns
my
  array based on a SQL query and here's the code:
  
  -begin code---
  function getCourses($UID)
{
global $link;
 $result = mysql_query( SELECT C.CourseName FROM tblcourses C, tblusers
U,
  tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
   $UID, $link );
if ( ! $result )
 die ( getRow fatal error: .mysql_error() );
return mysql_fetch_array( $result );
}
  end code 
  
  I call this from a PHP page with the following code:
  
  begin code--
  $myCourses = getCourses($session[id]);
  foreach ($myCourses as $value)
{
print br$value;
}
  end code---
  
  Now, when I test the SQL from my function directly on the database, it
  returns just want I want it to return but it isn't working that way on my
  PHP page. For results where there is a single entry, I am getting the
same
  entry TWICE and for records with more than a single entry I am getting
ONLY
  the FIRST entry TWICE.
  
  Now I know my SQL code is correct (I am testing it against a MySQL
database
  using MySQL-Front) so I suspect I'm doing something stupid in my foreach
  loop.


  I think your problem lies in a misunderstanding of the
  mysql_fetch_array() function. It doesn't return the entire result set
   in an array - just one record at a time. You can fix this in one of
  two ways:

  (1) Loop though the entire result set in your function:

  function getCourses($UID)
   {
global $link;

$ResultSet = array();

$result = mysql_query( SELECT C.CourseName FROM tblcourses C,
tblusers U,
 tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND
U.ID =
 $UID, $link );

if ( ! $result )
 die ( getRow fatal error: .mysql_error() );

while ($Row = mysql_fetch_array( $result ))
{
 $ResultSet[] = $Row['C.CourseName'];
}

return $ResultSet;
   }

  ...

  $myCourses = getCourses($session[id]);
  foreach ($myCourses as $value)
   {
   print br$value;
   }

  or (2) set a flag in getCourses() so that the query is only executed
  once, otherwise returning a result line - something like:

  function getCourses($UID)
   global $link;
   static $result = false;

   if (!$result)
{
  $result = mysql_query( SELECT C.CourseName FROM tblcourses C

Re: [PHP] Two cases going to same case?

2002-06-30 Thread Steve Edberg

At 5:18 AM -0400 6/30/02, Leif K-Brooks wrote:
I have a switch in a script I'm working on.  I need to have case 1 
and 2 both to to case 3, but without case 1 going through case 2. 
Is this possible?


No, but you can do it this way:

switch ($foo) {

case 1:
   ...
   do_something();
   break;

case 2:
   ...
   do_something();
   break;

case 3:
   do_something();
   break;

}

function do_something() {

# this is the stuff that you want to do that is common to your
# cases 1, 2 and 3

}

This accomplishes the same thing.

-steve


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Odd Request: Image 2 HEX

2002-07-09 Thread Steve Edberg


$hFile = fopen($PathToFile,'r');
$File = fread($hFile, $SizeOfLargestImageYouHave);
fclose($hFile);
$HexVal = bin2hex($File);

This doesn't do any error checking or stripping of image headers that 
may be necessary; you'll have to use string functions (eg; substr() 
or maybe regexps) to do that.

For more info, see:

http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fread.php
http://www.php.net/manual/en/function.bin2hex.php


-steve


At 9:08 AM -0700 7/9/02, JSheble wrote:
I'm using a Zebra label printer in an application I have and in 
order to display an image on the label, according to the ZPL II 
printer language, any image must be converted to HEX code. Does 
anyone hvae a code snippet or know of a free utility that will take 
a graphic image (BMP, GIF, JPG, etc...) and convert it to HEX values?

Thanx...



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] GD Lib

2002-07-09 Thread Steve Edberg

Are you compiling php with the --with-gd=shared option?

Personally (Solaris 8, gcc 2.95.3 , php 4.1.1 and later) I've never 
been able to get the gd shared object to work (gd.so load errors), so 
I've always ended up compiling it into PHP.

-steve


At 1:23 PM -0400 7/9/02, Yang wrote:
Hi Dave:

I have gd installed and now the configure, make and make install are working
fine. but aftere installation, I can't find any extension there.

Yang

Dave Macrae [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Hi there;
  
   I installed Apache2.0.39 and PHP4.2.1 on RedHat Linux 7.2. The
   installation
   procedure is fine. The php installation inlcude gd and some
   extension, but I
   can't find the php-gd.so on my computer.
  
   Anybody can help?

  Looks like the problem is that you haven't installed GD.

   Dave



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Check for Associative Array

2002-07-18 Thread Steve Edberg

At 12:57 PM -0400 7/18/02, Henning Sittler wrote:
What's the best way to check for an Associative Array?  There is no
is_assoc() or similiar function listed in the manual (I don't think anyway).


No, because AFAIK all PHP arrays are associative; there is no 
distinction between arrays  hashes as in Perl.


I'm using mysql_fetch_array() and I want to foreach only the assoc. part of
the array without using mysql_fetch_assoc():

foreach ($arr as $key=$value) {
   echo $key:$value;
}


If you really don't want to use mysql_fetch_assoc(), you can use the 
second parameter of mysql_fetch_array():

$arr = mysql_fetch_array($ResultHandle, MYSQL_FETCH_ASSOC);

This functions exactly like mysql_fetch_assoc(), and is available in 
PHP = 3.0.7.

See

http://www.php.net/manual/en/function.mysql-fetch-array.php

for more info.


But of course it show both the indexed array and the assoc array contents.
Is there an existing function to check this, or should I do one of these
things inside the foreach loop:

A) set $last=value and just check if $value = $lastval

B) check if the $key is just a number or just a string

C) $key += 1


Lastly, you _could_ just step through the array using each() in a 
loop, and use only every OTHER array entry...but this is really funky 
and you shouldn't do it this way anymore.

-steve



?? Thanks,


Henning Sittler
www.inscriber.com



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] viewing get/post variables

2002-04-16 Thread Steve Edberg

You might be thinking of the register_globals parameter here, instead
of safe_mode:

http://php.he.net/manual/en/configuration.php#ini.register-globals

It is, in general best to keep this off so that you can explicitly
validate user input. If you trust the POST or GET data, though, you
can turn register_globals ON or use the extract() function -

http://php.he.net/manual/en/function.extract.php

- for example:

extract($HTTP_GET_VARS);
echo $var1;

or in a function,

extract($GLOBALS['HTTP_GET_VARS']);
echo $var1;

I don't think the safe_mode setting affects this, but I'm not sure.
Some of the default settings may have changed between 4.0.6  4.2;
that might explain why behavior changed after upgrading.

-steve



At 10:43 AM -0300 4/16/02, Martín Marqués wrote:
On Mar 16 Abr 2002 10:35, Christoph Starkmann [EMAIL PROTECTED] wrote:
  Hi Martín!

   I can't remmeber how to configure php.ini so that if I get the URL
   http://localhost/index.php?var1=10
   an echo $var1 will return 10
   What I mean, is that _GET[var1] exists, but I want $var1 to
   be available.

  If $var1 is not available directly, your safe_mode seems to be
  turned on.
  One way would be to turn safe_mode off again: change the line

  safe_mode=On
  to
  safe_mode=Off

safe_mode is Off.

  in your php.ini.

  The safer way would be to prepare $var1, for example like this:

  $var1 = $HTTP_GET_VARS[var1];

  Now you can use $var1.

Before I upgraded PHP form 4.0.6 to 4.2.0RC2 it worked directly, without
having to pass the $HTTP_GET_VARS.

Saludos... :-)

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telematica
Universidad Nacional
 del Litoral
-


--
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| If only life would imitate toys. |
|  - Ted Raimi, March 2002   |
|  - http://www.whoosh.org/issue67/friends67a.html#raimi |
++

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




[PHP] Re:phpinfo

2002-05-23 Thread Steve Edberg

You might want to take a look at:

http://www.php.net/manual/en/ref.info.php

Specifically, get_cfg_var(), ini_get(), and ini_get_all()

-steve



At 10:08 AM -0700 5/23/02, Dennis Gearon wrote:
What I was trying to do was to find out how to get magic_quotes_sybase
config value. This will do it:
 $test = addslashes(');
 $this-sybase_magic  = strcmp( $test, \\');

Also, I looked up eval(), it doesn't return the output of all fucntions
like I thought. I would have to use system, the backticks, invoke php as
a one time interpreter, OR, have a page that I call that has the
appropriate version of PHPINFO in it, and call that page and process the
returned call, from with in the current script.

Dennis Gearon [EMAIL PROTECTED] wrote:
--
has anyone tried to eval() php info to prevent it from being displayed
Lso it could be processed for config checking, instead?

Since what version have the 'subsections' of phpinfo() been available,
like
 phpinfo(INFO_CONFIGURATION); ?
--
--

If You want to buy computer parts, see the reviews at:
http://www.cnet.com/
**OR EVEN BETTER COMPILATIONS**!!
http://sysopt.earthweb.com/userreviews/products/

--
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/ |
++
| If only life would imitate toys. |
|  - Ted Raimi, March 2002   |
|  - http://www.whoosh.org/issue67/friends67a.html#raimi |
++

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




Re: [PHP] Making varibles (more than one) with a function.

2002-05-23 Thread Steve Edberg

Because global is specific to the SCOPE not to the variable - 
variables themselves aren't tagged as global. If you add

global $text;

in your echoo() function it will work. Alternatively, you could replace

echo $text;
with
echo $GLOBALS['text'];

in your echoo() function.

See
http://www.php.net/manual/en/language.variables.php

for more info.

-steve


At 3:17 PM -0600 5/23/02, David Duong wrote:
If that works than the why does test file I tried previously to making the
post return a $text does not exist error?
?
echoo();

function test() {
$text = Testing;
global $text;
}

function echoo() {
test();
echo $text;
}

?

Sqlcoders.Com Programming Dept [EMAIL PROTECTED] wrote in message
009f01c20241$f05aaf80$6520fea9@dw">news:009f01c20241$f05aaf80$6520fea9@dw...
  Sqlcoders.com Dynamic data driven web solutions

  - Original Message -
  From: David Duong [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: May 22 2002 04:21 PM
  Subject: [PHP] Making varibles (more than one) with a function.
   I am aware that return can return strings but is their a set global or a
   function similar to return?

  hi there!,
  There sure is, it's called global.
  Usage:
  global $variable_a;
  global $variable_b;
  global $variable_c;
  ...

  HTH,
  Dw.

   


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| If only life would imitate toys. |
|  - Ted Raimi, March 2002   |
|  - http://www.whoosh.org/issue67/friends67a.html#raimi |
++

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




Re: [PHP] Disturbing parsing problems

2002-07-29 Thread Steve Edberg

At 12:19 PM -0400 7/29/02, [EMAIL PROTECTED] wrote:
   I added a few number_format() statements to previously working code (not
having changed any {}s ) and it started getting parse errors, 'unexpected
t_if, expected t_while'.  In other words, it thinks the do statement shown
below has been closed, and wants to hear about the while part.

 I checked over the sets of braces about 10 times, but the only way to
fix it ended up being to have an uneven number of braces - two close braces
needed eliminating.  I'm not going to post all the code unless it's
necessary but here is the basic control structure.  I've shown here what
braces I commented out.  All of the below is escaped in and out of HTML many
times.

 PHP 4.2.2 on Windows 2000 Professional.  Is this a bug, or have people
experienced weird problems with braces before?

Regards,
Colin Teubner

if (){
 do {
 if (){
 while () {}
 if () ;
 else if ();
 else ;
 }


I assume you mean

if () :
else if ():
else :

here (colon instead of semicolon)? AFAIK PHP doesn't allow the 
alternative syntax -

http://php.he.net/manual/en/control-structures.alternative-syntax.php

- with semicolons. Or do you really mean

if () {}
else if () {}
else {}

If you are using the alternative syntax, I recall several messages 
about people having problems nesting both forms of syntax. Try using 
all one style or the other.

Lastly, quadruple check that you haven't accidentally quoted or 
double-quoted a { or ( or something that you THOUGHT was part of PHP 
code; syntax highlighting editors can definitely help here.

-steve


 if () {}
 if () {
 if {
 }
 // }
 if () {
 if {
 }
 // }
 } while ();
 if() {} //(4x)
}

--
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/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Vars passed via URL disappearing

2002-08-02 Thread Steve Edberg

At 3:29 PM -0400 8/2/02, Monty wrote:
I just upgraded to PHP 4.2.2 and am trying to make my sites work with
register_globals turned OFF. I notice, however, that with register_globals
turned off any variables I pass via the URL don't seem to be recognized by
the script it was passed to.

So, if I pass http://my.site.com/page.php?id=2002;, the variable id is
empty when I try to access it in page.php ...

if (!empty($id)) { do stuff...}
else { echo error; }

With register_globals OFF, the above produces the error message. With
register_globals ON, it works fine.

I thought register_globals only affected session, cookie and get type
variables? Why is PHP ignoring the variables passed via the URL?


'variables passed via the URL' = 'GET variables'

-steve


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




RE: [PHP] Open 10 http connections in parallel

2002-08-08 Thread Steve Edberg

I've never done this before, but you probably could open these 
connections via a socket, and set them all non-blocking. Presumably 
you'd them have to write a loop that polled all connections to check 
if they'd closed, or time them out after some number of seconds. See

http://php.he.net/manual/en/function.socket-set-blocking.php
and
http://php.he.net/manual/en/ref.network.php


-steve

At 1:28 PM +1000 8/9/02, Martin Towell [EMAIL PROTECTED] wrote:
use C and fork()
php (AFAIK) can't do parallel programming

-Original Message-
From: NoWhErEMan [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 09, 2002 12:58 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Open 10 http connections in parallel


Hello,

I had to write a script  to open 10 http connections for different links and
get the response from the host.
I do it by fopen each url one by one and save the response to a separated
file. But it slow!
I wonder if i can open 10 connnect (or more) in parallel?

Thanks in advance.
NoWhErEMaN


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Average Number For Math Functions

2002-08-29 Thread Steve Edberg

At 05:55 PM 8/29/02 , JohnP wrote:
Ok I looked at all the math functions for PHP but saw no way of returning 
the average of a set of numbers - I plan on using this for a rating system 
- any help?

--
John


Nope - you'll have to 'roll your own' by looping though the set, or (if you 
have version = 4.0.5) you can use array_reduce() in conjunction with the 
count() function.

If these values are coming from a database, most databases have aggregate 
functions to do sums, averages, etc.

-steve




++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] request what a user clicked

2002-08-30 Thread Steve Edberg

At 03:12 PM 8/30/02 , stu9820 wrote:
what is php's request object?
like in ASP - Request(variable)


Short answer:

 $_REQUEST['variable']
 (for PHP version = 4.1.0)

Long answer:

 http://www.php.net/manual/en/language.variables.external.php

-steve


Jeff
UWG Student
[EMAIL PROTECTED]


++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] whitespace...

2002-09-04 Thread Steve Edberg

At 04:37 PM 9/4/02 , Matt Zur wrote:
How do I remove the whitespace from a document? I consulted the manual and 
it said to use the trim function.  But in a large PHP document, with lots 
of fuctions etc in PHP... is there a simple way to compress the whitespace 
of the entire document?  Rather than going through each var and using the 
trim?  Like add a header at the top:  ?PHP compresswhitespace() ?


If you have a 300k php document, won't the source code reveal (after the 
browser displays the page) a bunch of whitespace.  Doesn't this add to dl 
time and if so, how do I get rid of it.

Not 100% sure if I understand the drift of your question, but here's a few 
possibilities.

(1) Are you concerned about whitespace you put in a PHP program to enhance 
readability slowing down page loads?

Any whitespace WITHIN PHP tags does not get sent to the browser at all. So 
you don't need to worry about it.

(2) Are you concerned that the OUTPUT of your PHP program and/or HTML 
embedded therein might have excessive whitespace? If so, you could create 
an output handler that cleans up the output before sending, I think; see

 http://www.php.net/manual/en/ref.outcontrol.php

Or, use compression. See:

 http://www.php.net/manual/en/function.ob-gzhandler.php

(3) If you simply wanted to clean up excessive whitespace in a file, you 
could use a snippet like:

 ...read file into $file variable

 # Replace multiple spaces/tabs with a space
 $file = preg_replace('/[ \t]{2,}/','/ /', $file);
 # Replace multiple lines with single line
 $file = preg_replace('/(\n|\r|\r\n){2,}/', '\r', $file);

 ...write $file back out

That last line for replacing multiple blank lines is probably wrong; at the 
very least you'd have to do some platform checking (Win vs. Mac vs. Unix) 
to get the proper line ending. You might also be able to use the pattern 
'/(^$){2,}/m'

In PHP4 I think you can use arrays:

 ...read in
 $file = preg_replace(
 array('/[ \t]{2,}/', '/(\n|\r|\r\n){2,}/'),
 array('/ /', '\r'),
 $file
 );
 ...write out

See

 http://www.php.net/manual/en/function.preg-replace.php
 http://www.php.net/manual/en/pcre.pattern.syntax.php
 http://www.php.net/manual/en/pcre.pattern.modifiers.php

-steve


++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] PHP and Apache

2002-09-06 Thread Steve Edberg

It's certainly _possible_ -

Your httpd.conf (I'm assuming you use Apache, of course) file is just 
a text file that can be read/written like anything else. Then you 
could do a

system('/path/to/apache/bin/apachectl restart');

to activate. Doing it this simply, thoughm means that your 
webserver's user (usually nobody) would have write access to the conf 
file and execute perms to apachectl, which could open up some 
bulldozer-security holes. At the very least, you want to access 
things through SSL.

But you might want to try Webmin:

http://www.webmin.com/

Looks very comprehensive, and I've seem a number of good 
recommendations for it. I've been planning on doing a little testing 
of it on my test server, but haven't had the time.

-steve



At 4:48 PM +0100 9/6/02, Tim Haynes wrote:
Is there any easy way of creating,editing and deleting virtual hosts using
PHP via a website??  I have already thought of a way but seems a little long
winded.

Thanks in advance.


-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] Need more memory... possible to set?

2002-09-10 Thread Steve Edberg

Several ways:

(1) PHP still reads a php.ini file, so you could set it there; try a

php -i | grep php.ini

to find out where the commandline php thinks it is (and/or do

php -i | grep memory_limit

to find the default memory limit setting.

(2) You can set it at execution time via the -d command option:

php -d memory_limit=20M -f yourprogram.php

(3) Set it in your program with the ini_set() command:

http://php.he.net/manual/en/function.ini-set.php


-steve



At 11:29 PM -0500 9/9/02, Damian Harouff wrote:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 53738 bytes) in /var/cli/mp3anal/mp3anal.php on line 68.
Segmentation fault

This is line 68: while ($found = fscanf ($fp, %s - - 
[%[A-Za-z0-9/]:%[0-9:] %[+-0-9]] \%[A-Z-] %s %[A-Z0-9/.]\ %[0-9-] 
%[0-9-]\n,
$ip, $date, $time, $ofset, $request, $file, $protocol, 
$code, $bytes)) {

Since this is a command line program, is it possible to set the memory
allocation higher? It's a program to read the mp3 lines out of an apache
log file.

This is the entire program:
http://www.cekkent.net/upload/mp3anal/mp3anal.phps



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| The end to politics as usual:  |
| The Monster Raving Loony Party (http://www.omrlp.com/) |
++

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




Re: [PHP] ucwords added functionality?

2001-09-24 Thread Steve Edberg

I came up with a function to to that last month; see the PHP archives:

http://marc.theaimsgroup.com/?l=php-generalm=99778991424637w=2

-steve


At 11:20 PM -0400 9/23/01, Jack Dempsey wrote:
i could roll my own, and for now will just use a str_replace after ucwords,
but would it be possible to add an optional parameter to ucwords which would
be an array of words to skip? i would think this would be useful to
many.

any thoughts?


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Problem with regex

2001-09-25 Thread Steve Edberg

if (ereg('^[a-z][-a-z0-9\._]*[a-z]$', $TestPwd)) {
echo Good;
} else {
echo Bad password $TestPwd;
}

should do it.

If you want a case insensitive match, use eregi(...) instead. The 
above regexp allows passwords as short as 2 characters. If you want 
to, for example, enforce a password length of 4 to 8 characters, you 
can do:

ereg('^[a-z][-a-z0-9\._]{2,6}[a-z]$', $TestPwd)

See
http://php.he.net/manual/en/function.ereg.php

for more info.


-steve


At 5:55 PM -0700 9/24/01, Oliver Ertl wrote:
Hi,

I need a regex for a username validation. The ereg
function should be used.

o the username must start and end with a-z
o in the middle it could be a-z0-9\.-_
o and never something like this -- -. _- and so on

Thanks for your help

   Oliver



=
mailto: [EMAIL PROTECTED]
www.ertl.co.za

__
Do You Yahoo!?
Get email alerts  NEW webcam video instant messaging with Yahoo! 
Messenger. http://im.yahoo.com


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP is a Bloated Kludge, discuss!

2001-10-04 Thread Steve Edberg

At 4:48 PM +0200 10/4/01, [EMAIL PROTECTED] wrote:
(From behind filing cabinet where I am ducking preparing for flames).

Is it just me or is there anyone else that thinks PHP suffers from not
being modular.  Let me explain myself.  If you write a module for a lot of
procedural languages it sits on the filling system and is called up when it
is needed , loaded into memory and executed. There maybe some cashing which
happens but this is basically how it works.

PHP on the other hand seems to load in ALL the code that MAY be run. i.e.
an include brings things in which are inside an if,  even if the if equates
to false.


Not true; require() has this behavior, but include() does not. See

http://php.he.net/manual/en/function.require.php
and
http://php.he.net/manual/en/function.include.php


-steve



This means that the language is not extendible in the way others are.  If
you do write a function you wish to include in 'only the pages you wish to
use'  you have to first include it, then call it.

This has also meant that things like spell checking functions are built
into the core module rather than called in as or when they are needed.

Then there is the way database connectivity is handled.

There are a load of functions (again in the core language) with there NAMES
containing the name of the database you are connecting to.

For example all MySQL functions are mysql_something and I guess all oracle
ones are oracle_something.  This would only be a minor inconvenience
because wrapper functions can be written but from what I can gather
different databases have different functionality available.

I know this is partly because different databases have different
functionality.  what I would expect to see is a load of generic function
which attempt to provide same functionality where it is available or
implement some of the functionality themselves.  Obviously for some of the
less sophisticated databases these functions would have to do more work and
maybe some functionality wouldn't be available in certain databases (but
only the things like stored procedures).


If you can deal with the 'lowest common denominator' approach, use 
ODBC. Or, as you mentioned, use one of the db wrapper classes 
available in PHPLIB, PEAR or Metabase.


-steve

-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Access $HTTP_POST_VARS from class member fucntion

2001-11-04 Thread Steve Edberg

At 10:41 AM -0800 11/4/01, Daniel Harik wrote:
Hello

  I have a class called Member, it has member function called
  vallidateForm(), i try to pass it a $HTTP_POST_VARS array it looks like this:


clas Member{
var $HTTP_POST_VARS;
function vallidateForm ($HTTP_POST_VARS){
 echo $HTTP_POST_VARS['frmUsername'];
}
}


Syntax here is wrong; you don't need to declare function arguments 
using var; only class variables need that. I'm uncertain what will 
happen if you do this. I would expect that - if PHP's error reporting 
were turned up to the maximum - it might give you a warning message. 
So do either:

(1) Drop the 'var $HTTP_POST_VARS line;

OR do

(2)

clas Member{
var $HTTP_POST_VARS;
function vallidateForm (){
 echo $this-HTTP_POST_VARS['frmUsername'];
}
}

Although option (2) would require rewriting the code below.

Also I assume that the 'clas Member{' line is just a typo, and your 
actual code says 'class Member{'...


$user = new Member;
if($action==register){
global $HTTP_POST_VARS;
$user-vallidateForm($HTTP_POST_VARS);
}else{
$user-displayForm();
}
?

But i can't acces  $HTTP_POST_VARS['frmUsername'] within the function



If you are using an old (any PHP3.x, and I think some early betas of 
PHP4) version of PHP, you need to turn 'track_vars' on to enable 
$HTTP_POST_VARS and other $HTTP_xxx_VARS arrays. If that's the case - 
and you can't upgrade immediately - you need to turn track_vars on in 
httpd.conf, php.ini, or .htaccess (whatever's appropriate in your 
setup).

Hope that helps -

- steve edberg

-- 
+--- my people are the people of the dessert, ---+
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
+ said t e lawrence, picking up his fork +

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Image width??

2001-11-29 Thread Steve Edberg


http://php.he.net/manual/en/function.getimagesize.php


At 9:46 PM + 11/29/01, cosmin laslau wrote:
Hi,

Is there any function or command in PHP that will return the width 
an image (GIF)?

Thanks.



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Reg ex help-Removing extra blank spaces before HTMLoutput

2001-12-04 Thread Steve Edberg

One way to do it is:

$NewString = ereg_replace('[[:space:]]+', ' ', $String);

There are also ways to do it with preg functions that are slightly 
more efficient; see the pcre docs. And, the standard (AFAIK) 
reference book for regular expressions is O'Reilly's 'Mastering 
Regular Expressions'; a worthwhile purchase.

-steve


At 2:06 AM -0500 12/5/01, Ken wrote:
I want to remove all superfluous blank spaces before I sent my HTML 
output, to make the output smaller.

So I'd like to take $input, replace any number of blank space or 
newlines that are consecutive and replace them with a single blank.

I.e. I will list a blank space as b and a newline as n:

If input is: bTEXTHEREbbbnnnbnMOREbEVENMORE
Then output should be: bTEXTHEREbMOREbEVENMORE

I imagine this would be handled by a simple regular expression call, 
but I'm no pro with them yet.

Any help?

Thanks,
Ken
[EMAIL PROTECTED]



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] last entry in mysql

2001-12-12 Thread Steve Edberg

This may be stating the obvious, but:

(1) Does your table have an auto_increment column?

(2) If so, did a previous query in the program - for example, an 
INSERT - generate a new record with an auto_incremented value? AFAIK, 
mysql_insert_id() won't return the last id unless you have a previous 
query in that same program that INSERTED/UPDATED an auto_incremented 
column.

If you want the maximum value of the column, you can always issue the query:

SELECT
max(your_auto_incremented_column_name_here)
FROM
your_table_name_here


At 10:30 AM -0600 12/12/01, Yoed Anis wrote:
hey guys,

quick question I'm having trouble finding an answer too.
In a mysql database, how can I select that last row entry. This might be
done mins after i put that entry there and i tried to use:
  $lastid=mysql_insert_id(); to get the last id but to no avail.

Thanks
Yoed



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] phplib???

2001-12-13 Thread Steve Edberg


http://phplib.sourceforge.net/


At 4:59 PM -0500 12/13/01, Duane Douglas wrote:
hello,

can someone please explain phplib to me?  what is it used for?  i 
apologize if this question has been asked many times before.

thanks in advance.



-- 
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| Restriction of free thought and free speech is the most dangerous of  |
| all subversions. It is the one un-American act that could most easily  |
| defeat us.|
| - Supreme Court Justice (1939-1975) William O. Douglas |
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Steve Edberg

Something like this, perhaps (untested):

function smart_ucwords($String)
{

$ExceptionList = array('the', 'an', 'a'); # should all be in lowercase

$String = ucwords(strtolower(ltrim($String))); # LINE A

foreach ($ExceptionList as $Word)
{
$String = eregi_replace([[:space:]]+$Word[[:space:]]+, 
$Word, $String);
}

return $String; # LINE B

}

This will leave the exception word capitalized if it is the first 
word in the $String (as it should be), or if it is the last work in 
the $String (unlikely). If you want to handle cases where the 
exception word comes at the end of the string, just replace LINE A 
above with

$String = ucwords(strtolower($String)).' ';

and LINE B with

return rtrim($String);

Of course, there will be exceptions that are near-impossible to 
programmatically determine, eg;
'Dr. Martin van Hooten Hears a Who'

in this case, van should be lower case, since it isn't referring to a 
medium-capacity box-like automobile, tennis shoe brand, or naval 
vanguard.

-steve



At 11:07 AM -0500 8/13/01, Boget, Chris [EMAIL PROTECTED] wrote:
   Is there a prewritten function for capitalizing the first
  letter of each word in a string except for the common
  words you wouldn't want to capitalize in a title? Like
  Come Learn the Facts From an Industry Leader

None that I've seen.
But it wouldn't be hard to write a function that takes a
string, passes that string to ucwords() and then you can
run through a pre-defined array and just do an ereg_replace()
on those words you want to remain lowercase...

Or something like that...

Chris

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] ucwords Except 'The' 'And' etc?

2001-08-14 Thread Steve Edberg

I know, I know, I have a lot of work to do...I shouldn't be doing 
this. I did get to play with PCRE regexps here, though...lotsa cool 
features over eregs!. Anyway, here's a *** NEW!!! IMPROVED!!! *** 
version of smart_ucwords(), that's probably way too much overkill. I 
did some quick tests, seems to work. Beware of email-induced 
line-wrapping, particularly in the comment black  quoted strings:

?php

function smart_ucwords($String, $ForceCase=1, $CapitalizeTrailing=1) {


#
#  A more sophisticated approach to title-casing.
#
## PARAMETERS 
##
#
#  $String  string   Input string.
#  $ForceCase   0|1  If true, will force title case (only 
first letter
#capitalized, no matter what case the 
string is in.
#  $CaptializeTrailing  0|1  If true, will capitalize a normally-excepted
#word if it is the last word in the 
string. So, a
#string like 'Shot In the Dark, A' 
works properly.
#
## USAGE NOTES 
#
#
#  The Exception List words should be in the case you desire; 
normally this will
#  be lowercase.
#
#  The Invariant List contains words and titles (eg; NASA, MySQL, PostGreSQL,
#  eBusiness) whose capitalization should be fixed, no matter what.
#
#  If one of these arrays is not to be used, simply set it to array().
#
## MODIFICATION HISTORY 

#
#  14 august 2001: S. Edberg, UCDavis [EMAIL PROTECTED]
#  Original
#


$EXCEPTION_LIST = array(
   'a', 'an', 'and', 'at', 'but', 'for', 'nor', 'or', 'some', 
'the', 'to', 'with'
);
   
$INVARIANT_LIST = array(
   'NASA', 'MySQL', 'PostGreSQL', 'eBusiness'
);
   
#  First, strip  save leading  trailing whitespace

preg_match(
   '/^(\s*?)(.*)(\s*)$/U',
   ($ForceCase ? strtolower($String) : $String),
   $StringParts
);

#  Replace exception words

$String = ucwords($StringParts[2].($CapitalizeTrailing ? '' : ' '));

foreach ($EXCEPTION_LIST as $Word) {
   $String = preg_replace(/(\s+)$Word(\s+)/i, \\1$Word\\2, $String);
}

#  Replace invariants

$String =  $String ;
   
foreach ($INVARIANT_LIST as $Word) {
   $String = preg_replace(/(\s+)$Word(\s+)/i, \\1$Word\\2, $String);
}

#  Replace whitespace and return

return $StringParts[1].trim($String).$StringParts[3];

}

?


At 4:09 PM -0500 8/13/01, Jeff Oien wrote:
Fabulous. Thanks to Steve and Mark. Exactly what I needed.
Jeff Oien

  Something like this, perhaps (untested):

  I needed this too so I just tested it.

  function smart_ucwords($String)
  {
  
 $ExceptionList = array('the', 'an', 'a'); # should all be in
  lowercase
  
 $String = ucwords(strtolower(ltrim($String))); # LINE A
  
 foreach ($ExceptionList as $Word)
 {
 $String = eregi_replace([[:space:]]+$Word[[:space:]]+,
  $Word, $String);
 }


  this line should be more like:
  $String = eregi_replace(([[:space:]]+).$Word.([[:space:]]+),
  \\1.$Word.\\2, $String);

 return $String; # LINE B
  
  }

  thanks!
  - Mark
  


-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Unix vs PC test for server

2001-08-16 Thread Steve Edberg

Also -

see:

http://www.php.net/manual/en/function.php-uname.php

- it's a PHP4 function.

Alternatively, you could check the $SERVER_SOFTWARE (or 
$HTTP_SERVER_VARS['SERVER_SOFTWARE'], depending on your config) 
variable; you'd have to parse the OS out of the returned string, 
though.

- steve



At 4:59 PM +0200 8/16/01, Alexander Wagner [EMAIL PROTECTED] wrote:
Paul S. wrote:
  I design a website on a PC, and upload it to UNIX. Of course, there
  are always one or two variables that I have to keep track of as to
  whetherteh server is UNIX or PC. There MUST be a simple way to test

Just do a phpinfo(). There should be an environment-variable you should
be able to use. The safest way to retrieve them ist getenv().

getenv('SAPI') perhaps?

  if (the OS is Windows) {
   $siteurl = http:// www.website.com/ ;
   $mysqlpasswordfilelocation =  ... outsideroot.txt ;
  }else{
   $siteurl = http://127.0.0.1/;;
   $mysqlpasswordfilelocation =  ...outsideroot.txt  ;
  }

You could also use a config-file. This way, you could run your scripts
on more than two sites.

regards
Wagner

PS: My PC is running UNIX.

--
Madness takes its toll. Please have exact change.


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Errors

2001-08-19 Thread Steve Edberg

Well, since you're getting a PHP error, PHP is obviously parsing the 
page. My guess is that your error reporting (in php.ini, httpd.conf 
or .htaccess) is set very high, so that uninitialized variables 
generate a warning. You could either (1) initialize $page at the top 
of your program:

$page = false;

or (2) lower the warning level:

http://www.php.net/manual/en/features.error-handling.php
http://www.php.net/manual/en/configuration.php
http://www.php.net/manual/en/ref.errorfunc.php

If $page is coming from somewhere else (eg; GET/POST parameters) then 
you can test for its existence like so:

if (!isset($page)) { $page = false; }

or $page = 0...whatever's appropriate.

-steve


At 4:45 PM +0200 8/19/01, BRACK wrote:
Hi

I'm getting strange errors if I add
LoadModule php4_module ../php/sapi/php4apache.dll to http.conf
If I don't load it everything is working with php.exe without any 
errors but as I
load it as a modul I get for example -
Warning: Undefined variable: page in d:\abria
sql\apache\htdocs\inc\page.inc on line 2
  here is the page.inc file:
?php 
if (!$page):
 $page = 1;
endif;
$limit = ($page * 10) - 10;
?

What is wrong? I need php as a modul but what do I do
wrong, I did everything according to install.txt in php
directory.

Thank you

Youri

God is our provider
http://www.body-builders.org


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sorting IP Address Data (oops!)

2001-08-23 Thread Steve Edberg

And if the numbers are from different subnets, you could sort like so 
(assuming addresses are in a 1-dimensional array, here called 
$IpAddresses):

function sort_address($IpAddresses) {
$List = array();
foreach ($IpAddresses as $A) {
   list($x,$y,$z,$t) = explode('.', $A);
   $List[($x*16777216) + ($y*6553616) + ($z*256) + $t] = $A;
}
ksort($List, SORT_NUMERIC);
return array_values($List);
}

My first thought was to use the line

   $List[($x24) + ($y16) + ($z8) + $t] = $A;

instead, and gain a little speed advantage by bitshifting instead of 
multiplying, but then you'd need to force $x, $y, $z and $t to 
integers first. You might be able to do

   $List[(((int)$x)24) + (((int)$y)16) + (((int)$z)8) + $t] = $A;
or
   $List[(($x+0)24) + (($y+0)16) + (($z+0)8) + $t] = $A;



I MADE  A BIT OF A CUT'N'PASTE ERROR IN THE LINE ABOVE IN MY PREVIOUS EMAIL!



instead, though. If you wanted 'em in REVERSE order, use krsort() 
instead of ksort().

Usual 'untested code' warnings apply.

- steve

-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] is_numeric for php3

2001-08-28 Thread Steve Edberg

At 03:41 PM 8/28/01 , scott [gts] wrote:
my understanding is that numeric is a broad term for
number values (any value with only numbers and a
decimal point) like 1, 5.6, 332, 0.5532, for example.

integers are a sub-set of numerics, so any integer is
a numeric value, but any numeric value is not
necessarily an integer.

$num=123 is an integer *and* numeric value.

$num='123' might not be an integer, but it is
a numeric.

now the problem of how to devise a proper test for
numeric values (without using regexps) is what i'd
like to see.


function is_numeric($Something) { return (string)(1.0*$Something) == 
$Something; }

should work.

 -steve


++
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED] (530)754-9127 |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+



Re: [PHP] Quick TXT document stuff

2001-08-30 Thread Steve Edberg

At 1:31 PM -0700 8/30/01, Kyle Smith wrote:
ok i have this code to do whats below, but its not working

   ?php
$fp = fopen(meh.txt,r);
for($i=0;$i2;$i++)
{
print $fp[$i];
}
?


That's because $fp is a file POINTER, not the actual contents of the 
file. You might have been thinking of the file() function, which 
sucks the entire contents of the file into an array...very wasteful, 
if all you need are the first few lines. What you want here is:

$fp = fopen(meh.txt,r);
for($i=0;$i2;$i++)
{
print fread($fp, 4096);
}
or
unset($FileArray);
$fp = fopen(meh.txt,r);
for($i=0;$i2;$i++)
{
$FileArray[] = fread($fp, 4096);
}

foreach($FileArray as $line)
{
print $line;
}

The second parameter in the fread function is the maximum line 
length; normally, that would be set to ma number larger than the 
maximum line length you're likely to encounter (unless you have long 
lines, and only need the first few characters of that line). See:

http://www.php.net/manual/en/function.fopen.php
and
http://www.php.net/manual/en/function.fread.php


Also, the line

print $fp[$i];

isn't likely to work the way you expect; if $fp was an array, you'd 
get something like

Array[0]
Array[1]
Array[2]

as the printout, since the $i, in quotes, wouldn't be interpreted as 
an array index. Use something like

print $fp[$i];
or
print Some text here .$fp[$i]. more text here;

instead.



-lk6-
http://www.StupeedStudios.f2s.com
Home of the burning lego man!

ICQ: 115852509
MSN: [EMAIL PROTECTED]
AIM: legokiller666


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Engine Question

2001-09-04 Thread Steve Edberg

PHP4's configuration syntax has changed; see

http://www.php.net/manual/en/configuration.php

Try using the line

php_flag engine on


-steve


At 11:35 AM -0700 9/4/01, PHP List wrote:
Hi,
I am trying to update my server to php4. Everything seemd to compile fine.
httpd -l shows mod_php4.c in the list.

I used to use these entries in my httpd.conf to specifically turn 
php on in certain dirs instead of default on for everyting.

Directory /dir/dir/dir  
php3_engine on
/Directory

But I cannot find a combo that works now, I allways get an error. 
How do I do this with php4?

-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP Redirect in the middle of code?

2001-09-10 Thread Steve Edberg

Right off the top of my head, you have three options that I can see:

(1) Rewrite the code to avoid any output before the redirect.

(2) Use output buffering (available only in PHP4). I haven't used 
this, but check out

http://www.php.net/manual/en/ref.outcontrol.php

(3) Use a META REFRESH tag. For example:

META HTTP-EQUIV=refresh CONTENT=1;page.php

where 1 is the time (in seconds) before you want the redirect, and 
'page.php' is where you want the redirect to. Of course, this tag 
needs to be in the HEAD section, so it might not help you much.

As far as I know, though, cold fusion's cflocation tag only works 
because CF does output buffering implicitly. So, I'd guess you need 
to do option (2).

-steve



At 10:37 AM -0400 9/10/01, Andrew Penniman wrote:
I am trying to figure out how to use PHP to redirect the user to a new
location *after* processing and most likely outputting a bunch of code.
Because this redirection would happen late in the game I can't use
header(Location: .$redirect_to);

I come from a ColdFusion background and am used to CFAS' cflocation
tag.  Does PHP have an equivalent function?

I am really hoping not to use JavaScript, I want this redirection to
happen at the server and not the client.


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP Redirect in the middle of code?

2001-09-10 Thread Steve Edberg

I learn something every day, here :)

According to my McGraw-Hill HTML Programmer's Reference [please, no 
messages about HTML not being 'programming'!], the META tag _should_ 
only occur in the HEAD container. Of course, we all know how 
closely browsers adhere to the HTML specs ;P

-steve


At 1:00 PM -0400 9/10/01, Ken wrote:
At 08:11 AM 9/10/01 -0700, Steve Edberg wrote:
Right off the top of my head, you have three options that I can see:
(3) Use a META REFRESH tag. For example:

  META HTTP-EQUIV=refresh CONTENT=1;page.php

where 1 is the time (in seconds) before you want the redirect, and 
'page.php' is where you want the redirect to. Of course, this tag 
needs to be in the HEAD section, so it might not help you much.

Not necessarily true, the head part.  My application outputs a 
meta ...refresh... line really late in the HTML document - 
definitely inside the body section - and the refresh seems to be 
working for all.

- Ken
[EMAIL PROTECTED]


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] header redirection

2001-09-14 Thread Steve Edberg

It's my understanding that PHP's normal behavior IS to send the 
header when it is encountered in your program, and then continue 
running the program (unless you have an exit statement after the 
header).

Perhaps you have output buffering turned on?

If that's not the case, please most more info, and perhaps the 
relevant parts of the script if possible.

By the way, I'm pretty sure you don't need those trailing newlines 
(\n\n) there; PHP takes care of that for you. I don't know if 
that's the source of your problem or not...

-steve





At 12:59 PM -0400 9/14/01, Poppy Brodsky wrote:
does not execute until the remainder
of the script has executed...
How can I redirect the user:

header(Location: http://www.foo.bar\n\n;);

and continue to execute a set of commands
after the redirection?
Just having the redirection code before the other code does not work.


Linux running apache and php4

poppy


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Get the beginning array number

2001-09-18 Thread Steve Edberg

At 4:12 PM +0200 9/18/01, _lallous wrote:
reset($array);
list(, $value) = each($array);
this will give you first value in $value


...and according to

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

reset() returns the first element of the array, so you could shorten this to

$value = reset($array);

But if you need the key value as well, you (I think) WILL have to do 
it _lallous' way:

reset($array);
list($key, $value) = each($array);

For more info, see

http://www.php.net/manual/en/ref.array.php

-steve



Brandon Orther [EMAIL PROTECTED] wrote in message
!~[EMAIL PROTECTED]">news:!~[EMAIL PROTECTED]...
  Hello,

  I have an array sent to my script that starts at different numbers each
  time.  Here is an example


  $array[5] through $array[23]  will have values but [0]-[4] will not.

  Is there a way for me to find the first element of an array with a value?

  Thank you,

  
  Brandon Orther
  WebIntellects Design/Development Manager
  [EMAIL PROTECTED]
  800-994-6364
  www.webintellects.com
  
  


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: excuting several sql statements in one time

2001-09-20 Thread Steve Edberg

This is more of a MySQL question, but:

Actually, as of MySQL version 3.22.5, INSERT statements can have
multiple value lists. In your case, this would be

$query =
   INSERT INTO com VALUES .
   ('pentium'), ('amd');

mysql_query($query, $dbconnect) or die(mysql_error());

Also, you don't need a trailing ';' on the SQL query statement (you
DO need it, of course, at the end of the PHP statement).

See

http://www.mysql.com/doc/I/N/INSERT.html

for more information.

-steve



At 11:58 AM +0200 9/20/01, _lallous wrote:
No you can't! I wrote a simple routine for the task!


you might want to view it from:
http://www.kameelah.org/eassoft/php_files/sql2php.php.txt

just take the  parse_sql_stream($all) which returns an array that have all
the statments to be passed to mysql_query()

this script is usefull when you have a huge .SQL file that you want to
execute from PHP code.

VM ¡÷øN [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hello

  I want to know how to implement these several sql statements in one time.

  For example, I have 2 sql statements like :

   INSERT INTO com VALUES ('pentium');
  INSERT INTO com VALUES ('amd');

  Then, I want to excute these 2 sql statements in one time with PHP.

  I tried to implement like this :

  $query = 
  INSERT INTO com VALUES ('pentium');
  INSERT INTO com VALUES ('amd');
  ;
  mysql_query($query, $dbconnect);

  But as you know, it didn't work.

   Does any one know how to run this job?


--
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Run or execute a php cript within a php cript.

2001-09-21 Thread Steve Edberg

You can do something like

?php

# Master script

switch ($Something) {

case 1:
   include 'xx1.php';
   break;
case 2:
   include 'xx2.php';
   break;

#  ...and so on

}

# ...include any 'post-processing PHP stuff here, if necessary

?

Any variables in the master script's scope are in the scope of the 
included files as well.

If you want to actually REDIRECT the user to another page, you can 
use the header function to send a Location: header. See

http://www.php.net/manual/en/control-structures.switch.php
http://www.php.net/manual/en/function.include.php
http://www.php.net/manual/en/function.header.php

for more information.

-steve



At 8:46 AM +0200 9/21/01, hvm wrote:
Hi all.

Is there a command to execute (run) from HTML or a php4 script a 
other php script without a mouse click (A HREF=xx.php).

I have a lot of php scripts and need them to execute from a master php script.

any help?

Thanks all,

Yours Hans.

-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fired!

2001-09-21 Thread Steve Edberg

At 1:49 PM +0200 9/21/01, [EMAIL PROTECTED] wrote:
lets have a php-beer for all the dot.com unenployed!



My PHP 4.0.5 doesn't have php_beer() function :(  Is that available 
in CVS tree?

-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP3

2001-06-21 Thread Steve Edberg

The PHP version plays no part in this, since the SELECT statement 
below is passed directly to MySQL. And, yes, this should work on that 
MySQL version - it's a pretty simple statement.

Were you experiencing a problem with it? If so, post the relevant PHP 
code  the error message you're getting.

The only thing that might conceivably be a problem is the table alias 
syntax. What you have _should_ work, but you could also try

Select a.field, b.field from table_one AS a, table_two AS b
where a.id = b.id

- steve


At 1:48 PM -1000 6/20/01, William Poarch wrote:
Hi,

Does Select a.field, b.field from table_one a, table_two b where a.id =
b.id work in PHP3/MySQL 3.22.32?

Client's running PHP3, and I'm on 4.

thanks.
  - - - - - - - - - -
  Scott Poarch
  www.globalhost.com
  - - - - - - - - - -

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Filtering out \ when a ' is user entered?

2001-06-27 Thread Steve Edberg

See
www.php.net/stripslashes

Also check out the PHP configuration settings for magic_quotes_gpc

-steve



At 9:18 PM -0700 6/26/01, Marcus James Christian wrote:
Hello,

I'm pretty new to PHP but all I've seen of it so far I pretty much love!

I've built a web log but when the user enters their data and they use '
or   (and you know they will)   php always shows it from the included
web log as

\'  How can I filter out these backslashes so they don't appear on the
final public viewable page?

Thanks,
Marcus
--
Marcus James Christian - UNLIMITED -
Multimedia Internet Design
http://mjchristianunlimited.com

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] split() function

2001-07-04 Thread Steve Edberg

You don't need a character class here (signified by [] brackets); you can use

$line = split('|//', $field);

As you can see, this is identical to ReDucTor's solution, except that 
the brackets are omitted. Character classes only work for single 
characters, not multiple character strings like '//'.

- steve


At 3:21 PM -0400 7/4/01, David A Dickson wrote:
Thanks for replying ReDucTor but that didn't work either. I tried
$line = explode([(|//)], $field); and
$line = explode([(|)], $field); and
$line = explode([(|\/\/)], $field);
with no success. Any other ideas?

On Thu, 5 Jul 2001 04:50:29  
  ReDucTor wrote:
$line = explode([(|//)],$field); should work, or you might have to put
 but thats not \ so you shouldn't need to comment out the slash...
- Original Message -
From: David A Dickson [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Thursday, July 05, 2001 4:37 AM
Subject: [PHP] split() function


  I have a comma separated spreadsheet with one field that contains two
dates. the dates are formatted as dd/mm/yy and separated by either '' or
'//' ex:3/12/9228/1/93 or 3/12/92//28/1/93
  Problem: I need to split the field at the '' or '//' separator but if I
do
   split('[//]', $field);
  it splits on the '/' not the '//'.
  Can I do this in one function call to split() or will I have to do it
twice?



Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

- End Forwarded Message -

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Missing first record in PHP/Mysql query

2001-07-05 Thread Steve Edberg

At 7:11 PM -0700 7/5/01, Rory O'Connor wrote:
Excuse me if this is too newbie...but I'm writing a simple script to
query a database and loop through the reuslts, echoing them on the page.
  When I enter the query at the mysql command line, I get the correct
results.  But the same query run through PHP renders all results except
the first one.  Any idea why?


It's doing exactly what you told it to ;)

See below:


I've included the code snippet below:

//the query to select the data
$query = SELECT firstname,email,optin from contact where
interest='rory';
$result = mysql_query($query);
if(!$result) error_message(sql_error());

$query_data = mysql_fetch_row($result);


This line fetches the first row and moves the pointer to the next 
row. You then proceed to ignore the results of the first row! Just 
delete this line, and you'll be happy.



while($query_data = mysql_fetch_array($result)) {
 $firstname = $query_data[firstname];
 $email = $query_data[email];
 $optin = $query_data[optin];

 echo BR\n;
 echo $firstname;$email;$optin\n;

} //end while loop

also, what would be the code to output the reuslts to a text file
instead of (or in addition to) the screen?


Check out the file functions - fopen, fwrite, fclose will be of 
particular interest:

http://www.php.net/manual/en/ref.filesystem.php


thanks,

rory

providing the finest in midget technology



-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: string formatting help

2001-07-06 Thread Steve Edberg

In the original message below, did you mean that you're actually
SEEING the br tags in the output? If so, there may be a conversion
with htmlentities() going on somewhere that converts the br tags to
lt;brgt; (so they are displayed instead of being interpreted).

If you replaced the br's with spaces or newlines, the output
_should_ all be on one line, since HTML considers ALL strings of
whitespace (tabs, newlines, returns, spaces) to be a single space. If
you replaced br's with newlines and you are getting the line breaks
still, your output may be in a pre.../pre block.

- steve


At 3:36 PM -0300 7/6/01, InÈrcia Sensorial [EMAIL PROTECTED] wrote:
   Maybe:

$array = explode(br, $string);

foreach ($array as $key = $value) {
 echo $value;
}

   Would separate the string by br's and print all in one line.



Or, more compactly:

echo str_replace('br', '', $string);

This would only work if tags were lowercased; to handle mixed case,
you'd need to do

echo eregi_replace('br', '', $string);

or use the preg equivalent




   Julio Nobrega.

A hora est· chegando:
http://sourceforge.net/projects/toca

Chad Day [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm trying to pull a string from a database to use in a javascript
  function.. but it's doing line breaks on me, which in turn messes up the
  javascript.

  The string in the mysql db is like:
  kjdsakjadkbrskjdksbrbrkjkdfjdfkjfd

  When I pull it out, it becomes:

  kjdsakjadk
  br
  skjdks
  br
  br
  kjkdfjdfkjfd

  I've tried replacing the br's with blank spaces or new line characters,
but
  in the html code it still breaks on those breaks when I echo it back out.
  How can I force this string to be all on one line?

  Thanks,
   Chad


--
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] foreach loop

2001-07-07 Thread Steve Edberg




At 10:31 AM -0700 7/7/01, John Meyer wrote:
When I go through a foreach loop, are the values of the individual 
items in the array changed?
For instance:
$variables = array($author_firstname, $author_lastname, $author_dob, 
$author_dod, $author_bio);
  foreach($variables as $value) {
 $value = strip_tags($value);
 $value = AddSlashes($value);
  }
will the values be changed outside of the loop?



No, because $value is a copy the current array element, not simply a 
pointer to it. Furthermore, if I understand the documentation (see 
below) correctly, this construct (using the $variables array from 
above) -

$i = 0;
foreach ($variables as $value)
{
$variables[$i] =AddSlashes( strip_tags($value));
 $i++;
}

- will not work either, since foreach() operates a COPY of the array. 
 From the docs at

http://www.php.net/manual/en/control-structures.foreach.php :


Note: When foreach first starts executing, the internal array pointer 
is automatically reset to the first element of the array. This means 
that you do not need to call reset() before a foreach loop.

Note: Also note that foreach operates on a copy of the specified 
array, not the array itself, therefore the array pointer is not 
modified as with the each() construct and changes to the array 
element returned are not reflected in the original array.

- steve


John Meyer
[EMAIL PROTECTED]
Programmer

If we didn't have Microsoft, we'd have to blame ourselves for all of 
our programs crashing


-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Name of an array???

2001-07-09 Thread Steve Edberg

Not quite sure what you're getting at here. As you discovered, if you have

$Thing = array(5,6,7,8);

and you 'echo $Thing;' you get 'Array.' However, in this case, you 
know the variable name already - $Thing!

Are you thinking more along these lines:

$ArrayName = 'Thing';
$$ArrayName = array(5,6,7,8);

now,

echo $ArrayName;== Thing
echo $$ArrayName;   == Array
echo ${$ArrayName}[0];  == 5

See

http://www.php.net/manual/en/language.variables.variable.php

for more info.

-steve



At 1:03 PM -0700 7/9/01, Dallas K. wrote:
I need to echo the NAME of an array to the browser. when I try 
this all I get is Array. when I try to : echo $$array_name; I 
get nothing.

How can I get the NAME of an array to the browser?

Thanks.

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] sorting results of opendir()

2001-07-09 Thread Steve Edberg

Here's one way:


$dir = opendir('.');
unset($FileList);

while ($file=readdir($dir)) {

if($file!= '.'  $file != '..')
{
$FileList[] = $file;
}

}

sort $FileList;
reset($FileList);

while(list(, $F) = each($FileList)) {

echo $Fbr\n;

}

If you're using PHP4, you can replace everything after the 
sort($FileList) with the more compact:

foreach($FileList as $F) { echo $Fbr\n; }


See

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

for more info on sorting arrays.


- steve



At 1:05 PM -0500 7/9/01, kmurrah wrote:
Greetings.

I need to read the contents of a directory, sort it alphabetically, and
display it 

i'm doing find on the reading and displaying, but can someone help me with
the sort?

$dir = opendir(.);

while ($file=readdir($dir)) {


   if($file!= .  $file != ..)
   {
   echo($filebr);
   }
}



-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help..Parse error

2001-07-19 Thread Steve Edberg

My guess is that you have the short_open_tags option on in your PHP3 
config, but off in your PHP4 config. If it's off, PHP will only 
recognize the ?php...? tags, not ?...?. PHP config params can be 
set in php.ini, .htaccess, and/or Apache httpd.conf files. Scroll 
down to short_open_tag in

http://www.php.net/manual/en/configuration.php#configuration.file

for more info. You can also check your config via the phpinfo() function.

- steve



At 1:45 AM -0400 7/20/01, Jack Sasportas wrote:
I have some code that runs under php3, but under 4 I get a parse error
on this specific line, can't figure out how to resolve it.

the code looks like this
html stuff
? } ?
more html stuff

the error is in the middle line  which is the end of a condition...

Thanks in advance...


--
___
Jack Sasportas
Innovative Internet Solutions
Phone 305.665.2500
Fax 305.665.2551
www.innovativeinternet.com
www.web56.net

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Mysterious MYSQL Error..

2001-07-22 Thread Steve Edberg

Do you know if you've even made a valid database connection? Try 
echoing $this-database as well. If that is null, you haven't 
connected to your database; perhaps the username, password and or 
permissions were changed, so that you're unable to connect from your 
PHP program.

- steve


At 9:47 AM -0400 7/22/01, Greg Schnippel wrote:
I'm stumped on this one.. I set up PHP 4.04/Apache/Mysql 3.23
on my Windows 98 box for development purpouses. Its been
working flawlessly for 2-3 years now (using the same
configuration files, etc).

However, as of 3 days ago, i can't get it to execute a simple
select * from table query. Here's the code I'm using:

$query = select * from $this-table where $this-primary_key='$record_id';
$result = mysql_query($this-database, $query);
echo mysql_errno().: .mysql_error().BR;

and the query that it sends to the mysql database is

select * from article where article_id='1';

However, mysql fails to execute the query. Result returns
nothing and the echo command returns:

errno: 0
mysql_error_text: 

??!? I've tried everything to get it to display any more information
as to why its breaking but nothing works. I even uninstalled and
reinstalled all of the packages, thinking it had something to do
with a windows dll file or something annoying like that but no luck.

Any ideas? Anyone encountered a problem like this?

Thanks,

Greg


-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using $$ to access a variable

2001-07-23 Thread Steve Edberg

I'm not sure that your construct will work; however, you could always do

echo $HTTP_POST_VARS[$table_array[$iCnt][0]];

in place of 'echo $$var' or

$var = 'HTTP_POST_VARS';
echo ${$var}[$table_array[$iCnt][0]];

When using variable variables, the array index - here, 'ld_val' might 
not be interpreted correctly; I'm guessing that PHP is looking for a 
variable named 'HTTP_POST_VARS[ld_val]', not an element of the 
HTTP_POST_VARS array. More info is at

http://www.php.net/manual/en/language.variables.variable.php


On the other hand, are you absolutely sure that something (other than 
whitespace) is actually IN $HTTP_POST_VARS['ld_val'] ??

- steve



At 5:36 PM + 7/23/01, [EMAIL PROTECTED] wrote:
Please forgive my probably newbie question...
I am cycling thru my database using a SQL describe statement and then
am getting values from a form based upon the field name I find.  This
is working up 'til I try to read the form data.

I have defined a variable like this:
   $var = $prefix.$table_array[$iCnt][0].$postfix;

If I echo $var the printed result is:
   HTTP_POST_VARS[Id_val]

This is perfect because I want to access a field on the submitted form
named Id_val, but when I try echoing with a $$ like this:
   echo $$var

I get nothing.  I was under the impression that I could access my
variable this way.  Am I missing something basic here??

Thanks!

Mark



-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to reference global variables in strings

2001-02-05 Thread Steve Edberg

At 10:57 AM -0700 2/5/01, Karl J. Stubsjoen wrote:
If you don't prefix a global variable with $ then how can you interpit a
global variable within a string?  AS IN:

define ("MY_PATH", "/home/me/");

print("This is My Path:  MY_PATH or is it?");


This wouldn't be a global variable; rather, it's a constant. And, 
you'd reference it like

print("This is My Path:  ".MY_PATH." or is it?");


See
http://www.php.net/manual/en/function.define.php
and
http://www.php.net/manual/en/language.variables.php

-steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Date Formatting

2001-02-06 Thread Steve Edberg

At 3:04 PM -0800 2/6/01, Richard Scott Crawford wrote:
Cold Fusion has a wonderful function called CreateODBCDate(), which 
takes as an argument any date in just about any format and returns a 
standard ODBC date format that you can plug into a database without 
worrying about conversion.

Does PHP have a similar function?  I've looked for one but can't 
seem to find it anywhere.

From
http://www.php.net/manual/en/function.strtotime.php

-
"strtotime - Parse about any english textual datetime 
description into a UNIX timestamp"

If the ODBC timestamp looks like

-mm-dd hh:mm:ss

then you could do:

$Date = '1 jan 2001';
ODBCDate = date('Y-m-d H:i:s', strtotime($Date));

And if you really want, just define the function

function CreateODBCDate($DateString)
{
return date('Y-m-d H:i:s', strtotime($DateString));
}

and you can ease your CF-PHP transition :)

If you want to default to returning the current date:

function CreateODBCDate($DateString='')
{
return
(
$DateString ?
date('Y-m-d H:i:s', strtotime($DateString)) :
date('Y-m-d H:i:s')
);
}

Sorry about the weird indent style --- I was trying to avoid wordwrapping.

It doesn't specify in the docs, but I _assume_ strtotime() returns 
false if it can't figure out what the date string is...you might want 
to test that.

- steve


--
Richard Crawford (mailto:[EMAIL PROTECTED])
http://www.mossroot.com  AIM Handle: Buffalo2K
"Tomorrow, we'll seize the day and throttle it!"  -Calvin


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] [Newbie] PHP Variables

2001-02-09 Thread Steve Edberg

At 8:06 PM +0100 2/9/01, Steve Haemelinck wrote:
I just wanted to try this:

I take a link : http//www.xy.com/index.php?contents=HOME

There I echo contents

?php echo $contents?
div align="center"?php echo $contents; ?/div

It should display HOME? But it does not !


Two possibilities I can think of:

(1) Is your echo statement above within a function? If so, you have 
to globalize it, or pass it as a function parameter:

function zaphod($beeblebrox)
{
return  'div align="center"'.
$beeblebrox.
'/div';
}

echo zaphod($contents);
or

function zaphod()
{
global $contents;
return  'div align="center"'.
$contents.
'/div';
}

echo zaphod();

See
http://www.php.net/manual/en/language.variables.scope.php

for more info.

(2) The register_globals parameter is not set. This must be on if you 
want GET/POST/COOKIE etc. parameters to be automagically converted to 
variables. This can be set in php.ini, .htaccess, or httpd.conf, and 
can also be programmatically set and checked via ini_set() and 
ini_get(), respectively. If this is NOT set, you'll have to refer to 
your GET parameter as

$HTTP_GET_VARS['contents']


See
http://www.php.net/manual/en/configuration.php
http://www.php.net/manual/en/language.variables.external.php

http://www.php.net/manual/en/function.ini-set.php
http://www.php.net/manual/en/function.ini-get.php

for more info.

- steve




  -Original Message-
From:  Brian V Bonini [mailto:[EMAIL PROTECTED]]
Sent:  donderdag 8 februari 2001 23:55
To:Steve Haemelinck
Subject:   RE: [PHP] [Newbie] PHP Variables

you can, what's the rest of your script look like.

  -Original Message-
  From: Steve Haemelinck [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, February 08, 2001 3:49 PM
  To: PHP Mailing Listl (E-mail)
  Subject: [PHP] [Newbie] PHP Variables


  I thought you can pass variables in PHP as in CGI.

  http://www.xy.com/index.php?contents=HOME

  contents should be available as variable, but it does not seem to
  work. Doe
   anyone has an idea why not?



-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using while as for...

2001-02-24 Thread Steve Edberg

At 12:44 PM -0800 2/24/01, Felipe Lopes wrote:
I was trying to code the following script using while instead of for,
but I'm havig a lot of problems...Is it possible to do what I want?

for ($count = 0; $count = 10; $count++){
echo "Number is $count BR\n";
}

Could anyone tell me how is it with while instead of for??
Thank you!!


$count = 0;
while ($count = 10) {
echo "Number is $count BR\n";
$count++;
}

I think - if you're feeling obscure - that

$count = 0;
while
(($count = 10)  print 'Number is '.$count++." br\n")
{}

will work too. As will - using alternate while syntax -

$count = 0;
while ($count = 10):
echo 'Number is '.$count++." br\n";
endwhile;

See:

http://www.php.net/manual/en/control-structures.while.php

for more info.

-steve


Felipe Lopes
MailBR - O e-mail do Brasil -- http://www.mailbr.com.br
Faa j o seu.  gratuito!!!


--
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Newbie: why do I get this error?

2001-02-26 Thread Steve Edberg

At 3:47 PM +0530 2/26/01, Harshdeep S Jawanda wrote:
Hello everybody,

I am a newbie, so please help me out with my rather basic question.

Please take a look at the following code snippet:

   class HTMLTable extends HTMLElement {
 var $attributes;

 function HTMLTable() {
   $attributes[] = array("border", "0");
   $attributes[] = array("cellpadding", "0");
   // and some other things
 }

 function emit() {
   // I get an error on this line
   $arrLength = count($this-attributes[1]);
 }
   }

On the line indicated above, I get the error: "Warning: Undefined
property: attributes in html_base_classes.inc on line line-number"

Can anybody give me a clue as to why this is happening?


In your HTMLTable() function, use

$this-attributes[] = array("border", "0");
$this-attributes[] = array("cellpadding", "0");

otherwise, PHP thinks $attributes is a variable local to that 
function, rather that a class variable.

-steve


--
Regards,
Harshdeep Singh Jawanda.


-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to disable some functions?

2001-02-28 Thread Steve Edberg

At 4:54 PM + 2/28/01, Philip Reynolds wrote:
Batonik's [[EMAIL PROTECTED]] 15 lines of wisdom included:
:Hi,
:
: I've heard that it is possible, for security reasons, to disable
:such functions like phpinfo(). How can I do this?

You can edit the sources...
PHP4:  $PHP_BASE_DIR/ext/standard/basic_functions.c

You're looking for a struct called
function_entry basic_functions[]

On my version (4.0.4-pl1) it's on line 91.
Your functions are listed there..

for example, delete line "PHP_FE(time,  NULL)"
which is on line 100 on my version disables the time function.
However, why you want to disable functions is beyond me, to make PHP
"safe" you're going to have to disable a LOT of functions..

There might be some PHP4 way to disable functions, I think there
might be some way to do it from php.ini, but I can't find it
offhand.
Phil.


It's not documented yet at

http://www.php.net/manual/en/configuration.php

, but you can use the following in your php.ini file:

disable_functions = ; This directive allows you to disable certain
; functions for security reasons.  It receives
; a comma separated list of function names.
; This directive is *NOT* affected by whether
; Safe Mode is turned on or off.

I presume you could use the

php_value disable_functions phpinfo

syntax in your httpd.conf or .htaccess (you might need to use 
php_admin_value instead of php_value). This is available in php 
4.0.4; I don't know about availability in earlier versions. I don't 
use this, though, so I'm just copying from the provided .ini file.

-steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Need an array parser(CONT)

2001-02-28 Thread Steve Edberg

At 12:33 PM -0800 2/28/01, Dallas K. wrote:
I am looking for somthing that will parse a multidimentional array of any
size, and return a key / value listing for debugging

Example:

if I have an array such as...

$arr[name] = dallas
$arr[address][city] = austin
$arr[address][state] = Texas
$arr[somthing][somthing_else][blah1]= some_value1
$arr[somthing][somthing_else][blah2]= some_value2
$arr[somthing][somthing_else][blah3]= some_value3

I would want the result to be displaied as:

ARR
 name --- dallas
 address --- city --- austin
 address --- state --- Texas
 somthing --- somthing_else --- blah1 --- some_value1
 somthing --- somthing_else --- blah1 --- some_value1


var_dump($arr) or print_r($arr) --- see

http://www.php.net/manual/en/function.var-dump.php

http://www.php.net/manual/en/function.print-r.php


-steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+-- FBI Special Agent Dale Cooper ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] two small issues with php mail

2007-11-20 Thread Steve Edberg

Personally  At 1:31 PM -0500 11/20/07, Jason Pruim wrote:
I preferHonestly for me... top posting,
sideOn Nov 20, 2007, at 1:19 PM, Michael McGlothlin wrote:
posting.
I hate top posters. Pure evil.
-steve  OMG the top posting on this freakin' issue is a headache

		Whereas removing all of the previous message is 
like a sensual

massage

inline posting,




PS. Sometimes interlacing is


Pure stress-relief.


appropriate as well.



bottom posting...

		None of it matters... As long as it's CONSISTENT 
through out the thread :) It's all just as easy for me to follow. 
Now... Trimming on the other hand annoys me... if you trim to much 
then you have to go back and look up the e-mail that the info was in 
:)


*Gets ready to duck* :)

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] Rewind foreach loop

2007-11-29 Thread Steve Edberg

At 2:11 PM +1100 11/30/07, Jeffery Fernandez wrote:

On Fri, 30 Nov 2007 02:01:47 pm Chris [EMAIL PROTECTED] wrote:

 Jeffery Fernandez wrote:
  Hi all,
 
  Is it possible to rewind a foreach loop? eg:
 
 
  $numbers = array(0,1,2,3,4,5,6,7,8,9,10);
 
  foreach ($numbers as $index = $value)
  {
  if ($value == 5)
  {
  prev($numbers);
  }

   echo Value: $value . PHP_EOL;

  }
 
  The above doesn't seem to work. In one of my scenarios, when I encounter
  and error in a foreach loop, I need the ability to rewind the array
  pointer by one. How can I achieve this?

 echo $numbers[$index-1] . PHP_EOL;


That will only give me the value of the previous index. What I want is to
rewind the array pointer and continue with the loop.



I would think that if you rewound the array pointer as above, you'd 
simply end up in an infinite loop, as you'd keep hitting the 
condition that triggered the rewind. So I'm assuming you have some 
other test in there and this is just a stripped down example.


If you're using a one-dimensional array, as opposed to a 
multidimensional and/or associative array, you can do (untested):


$Count = count($numbers);

for ($i=0; $i$Count; $i++) {
$value = $numbers[$i];
if ($value == 5  some_other_test()) {
$value = $numbers[--$i];
}
echo Value: $value . PHP_EOL;
}

Wouldn't be much more complex to extend to a multidimensional array 
with an integer index. If you were using an associative array with a 
string index, you'd probably have to do something like


$NotJustNumbers = array('a'='slurm', 'b'='fry', 'c'='leela');
$Keys = array_keys($NotJustNumbers);
$Count = count($Keys);

for ($i=0; $i$Count; $i++) {
$value = $NotJustNumbers[$Keys[$i]];
if ($value == 5  some_other_test()) {
$value = $NotJustNumbers[$Keys[--$i]];
}
echo Value: $value . PHP_EOL;
}


- steve

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] Join question

2007-11-30 Thread Steve Edberg

At 10:30 AM -0500 11/30/07, Daniel Brown wrote:

On Nov 30, 2007 10:22 AM, Jochem Maas [EMAIL PROTECTED] wrote:

 Daniel Brown wrote:
  I was tempted to flame Tedd just because he's Tedd.  ;-P

 lol. but then the guy was programming Rocks(tm) way before I was
 born, that has to count for something :-)



Please keep all replies on the list, Jochem.  ;-P

HA!  It was too good not to share.



Programming Rocks you say? It's not that old...

http://www.rocksclusters.org/wordpress/

:)

It appears to be a Friday...

- steve

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Steve Edberg

Just to add my two cents -

I don't think it matters much what tokens you use to represent true 
or false, since you're going to be explicitly checking them on the 
server end anyway. I can't see much difference in principle between, 
for example:


if ($_GET['foo'] == 'y')...
and
if ($_GET['foo'] == '1')...
or even
if ($_GET['foo'] == 'Oui')...

One should really not do be doing just

if ($_GET['foo'])

anyway. Checking that a specific value is passed, rather than just 
some value that PHP evaluates to true or false, is one way to catch 
possible form hacking. For general reference, there are a number of 
php security howtos out there on how to sanitize user input, but I'll 
leave finding them as an 'excercize for the reader' at the moment. I 
suppose using 0/1 does have the advantage of 'doing the right thing' 
if a if ($_GET['foo']) creeps into your code, though. As would 
using 'Y'/''.


That being said, I've used 0/1 along with y/n in the past; it depends 
on whether I'm thinking like a programmer or a human ;)


steve


At 12:36 PM -0600 12/2/07, Larry Garfield wrote:

First of all, using y and n for boolean values (such as a checkbox) is
very sloppy.  n is boolean True.  A boolean value should evaluate correctly
in a boolean context.  For that, you should use 1 and 0 for your values. 


What I usually do is this:

input type=hidden name=foo value=0 /
input type=checkbox name=foo value=1 ?php echo $checked; ? /

Then when it gets submitted, foo will get the value of the form element that
was submitted last that has a value.  That is, if the checkbox is checked
then foo will be 1, otherwise it will be 0.  That gives you a nice, clean
boolean value you can rely on being present (mostly g). 


On Sunday 02 December 2007, Ronald Wiplinger wrote:

 I have now tried to add many of the security hints on a web page and
 come to a problem.
 I am checking if the allowed fields match the sent fields.
 From the database I get the information if a checkbox is checked or not:

 ?php if($DB_a ==y) {
 $checked=checked;
 } else {
 $checked=;
 }
 ?
 input type=checkbox name=R_a value=y ?php echo $checked ?


 If the user takes out the checkmark the value will become  and the
 field will not submitted which results in a missing field.

 $allowed = array();
 $allowed[]='form';
 $allowed[]='R_a';
 $allowed[]='R_b';
 
 $sent = $array_keys($_POST);
 if($allowed == $sent) {
 ... do some checking ...
 } else {
 echo Expected input fields do not match!;
 }
 break;


 How can I force a n for not checked in the input field? or how can I
 solve that?

 bye


  Ronald




--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] XML Data merging

2008-01-12 Thread Steve Edberg

At 12:10 PM -0500 1/12/08, Eric Butera wrote:

On 1/12/08, Naz Gassiep [EMAIL PROTECTED] wrote:

 I'm using simplexml to fetch data from a set of data files. If I have
 two files, and one is an update to the other, is there an easy way to
 merge the two files together, rather than having write logic that checks
 one and then the other?

 Both files conform to the same DTD and thus the data in the update will
 perfectly eclipse the data in the main file. If I can do this it would
 save me writing a whole bunch of logic.

 Thanks,
 - Naz.

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




diff!



...Although your standard diff wouldn't account for files that parse 
identically but have slightly different but functionally identical 
XML (eg; differing case/whitespace in tags, different order of 
attributes). That's what tools like XMLdiff (python) -


http://www.logilab.org/project/xmldiff

- xmldiff (perl) -

http://www.xml.com/pub/r/1354

- xmldiffpatch (MS executable) -

http://msdn2.microsoft.com/en-us/library/aa302294.aspx

- and probably numerous others are for. Here's a possibly-useful article:

http://www.xmlhack.com/read.php?item=1681

Disclaimer: I've never used any of those tools, so YMMV, IANAL, RTFM, 
LOL, etc...


steve


--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] var_dump() results

2008-01-13 Thread Steve Edberg

At 12:32 PM -0500 1/13/08, Europus wrote:

It's pretty much the same. With var_dump(), values from the first row
of the table are iterated twice, the script is not looping through and
reporting all 2100 rows. Grossly similar behavior was observed with
print_r() and echo: while different data was reported by each, the
loop wouldn't loop. The first row was reported once (or twice) and
that was the end of that. I've tried foreach() also, same-same. It
doesn't loop, it just reports the first row.

Here's my code:

?php

//connect to db
$link = mysql_pconnect('$host', '$login', '$passwd');
if (!$link) {
die('Unable to connect : ' . mysql_error());
}
// make $table the current db
$db_selected = mysql_select_db('$table', $link);
if (!$db_selected) {
die ('Unable to select $table : ' . mysql_error());
}

//get column data
$sql= SELECT column2, column3 FROM $table;
$result = mysql_query($sql);
$row = mysql_fetch_row($result);

//loop through to display results
for($i=0; $i  count($row); $i++){
var_dump($row);
echo br /br /;
?

Ulex



As far as displaying only the first row, that's because you're only 
fetching the first row; count($row) in your for loop will always 
evaluate to 0 (if there are no results) or 1. You need to move the 
mysql_fetch_row() call into your loop; something like


$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
var_dump($row);
...
}

or you could do

$result = mysql_query($sql);
$count = mysql_num_rows($result);
for ($i=0; $i$count; $i++) {
var_dump($row);
...
}

As far as displaying the results twice, I'm not sure; that resembles 
the behavior of mysql_fetch_array() -


http://us.php.net/manual/en/function.mysql-fetch-array.php

- where the default is to return data as both an associative and 
numerically-indexed array. I'm guessing that the above code isn't an 
exact cut-and-paste, as using single quotes (eg, 
mysql_pconnect('$host', '$login', '$passwd') does not interpolate 
variables, so that line will not work unless your username is 
actually '$login', etc. Which it probably isn't. Are you sure the 
real code isn't using mysql_fetch_array() instead of 
mysql_fetch_row()?


steve


--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] how to display photos of the day?

2008-01-29 Thread Steve Edberg

At 6:33 PM +0800 1/29/08, jeffry s wrote:

sorry if this question sound stupid.
i need a good, simple and efficient function to display lets say photo of
the day.

i have a mysql table contain data about 1000 rows. i want to display any of
the photos randomly
and it is fixed for one day.

anyone know how to write the function that return a fixed table id for the
day?



What I would do is something like this (assuming your table has a 
column 'filename' in it):


Create a cron job (on windows, I think the command is called 'at'?) 
that runs this query


select filename from photo_table order by rand() limit 1

once per day, then copies that file to a predefined location (eg 
images/pic_of_the_day.jpg).


Then, your web page simply refers to images/pic_of_the_day.jpg. The 
contents of pic_of_the_day.jpg change every time the cronjob runs 
(unless you randomly pick the same picture twice; not likely with 
1000 rows, but you could include some sort of flag [eg; last used 
date] to avoid picking the same image twice, or to cycle through all 
images before reusing them).


This requires one database hit per day, returning one row, so the 
load is next to nothing.


The cronjob could be written in any language, but since this is a PHP 
list you'll have to promise to write it in PHP ;)


steve


--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] More than one values returned?

2008-02-19 Thread Steve Edberg

At 4:57 PM -0600 2/19/08, Greg Donald wrote:

On 2/18/08, Nick Stinemates [EMAIL PROTECTED] wrote:

 I have found, however, that if I ever need to return /multiple/ values,
 it's usually because of bad design and/or the lack of proper encapsulation.


Yeah, that's probably why most popular scripting languages support it.

In Ruby:

def foo
  1, 2
end

a, b = foo


In Python:

def foo
  return 1, 2

a, b = foo


In Perl:

sub foo
{
  return (1, 2);
}

(my $a, my $b) = foo;



For completeness sake, this is pretty much the same in PHP:

   function test() {
  return array(1,2);
   }

   list($a,$b) = test();

works as above. Works fine with complex arrays as well:

   function test() {
  return array(1,array('a','b'));
   }

   list($a,$b) = test();

steve

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] avoid calling php script

2008-03-12 Thread Steve Edberg

At 3:55 AM +0100 3/13/08, H u g o H i r a m wrote:

Hello

I have a swf that runs a PHP script that generates a XML, on the PHP 
is there any way to detect if the file is being called from the swf 
or from the browser? because I want to avoid the file being run 
directly from the browser or from any other file than the swf.


regards,
Hugo.



You might want to check the HTTP_REFERER value; test the program from 
a browser and the swf, and see what happens. Alternatively you could 
use a GET parameter like


   http://example.com/yourscript.php?calledby=swf

Be aware that anything sent back from the client can be spoofed - and 
HTTP_REFERER can be altered or disabled -  so it probably wouldn't be 
hard for someone to make it appear to your script that it is being 
called by your SWF.


If you're really concerned about restricting the communication 
between the Flash movie and your server, there might be some way to 
build a challenge-response mechanism into the flash; I don't know 
much about it.


If, on the other hand, you just don't want to confuse someone who 
might accidentally run the XML-generating script from the browser, 
checking a GET parameter as above is probably the safest. If it's not 
set properly, redirect the user, eg:


   if (!isset($_GET['calledby']) || $_GET['calledby'] != 'swf') {
  header('Location: http://example.com/thecorrectpage.html');
  exit();
   }
   ...

- steve

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] Single Sign On

2007-06-04 Thread Steve Edberg

At 8:06 AM +0530 6/4/07, Sudheer Satyanarayana wrote:

Hi,

We have three web sites
a) example1.com
b) example2.com
c) my.example2.com


Our sites include exclusive pages for registered users. All user 
account management tasks are handled by my.example2.com including 
registration, modification, cancellation, etc.  We would like to 
create a single sign on system for all the three web sites. The user 
would sign on with a single username and password to all three web 
sites. For example, when the user visits a membership page in 
example1.com he would be prompted to sign on to his account.  His 
credentials are stored in my.example2.com.  my.example2.com is now 
fully functional. After the successful sign on, the user would be 
redirected to original membership page in example1.com.


How would I pass the information from my.example2.com to 
example1.com about the authentication status of user?


We use MySQL database to store and retrieve user account details in 
my.example2.com. The web host does not allow remote database 
connections.



If you have some control over software installation/web server 
configuration, you may find Pubcookie -


http://www.pubcookie.org/

- useful.

steve

--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



  1   2   >