[PHP] ob_start callback preg_replace

2004-06-02 Thread John Kaspar
Can someone help me with preg_replace?
I want to convert all numbers either 8 or 9 digits in length, into a 
link.  Such that when it sees:

John Doe, 456890123, is a new employee.
It converts it to:
John Doe, 456890123, is a new 
employee.

function callback($buffer) {
  // create id links
  return ???;
}
ob_start("callback");
Thanks much,
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: clearing new pages

2004-05-26 Thread John Kaspar
I put this at the top of long pages,
$processing = "

processing, please wait ...

";
echo $processing;
flush();
Then put this at the bottom,
$hide = "

if (document.layers) {
processing.visibility='hide'
} else if (document.all) {
document.all('processing').style.visibility='hidden'
} else {
document.getElementById('processing').style.display='none'
}

";
echo $hide;
Works pretty good.
- John

On 5/26/2004 10:20 AM, Michael Young wrote:
Hi,
a file called a.php prints "hello" to the browser then calls b.php 
which prints "goodbye" to the browser.
the output looks like this:

hello
goodbye
how do I clear the screen so the end results looks like this:
goodbye
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Perfect Squares

2004-05-25 Thread John Kaspar
Try taking the square root of the variable
$sqrt = sqrt($var);
then compare the number of decimal places.
if (strlen(strstr($sqrt,".")) <= strlen(strstr($var,"."))) {
// perfect
}
Just guessing of course.
On 5/25/2004 5:06 PM, Stephen Craton wrote:
I'm in a bit of a pickle. I need to find out if a variable is a perfect
square or not, and this needs to test for decimal numbers as well, such as
2.25. The thing is, the only function I've found in PHP is
gmp_perfect_square() which isn't supported on my web server, and I don't
know how to compile the GMP code into PHP on my windows box. So, how exactly
would you go about finding out if something is a perfect square or not?
 

Thanks,
Stephen Craton
http://www.melchior.us
 

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


[PHP] Re: other eyes

2004-05-24 Thread John Kaspar
$search_usename <> $search_username
you're missing an "r"
On 5/24/2004 5:55 PM, Bob Lockie wrote:
I can't see it.
Maybe other eyes will help. :-)
Why does search_username.1 show the data that was posted with the form 
but search_username.2 is empty?

$search_usename = $_REQUEST[search_username];
echo "search_username.1='$_REQUEST[search_username]'";
echo "search_username.2='$search_username'";
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: multi array wildcard

2004-05-24 Thread John Kaspar
I went ahead and just wrote a quick function.  If there is an easier 
way, please let me know.  Thanks.

function multi_pick($multi_array, $return_key) {
$ret_array = array();
foreach ($multi_array as $key=>$sub_array) {
if (isset($sub_array[$return_key])) {
$ret_array[$key] = $sub_array[$return_key];
}
}
return $ret_array;
}
On 5/24/2004 4:32 PM, John Kaspar wrote:
Something like $users[*]['name']
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] multi array wildcard

2004-05-24 Thread John Kaspar
Is there a shortcut way to turn an subelement
in a multi-dimensioned array into a regular array.
For example, here's my array:
// print_r($users)
Array
(
[1] => Array
(
[name] => John
[email] => [EMAIL PROTECTED]
)
[2] => Array
(
[name] => Chuck
[email] => [EMAIL PROTECTED]
)
)
I'd like a quick conversion for the names to
Array
(
[1] => John
[2] => Chuck
)
Something like $users[*]['name']
Thanks, John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Variables inside a function

2004-03-08 Thread John Kaspar
use the global keyword...
http://www.php.net/manual/en/language.variables.scope.php
On 3/7/2004 6:17 PM, Nathan Croker wrote:

I am relatively new to PHP. But something I can't seem to make work is when
I call one of the functions I have made and a variable is set inside that
function
eg. function blah ($bl,$ah) {
$bl++;
$ah++;
$blah=$bl+$ah;
}
I then echo $blah; somewhere else in the script but nothing is echo'd. How
do I make it so that I can use $blah anywhere in the script?
Thank you in advance for any help.

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


[PHP] Re: syntax help

2004-02-13 Thread John Kaspar
If you want to actually want the variables $flyertotal, $emailtotal, and 
$phonetotal, use the line:

${$array[0]."total"} = $row[0];

But as you defined $array, that will actually create the variables 
$Flyertotal, $Emailtotal, and $Phonetotal (note the caps).

On 2/13/2004 6:10 AM, Bob pilly wrote:
  $array[$i].total=$row[0];<-- problem here

so for the above code i would like to create three
variable $flyertotal,$emailtotal & $phonetotal
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] update password cookie

2003-09-18 Thread John Kaspar
I'm just storing its hash.  Then comparing it to the database hash.  Is 
that bad?  Is there a good write-up somewhere discussing authentication 
techniques that you could recommend?

Yahoo makes you reenter your password every time you reopen your 
browser.  I'll check other sites though.  Thanks for the advice.

On 9/18/2003 5:37 PM, Chris Shiflett wrote:
First, I hope you're not storing a password in a cookie, since it sounds like
you are.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] update password cookie

2003-09-18 Thread John Kaspar
When my users log in, they enter their username and password, and click 
a checkbox to remember the login in the future. If the remember checkbox 
is left unchecked, the cookie expire is set to zero. I also have a page 
where they can change the password.

My question is - how do I update the password cookie without having to 
ask whether or not they want to remember it again? How can I find out 
when the current cookie expires?

Thanks, John

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


[PHP] Re: Multidimensional arrays

2003-07-18 Thread John Kaspar
$sql = "select id, name from customer";
$rs = mysql_query($sql) or die("sql=$sql => ".mysql_error());
while ($row = mysql_fetch_assoc($rs)) {
$custarray[] = $row;
}
/*
$row is an array with the elements 'id' and 'name'
$custarray becomes a multi-array indexed starting a 0
e.g.
$custarray[0]['id'] = 5126
$custarray[0]['name'] = 'jo'
$custarray[1]['id'] = 5127
$custarray[1]['name'] = 'mark'
*/
On 7/18/2003 8:33 AM, Gary Broughton wrote:
Hi

Can anybody help me grasp multidimensional arrays please?  Basically, I am
retrieving all records from one table (two fields), and want to return them
in an array.
I am converting code from ASP to PHP, and in the former I did something like
this:
select id, name from customer
redim custarray(recordcount,2)
i = 0
while not eof
custarray(i,0) = id;
custarray(i,1) = name;
i = i+1;
movenext
wend
... but all my efforts to store them in the same kind of way in PHP have
proved fruitless.  Any advice would be much appreciated.
Many thanks
Gary



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