Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

On 10/8/2013 11:13 AM, Simon Schick wrote:

Hi, Jim

I suggest to read this page of the tutorial. It seems, that it solves the
questions, you posted here:
http://www.php.net/manual/en/configuration.file.per-user.php

Please be aware, that the ini-file is not re-read on every request, but
after a defined time.
Neither are all settings changeable in those per-user ini-files.

Read also the other pages in this chapter, they're good to keep in mind ;)

If you're now calling the script from a webserver, you called by requesting
a page on a subdomain or a top-level-domain, doesn't matter.

Bye,
Simon


On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


Can someone give me an understanding of how the .ini settings are located
and combined?  I am under the impression that there is a full settings .ini
file somewhere up high in my host's server tree and that any settings I
create in .ini files in each of my domain folders are appended/updated
against the 'main' ini settings to give me a 'current' group of php.ini
settings.

What I'm looking to find out is does an ini setting established in a test
subdomain of my site affect those ini settings outside of my test subdomain?

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





I need more!
1 - the doc you mentioned refers to 'user.ini'.  Does that literally 
mean the file is called 'USER.ini'?  I have been placing my .ini 
overrides/settings in each of my folders under the name 'php.ini'.  Do I 
have to change them all because it seems that they are working fine.


2 - I didn't understand your last paragraph.

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



Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

re: changing ini settings.

If my running script modifies an ini setting I currently believe that 
that changed setting will apply to that specific process and any others 
that run after that from that same folder (since i have an ini file in 
each folder currently).  Correct?


And if I do make a setting change as above, it only affects the ini file 
and processes in that folder, thus leaving the setting unchanged in any 
and all other folders above that one.  Correct?


And from the article pointed out to me, I get the impression that the 
search for ini files bubbles up from the executing folder.  If that is 
so, then am I correct in assuming that settings in the lowest ini file 
take precedence over any found in 'bubbled-up' ini files?


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



Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

On 10/9/2013 3:14 AM, Simon Schick wrote:

On Tue, Oct 8, 2013 at 9:50 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


On 10/8/2013 2:42 PM, Simon Schick wrote:


On Tue, Oct 8, 2013 at 5:25 PM, Jim Giner jim.gi...@albanyhandball.com*
*wrote:

  re: changing ini settings.


If my running script modifies an ini setting I currently believe that
that
changed setting will apply to that specific process and any others that
run
after that from that same folder (since i have an ini file in each folder
currently).  Correct?

And if I do make a setting change as above, it only affects the ini file
and processes in that folder, thus leaving the setting unchanged in any
and
all other folders above that one.  Correct?

And from the article pointed out to me, I get the impression that the
search for ini files bubbles up from the executing folder.  If that is
so,
then am I correct in assuming that settings in the lowest ini file take
precedence over any found in 'bubbled-up' ini files?


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


  Hi, Jim


Never mind my last paragraph ... I was thinking the wrong way of what you
wrote earlier.

I haven't tested it properly in every detail, but from the perspective of
what I know it's like you wrote.

The file that's mentioned as php.ini is the main configuration file of
your php-installation. It may be, that the user-ini file was renamed to
php.ini as well, but if you read about php.ini, they always mean the
configuration-file that you see listed in the output of phpinfo() as
Configuration File (php.ini) Path.

* You can rename the user-ini file by changing the user_ini.filename
setting in the php.ini file (as written on the page I linked you to)

* The php-settings are restored after/before each script-execution

* The manual doesn't catch if a user-ini file was found ... just that it
bubbles up to the document_root. Maybe the configuration found in user-ini
files is merged, or just the first file is taken.

* I don't know what happens to configuration you apply f.e. in nginx ... I
know neither when settings in php-fpm are applied ... that's something
left
for testing, or until somebody finds the documentation explaining it (I
know there is one ...), but I guess they're applied after the php.ini and
before the user-ini files.
Examples are listed here:
http://php.net/manual/en/**install.fpm.configuration.php#**example-60http://php.net/manual/en/install.fpm.configuration.php#example-60

* What you set using set_ini() is just applied for the rest of the
currently running script.

Bye
Simon

  I understand most of what you wrote and agree all except for one thing.

  You keep using the name user.ini and I asked for clarification on this
earlier.  Do I have to create files named EXACTLY that way, or are
php.ini files correctly named?


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



Hi, Jim

You can define the name for this file your configuration (php basic
configuration file or in the webserver, calling the cgi/fcgi script).

The configuration is called user_ini.filename, and it's default value is
set to .user.ini. Of course, your provider (or you, if you're the
administrator of the php-instance) may changed this setting to something
like php.ini. Then the php-process will search for a php.ini file in
the directories a user-ini file is searched in.
When talking about configuration files, this may be misleading, as the
basic configuration file is refered as php.ini over all in the
documentation.

I don't believe, that the PHP process would search for a file called
php.ini, if the value is set to something like .user.ini - if that's
what you mean.

It may be, that you can change the setting later on, but it will have no
effect (f.e. if you change it using set_ini() ... if it doesn't trigger a
E_WARNING or something the like).

Hope this answers the remaining question. If not, I kindly ask you to write
some examples.

Bye,
Simon

Ok - here is what I see happening now.  PHPINFO shows a setting named 
'user_ini.filename' set to '.user.ini'  At the same time the setting 
loaded configuration file shows that a php.ini file was loaded from 
the current sub folder that this call to phpinfo was running in (as I 
expect!).  So apparently my host has set php to look for user.ini 
files, but php.ini files are still accepted and loaded.


I'm guessing that despite the user_ini filename setting, a PHP.ini file 
will still be read, which suits me just fine.


Thanks for all the help Simon!

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



[PHP] php.ini

2013-10-08 Thread Jim Giner
Can someone give me an understanding of how the .ini settings are 
located and combined?  I am under the impression that there is a full 
settings .ini file somewhere up high in my host's server tree and that 
any settings I create in .ini files in each of my domain folders are 
appended/updated against the 'main' ini settings to give me a 'current' 
group of php.ini settings.


What I'm looking to find out is does an ini setting established in a 
test subdomain of my site affect those ini settings outside of my test 
subdomain?


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



Re: [PHP] date time problem

2013-10-07 Thread Jim Giner

On 10/6/2013 11:21 PM, Romain CIACCAFAVA wrote:

An easier way to do that would be using the diff() method of a DateTime object 
on another.

Regards
Romain Ciaccafava

Romain - you were so right.  A little less calculating to be done and I 
got the result I wished.  For anyone interested here's the function I'm 
using to determine how much time there is until a cookie expires.  The 
cookie in question contains the expiration datetime that was used to 
create a paired cookie.


function GetTimeLeft($applid)
{
   if (isset($_COOKIE[$applid]))
   {
  if (isset($_COOKIE[$applid.expire]))
  {
 $curr_time = new datetime();
 $cookietime = $_COOKIE[$applid.expire];
 $exp_time = new datetime();
 $exp_time-setTimeStamp($cookietime);
 $diff = $curr_time-diff($exp_time);
 $days = $diff-format(%d);
 $days = ($days  1) ? $days days: ($days == 1) ?
   $days day : '';
 $hms = $diff-format(%h:%i:%s);
 return Time left: $days $hms;
  }
  else
 return '?';
   }
   else
  return '0';
}



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



[PHP] date time problem

2013-10-06 Thread Jim Giner
I always hate dealing with date/time stuff in php - never get it even 
close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid.expire];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date(h:i:s,$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only 00:43:04.

So - where is the hour value of '07' coming from?? And how do I get this 
right?


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



Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 6:36 PM, Farzan Dalaee wrote:

You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate(H:i:s,$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid.expire];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date(h:i:s,$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only 00:43:04.

So - where is the hour value of '07' coming from?? And how do I get this right?

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



Thanks for the quick response, but why do I want to show the time in 
GMT?  However, I did try it, changing the 'time_left' calc to use 
gmdate.  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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



Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 6:49 PM, Farzan Dalaee wrote:

Try this please

  gmdate(H:i:s, $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate(H:i:s,$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid.expire];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date(h:i:s,$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only 00:43:04.

So - where is the hour value of '07' coming from?? And how do I get this right?

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

Thanks for the quick response, but why do I want to show the time in GMT?  However, I did 
try it, changing the 'time_left' calc to use gmdate.  Now instead of a 7 for 
hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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




Doesn't work either.

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



Re: [PHP] date time problem

2013-10-06 Thread Jim Giner
Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote:

 Jim,
 
 The date method takes in a timestamp (not seconds away).
 
 You have the seconds, you will need to manually convert those seconds to what 
 you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
 
 Aziz
 
 
 On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote:
 Its so freaky
 
 Best Regards
 Farzan Dalaee
 
  On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote:
 
  On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
  Try this please
 
   gmdate(H:i:s, $diff%86400)
 
  Best Regards
  Farzan Dalaee
 
  On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote:
 
  On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
  You should use  gmdate() if you want to how many hours left to expire
  $time_left = gmdate(H:i:s,$diff);
 
  Best Regards
  Farzan Dalaee
 
  On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com 
  wrote:
 
  I always hate dealing with date/time stuff in php - never get it even 
  close until an hour or two goes by
 
  anyway
 
  I have this:
 
  // get two timestamp values
  $exp_time = $_COOKIE[$applid.expire];
  $curr_time = time();
  // get the difference
  $diff = $exp_time - $curr_time;
  // produce a display time of the diff
  $time_left = date(h:i:s,$diff);
 
  Currently the results are:
  exp_time is 06:55:07
  curr_time is 06:12:03
  the diff is 2584
  All of these are correct.
 
  BUT time_left is 07:43:04 when it should be only 00:43:04.
 
  So - where is the hour value of '07' coming from?? And how do I get 
  this right?
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  Thanks for the quick response, but why do I want to show the time in 
  GMT?  However, I did try it, changing the 'time_left' calc to use 
  gmdate.  Now instead of a 7 for hours I have a 12.
 
  exp 07:34:52
  curr 06:40:14
  diff 3158
  left is 12:52:38
 
  The 52:38 is the correct value, but not the 12.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  Doesn't work either.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 7:40 PM, Aziz Saleh wrote:

The resulting subtraction is not a valid timestamp, but rather the
difference between the two timestamps in seconds . The resulting diff can
be 1 if the timestamps are 1 seconds apart. The
linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan
sent out contains functions that does the division for you with
results. Another link you can check out:

http://stackoverflow.com/a/9143387/1935500



On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote:

Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote:


Its so freaky

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com

wrote:



On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate(H:i:s, $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com

wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate(H:i:s,$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com

wrote:


I always hate dealing with date/time stuff in php - never get it

even close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid.expire];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date(h:i:s,$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only 00:43:04.

So - where is the hour value of '07' coming from?? And how do I get

this right?


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

Thanks for the quick response, but why do I want to show the time in

GMT?  However, I did try it, changing the 'time_left' calc to use gmdate.
  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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

Doesn't work either.

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








Good Point!  I never looked at it that way.  I guess the Date function 
can't be relied on in that case.  So now I'll have to calculate my time 
in a mathematical way instead of letting Date translate it for me.


Thanks!



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



Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 7:55 PM, Ashley Sheridan wrote:

On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:


Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote:


Its so freaky

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote:


On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate(H:i:s, $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com

wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate(H:i:s,$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com

wrote:


I always hate dealing with date/time stuff in php - never get it

even close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid.expire];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date(h:i:s,$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only 00:43:04.

So - where is the hour value of '07' coming from?? And how do I get

this right?


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

Thanks for the quick response, but why do I want to show the time in

GMT?  However, I did try it, changing the 'time_left' calc to use gmdate.
  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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

Doesn't work either.

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






Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

Thanks,
Ash
http://www.ashleysheridan.co.uk



Thanks Ash, but the previous (top) post explained my dilemma just as you 
have done here.  My attempt to use a function to avoid doing the math 
has now been resolved.  Guess I'll have to do it the old-fashioned way.


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



[PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/28/2013 10:33 PM, Ethan Rosenberg wrote:

Dear List -

I have a working program.  I made one change in a switch statement, and
it does not work.  I'm probably missing something fundamental.

Here are some code SNIPPETS...  [please note that all my debug
statements are at the left margin]

Setup...

?php
 session_start();
 session_name(STORE);
 set_time_limit(2400);
 ini_set('display_errors', 'on');
 ini_set('display_startup_errors', 'on');
 error_reporting(-2);

 ini_set('error_reporting', 'E_ALL | E_STRICT');
 ini_set('html_errors', 'On');
 ini_set('log_errors', 'On');
 require '/home/ethan/P/wk.inc'; //password file
 $db = Store;
 $cxn =mysqli_connect($host,$user,$password,$db);
 if (!$cxn)
 {
 die('Connect Error (' . mysqli_connect_errno() . ') '
 . mysqli_connect_error());
 }// no error
 if($_REQUEST['welcome_already_seen']!= already_seen)
 show_welcome();

 //end setup
 function show_welcome() //this is the input screen
 {
 snip

 echo  input type='hidden' name='welcome_already_seen'
value='already_seen';
 echo  input type='hidden' name='next_step' value='step20' /;

 snip
 }


 //end input screen

 //Switch statement

echo 'before';
print_r($_POST); //post#1

 switch ( $_POST['next_step'] )
 {

 case 'step20':
 {
pint_r($_POST);//post#2
echo 'step20';
 if(!empty($_POST['Cust_Num']))
 good();
 if(empty($_POST['Cust_Num']))
 bad();
 break;
 } //end step20

 snip
 } //end switch



post#1

beforeArray
(
 [Cust_Num] = 123
 [Fname] =
 [Lname] =
 [Street] =
 [City] =
 [state] = NY
 [Zip] = 10952
 [PH1] =
 [PH2] =
 [PH3] =
 [Date] =
 [welcome_already_seen] = already_seen
 [next_step] = step20

)

Cust_Num state and Zip are as entered.

The switch statement is never entered, since post#2 is never displayed,
and neither good() or bad() functions are entered.


TIA

Ethan


Once again you are posting code that has no chance of running.  And 
since you are DISABLING error reporting with that -2 value you won't 
even know you have bad code.


Try again.  Post#2 will never display since you aren't printing it.

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



[PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

?php
 session_start();
 session_name(STORE);
 set_time_limit(2400);
 ini_set('display_errors', 'on');
 ini_set('display_startup_errors', 'on');
 error_reporting(-2);

 ini_set('error_reporting', 'E_ALL | E_STRICT');
 ini_set('html_errors', 'On');
 ini_set('log_errors', 'On');


Ethan,Ethan,Ethan - what is all this stuff you have at the top???  Do 
you know how any of this is supposed to be written?  You can not put 
Constants in quotes - they become just plain strings then, not Constants 
with the predefined values you (and the functions) are expecting.  For 
example, 'on' is NOT the same as the use of the word :  on.  And your 
error_reporting setting (which you are attempting to do TWICE) is 
actually causing your script to NOT show any errors, which is preventing 
you from seeing that your script dies at the misspelled print statement 
and never gets to the pair of if statements that should call your good 
and bad functions.


Hate to do this to you, but you've been attempting to pick up PHP for 
two years now almost and from this latest post you appear to not have 
learned anything.


And WHY would you EVER want to have a time limit of 2400 seconds???

And stop burying functions in the middle of your straight line code. 
It's ridiculous and makes reading your scripts a royal PIA.




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



Re: [PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/29/2013 1:29 AM, Ethan Rosenberg wrote:

On 09/28/2013 11:59 PM, Jim Giner wrote:

?php
 session_start();
 session_name(STORE);
 set_time_limit(2400);
 ini_set('display_errors', 'on');
 ini_set('display_startup_errors', 'on');
 error_reporting(-2);

 ini_set('error_reporting', 'E_ALL | E_STRICT');
 ini_set('html_errors', 'On');
 ini_set('log_errors', 'On');


Ethan,Ethan,Ethan - what is all this stuff you have at the top???  Do
you know how any of this is supposed to be written?  You can not put
Constants in quotes - they become just plain strings then, not Constants
with the predefined values you (and the functions) are expecting.  For
example, 'on' is NOT the same as the use of the word :  on.  And your
error_reporting setting (which you are attempting to do TWICE) is
actually causing your script to NOT show any errors, which is preventing
you from seeing that your script dies at the misspelled print statement
and never gets to the pair of if statements that should call your good
and bad functions.

Hate to do this to you, but you've been attempting to pick up PHP for
two years now almost and from this latest post you appear to not have
learned anything.

And WHY would you EVER want to have a time limit of 2400 seconds???

And stop burying functions in the middle of your straight line code.
It's ridiculous and makes reading your scripts a royal PIA.


Jim -

Thanks.

Changed error_reporting to -1. No error messages. No change in output.

Ethan

CORRECT ALL THE WRONG SHIT AND YOULL GET ERROR MESSAGES!!!

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



Re: [PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/29/2013 1:38 AM, Jim Giner wrote:

   session_start();
 session_name(STORE);
 set_time_limit(2400);
 ini_set('display_errors', 'on');
 ini_set('display_startup_errors', 'on');
 error_reporting(-2);

 ini_set('error_reporting', 'E_ALL | E_STRICT');
 ini_set('html_errors', 'On');
 ini_set('log_errors', 'On');

This is what you should have in place of all of the above:

session_start();
error_reporting(E_ALL | E_STRICT | E_NOTICE);	ini_set('display_errors', 
'1');

set_time_limit(2);// if you use more than 2 secs you have a problem




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



Re: [PHP] jquery fill select option value

2013-09-22 Thread Jim Giner

On 9/22/2013 3:52 AM, Ashley Sheridan wrote:



iccsi inu...@gmail.com wrote:

select id=mark name=mark
  option value=--/option
  option value=bmwBMW/option
  option value=audiAudi/option
/select

I use above code to have my select drop down on the form and would like
to
use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example
code at
server site is appreciated,

Your help and information is great appreciated,

Regards,

Iccsi,


Yes it is possible but a) not at server side because JavaScript is run on the 
browser, and b) this is a PHP list not a JavaScript list.

Saying that, why aren't you populating it on the server side with PHP?

Thanks,
Ash

Not sure what you are asking.  With PHP it is possible to have a specifi 
item from the options selected in the drop down when the page is loaded. 
 With JS it is possible to capture the newly selected option value and 
place it in another field, if that is what you want.  Obviously when the 
user clicks on an option, that value IS placed in the select tag for 
processing at the server side by PHP on submit.


So what is it you want to accomplish?

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



Re: [PHP] jquery fill select option value

2013-09-22 Thread Jim Giner

On 9/22/2013 12:04 PM, Tedd Sperling wrote:

On Sep 21, 2013, at 9:06 PM, iccsi inu...@gmail.com wrote:

select id=mark name=mark
option value=--/option
option value=bmwBMW/option
option value=audiAudi/option
/select

I use above code to have my select drop down on the form and would like to use 
jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at 
server site is appreciated,

Your help and information is great appreciated,


While jQuery is great, you don't need jQuery for this -- a simple AJAX routine 
will do what you want. Here's an example:

http://php1.net/a/zipcode-states/

The ajax routine is there -- you can copy it.

The HTML is there -- you can copy that too.

The php script is a simple script that is triggered by an ajax script 
(triggered by the user via onchange() ) that then pulls whatever data is needed 
to populate the remaining option controls via a GET.

HTH's

tedd

___
tedd sperling
tedd.sperl...@gmail.com


OH!!! So you want to populate another(!) select box after the user makes 
his first selection.  You didn't say that.


Yes - ajax call would be just what you want to do.

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



Re: [PHP] Re: refernces, arrays, and why does it take up so much memory?

2013-09-03 Thread Jim Giner

On 9/3/2013 1:09 AM, Daevid Vincent wrote:




-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
Sent: Monday, September 02, 2013 8:14 PM
To: php-general@lists.php.net
Subject: [PHP] Re: refernces, arrays, and why does it take up so much
memory?

On 9/2/2013 9:30 PM, Daevid Vincent wrote:

I'm confused on how a reference works I think.

I have a DB result set in an array I'm looping over. All I simply want

to

do

is make the array key the id of the result set row.

This is the basic gist of it:

 private function _normalize_result_set()
 {
foreach($this-tmp_results as $k = $v)
{
   $id = $v['id'];
   $new_tmp_results[$id] = $v; //2013-08-29 [dv]

using

a

reference here cuts the memory usage in half!
   unset($this-tmp_results[$k]);

   /*
   if ($i++ % 1000 == 0)
   {
 gc_enable(); // Enable Garbage Collector
 var_dump(gc_enabled()); // true
 var_dump(gc_collect_cycles()); // # of

elements

cleaned up
 gc_disable(); // Disable Garbage Collector
   }
   */
}
$this-tmp_results = $new_tmp_results;
//var_dump($this-tmp_results); exit;
unset($new_tmp_results);
 }

Without using the = reference, my data works great:
$new_tmp_results[$id] = $v;

array (size=79552)
6904 =
  array (size=4)
'id' = string '6904' (length=4)
'studio_id' = string '5' (length=1)
'genres' = string '34|' (length=3)
6905 =
  array (size=4)
'id' = string '6905' (length=4)
'studio_id' = string '5' (length=1)
'genres' = string '6|37|' (length=5)

However it takes a stupid amount of memory for some unknown reason.
MEMORY USED @START: 262,144 - @END: 42,729,472 = 42,467,328 BYTES
MEMORY PEAK USAGE: 216,530,944 BYTES

When using the reference the memory drastically goes down to what I'd

EXPECT

it to be (and actually the problem I'm trying to solve).
MEMORY USED @START: 262,144 - @END: 6,029,312 = 5,767,168 BYTES
MEMORY PEAK USAGE: 82,051,072 BYTES

However my array is all kinds of wrong:

array (size=79552)
6904 = 
  array (size=4)
'id' = string '86260' (length=5)
'studio_id' = string '210' (length=3)
'genres' = string '8|9|10|29|58|' (length=13)
6905 = 
  array (size=4)
'id' = string '86260' (length=5)
'studio_id' = string '210' (length=3)
'genres' = string '8|9|10|29|58|' (length=13)

Notice that they're all the same values, although the keys seem right. I
don't understand why that happens because
foreach($this-tmp_results as $k = $v)
Should be changing $v each iteration I'd think.

Honestly, I am baffled as to why those unsets() make no difference. All

I

can think is that the garbage collector doesn't run. But then I had also
tried to force gc() and that still made no difference. *sigh*

I had some other cockamamie idea where I'd use the same tmp_results

array

in

a tricky way to avoid a  second array. The concept being I'd add 1

million

to the ['id'] (which we want as the new array key), then unset the

existing

sequential key, then when all done, loop through and shift all the keys

by

1

million thereby they'd be the right index ID. So add one and unset one
immediately after. Clever right? 'cept it too made no difference on

memory.

Same thing is happening as above where the gc() isn't running or

something

is holding all that memory until the end. *sigh*

Then I tried a different way using array_combine() and noticed something
very disturbing.
http://www.php.net/manual/en/function.array-combine.php


 private function _normalize_result_set()
 {
if (!$this-tmp_results || count($this-tmp_results)  1)
return;

$D_start_mem_usage = memory_get_usage();
foreach($this-tmp_results as $k = $v)
{
   $id = $v['id'];
   $tmp_keys[] = $id;

   if ($v['genres'])
   {
  $g = explode('|', $v['genres']);
 $this-tmp_results[$k]['g'] = $g; //this

causes a

massive spike in memory usage
   }
}
//var_dump($tmp_keys, $this-tmp_results); exit;
echo \nMEMORY USED BEFORE array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
(.number_format(memory_get_peak_usage(true)).)br\n;
$this-tmp_results = array_combine($tmp_keys,
$this-tmp_results);
echo \nMEMORY USED FOR array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
(.number_format

[PHP] Re: refernces, arrays, and why does it take up so much memory?

2013-09-02 Thread Jim Giner

On 9/2/2013 9:30 PM, Daevid Vincent wrote:

I'm confused on how a reference works I think.

I have a DB result set in an array I'm looping over. All I simply want to do
is make the array key the id of the result set row.

This is the basic gist of it:

private function _normalize_result_set()
{
   foreach($this-tmp_results as $k = $v)
   {
  $id = $v['id'];
  $new_tmp_results[$id] = $v; //2013-08-29 [dv] using a
reference here cuts the memory usage in half!
  unset($this-tmp_results[$k]);

  /*
  if ($i++ % 1000 == 0)
  {
gc_enable(); // Enable Garbage Collector
var_dump(gc_enabled()); // true
var_dump(gc_collect_cycles()); // # of elements
cleaned up
gc_disable(); // Disable Garbage Collector
  }
  */
   }
   $this-tmp_results = $new_tmp_results;
   //var_dump($this-tmp_results); exit;
   unset($new_tmp_results);
}

Without using the = reference, my data works great:
$new_tmp_results[$id] = $v;

array (size=79552)
   6904 =
 array (size=4)
   'id' = string '6904' (length=4)
   'studio_id' = string '5' (length=1)
   'genres' = string '34|' (length=3)
   6905 =
 array (size=4)
   'id' = string '6905' (length=4)
   'studio_id' = string '5' (length=1)
   'genres' = string '6|37|' (length=5)

However it takes a stupid amount of memory for some unknown reason.
MEMORY USED @START: 262,144 - @END: 42,729,472 = 42,467,328 BYTES
MEMORY PEAK USAGE: 216,530,944 BYTES

When using the reference the memory drastically goes down to what I'd EXPECT
it to be (and actually the problem I'm trying to solve).
MEMORY USED @START: 262,144 - @END: 6,029,312 = 5,767,168 BYTES
MEMORY PEAK USAGE: 82,051,072 BYTES

However my array is all kinds of wrong:

array (size=79552)
   6904 = 
 array (size=4)
   'id' = string '86260' (length=5)
   'studio_id' = string '210' (length=3)
   'genres' = string '8|9|10|29|58|' (length=13)
   6905 = 
 array (size=4)
   'id' = string '86260' (length=5)
   'studio_id' = string '210' (length=3)
   'genres' = string '8|9|10|29|58|' (length=13)

Notice that they're all the same values, although the keys seem right. I
don't understand why that happens because
foreach($this-tmp_results as $k = $v)
Should be changing $v each iteration I'd think.

Honestly, I am baffled as to why those unsets() make no difference. All I
can think is that the garbage collector doesn't run. But then I had also
tried to force gc() and that still made no difference. *sigh*

I had some other cockamamie idea where I'd use the same tmp_results array in
a tricky way to avoid a  second array. The concept being I'd add 1 million
to the ['id'] (which we want as the new array key), then unset the existing
sequential key, then when all done, loop through and shift all the keys by 1
million thereby they'd be the right index ID. So add one and unset one
immediately after. Clever right? 'cept it too made no difference on memory.
Same thing is happening as above where the gc() isn't running or something
is holding all that memory until the end. *sigh*

Then I tried a different way using array_combine() and noticed something
very disturbing.
http://www.php.net/manual/en/function.array-combine.php


private function _normalize_result_set()
{
   if (!$this-tmp_results || count($this-tmp_results)  1)
return;

   $D_start_mem_usage = memory_get_usage();
   foreach($this-tmp_results as $k = $v)
   {
  $id = $v['id'];
  $tmp_keys[] = $id;

  if ($v['genres'])
  {
 $g = explode('|', $v['genres']);
$this-tmp_results[$k]['g'] = $g; //this causes a
massive spike in memory usage
  }
   }
   //var_dump($tmp_keys, $this-tmp_results); exit;
   echo \nMEMORY USED BEFORE array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
(.number_format(memory_get_peak_usage(true)).)br\n;
   $this-tmp_results = array_combine($tmp_keys,
$this-tmp_results);
   echo \nMEMORY USED FOR array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
(.number_format(memory_get_peak_usage(true)).)br\n;
   var_dump($tmp_keys, $this-tmp_results); exit;
}

Just the simple act of adding that 'g' variable element to the array causes
a massive change in memory usage. WHAT THE F!?

MEMORY USED BEFORE array_combine: 105,315,264 PEAK: (224,395,264)
MEMORY USED FOR array_combine: 106,573,040 PEAK: (224,395,264)

And taking out the

Re: [PHP] Basic Auth

2013-08-28 Thread Jim Giner

Stuart,

Just wanted to follow up with my thanks for your excellent help in 
providing understanding of how to generate the 401 error page and 
getting me thru the process of performing a sign-out from basic auth. 
Without your patience it never would have happened.


Also wanted to tell you that I've scrapped it all.  Keeping the code for 
a rainy day of course, but giving up on using it (as well as the basic 
auth signon process) to use my own 'roll-your-own' code.  Since IE 
insisted on presenting multiple credentials during the signon process it 
was a futile effort to be doing a signoff.  And yes - I've taken the 
proper precautions to hash the incoming password value before submission 
and storing in my db that way.


Thanks again.  It's help like this that makes this group such a great 
resource.


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



Re: [PHP] exec and system do not work

2013-08-27 Thread Jim Giner

On 8/26/2013 5:01 PM, Ethan Rosenberg, PhD wrote:


On 08/26/2013 03:28 PM, Jim Giner wrote:

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um
08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  Please show the output of the directory listing.
  Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything
works.


  When you say does not work, can you show what is actually not
working? I
  believe the exec and system functions are likely working just fine,
but that
  the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDNT ACTUALLY RUN.

I've told you multiple times that you need to do these two things and
you are back at it again.

The sample php above has plain simple syntax errors that would keep it
from running, which error checking would tell you IF YOU RAN IT.



Jim -

Thank you.

I don't totally understand your reply ...

but I will try to answer

The code is taken from an operating program.  My error checking is set
to maximum sensitivity.

If you would point out my syntax errors, I will fix them.

TIA

Ethan


you have semis after your if lines - therefore no logic gets executed.

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



[PHP] Basic Auth

2013-08-27 Thread Jim Giner
Im using basic auth for a few of my pages that I want to limit access 
to - nothing of a sensitive nature, but simply want to limit access to. 
 Want to implement a signoff process, but can't figure it out.


From the comments in the manual I take it one can't do this by simply 
unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why 
this doesn't suffice?  The signon process expects them to be there, so 
when they are not (after the 'unset'), how come my signon process still 
detects them and their values?


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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 9:46 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 14:37, Jim Giner jim.gi...@albanyhandball.com wrote:


Im using basic auth for a few of my pages that I want to limit access to - 
nothing of a sensitive nature, but simply want to limit access to.  Want to 
implement a signoff process, but can't figure it out.

 From the comments in the manual I take it one can't do this by simply 
unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why this 
doesn't suffice?  The signon process expects them to be there, so when they are 
not (after the 'unset'), how come my signon process still detects them and 
their values?


The global variables you're referring to are just that, global variables; 
changing them will have no effect on the browser. Basic Auth was not designed 
to allow users to log out, but you can make it happen with some Javascript.

Have your log out link call a Javascript function which sends an XMLHttpRequest 
with an invalid username and password. The server will return a 401 which you 
ignore and then take the user to whatever URL you want them to see after they 
log off. Not pretty, but it works.

-Stuart


Thanks for the timely response!

Before I try your suggestion - one question.  Since when is a global 
variable not changeable?  Doesn't the fact that it reflects a modified 
value when I do change it tell me it worked?  I change the value to 
'xxx' and show it having that value, but when the script is called again 
the old value appears.  Very confusing!



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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart



Not really - this is the first time I've had something not work as expected.


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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

   I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart

This may very well be the first time with this problem because I haven't 
tried anything like this before.


That said - can you give me some pointers on how to do the JS solution?  
I'm calling a script that is similar to the one I used to signon.  It 
sends out something like:


header(WWW-Authenticate: Basic realm=$realm);
header('HTTP/1.0 401 Unauthorized');
echo h3You have entered invalid credentialsbr;
echo Click a href='$return_url' here /a to return to the 
menu.;

exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid 
value, but what do I do with that?  How do I ignore the 401?   Now I'm 
getting the signin dialog and I'm stuck.



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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:55 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

   I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart


This may very well be the first time with this problem because I haven't tried 
anything like this before.

That said - can you give me some pointers on how to do the JS solution?  I'm 
calling a script that is similar to the one I used to signon.  It sends out 
something like:

header(WWW-Authenticate: Basic realm=$realm);
header('HTTP/1.0 401 Unauthorized');
echo h3You have entered invalid credentialsbr;
echo Click a href='$return_url' here /a to return to the menu.;
exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid value, 
but what do I do with that?  How do I ignore the 401?   Now I'm getting the 
signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart

I am familiar with an ajax request (xmlhttprequest) and I have a 
function ready to call a script to effect this signoff.  I just don't 
know what to put in that php script I'm calling.  From what you just 
wrote I'm guessing that my headers as shown previously  may be close - 
Im confused about your mention of contains an invalid username  
As you can see from my sample I don't include such a thing.



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



Re: Fwd: [PHP] Basic Auth

2013-08-27 Thread Jim Giner

On 8/27/2013 11:56 AM, Stuart Dallas wrote:

Oops, sent this message from the wrong email address, so the list rejected it.

Begin forwarded message:


From: Stuart Dallas stu...@3ft9.com
Subject: Re: [PHP] Basic Auth
Date: 27 August 2013 16:36:27 BST
To: jim.gi...@albanyhandball.com
Cc: php-general@lists.php.net

On 27 Aug 2013, at 15:59, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:55 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

  I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart


This may very well be the first time with this problem because I haven't tried 
anything like this before.

That said - can you give me some pointers on how to do the JS solution?  I'm 
calling a script that is similar to the one I used to signon.  It sends out 
something like:

   header(WWW-Authenticate: Basic realm=$realm);
   header('HTTP/1.0 401 Unauthorized');
   echo h3You have entered invalid credentialsbr;
   echo Click a href='$return_url' here /a to return to the menu.;
   exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid value, 
but what do I do with that?  How do I ignore the 401?   Now I'm getting the 
signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart


I am familiar with an ajax request (xmlhttprequest) and I have a function ready to call a 
script to effect this signoff.  I just don't know what to put in that php script I'm calling.  
From what you just wrote I'm guessing that my headers as shown previously  may be close - 
Im confused about your mention of contains an invalid username  As you 
can see from my sample I don't include such a thing.


For the last time: YOU DO NOT NEED TO MAKE ANY CHANGES SERVER-SIDE.

 From the Javascript, request any URL that requires authentication - it doesn't 
matter. When you make the AJAX request, pass an Authentication header that 
contains an invalid username and password. If you don't know what I mean by 
that, please google how HTTP Basic Auth works.

-Stuart

--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


It's not the basic auth that I'm having the issue with - it's the 
'header' thing and understanding what a 401 is doing and how I'm to 
ignore it.  Never had to play with these things before and this part is 
all new.  Let's face it - I'm an applications guy, not a systems guy. 
All this talk of headers and such is greek to me.


I have spent the last hour googling away on this topic - still no 
understanding.


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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 12:53 PM, Stuart Dallas wrote:

On 27 Aug 2013, at 17:28, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 11:56 AM, Stuart Dallas wrote:

Oops, sent this message from the wrong email address, so the list rejected it.

Begin forwarded message:


From: Stuart Dallas stu...@3ft9.com
Subject: Re: [PHP] Basic Auth
Date: 27 August 2013 16:36:27 BST
To: jim.gi...@albanyhandball.com
Cc: php-general@lists.php.net

On 27 Aug 2013, at 15:59, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:55 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

  I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart


This may very well be the first time with this problem because I haven't tried 
anything like this before.

That said - can you give me some pointers on how to do the JS solution?  I'm 
calling a script that is similar to the one I used to signon.  It sends out 
something like:

   header(WWW-Authenticate: Basic realm=$realm);
   header('HTTP/1.0 401 Unauthorized');
   echo h3You have entered invalid credentialsbr;
   echo Click a href='$return_url' here /a to return to the menu.;
   exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid value, 
but what do I do with that?  How do I ignore the 401?   Now I'm getting the 
signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart


I am familiar with an ajax request (xmlhttprequest) and I have a function ready to call a 
script to effect this signoff.  I just don't know what to put in that php script I'm calling.  
From what you just wrote I'm guessing that my headers as shown previously  may be close - 
Im confused about your mention of contains an invalid username  As you 
can see from my sample I don't include such a thing.

For the last time: YOU DO NOT NEED TO MAKE ANY CHANGES SERVER-SIDE.

 From the Javascript, request any URL that requires authentication - it doesn't 
matter. When you make the AJAX request, pass an Authentication header that 
contains an invalid username and password. If you don't know what I mean by 
that, please google how HTTP Basic Auth works.

-Stuart

It's not the basic auth that I'm having the issue with - it's the 'header' 
thing and understanding what a 401 is doing and how I'm to ignore it.  Never 
had to play with these things before and this part is all new.  Let's face it - 
I'm an applications guy, not a systems guy. All this talk of headers and such 
is greek to me.

HTTP headers are as important for application guys as they are for systems 
guys. I appreciate that this may be new to you, but it's pretty basic knowledge 
about how HTTP works.

Basic auth is simple, and you need to understand how it works to understand 
what I've been trying to say. Here's how HTTP auth works:

1) Browser hits page.
2) The PHP script knows this page requires HTTP Auth, checks the 
PHP_AUTH_[USER|PW] variables but doesn't find anything, so it responds with an 
HTTP status of 401 Unauthorised.
3) The browser gets the 401 response and displays the login box.
4) User enters username and password.
5) Browser sends the request again

Re: [PHP] exec and system do not work

2013-08-26 Thread Jim Giner

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  Please show the output of the directory listing.
  Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


  When you say does not work, can you show what is actually not
working? I
  believe the exec and system functions are likely working just fine,
but that
  the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDNT ACTUALLY RUN.

I've told you multiple times that you need to do these two things and 
you are back at it again.


The sample php above has plain simple syntax errors that would keep it 
from running, which error checking would tell you IF YOU RAN IT.


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



Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Jim Giner

On 8/22/2013 8:05 AM, Curtis Maurand wrote:




Is the subdomain also in a subfolder of the main domain?

Jim Giner wrote:

I have a main domain (of course) and a sub

domain.  I'm really trying to

steer my personal stuff away from

the main one and have focused all of

my php development to the

sub-domain.


Lately I noticed that google catalogs my

sub-domain site stuff under the

main domain name and the links

that come up lead to that domain name

with the path that takes

the user to the sub-domain's home folder and

beyond.




Is there something that php (apache??) can do to control either

google's

robots or the user's view (url) so that it appears as a

page of my

sub-domain?  I'm really new at this stuff and know

nothing.  I'm lucky

that google is even finding my site!

IN advance - I apologize for this off-topic question,

but this place is

a source of much knowledge, so I just threw in

a quick interlude here to

pick someone's brain.  :)




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




Yes - the sub is an add-on domain to my primary domain.  Hence the 
overlap and problem.


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



Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Jim Giner

On 8/22/2013 9:43 AM, Willie wrote:

The only way that I know of to take care of that is to put a file in your
main directory called robots.txt. In that file you will put:


User-agent: *
Disallow: /FolderName



On Thu, Aug 22, 2013 at 6:19 AM, Jim Giner jim.gi...@albanyhandball.comwrote:


On 8/22/2013 8:05 AM, Curtis Maurand wrote:





Is the subdomain also in a subfolder of the main domain?

Jim Giner wrote:


I have a main domain (of course) and a sub


domain.  I'm really trying to


steer my personal stuff away from


the main one and have focused all of


my php development to the


sub-domain.



Lately I noticed that google catalogs my


sub-domain site stuff under the


main domain name and the links


that come up lead to that domain name


with the path that takes


the user to the sub-domain's home folder and


beyond.



  Is there something that php (apache??) can do to control either



google's


robots or the user's view (url) so that it appears as a


page of my


sub-domain?  I'm really new at this stuff and know


nothing.  I'm lucky


that google is even finding my site!

IN advance - I apologize for this off-topic question,


but this place is


a source of much knowledge, so I just threw in


a quick interlude here to


pick someone's brain.  :)



  --

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




  Yes - the sub is an add-on domain to my primary domain.  Hence the

overlap and problem.


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






I'll try it.

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



[PHP] Off the wall - sub-domain question

2013-08-21 Thread Jim Giner
I have a main domain (of course) and a sub domain.  I'm really trying to 
steer my personal stuff away from the main one and have focused all of 
my php development to the sub-domain.


Lately I noticed that google catalogs my sub-domain site stuff under the 
main domain name and the links that come up lead to that domain name 
with the path that takes the user to the sub-domain's home folder and 
beyond.


Is there something that php (apache??) can do to control either google's 
robots or the user's view (url) so that it appears as a page of my 
sub-domain?  I'm really new at this stuff and know nothing.  I'm lucky 
that google is even finding my site!


IN advance - I apologize for this off-topic question, but this place is 
a source of much knowledge, so I just threw in a quick interlude here to 
pick someone's brain.  :)


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



[PHP] Re: Output to File Instead of Browser

2013-08-20 Thread Jim Giner

On 8/20/2013 12:38 PM, Floyd Resler wrote:

I have a php file that generates a form.  Of course, this displays in the 
browser.  How can I have the form generated from my script but either saved to 
a file or the output returned to another script?

Thanks!
Floyd


Store your generated web page (from !doctype to /html) in a variable. 
 Then either use file_put_contents or save the var to a session one and 
call the next script.


That's what I would do, if I ever found myself needing to do
such a thing.

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



Re: [PHP] Output to File Instead of Browser

2013-08-20 Thread Jim Giner

On 8/20/2013 3:20 PM, Daniel Pöllmann wrote:

Buffering is the more comftable way because if you write all html to a
variable, output that might be created in a function, you did not modify
will not be included.

Non critical errors that create an output (notice/warning) will not ve
included as well.

Another way would be to create a script which makes a http request to the
output script and saves the response to the file

Daniel
Am 20.08.2013 18:39 schrieb Floyd Resler fres...@adex-intl.com:


I have a php file that generates a form.  Of course, this displays in the
browser.  How can I have the form generated from my script but either saved
to a file or the output returned to another script?

Thanks!
Floyd




I assumed that the user would only be doing this once it had been 
debugged.

Don't understand why a function generating output would present a problem.

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



[PHP] fpdf problem?

2013-08-09 Thread Jim Giner
I've been using fpdf to create pdf files for my site.  All has been well 
for over a year.  Suddenly I have a problem wherein IE 10 on W7 crashes 
when I try to print one of these pdfs created by my php scripts.


The pdf files that I create seem fine.  If I bring one up in IE and then 
save it to my drive, I can then exit IE and go open the pdf and print it 
just fine.


I have removed my pdf printer drivers from my system and that hasn't 
improved my situation.  No luck there.


The exact scenario is:
- script generates pdf and opens it in a new target window;
- user clicks on print toolbar icon or File,Print;
- print dialog opens;  here I see some problems in that the (very 
complex) dialog is not displaying correctly with controls misaligned or 
overlaying other controls;
- click on Ok to execute the print to printer and nothing happens;  wait 
5 minutes and still nothing;
- NOW the problems begin;  when the window with the pdf in it is closed, 
in about 2 seconds I get a dialog box telling me IE has stopped working.


Note that the problem only occurs when I attempt to print.  If my script 
opens the pdf target window and I simply close it - no problems occur. 
BUT - if I actually open a print dialog I get a crash whether I click OK 
or Cancel, as soon as I close the window containing the pdf.


My question is does anyone have problems with fpdf lately?  Since my 
files seem to be completely normal to adobe reader I don't think their 
content is at fault.  It seems more like IE is not handling them and I 
can't find anything online about this.


I'm really hoping this is a problem wtih fpdf rather than IE since 
solutions are more apt to come out of this forum than the great wizards 
of M$ Oz.


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



Re: [PHP] fpdf problem?

2013-08-09 Thread Jim Giner

On 8/9/2013 12:06 PM, Tamara Temple wrote:


On Aug 9, 2013, at 10:50 AM, Jim Giner jim.gi...@albanyhandball.com wrote:


I've been using fpdf to create pdf files for my site.  All has been well for 
over a year.  Suddenly I have a problem wherein IE 10 on W7 crashes when I try 
to print one of these pdfs created by my php scripts.

The pdf files that I create seem fine.  If I bring one up in IE and then save 
it to my drive, I can then exit IE and go open the pdf and print it just fine.

I have removed my pdf printer drivers from my system and that hasn't improved 
my situation.  No luck there.

The exact scenario is:
- script generates pdf and opens it in a new target window;
- user clicks on print toolbar icon or File,Print;
- print dialog opens;  here I see some problems in that the (very complex) 
dialog is not displaying correctly with controls misaligned or overlaying other 
controls;
- click on Ok to execute the print to printer and nothing happens;  wait 5 
minutes and still nothing;
- NOW the problems begin;  when the window with the pdf in it is closed, in 
about 2 seconds I get a dialog box telling me IE has stopped working.

Note that the problem only occurs when I attempt to print.  If my script opens 
the pdf target window and I simply close it - no problems occur. BUT - if I 
actually open a print dialog I get a crash whether I click OK or Cancel, as 
soon as I close the window containing the pdf.

My question is does anyone have problems with fpdf lately?  Since my files seem 
to be completely normal to adobe reader I don't think their content is at 
fault.  It seems more like IE is not handling them and I can't find anything 
online about this.

I'm really hoping this is a problem wtih fpdf rather than IE since solutions 
are more apt to come out of this forum than the great wizards of M$ Oz.


Does this happen only for pdfs you've generated with fpdf, or any pdf file?

Good question and the answer is: it happens for other pdfs as well, so I 
guess it's not fpdf.


Sorry for the mis-post here - I'll do more research on Adobe and IE.

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



Re: [PHP] fpdf problem?

2013-08-09 Thread Jim Giner

On 8/9/2013 12:11 PM, Jim Giner wrote:

On 8/9/2013 12:06 PM, Tamara Temple wrote:


On Aug 9, 2013, at 10:50 AM, Jim Giner jim.gi...@albanyhandball.com
wrote:


I've been using fpdf to create pdf files for my site.  All has been
well for over a year.  Suddenly I have a problem wherein IE 10 on W7
crashes when I try to print one of these pdfs created by my php scripts.

The pdf files that I create seem fine.  If I bring one up in IE and
then save it to my drive, I can then exit IE and go open the pdf and
print it just fine.

I have removed my pdf printer drivers from my system and that hasn't
improved my situation.  No luck there.

The exact scenario is:
- script generates pdf and opens it in a new target window;
- user clicks on print toolbar icon or File,Print;
- print dialog opens;  here I see some problems in that the (very
complex) dialog is not displaying correctly with controls misaligned
or overlaying other controls;
- click on Ok to execute the print to printer and nothing happens;
wait 5 minutes and still nothing;
- NOW the problems begin;  when the window with the pdf in it is
closed, in about 2 seconds I get a dialog box telling me IE has
stopped working.

Note that the problem only occurs when I attempt to print.  If my
script opens the pdf target window and I simply close it - no
problems occur. BUT - if I actually open a print dialog I get a crash
whether I click OK or Cancel, as soon as I close the window
containing the pdf.

My question is does anyone have problems with fpdf lately?  Since my
files seem to be completely normal to adobe reader I don't think
their content is at fault.  It seems more like IE is not handling
them and I can't find anything online about this.

I'm really hoping this is a problem wtih fpdf rather than IE since
solutions are more apt to come out of this forum than the great
wizards of M$ Oz.


Does this happen only for pdfs you've generated with fpdf, or any pdf
file?


Good question and the answer is: it happens for other pdfs as well, so I
guess it's not fpdf.

Sorry for the mis-post here - I'll do more research on Adobe and IE.


Update:
Solved my print problem by unchecking an option in Adobe Reader - 
Display PDF in browser.  Solved my garbled dialog box and the printing 
of the document.


Of course - the down side is that you must close the document and then 
the now-empty browser window.



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



Re: [PHP] fpdf problem?

2013-08-09 Thread Jim Giner

On 8/9/2013 1:56 PM, Jan Ehrhardt wrote:

Jim Giner in php.general (Fri, 09 Aug 2013 12:33:30 -0400):

Good question and the answer is: it happens for other pdfs as well, so I
guess it's not fpdf.

Sorry for the mis-post here - I'll do more research on Adobe and IE.


Update:
Solved my print problem by unchecking an option in Adobe Reader -
Display PDF in browser.  Solved my garbled dialog box and the printing
of the document.


Although it is off-topic: I do not have this problem with PDFs in a IE10
browser window. No garbled print dialogue, prints OK, no crash.

IE 10.0.9200.16635, Update version 10.0.7, W7 Pro 64-bits. Adobe Reader
XI, version 11.0.3.

Jan

I have since my last post discovered that XI does indeed solve the 
problem completely.  Too bad M$ doesn't post that info on all the many 
forum topics complaining about this.



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



[PHP] Re: Operand error...

2013-08-08 Thread Jim Giner

On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:

$oppdater_lager_med_antall_kg = $kg_pa_lager +
$kg_fra_transportdokument_inn_pa_valgt_lager;


result:
*Fatal error*: Unsupported operand types in *
/Users/karl/Sites/kasen/io/kp/index.php* on line *2970

*I have also tried this:
$kg_pa_lager += $kg_fra_transportdokument_inn_pa_valgt_lager;

Both of them return this Fatal error.
I am using Dreamweaver CS6 and the syntax check in my software say: No
syntax error

What am I doing wrong this time?

Thanks for your good advice!

Karl


You do a var_dump on each variable to see what type they were defined as.

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



Re: [PHP] Re: Operand error...

2013-08-08 Thread Jim Giner

On 8/8/2013 1:43 PM, Karl-Arne Gjersøyen wrote:

2013/8/8 Jim Giner jim.gi...@albanyhandball.com


On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:


$oppdater_lager_med_antall_kg = $kg_pa_lager +
$kg_fra_transportdokument_inn_**pa_valgt_lager;


result:
*Fatal error*: Unsupported operand types in *
/Users/karl/Sites/kasen/io/kp/**index.php* on line *2970

*I have also tried this:

$kg_pa_lager += $kg_fra_transportdokument_inn_**pa_valgt_lager;

Both of them return this Fatal error.
I am using Dreamweaver CS6 and the syntax check in my software say: No
syntax error

What am I doing wrong this time?

Thanks for your good advice!

Karl

  You do a var_dump on each variable to see what type they were defined as.



NULL array(2) { [0]= string(3) 100 [1]= string(3) 340 }


That is one var. What is the other var?

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



Re: [PHP] Re: Operand error...

2013-08-08 Thread Jim Giner

On 8/8/2013 1:56 PM, Karl-Arne Gjersøyen wrote:

2013/8/8 Jim Giner jim.gi...@albanyhandball.com


On 8/8/2013 1:43 PM, Karl-Arne Gjersøyen wrote:


2013/8/8 Jim Giner jim.gi...@albanyhandball.com

  On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:


  $oppdater_lager_med_antall_kg = $kg_pa_lager +

$kg_fra_transportdokument_inn_pa_valgt_lager;



result:
*Fatal error*: Unsupported operand types in *
/Users/karl/Sites/kasen/io/kp/index.php* on line *2970


*I have also tried this:

$kg_pa_lager += $kg_fra_transportdokument_inn_pa_valgt_lager;


Both of them return this Fatal error.
I am using Dreamweaver CS6 and the syntax check in my software say: No
syntax error

What am I doing wrong this time?

Thanks for your good advice!

Karl

   You do a var_dump on each variable to see what type they were defined
as.





NULL array(2) { [0]= string(3) 100 [1]= string(3) 340 }

  That is one var. What is the other var?



Thank you very much!
Now I know the error.. One of those variables are NULL! When I fix it I
think it work!

Karl

actually, the null is ok I think.  The array is wrong - you can't 'add' 
an array to a scalar variable, which an integer or null is.


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



Re: [PHP] Re: Operand error...

2013-08-08 Thread Jim Giner

On 8/8/2013 2:11 PM, Karl-Arne Gjersøyen wrote:

2013/8/8 Jim Giner jim.gi...@albanyhandball.com


On 8/8/2013 1:56 PM, Karl-Arne Gjersøyen wrote:


2013/8/8 Jim Giner jim.gi...@albanyhandball.com

  On 8/8/2013 1:43 PM, Karl-Arne Gjersøyen wrote:


  2013/8/8 Jim Giner jim.gi...@albanyhandball.com


   On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:



   $oppdater_lager_med_antall_kg = $kg_pa_lager +


$kg_fra_transportdokument_inn_**pa_valgt_lager;




result:
*Fatal error*: Unsupported operand types in *
/Users/karl/Sites/kasen/io/kp/**index.php* on line *2970



*I have also tried this:

$kg_pa_lager += $kg_fra_transportdokument_inn_**pa_valgt_lager;



Both of them return this Fatal error.
I am using Dreamweaver CS6 and the syntax check in my software say:
No
syntax error

What am I doing wrong this time?

Thanks for your good advice!

Karl

You do a var_dump on each variable to see what type they were
defined
as.





NULL array(2) { [0]= string(3) 100 [1]= string(3) 340 }

   That is one var. What is the other var?





Thank you very much!
Now I know the error.. One of those variables are NULL! When I fix it I
think it work!

Karl

  actually, the null is ok I think.  The array is wrong - you can't 'add'

an array to a scalar variable, which an integer or null is.



Yes, it is me and arrays again :D

$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
 $antall = mysql_num_rows($resultat);
 for($i = 0; $i  $antall; $i++){
 $rad = mysql_fetch_array($resultat, MYSQL_ASSOC);

and write it tis way can perhaps make someting more correct?
For example $variable[$i] ?

Karl

Not sure what your question is now.  But - $rad will contain a single 
row of values here, all in an array such as 
$rad['field_name1'],$rad['field_name2'],$rad['field_name3'],  .


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



[PHP] Re: How to delete 3 months old records in my database?

2013-08-02 Thread Jim Giner

On 8/2/2013 6:58 AM, Karl-Arne Gjersøyen wrote:

Hello again, folks!
I wish to delete records in my database that is older than 3 months.

$todays_date = date('Y-m-d');
$old_records_to_delete =  ???

if($old_records_to_delete){
include(connect.php);
$sql = DELETE FROM table WHERE date = '$old_records_to_delete';
mysql_query($sql, $connect_db) or die(mysql_error());
}

Thank you very much for your help to understand also this question :)

Karl


So close!  BUT - you need to reverse your test.

where date = '$old_records_to_delete'



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



[PHP] Re: SELECT data base on a upper level SELECT

2013-08-01 Thread Jim Giner

On 7/31/2013 9:37 PM, iccsi wrote:

I have 5 SELECT for Department, Manager, supervisor, Group Leader and
Employees
I want to every SELECT list narrow down for an upper SELECT.
For example, once user select Department then all Manager, Supervisor,
Group Leader and Employee list will be narrow down by department and
same for manager and supervisor and so on.

I can use iframe or jQuery to do every level, but it needs to call
iframe or jQuery to 5 levels.
I would like to know are there any better way to handle this situation,

Your help and information is great appreciated,

Regards,


Iccsi,

How about using just one select and add variables to the where clause? 
Set the variable(s) to the values that you want to filter on.


For ex.:

your query is
$sel = 1;
$q = select Department, Manager, supervisor, Group Leader,Employees 
where $sel;


Then when the user selects a department $d:

$sel = Department = '$d';

OR if you have selected a department $d and a manager $m:

$sel = Department ='$d' and Manager='$m';

One query.  A variable 'where' clause.

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



Re: [PHP] POST action

2013-07-28 Thread Jim Giner

On 7/28/2013 1:26 PM, Larry Garfield wrote:

On 07/28/2013 12:14 PM, iccsi wrote:

form action=action.php method=post
pYour name: input type=text name=name //p
pYour age: input type=text name=age //p
pinput type=submit //p
/formIn the PHP tutorial manual, it says that we can have post
action to the form itself just like above coding.I would like to know
in the real projects, can we have action to the same PHP file, since
that we only need have one filebut not 2 files foe POST request,Your
help and information is great appreciated,regards,Iccsi,


Real projects to all kinds of things.  Which is best depends on who
you ask. :-)

I would argue that there's 3 good approaches, both of which are viable:

1) Define your form abstractly via an API, and have the API detect the
presence of POST request and then process the form after it's built.
That means you do submit back to the same URL.  (Drupal 7 and earlier do
this.)

2) Put 2 separate request handlers / controllers at the same path, one
for GET and one for POST.  So you submit back to the same URL but an
entirely different piece of code responds to it.  (This requires a good
routing system that can differentiate between GET and POST.)

3) Every form is defined as its own object somewhere with a unique ID.
All forms post to the same URL but include the form ID.  Code at that
URL looks up the form object by ID and maps the submitted data to it to
know what to do with it.

Note that in all 3 cases you're defining a form via an API of some
kind.  You are not writing form tags yourself.  Don't do that. Ever.  I
promise you that you will have a security hole or six if you do.  Use a
good form handling API for building forms.  That's what good Real
projects do.  There are a lot out there.  Most fullstack frameworks or
CMSes have one built in (I know Drupal and Code Ignighter do, although
they're quite different), and there are reasonably stand-alone
components available in both Symfony2 Components and Zend Framework.
Please don't write your own.  There are too many good ones (and even
more bad ones, of course) already out there that have been security
hardened.

--Larry Garfield
Never write your own form?  I'm guilty - oh, so guilty.  What exactly is 
a 'security hardened' form?


IN answer to OP - yes you can use a single script to handle your from 
return.  I do that too!  I start by recognizing my first time thru and 
send out a form/page.  I process the submit back from that page, doing 
something based on the label of the submit button that I detect.  I may 
then do some more processing and produce a newer version of the same 
form/page and repeat.  Or I may end it all at that point.  Depends on 
what the overall appl is doing.


And now I'll watch and see how much I'm doing wrong.

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



Re: [PHP] POST action

2013-07-28 Thread Jim Giner


On 7/28/2013 1:38 PM, Ashley Sheridan wrote:

On Sun, 2013-07-28 at 13:37 -0400, Jim Giner wrote:

On 7/28/2013 1:26 PM, Larry Garfield wrote:
 On 07/28/2013 12:14 PM, iccsi wrote:
 form action=action.php method=post
 pYour name: input type=text name=name //p
 pYour age: input type=text name=age //p
 pinput type=submit //p
 /formIn the PHP tutorial manual, it says that we can have post
 action to the form itself just like above coding.I would like to know
 in the real projects, can we have action to the same PHP file, since
 that we only need have one filebut not 2 files foe POST request,Your
 help and information is great appreciated,regards,Iccsi,

 Real projects to all kinds of things.  Which is best depends on who
 you ask. :-)

 I would argue that there's 3 good approaches, both of which are viable:

 1) Define your form abstractly via an API, and have the API detect the
 presence of POST request and then process the form after it's built.
 That means you do submit back to the same URL.  (Drupal 7 and earlier do
 this.)

 2) Put 2 separate request handlers / controllers at the same path, one
 for GET and one for POST.  So you submit back to the same URL but an
 entirely different piece of code responds to it.  (This requires a good
 routing system that can differentiate between GET and POST.)

 3) Every form is defined as its own object somewhere with a unique ID.
 All forms post to the same URL but include the form ID.  Code at that
 URL looks up the form object by ID and maps the submitted data to it to
 know what to do with it.

 Note that in all 3 cases you're defining a form via an API of some
 kind.  You are not writing form tags yourself.  Don't do that. Ever.  I
 promise you that you will have a security hole or six if you do.  Use a
 good form handling API for building forms.  That's what good Real
 projects do.  There are a lot out there.  Most fullstack frameworks or
 CMSes have one built in (I know Drupal and Code Ignighter do, although
 they're quite different), and there are reasonably stand-alone
 components available in both Symfony2 Components and Zend Framework.
 Please don't write your own.  There are too many good ones (and even
 more bad ones, of course) already out there that have been security
 hardened.

 --Larry Garfield
Never write your own form?  I'm guilty - oh, so guilty.  What exactly is
a 'security hardened' form?

IN answer to OP - yes you can use a single script to handle your from
return.  I do that too!  I start by recognizing my first time thru and
send out a form/page.  I process the submit back from that page, doing
something based on the label of the submit button that I detect.  I may
then do some more processing and produce a newer version of the same
form/page and repeat.  Or I may end it all at that point.  Depends on
what the overall appl is doing.

And now I'll watch and see how much I'm doing wrong.



I don't think there's anything inherently wrong with writing your own 
form processing code, as long as you understand what's going on. Many 
frameworks do make this a lot easier though, but sometimes I find it 
encourages you to ignore some of the details (like security) because 
you know the framework handles that stuff.


I would say code forms on your own first, as a learning experience, 
then use frameworks once you know what you're doing.


Thanks,
Ash
http://www.ashleysheridan.co.uk


I dont' know that i'll ever use a framework.  Strictly an 
ex-professional here doing my own website stuff.  As you say 'code your 
own forms first as a learning experience'.  Well, once I've coded them 
(aside: I think you mean 'process', not code) and learned how to do it 
right, why should I give up that task and pick up a framework?


Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Jim Giner
I think you should change from using 'rsort' ( a SORT function) to 
'array_reverse', a simple reverse function.

Your example of what you desire is wrong.
24-7-2013 will give you the 2013-24-7 that you want.
Here is my sample code.  Try it yourself.

?
$dag = array(24/7/2013);
echo Began with: ;var_dump( $dag);
echo br**br;
echo Try using rsortbr;
$dagparts = explode(/,$dag[0]);
echo dagparts: ;
var_dump($dagparts);
echo br**br;
rsort($dagparts);
echo sorted dagparts: ;
var_dump($dagparts);
echo br**br;
$newdag = implode(-,$dagparts);
echo newdag: ;
var_dump($newdag);
echo br**br;
echo Now use array_reversebr;
$dagparts = explode(/,$dag[0]);
echo dagparts: ;
var_dump($dagparts);
echo br**br;
$dagparts = array_reverse($dagparts);
echo REVERSED dagparts: ;
var_dump($dagparts);
echo br**br;
$newdag = implode(-,$dagparts);
echo newdag: ;
var_dump($newdag);
echo br**br;


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



Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Jim Giner

On 7/26/2013 10:10 AM, Jim Giner wrote:

I think you should change from using 'rsort' ( a SORT function) to
'array_reverse', a simple reverse function.
Your example of what you desire is wrong.
24-7-2013 will give you the 2013-24-7 that you want.


oops.
I meant to say will NOT give you the 2013-2407 that you want.


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



Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Jim Giner

On 7/26/2013 5:29 PM, Robert Cummings wrote:

On 13-07-26 04:38 PM, jomali wrote:

On Fri, Jul 26, 2013 at 1:08 PM, Robert Cummings
rob...@interjinn.comwrote:


On 13-07-26 11:42 AM, jomali wrote:


On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen
karlar...@gmail.com

wrote:


  Below is something I try that ofcourse not work because of rsosort.

Here is my code:
---
$lagret_dato = $_POST['lagret_dato'];
  foreach($lagret_dato as $dag){

  $dag = explode(/, $dag);
 rsort($dag);
  $dag = implode(-, $dag);
  var_dump($dag);

What I want is a way to rewrite contents of a variable like this:

  From 24/7/2013 to 2013-07-24

Is there a way in PHP to do this?

Thank you very much.

Karl



$conv_date = str_replace('/', '-','24/7/2013');
echo date('Y-m-d', strtotime($conv_date));
Result: 2013-07-24



It would be better if you reformatted first since this is ambiguous when
you have the following date:

 6/7/2013




Here's a completely unambiguous solution:

?php

 $old = '24/7/2013';

 $paddy = function( $bit ){ return str_pad( $bit, 2, '0',
STR_PAD_LEFT
); };
 $new = implode( '-', array_map( $paddy, array_reverse( explode(
'/',
$old ) ) ) );

 echo $new.\n;

?

Cheers,
Rob.


The original question was  about reformatting a European (Day/Month/Year)
date. Your solution does not address this problem. Mine assumes the
European date format explicitly.


Jomali,

Your solution is broken. The original poster requested the following:

  What I want is a way to rewrite contents of a variable like this:
 
From 24/7/2013 to 2013-07-24

Your solution makes use of the strtodate(). A useful strategy EXCEPT (as
you have already noted) the date follows the European formatting rules
of dd/mm/ since the 24 as the first number makes that obvious.
HOWEVER, you failed to realize the following (from the PHP online manual):

 Dates in the m/d/y or d-m-y formats are disambiguated by looking
 at the separator between the various components: if the separator
 is a slash (/), then the American m/d/y is assumed; whereas if
 the separator is a dash (-) or a dot (.), then the European d-m-y
 format is assumed.

And so, as soon as an abiguous date arises, the solution will be
incorrect because strtotime() will presume an American format due to the
appearance of the slash instead of the hyphen. It is dangerous to rely
on magical functions like strtotime() unless you completely understand
how ambiguity is resolved.

Another solution that was posted only re-ordered the elements and you
likely noticed that there is a single digit 7 in the source date and in
the response date it has been 0 padded to conform to the standard
-mm-dd date format. The other solution does not do this and so it is
also incorrect.

And so it follows, that my solution, thus far, is the only solution
posted that actually meets the requirements. Why you think my solution
does not perform is beyond me since a simple run of the code would
output the correct answer (yes I did test)-- mine also presumes the
European ordering for all input with components separated by a slash.

Cheers,
Rob.

And my solution doesn't work?

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



[PHP] Re: What wrong am I doing now?

2013-07-24 Thread Jim Giner

On 7/24/2013 8:19 AM, Karl-Arne Gjersøyen wrote:

mysql SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
+---+
| DATE_FORMAT(dato, '%e-%c-%Y') |
+---+
| 24-7-2013 |
| 23-7-2013 |
+---+
2 rows in set (0.00 sec)

mysql


// My PHP code looks like this.
// -
$sql = SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

while($rad = mysql_fetch_array($resultat)){
$dato = $rad['dato'];
var_dump($dato);

I gott NULL,NULL here and believe it is something with my PHP Source that
is wrong when using DATE_FORMAT. As you see above it work in terminal.

I hope this not is off-topic for the list. If so, I am sorry for it and
hope you can give me advice about a good MySQL list for newbie's.

Thanks again for your help!

Karl


Add a check on the query result to be sure your query actually ran.
 $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

if (!$resultat)
{
   echo Query failed to run - .mysql_error();
   exit();
}
 while($rad = mysql_fetch_array($resultat)){

...


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



Re: [PHP] Re: What wrong am I doing now?

2013-07-24 Thread Jim Giner



Jim,

He already has that...

- Matijn


oops

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



Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Jim Giner
Your original code snippet had some errors.  It really couldn't have 
been what you wanted to do.


Example:

You have a named field of 'number_of_items' and then you try to retreive 
$_POST['number_of_itemsi'].  That won't work.


Then you have a var called $number_of_items which we don't see defined, 
and you are assigning each to $itemi but then you use $item in your 
query.  Very Confusing!!


Perhaps if you clean up the errors you might see better results.

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



Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Jim Lucas

On 07/22/2013 04:39 AM, Karl-Arne Gjersøyen wrote:




Might I suggest that you place your include for ../../tilkobling.php at 
the very top of this page?  It would save you from possibly including it 
twice.



// The acutual source code is below:
// ==
if(!empty($_POST['antall_kolli'])){
 include('../../tilkobling.php');   ---  remove this line

 foreach($antall_kolli as $kolli){
 echo $kollibr;

 //echo $kolli. br;
 $sql = UPDATE transportdokument SET antall_kolli_stk =
'$kolli' WHERE dato = '$dagens_dato' AND signatur = '$brukernavn';
 mysql_query($sql,$tilkobling) or die(mysql_error());
  }


Your WHERE conditions are the same, that is why it is updating a single 
row.  Where are $dagens_dato and $brukernavn being defined?  As others 
have stated, you need to include a unique identifier in your query so 
your query updates a specific record.



}

// THE PHP/HTML Form below:
include('../../tilkobling.php');   ---  move this to the top of the 
script

 $sql = SELECT * FROM transportdokument WHERE dato = '$dagens_dato' AND
signatur = '$brukernavn';
 $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
 while($rad = mysql_fetch_array($resultat, MYSQL_ASSOC)){
 $valgt_lager = $rad['valgt_lager'];
 $un_nr = $rad['un_nr'];
 $sprengstofftype = $rad['sprengstofftype'];
 $varenavn = $rad['varenavn'];
 $varenr = $rad['varenr'];
 $antall_kolli = $rad['antall_kolli_stk'];
 $adr_vekt_kg = $rad['adr_vekt_kg'];
 $varenavn = $rad['varenavn'];
 $emb = $rad['emb'];
?
tr
 td align=left valign=top?php echo $un_nr; ?/td
 td align=left valign=topstrongSprengstoff/strong,?php echo
$sprengstofftype; ?/td
 td align=left valign=top?php echo $varenavn; ?/td
 td align=left valign=topstrong1.1D/strong/td
 td align=left valign=topnbsp;/td
 td align=left valign=top?php echo $emb; ?/td
 td align=left valign=top
 input type=hidden name=varenr[] value=?php echo $varenr; ?
 input type=number name=antall_kolli[] size=6 value=?php echo
$antall_kolli; ? required=required
 /td
 td align=left valign=topinput type=text name=exan_kg_ut[]
size=6 value=?php echo $adr_vekt_kg; ? required=required/td
/tr
?php
$total_mengde_kg_adr += $rad['adr_vekt_kg'];
$total_antall_kolli += $rad['antall_kolli_stk'];
 }

?



--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



Re: [PHP] query order issue

2013-07-21 Thread Jim Lucas

On 7/20/2013 9:21 AM, dealTek wrote:

Hi all,


I have a page that starts with several mysql sql query searches and displays 
data below...

then I added a form (with hidden line do-update value UPDATE) on the same 
page with action to same page...


then above other sql queries - I put...

if ((isset($_POST[do-update]))  ($_POST[do-update] == update)) {

---do update query---

echo 'meta http-equiv=refresh content=0; url=gohere.php';


By your description of what you think should be happening in the line 
above, my suggestion to would be to look at the header() function in 
PHP.  It can send a header to the browser that will cause the browser to 
stop loading the current page and redirect it to another URL.


http://php.net/header

if ( ... ) {

  Do some work...

  header('Location: someotherpage.php');
  exit();

}

You want to make sure you always call exit(); after issuing a call to 
header('Location: ...');





}

but it shows error that happens AFTER the meta http-equiv=refresh has happened

Catchable fatal error: xxx on line 226

BTW - the meta http-equiv=refresh does work but the error flashes 1st for a 
second...

Q: I would have thought that it would not go past the line - meta 
http-equiv=refresh - but it does any insight on this

--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]





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



[PHP] Re: query order issue

2013-07-20 Thread Jim Giner

On 7/20/2013 12:21 PM, dealTek wrote:

Hi all,


I have a page that starts with several mysql sql query searches and displays 
data below...

then I added a form (with hidden line do-update value UPDATE) on the same 
page with action to same page...


then above other sql queries - I put...

if ((isset($_POST[do-update]))  ($_POST[do-update] == update)) {

---do update query---

echo 'meta http-equiv=refresh content=0; url=gohere.php';

}

but it shows error that happens AFTER the meta http-equiv=refresh has happened


Catchable fatal error: xxx on line 226



BTW - the meta http-equiv=refresh does work but the error flashes 1st for a 
second...

Q: I would have thought that it would not go past the line - meta 
http-equiv=refresh - but it does any insight on this






--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


YOu are checking for a value of 'update' but you stated that the value 
clause was 'UPDATE'



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



[PHP] Re: query order issue

2013-07-20 Thread Jim Giner

On 7/20/2013 12:21 PM, dealTek wrote:

Hi all,


I have a page that starts with several mysql sql query searches and displays 
data below...

then I added a form (with hidden line do-update value UPDATE) on the same 
page with action to same page...


then above other sql queries - I put...

if ((isset($_POST[do-update]))  ($_POST[do-update] == update)) {

---do update query---

echo 'meta http-equiv=refresh content=0; url=gohere.php';

}

but it shows error that happens AFTER the meta http-equiv=refresh has happened


Catchable fatal error: xxx on line 226



BTW - the meta http-equiv=refresh does work but the error flashes 1st for a 
second...

Q: I would have thought that it would not go past the line - meta 
http-equiv=refresh - but it does any insight on this






--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


YOu are checking for a value of 'update' but you stated that the value 
clause was 'UPDATE'



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



[PHP] Re: Premature end of script

2013-07-17 Thread Jim Giner

On 7/17/2013 11:22 AM, R B wrote:

Hello,

5 years ago, y developed a php system and was working fine. But 20 days
ago, when y try to access to some pages (not all the pages), in the log
appears this message and the page is not displayed:

== /usr/local/apache/logs/error_log ==
[Wed Jul 3 02:36:58 2013] [error] [client 10.30.6.161] Premature end of
script
headers: /home/capitale/public_html/miembros/myscript.php

Can you help me please with this error?

Thank you.

Since you state that you haven't made any changes to the system (in 
general), I'm going to guess that you modified an 'included' file and it 
has an error in it, such as an unmatched curly brace.  As Dan said, turn 
on all error checking and reporting and see what message you get.


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



[PHP] Re: Error checking ON

2013-07-17 Thread Jim Giner

On 7/17/2013 11:49 AM, Tedd Sperling wrote:

Hi gang:

Considering:

On Jul 17, 2013, at 11:41 AM, Jim Giner jim.gi...@albanyhandball.com wrote:


Since you state that you haven't made any changes to the system (in general), 
I'm going to guess that you modified an 'included' file and it has an error in 
it, such as an unmatched curly brace.  As Dan said, turn on all error checking 
and reporting and see what message you get.


This is what I do for error checking:

ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'On');
ini_set('log_errors', 'On');
ini_set('error_log', 'error_log');  

Is this:

1. Sufficient?

2. An overkill?

3. OK?

4. OR, better served with this (and provide an example).

Cheers,

tedd

_
t...@sperling.com
http://sperling.com

When I'm in development mode, I leave out the last two settings and take 
my error messages from the screen.  Simpler, quicker.  I use an include 
file that is based upon a switch.  When it's on, I set my devl settings, 
when not, I set my prod settings.


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



Re: [PHP] Error checking ON

2013-07-17 Thread Jim Lucas

On 07/17/2013 09:28 AM, Tedd Sperling wrote:

On Jul 17, 2013, at 11:55 AM, Daniel Brown danbr...@php.net wrote:

On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote:

This is what I do for error checking:

ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'On');
ini_set('log_errors', 'On');
ini_set('error_log', 'error_log');

Is this:

1. Sufficient?

2. An overkill?

3. OK?

4. OR, better served with this (and provide an example).


That's standard practice.  Sometimes, though, it isn't enough, and
we find ourselves using Derick's Xdebug, mod_top, or performing an
strace on either the execution or attached to a process.  For nearly
all cases, though, that's sufficient without being overkill (except
for production cases).



Daniel:

Thanks -- I always wondered about that.

Cheers,

tedd

PS: Of course, turned OFF for production. :-)

_
t...@sperling.com
http://sperling.com



But...  It won't work in all cases.  I find it best to set these 
settings in the server itself.  Not in code.  Sometimes, if you have 
broken code that cannot be parsed, your commands listed above will never 
be executed.  Therefor they will never do any good.


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



[PHP] syntax question

2013-07-10 Thread Jim Giner
Can someone tell me what this syntax is?  I looked around but don't see 
any mention of it.


while(condition) : (statement);




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



Re: [PHP] syntax question

2013-07-10 Thread Jim Giner

Thanks!

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



[PHP] Re: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Jim Giner

On 7/10/2013 8:30 AM, Karl-Arne Gjersøyen wrote:

I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a truck document but
that's it and here I need some advice.

I like to register new products and the amount in number (for example 4)
and weight in kg.

I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10


Show us your code?

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



[PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Jim Giner

On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:

Sorry, the first mail in this subject run out for me. This is an updated
one.



I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a truck document but
that's it and here I need some advice.

I like to register new products and the amount in number (for example 4)
and weight in kg.

I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg

Then I like to 4+10 = 14
and 200+10 = 210.

It shall looks like this:
==
Dynamite |  4  | 200
Lunt | 10 |  10
--
TOTAL| 14 | 210

It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.

Thanks for your time and effort to learn me programming.

Karl





Ahhh.

So - you should run a query that selects the products and information 
that you want.  Then you start by creating an html table header and then 
loop through your query results and echo a table row for each result row.


// start the table
echo table border=1;
echo trthProduct/ththAmount/th/tr;

// loop thru each item found
while ($results = $qrslts-fetch(PDO::FETCH_ASSOC))
{
   echo 
trtd.$results['product_name']./tdtd.$results['product_amt']./td/tr;

}

// finish the table html
echo /table;




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



Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get incorrect direction...

2013-07-10 Thread Jim Giner

On 7/10/2013 9:07 AM, Karl-Arne Gjersøyen wrote:

2013/7/10 Jim Giner jim.gi...@albanyhandball.com


On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:


Sorry, the first mail in this subject run out for me. This is an updated
one.



I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a truck document but
that's it and here I need some advice.

I like to register new products and the amount in number (for example 4)
and weight in kg.

I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg

Then I like to 4+10 = 14
and 200+10 = 210.

It shall looks like this:
==**
Dynamite |  4  | 200
Lunt | 10 |  10
--**--**--
TOTAL| 14 | 210

It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.

Thanks for your time and effort to learn me programming.

Karl




  Ahhh.


So - you should run a query that selects the products and information that
you want.  Then you start by creating an html table header and then loop
through your query results and echo a table row for each result row.

// start the table
echo table border=1;
echo trthProduct/thth**Amount/th/tr;

// loop thru each item found
while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC))
{
echo trtd.$results['product_**name']./tdtd.$results['**
product_amt']./td/tr;
}

// finish the table html
echo /table;



Yes that part is OK. I do have problem to add total weight and package at
bottom of the table like this:

Product_one   40kg
Product_two   60kg
-
Total: 100kg
===

Because sometimes it is only a few products and other times many products.
I then need to summing them at bottom. One timer only 3 rows, other times
20 rows. The program need a way to add every singel product and see if it's
a few or many,

Karl

So - as you loop thru the results, accumulate your totals and then at 
the end before you close the table generate one last row with those 
amounts in it.  Simple!


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



[PHP] Re: Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

On 7/10/2013 1:21 PM, Ajay Garg wrote:

Hi all.

I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.

Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
finally (that is, after being copied from the temporary location,
via move_uploaded_file)

Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous Hello World examples
available :)



Now, I am facing the following use-case ::

1)
User 1 starts uploading a large file, say big_file.avi.

2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name big_file.avi.


In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?

( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).


Any way the issue may be solved?

I will be grateful for any pointers :)



Regards,
Ajay

The problem is not of PHP's making.  It is something that you have to 
program around.  Is the user determining the filename to be used?  If 
so, then you need to check for that name before doing you move.  If 
it's a duple, then create a temporary name in your final place, hide it 
in the user's page and send it back to him with a message to change his 
name.


If the user is NOT determining the name, then your normal process would 
be to pick an unused name I presume and send That back to the user 
anyway, so problem never happens.


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



Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

On 7/10/2013 2:15 PM, Ajay Garg wrote:

Thanks Jim and Matijn for the quick replies.
I will try to have a workaround.



On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote:





On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote:


Hi all.

I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.

Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
finally (that is, after being copied from the temporary location,
via move_uploaded_file)

Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous Hello World examples
available :)



Now, I am facing the following use-case ::

1)
User 1 starts uploading a large file, say big_file.avi.

2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name big_file.avi.


In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?

( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).


Any way the issue may be solved?

I will be grateful for any pointers :)



Regards,
Ajay




Hi,

This is not possible with PHP, PHP will not know about the file until the
upload is completed. You can use HTML5 or flash(not recommended) for an
alternative way of uploading, and then you can check the file name in
advance.

- Matijn





As Matijn said, you don't know the name until your php processes the 
file that has been uploaded alreaday.  But my solution will work for you 
- you just have to save it under the temp name until the user responds 
to your message and request for a new title.  You may have to run a 
periodic script to clean up any files with your temp names that the user 
declined to re-name for you.  I'd make up a temp name with some special 
prefix so that you can find and delete them.


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



Re: [PHP] Query regarding temporarily-uploaded files

2013-07-10 Thread Jim Giner

On 7/10/2013 3:37 PM, Ajay Garg wrote:

Thanks Jim and Anthony.

Jim,
You are right, your solution is doable.

But one thing I am a little skeptical about, is what would be the
percentage of the people willing to suggest a new name immediately,
versus the percentage of people who would like to cancel the current
upload, and come back later after walking and coming up with a new name.

Anyhow, let me sleep over it :)


Anthony,
your solution is really a special case of Jim's solution :)



Thanks guys for the quick replies; I am obliged, really.



On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski ant92...@gmail.comwrote:


Is there anything that would prevent you from somehow uniquely knowing who
the user is uploading the file. For example you mentioned client'.  If
you know
who the client is you can append that to the filename or prepend it, for
the
destination string (second parameter to the function call).  That way it
is unique
to that client.

-Anthony


On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg ajaygargn...@gmail.com wrote:


Thanks Jim and Matijn for the quick replies.
I will try to have a workaround.



On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote:





On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com

wrote:



Hi all.

I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.

Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
finally (that is, after being copied from the temporary location,
via move_uploaded_file)

Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous Hello World examples
available :)



Now, I am facing the following use-case ::

1)
User 1 starts uploading a large file, say big_file.avi.

2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name big_file.avi.


In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?

( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).


Any way the issue may be solved?

I will be grateful for any pointers :)



Regards,
Ajay




Hi,

This is not possible with PHP, PHP will not know about the file until

the

upload is completed. You can use HTML5 or flash(not recommended) for an
alternative way of uploading, and then you can check the file name in
advance.

- Matijn





--
Regards,
Ajay





--
Anthony W.
ant92...@gmail.com





That's why I said you would have to do a cleanup periodically.  People 
who walk away could lose their session perhaps and the page wiht the 
hidden temp name buried in it, so they would have to do their upload 
from the beginning again.  If they didn't lose their session and 
therefore that screen, then they could still respond and things would 
flow smoothly.


so - who is scanning these files for viruses and what not?  It's one 
thing to host them but if you are going to let users view them on their 
clients you could be spreading things.


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



Re: [PHP] strlen ?

2013-07-06 Thread Jim Giner

On 7/6/2013 2:59 AM, Lester Caine wrote:

Jim Giner wrote:

And the answer is - yes, there is a LF char at the end of my data in
my whole
table.

Now the question is - how the heck did I put that in there?  Certainly
not
intentionally.  The data is captured from a d/e screen I wrote and it
simply
grabs the post value and inserts a new record with that value along
with some
other values.  And I don't see anything concatenating a LF to my string.


The obvious question that comes to mind is 'What OS'? Having seen this
sort of niggle many times I tend to find it relates to something working
'cross-os' a bit like windows ignoring case in file name and linux then
complaining it can't find a file.

It's probably worth checking the sting length back through your code
just to confirm what added it?

The best I can figure is that I did a preload of many of the names from 
a csv file.  Apparently when I do that it stores the LF at the end of 
the csv line.  Have to remember that the next time.


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



[PHP] strlen ?

2013-07-05 Thread Jim Giner
Trying to manage line breaks in some output I'm generating and using 
strlen to measure the lengths of the strings I'm printing.  Discovered 
something strange (to me!) in that strlen is returning +1 more than it 
should.


The strings are from a query of my database - simple name fields.  But 
everyone of them is coming back with a length that is one more than I see.


Ex.

Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.

I've looked at my data and counted the chars - there is no extra space 
at the beginning or end in my table.


Anyone have an explanation?

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



Re: [PHP] strlen ?

2013-07-05 Thread Jim Giner

On 7/5/2013 1:32 PM, shiplu wrote:

On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.



Doesn't work for me.

php  var_dump(Mike Hall, strlen(Mike Hall));
string(9) Mike Hall
int(9)

Try trimming it first and then apply strlen.


Why would I need to trim something that I can already see doesn't have 
any trailing or leading characters?


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



Re: [PHP] strlen ?

2013-07-05 Thread Jim Giner

On 7/5/2013 2:42 PM, Matijn Woudt wrote:

On Fri, Jul 5, 2013 at 8:39 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


  I checked them in the db manually.  Clicked on the name, selected it, no
extra space highlighted.  Cursored through the length of the value - no
extra movements.



That does still not guarantee there are no extra characters. Some
characters are just not visible (NUL, CR, LF, ..)




On 7/5/2013 2:36 PM, Matijn Woudt wrote:




On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


On 7/5/2013 1:32 PM, shiplu wrote:


On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.com

wrote:


  Mike Hall  comes back as 10, not 9

F.B. comes back as 5, not 4.



Doesn't work for me.

php  var_dump(Mike Hall, strlen(Mike Hall));
string(9) Mike Hall
int(9)

Try trimming it first and then apply strlen.


  Why would I need to trim something that I can already see doesn't have

any trailing or leading characters?



  Because there are characters you can't see?





And the answer is - yes, there is a LF char at the end of my data in my 
whole table.


Now the question is - how the heck did I put that in there?  Certainly 
not intentionally.  The data is captured from a d/e screen I wrote and 
it simply grabs the post value and inserts a new record with that value 
along with some other values.  And I don't see anything concatenating a 
LF to my string.


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



Re: [PHP] strlen ?

2013-07-05 Thread Jim Giner

On 7/5/2013 3:02 PM, Stephen wrote:

On 13-07-05 02:50 PM, Jim Giner wrote:


Now the question is - how the heck did I put that in there? Certainly
not intentionally.  The data is captured from a d/e screen I wrote and
it simply grabs the post value and inserts a new record with that
value along with some other values.  And I don't see anything
concatenating a LF to my string.


Is this a browser being used for input? Never assume what a browser will
do.

It is good practice to validate and condition data before inserting into
a database.

Consider trimming the data before doing the INSERT.

I do validate my data by quoting it but I never expected to have to do a 
trim to remove a LF.  Especially on an iphone for input, since it's not 
easy to enter a LF.


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



[PHP] Re: Web dev, DB and proper db design.

2013-07-04 Thread Jim Giner

On 7/4/2013 6:42 AM, Richard Quadling wrote:

Hi.

I've just had a conversation regarding DB, foreign keys and their benefits.

I was told I've never worked on a web application where foreign keys were
used in the database.

As someone who has spent 25 years working on accounting/epos systems on MS
SQL Server (yep, windows) and now in a web environment and hearing the
above, ... well, ... slightly concerned.

So, in the biggest broadest terms, what do you lot do?

DBs with no foreign keys (constrainted or not).
ORM builders with manual definition of relationships between the tables.
Inline SQL where you have to just remember all the relationships.
Views for simple lookups? How do you handle updatable views (does mysql
support them?)
etc.

Is there a difference in those in 'startups' and web only situations, or
those doing more traditional development (split that as you like - I'm just
trying to get an understanding and not go off on one!).

No definitive answers, and I hope I get some wide experiences here.

Thanks for looking.

Richard.

Im going to guess that your source of such drivel never learned about 
such things.  Probably thinks that a 'key' has to be defined as such in 
the db, whereas we know what a FK really is.


Don't worry.  As a former big iron guy and then a c/s guy and now a 
(new) web guy, things haven't changed.


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



Re: [PHP] Reseting the auto-increment number in a MySQL database.

2013-06-26 Thread Jim Giner

On 6/26/2013 1:30 PM, Tedd Sperling wrote:

On Jun 26, 2013, at 1:13 PM, Stuart Dallas stu...@3ft9.com wrote:


On Wednesday, 26 June 2013 at 18:07, Tedd Sperling wrote:

Hi gang:

I have a client where their next auto-increment number just jumped from 2300 to 
10 for reasons not understood. They want it set back.

Options such as dropping the primary key and rebuilding the index is NOT 
possible -- this is a relational table thing.

So, is there a way (programmatically) to set the next number in an 
auto-increment?

Something like:

alter table abc auto_increment = 2301;



ALTER TABLE tbl AUTO_INCREMENT = 2301;

-Stuart


Thanks -- I needed confirmation on that.

It is something that i don't want to do.

Cheers,

tedd

_
t...@sperling.com
http://sperling.com

But more importantly - don't you need to figure out why it happened?? 
As well as correcting any inserts with the bogus id?


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



Re: [PHP] Reseting the auto-increment number in a MySQL database.

2013-06-26 Thread Jim Lucas

On 06/26/2013 10:07 AM, Tedd Sperling wrote:

Hi gang:

I have a client where their next auto-increment number just jumped from 2300 to 
10 for reasons not understood. They want it set back.

Options such as dropping the primary key and rebuilding the index is NOT 
possible -- this is a relational table thing.

So, is there a way (programmatically) to set the next number in an 
auto-increment?

Something like:

alter table abc auto_increment = 2301;

Any ideas of why this happened?

Cheers,


tedd

_
t...@sperling.com
http://sperling.com





If mysql logging is turned on, you might be able to rummage through the 
logs and see what happened and when it happened.


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



[PHP] Re: Problem with variables

2013-06-25 Thread Jim Giner

On 6/25/2013 5:46 PM, Fernando A wrote:

Hello,

I am working with php and codeigniter, but I have not yet experienced.
I need create a variable that is available throughout  system.
This variable contains the number of company and can change.
as I can handle this?

Thank you, very much!

Ferd


One way would be to create a file like this:

?
// company_info.php
$_SESSION['company_name'] = My Company;
$_SESSION['company_addr1'] = 1 Main St.;
etc.
etc.
etc.

Then - in your startup script (or in every script), use an include 
statement:


?php
session_start();
include($path_to_includes./company_info.php);


Now you will have those SESSION vars available for the entire session, 
basically until you close your browser.


You can also use the php.ini auto-prepend setting, which automatically 
does this for you, altho the vars would not be session vars, since the 
prepend-ed file happens before your script issues the session_start (I 
think).


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



[PHP] Re: Newbie form question

2013-06-21 Thread Jim Giner

On 6/21/2013 10:09 AM, Karl-Arne Gjersøyen wrote:

Hello.

I have an application that generete HTML5 form in PHP.
The form is written in a while loop and therefore the form field has exact
same name for every row in the loop.
And that is the problem. Because when my PHP document shall handle
submitted data it only take the very last row in the while loop and show
the result of it.

if(isset($_POST['update_explosive'])){
 $item_serial_number = $_POST['item_serial_number'];
 $update_item_in_store = $_POST['update_item_in_store'];

 if($item_serial_number === ETX1.22X1000){
 echo h1$update_item_in_store/h1;
 }
 if($item_serial_number === ETX1.17X460){
 echo h1$update_item_in_store/h1;
 }
 }

I think the solution will be to create different and unike fieldname
dymamic. For example I tried to write input type=text name=?php echo
$item_serial_number; ? value=?php echo $item_serial_number; ? in
the HTML5/PHP form.

But the problem is that periode . not is allowed as $variable_name.
I then try to write it this way:

if(isset($_POST['update_explosive'])){
 $item_serial_number = $_POST['ETX1.22X1000'];
 $update_item_in_store = $_POST['update_item_in_store'];

 if($item_serial_number === ETX1.22X1000){
 echo h1$update_item_in_store/h1;
 }
 if($item_serial_number === ETX1.17X460){
 echo h1$update_item_in_store/h1;
 }
 }

But this last part did not make any sense to me. I recive no output when
tried that one.

One problem is that I have between 2 and 25 items with different serial
number. Sometimes only 5 of this shall be updated and other times all 25
items. I like to do this through one simple form and not for one time for
every single item. (I know how to do when select one by one and update
them, but that is a long and hard way for people using my application. A
better solution is to just use one form and view all items there. Then just
write the amount of item in input type=number
name=update_item_in_store size=6 field.)

If you have time to help me *understand* this newbie question by explain or
give me an example or post a link to a tutorial that can help me though, I
am very thankful.

Karl


Make your names on your input tags like this:
if you currently have
input type='text' name='field1'
then change it to this:
input type='text' name='field1[]'

This will give you an array of in your POST/GET array.



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



[PHP] basic authentication usage

2013-06-10 Thread Jim Giner
Trying to learn how this works for a simple security need I have. 
Nothing serious, hence this experiment.


My code:
if (!isset($_SERVER['PHP_AUTH_USER']))
{
   header('WWW-Authenticate: Basic realm=My Realm');
   header('HTTP/1.0 401 Unauthorized');
   echo 'h3You have chosen not to signinbrbr';
   echo Click a href='/index.php'here/a to go back to the menu;
   unset($_SERVER['PHP_AUTH_USER']);
   unset($_SERVER['PHP_AUTH_PW']);
   unset($_ENV['PHP_AUTH_USER']);
   unset($_ENV['PHP_AUTH_PW']);
   exit;
}
else
{
   echo checking credsbr;
   if ($_SERVER['PHP_AUTH_USER']  validuser)
   {
  unset($_SERVER['PHP_AUTH_USER']);
  unset($_SERVER['PHP_AUTH_PW']);
  unset($_ENV['PHP_AUTH_USER']);
  unset($_ENV['PHP_AUTH_PW']);
  echo 'h3You have entered invalid information.brbr';
  echo Click a href='/index.php'here/a to go back to the menu;
  exit();
   }
}
(if we get here we have signed on)
(continue on with script)

***
My problem is trying to remove the invalid credentials (unsets) so that 
when the user attempts to access the page again, the signin dialog gets 
displayed.  On my second attempt I always get the invalid path and 
never get a chance to re-enter the credentials.


What am I missing (besides it's a lousy security solution)?
Can one NOT unset a SERVER variable?  How does one get around that in 
this case if so?



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



Re: [PHP] basic authentication usage

2013-06-10 Thread Jim Giner

On 6/10/2013 4:33 PM, Julian Wanke wrote:

I think that the problem here is, that the unset of the
$_SERVER[PHP_AUTH_USER] variable is not affecting the client's browser.
If you've got a directory protection, the browser needs a restart to
show the login dialog before.
I may be wrong because I'm using forms normally but the Authentification
cannot be reset so easily...



No - I think you misunderstood.  I am NOT using directory protection, 
hence my attempt at using this method.





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



Re: [PHP] Re: limit access to php page

2013-05-30 Thread Jim Giner

On 5/29/2013 9:38 PM, tamouse mailing lists wrote:



Okay, first off, your application *has* to have some entry point that
*is* accessible to a browser; otherwise nothing will find it.



Once again - I was wrong in my suggestion as Ashley has pointed out so 
correctly.  Had to test it out this morning only to discover that I had 
never done quite that kind of Header redirect before.


So - the include method still works, as would the single script 
'controller' method.  Within a php script any file is accessible (within 
your domain at least) and may therefore be included and executed.  On 
the other hand, if you must have the target script in your 
web-accessible tree, simply establish some kind of security handler and 
add logic to your page(s) to check permissions before displaying 
anything.  This handler could be based upon session vars, cookies, db 
entries (my pref).  Once established it can be a universal addition to 
any and all of your appls.


My personal method is to create a db table containing an appl name, page 
name, and a non-unique security level (I use an integer).  Then have an 
admin screen for creating userids for an appl with multiple recs each 
containing a security level for that user for that appl. Then have a 
signon method that validates credentials and builds a session array 
containing all the user's security levels.  In every page that I want 
secured, I call a function with that script's internal pagename and appl 
name and confirm that the page's sec level is contained in the user's 
session array.  I also have a master level (99) that if present gives 
global access for myself as administrator.  There's a bit more to it, 
but that's my security method.




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



Re: [PHP] Re: limit access to php page

2013-05-30 Thread Jim Giner

On 5/30/2013 10:22 AM, tamouse mailing lists wrote:


So - the include method still works, as would the single script

'controller' method.  Within a php script any file is accessible (within
your domain at least) and may therefore be included and execute.

I want to throw in a caveat here, and that is the open_basedir directive,
wbicb limits where you can include files from.

Once again - an additional truth provided.  In my case, upon checking I 
see that setting was provided by my hoster and was set to null, so I was 
never aware of a possible restriction.


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



[PHP] Re: Webpage Persistence Load balancing

2013-05-29 Thread Jim Giner

On 5/29/2013 8:03 AM, Al wrote:

I'm having a webpage Persistence problem, it is intermittent.  I suspect
it is caused by load-balancing.

Specifically:

Users are connected to a webpage form to complete.  Generally,
everything is OK if they take a minute or even more to complete the
form. However, sometimes they report to me, and I've seen it myself, the
connection has been dropped by the server in a short time.  They enter
the data and Submit it to the server, and the page just reloads and
their data is lost.

I have the PHP ignore_user_abort(true); etc.

Is there anything I can do to fix this or is it a server issue that you
must fix?

Thanks, Al.

I'm not familiar with this kind of problem but I'm curious.

What exactly do you imply by your statement Users are connected to...? 
 From my perspective, web apps are not connected to clients while the 
user is making input.  Not like the old days of CICS screens, etc.  So, 
as the other responder asked, are you handling the input from the user 
with a new script that is not properly handling the incoming data from 
the first screen?  Persistance has never been an issue for me - I rely 
on Sessions to provide me any data I need, along with the POST/GET array 
contents for continuity, so I've never run into a 'persistence' issue. 
I suppose that a session can time out after a set amount of time, but 
certainly not within a few (5-10?) minutes.


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



Re: [PHP] REQUEST

2013-05-29 Thread Jim Giner

On 5/29/2013 12:51 PM, Stuart Dallas wrote:

Please find your caps-lock key and turn it off!

Also, please include the list when replying, or expect an invoice for my 
consulting services.

On 29 May 2013, at 17:36, Last Hacker Always onpoint lasthack...@gmail.com 
wrote:


A SIMPLE MACHINE FUNCTION, IS A FORUM SITE SCRIPT FROM THE SIMPLE MACHINE 
COMPANY BUT UNLIKE OTHER SCRIPTS IT HAS A DIFFERENT TYPE OF SCRIPTING.


If you're having issues with forum software supplied by a company, please 
contact that company.


AM STILL LEARNING PHP THOUGH BUT ASK ME A QUESTION SO I CAN PROVE MYSELF WORDY. 
COZ YOU SEEM TO SEE ME NOT WORDY


At a rough guess you mean worthy, not wordy. Worthy of what? You have nothing 
to prove to me other than the ability to make sense and ask a question that can 
be answered without four tonnes of interpretation.

-Stuart

Frankly I am a little reluctant to respond to someone who names himself 
hacker.  Makes me worry about what they think they are doing.  If the 
person hasn't learned enough php yet to be dangerous, why would I want 
to help him?


I love the responses so far.  Especially the one about how to ask a 
question.


As for our would-be hacker -

Try dealing with people you don't know with some respect.  Afterall - 
you are asking for help and you don't know any of us.  We're not your 
dudes/guyz/bros or anything like that.  Also - judging by your email 
address and your choice of conversational style, I'm assuming that your 
native language is (some form of) English.  In that case, TRY LEARNING 
HOW TO SPELL IT.  (I'm done shouting now.)


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



Re: [PHP] REQUEST

2013-05-29 Thread Jim Giner
And after all I said - a few minutes of searching tells me that the SMF 
forum software (according to the simplemachines.org site itself) is 
written in a very familiar language - PHP.  WITH a very familiar (to me) 
MySQL DB behind it.


So apparently our erstwhile hacker can't yet recognize PHP script when 
he sees it.  :)


Note to hacker:  Getting some free software doesn't mean the work to 
implement it is free also.


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



[PHP] Re: include() Error

2013-05-29 Thread Jim Giner

On 5/29/2013 1:39 PM, Ron Piggott wrote:


Good morning all:

I have recently purchased a computer and am using it as a dedicated server.  A 
friend helped me install PHP and configure.  I am saying this because I wonder 
if using a newer version of PHP (compared to my commercial web host) may be the 
reasoning behind the error I am receiving.

I created a function to generate a form submission key.
- This created hidden variable for forms
- This is also session variable

With this function I have an ‘ include ‘ for the file containing the mySQL 
database, username and password.  I know this file is being accessed because I 
added:

===
echo $mySQL_user;
===

following the login credentials.

But when I remove this line from mySQL_user_login.inc.php and place within the 
function on the line following the include the echo” returns nothing.

===
include(mySQL_user_login.inc.php);

echo $mySQL_user;
===

Can any of you tell me why this is happening?

Ron Piggott



www.TheVerseOfTheDay.info


#1 - it's not an include error.  It's a programmer error

#2 - that said - why would you want to do this?  The release of 
usernames/passwords is a dangerous practice - even in development.  If 
all you want to do is verify that you passed thru this bit of code, echo 
some less sensitive message, such as Connected successfully. Or even 
better have the connect function return true or false and check the return.


#3 - global
#4 - global
and #5 global.  Anytime you want to use a var withing a function include 
it in a global statement.


I always forget too.  But I'm getting pretty good at remembering how to 
resolve it.


PS - do you store your .inc file with this sensitive info on your server 
outside of the web-accessible path?  I hope so.


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



Re: [PHP] REQUEST

2013-05-29 Thread Jim Giner

On 5/29/2013 5:45 PM, Tedd Sperling wrote:


PS: I think it probably best not to rise to the bait from people who forgot to 
turn off their cap's key.



You call it bait?  I call it stupidity.  Once no, more than once YES.


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



Re: [PHP] REQUEST

2013-05-29 Thread Jim Giner


On 5/29/2013 5:53 PM, Matijn Woudt wrote:



I'm surprised he didn't call himself la5T hax0R alwayZ 0nP01nT  :)
He apparently can't find the caps key - how would he ever type that 
string correctly on a consistent basis?




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



[PHP] Re: limit access to php page

2013-05-29 Thread Jim Giner

On 5/29/2013 7:11 PM, Tim Dunphy wrote:

Hello list,

  I've created an authentication page (index.php) that logs into an LDAP
server, then points you to a second page that some folks are intended to
use to request apache redirects from the sysadmin group (redirect.php).

Everything works great so far, except if you pop the full URL of
redirect.php into your browser you can hit the page regardless of the login
process on index.php.

How can I limit redirect.php so that it can only be reached once you login
via the index page?

Thank you!
Tim

I would simply place my redirect.php script outside of the 
web-accessible tree.  The user can never type that uri into his browser 
and have it work.


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



Re: [PHP] Re: limit access to php page

2013-05-29 Thread Jim Giner

On 5/29/2013 9:20 PM, Glob Design Info wrote:

On 5/29/13 6:14 PM, Jim Giner wrote:

On 5/29/2013 7:11 PM, Tim Dunphy wrote:

Hello list,

  I've created an authentication page (index.php) that logs into an LDAP
server, then points you to a second page that some folks are intended to
use to request apache redirects from the sysadmin group (redirect.php).

Everything works great so far, except if you pop the full URL of
redirect.php into your browser you can hit the page regardless of the
login
process on index.php.

How can I limit redirect.php so that it can only be reached once you
login
via the index page?

Thank you!
Tim


I would simply place my redirect.php script outside of the
web-accessible tree.  The user can never type that uri into his browser
and have it work.


I always see this answer a lot but never any sample code of how to
include that file using require_once() or include_once().

It would be nice to know the exact syntax of inclusion of such files.

Say, for example if I put the login/redirect .php file 3-4 levels up
from my webroot.

-d
simply a require statement pointing to the script.  PHP can load 
anything, http can only see the web tree.


I personally have a std. set of code in my scripts that always creates a 
var that points to my document root (web root) and another that points 
to my php folder which is outside of the web root.


As for the location - it need be only one level above or at a level 
parallel but outside of the web root.  My hoster actually sets up their 
accounts with a 'php' folder at the same level as the public_html (web 
root) folder.


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



Re: [PHP] Re: Can javascript or php help with this

2013-05-26 Thread Jim Giner

On 5/25/2013 9:11 PM, dealTek wrote:


On May 25, 2013, at 4:30 PM, Jim Giner jim.gi...@albanyhandball.com wrote:




So - create another field on your form.  Add an onclick event to your submit 
button.  Have it run a js function that takes the two fields and places them 
into the new field.

function combineFields()
{
  var mm = document.getElementById(monthfld).value;
  var yy = document.getElementById('yearfld).value;
  document.getElementByID(mmyy).value = +mm+yy;
  return true;
}

Might have to play with this syntax to avoid the values being arithmetically 
added instead of concatenated, but this is one way.

And of course - you could try posting on a js site instead of a php one.




Thanks so much Jim - I will check into this (and I did just join a 
javascript list)


--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]



HTH.
BTW - I see a small typo in my concat statement - 'Id', not 'ID'.

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



[PHP] Re: Can javascript or php help with this

2013-05-25 Thread Jim Giner

On 5/25/2013 4:33 PM, dealTek wrote:

Hi all,

I have a php form that has a pull down select for MONTH and one for YEAR

- usually when the form is submitted you would combine them at the other end 
like 0517 (like credit card exp date) - but in this case I need to combine them 
prior to submitting the form...

I don't know javascript but I'm curious if someone might know a way to use javascript (or 
some other method) to set another input field - EXPDATE - to contain the value MONTH 
 YEAR combined prior to submitting the form?

... and in this case the form is going outside my site and other reasons so 
it's best to set this up prior to submitting the form.


--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]

So - create another field on your form.  Add an onclick event to your 
submit button.  Have it run a js function that takes the two fields and 
places them into the new field.


function combineFields()
{
  var mm = document.getElementById(monthfld).value;
  var yy = document.getElementById('yearfld).value;
  document.getElementByID(mmyy).value = +mm+yy;
  return true;
}

Might have to play with this syntax to avoid the values being 
arithmetically added instead of concatenated, but this is one way.


And of course - you could try posting on a js site instead of a php one.

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



[PHP] Re: Can javascript or php help with this

2013-05-25 Thread Jim Giner

On 5/25/2013 4:33 PM, dealTek wrote:

Hi all,

I have a php form that has a pull down select for MONTH and one for YEAR

- usually when the form is submitted you would combine them at the other end 
like 0517 (like credit card exp date) - but in this case I need to combine them 
prior to submitting the form...

I don't know javascript but I'm curious if someone might know a way to use javascript (or 
some other method) to set another input field - EXPDATE - to contain the value MONTH 
 YEAR combined prior to submitting the form?

... and in this case the form is going outside my site and other reasons so 
it's best to set this up prior to submitting the form.


--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]

So - create another field on your form.  Add an onclick event to your 
submit button.  Have it run a js function that takes the two fields and 
places them into the new field.


function combineFields()
{
  var mm = document.getElementById(monthfld).value;
  var yy = document.getElementById('yearfld).value;
  document.getElementByID(mmyy).value = +mm+yy;
  return true;
}

Might have to play with this syntax to avoid the values being 
arithmetically added instead of concatenated, but this is one way.


And of course - you could try posting on a js site instead of a php one.

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



Re: [PHP] Random

2013-05-24 Thread Jim Giner

On 5/24/2013 3:04 AM, Last Hacker Always onpoint wrote:

I needed something like this echo(rand(1,30))

On 5/24/13, Last Hacker Always onpoint lasthack...@gmail.com wrote:

okay thanks tamouse and others you think am not on point hmmm? I'll
show you i am.

On 5/24/13, tamouse mailing lists tamouse.li...@gmail.com wrote:

On Thu, May 23, 2013 at 3:51 PM, Last Hacker Always onpoint
lasthack...@gmail.com wrote:

Hey I need code for random number 1-30 for my site.


function rand_from_1_to_30() {
 return 4;
}




Apparently, your laziness was overcome by all the abuse you took here.

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



[PHP] Re: pass parameter via URL

2013-05-20 Thread Jim Giner

On 5/20/2013 9:17 AM, iccsi wrote:

I would like to know how can I pass a parameter via URL using control
value on the form.
something like myPage.php?MyID=txtMyID.value
I can use myPage.php?MyID=1, but cannot use myPage.php?MyID=txtMyID.value.

Your help and information is great appreciated,

Regards,

Iccsi

Yes - this is a JS question.  But - the answer is:

var url=myPage.php?MyID=+txtMyId.value;

Now the variable 'url' contains your url

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



[PHP] Re: pass parameter via URL

2013-05-20 Thread Jim Giner

On 5/20/2013 10:06 AM, iccsi wrote:

Thanks a million for helping,
I just need to have a JS function to return a string var which contains
my variable from sending page and call the function onClick on the button.
Please let me know if I am wrong,
Thanks again for helping,

Regards,

Iccsi,

Jim Giner  wrote in message news:40.54.04612.03b2a...@pb1.pair.com...

On 5/20/2013 9:17 AM, iccsi wrote:

I would like to know how can I pass a parameter via URL using control
value on the form.
something like myPage.php?MyID=txtMyID.value
I can use myPage.php?MyID=1, but cannot use
myPage.php?MyID=txtMyID.value.

Your help and information is great appreciated,

Regards,

Iccsi

Yes - this is a JS question.  But - the answer is:

var url=myPage.php?MyID=+txtMyId.value;

Now the variable 'url' contains your url


Then put my sample statement in the function that your onclick= is 
calling.  Although - I don't know what you mean by 'sending page'.  This 
all has to be done in the same page.  Or if you want the 'value' to be 
sent to the 'myPage.php' script, you could just make 'txtMyID' a hidden 
input field and use a POST action instead of a GET.


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



Re: [PHP] undef func - any more clues ?

2013-05-14 Thread Jim Lucas

On 5/13/2013 11:32 PM, georg wrote:

Thanks !

yum install php-odbc really did the trick.

Now Im stuck where connect gives an error in apache error_log
that it cannot find file /lib/libmimerodbc.so  which is evidently there
in exactly that place (as given in odbcini.ini for driver definition) !
A bit unexpected. (possibly an error in errorhandling ?, i.e. other cause)


So, the file /lib/libmimerodbc.so exists?  If it does and Apache cannot 
access it, then it might be permissions.  Make sure it is readable by 
httpd.  And that your httpd is not setup in a chroot environment.




/georg

- Original Message - From: Jim Lucas li...@cmsws.com
To: georg georg.chamb...@telia.com
Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
Sent: Tuesday, May 14, 2013 3:25 AM
Subject: Re: [PHP] undef func - any more clues ?



On 05/12/2013 10:34 AM, georg wrote:

Hi
Im not really following, I have done:
pecl list-all ; but dont find anything that has to do with ODBC

so still stuck with Apache error log saying : no such function (or eqiv
speak) odbc_connect()
tnx
Georg



I am using a CentOS 6.4 system as a work station.  So, with that said,
the systems are similar, but still different enough that you need to
make a few changes regarding the package names to get things working.

I also have Apache installed the I develop with.  These are the steps
that I performed, and the order I performed them in, to get odbc
working at the CLI and with Apache.

Here first is an example of what I got when trying to call
odbc_connect() without the proper packages installed from the CLI.

[root@jim ~]# php -r odbc_connect();
PHP Fatal error:  Call to undefined function odbc_connect() in Command
line code on line 1

Fatal error: Call to undefined function odbc_connect() in Command line
code on line 1


Search for the correct package.
[root@jim ~]$ yum list php* | grep -i odbc
php-odbc.x86_64  5.3.3-22.el6 base

Install found package... (change the package name if needed)
[root@jim ~]# yum install php-odbc

...

Total download size: 428 k
Installed size: 1.2 M
Is this ok [y/N]: y

...

Running Transaction
  Installing : unixODBC-2.2.14-12.el6_3.x86_64   1/2
  Installing : php-odbc-5.3.3-22.el6.x86_64  2/2
  Verifying  : php-odbc-5.3.3-22.el6.x86_64  1/2
  Verifying  : unixODBC-2.2.14-12.el6_3.x86_64   2/2

Installed:
  php-odbc.x86_64 0:5.3.3-22.el6

Dependency Installed:
  unixODBC.x86_64 0:2.2.14-12.el6_3

Complete!

Update your locate database
[root@jim ~]# updatedb

Search for the recently installed package
[root@jim ~]# locate odbc.so | grep php
/usr/lib64/php/modules/odbc.so
/usr/lib64/php/modules/pdo_odbc.so

Re-run the first test - ah it is found...
[root@jim ~]# php -r odbc_connect();
PHP Warning:  odbc_connect() expects at least 3 parameters, 0 given in
Command line code on line 1

Warning: odbc_connect() expects at least 3 parameters, 0 given in
Command line code on line 1


Once you have this, you know that everything in place to get it
working with Apache.

Now to test in the web server.  This is what I received when I viewed
my test script via Apache and my browser.

URL: http://localhost/odbc_test.php

Fatal error: Call to undefined function odbc_connect() in
/var/www/html/odbc_test.php on line 3


Now, to get it working with Apache, all I had to do was restart the
web server.

[root@jim html]# service httpd restart
Stopping httpd:[  OK  ]
Starting httpd:[  OK  ]

Now, refreshing the above page gives me this.

Warning: odbc_connect() expects at least 3 parameters, 0 given in
/var/www/html/odbc_test.php on line 3

So, it is now working.

Review my steps above, make sure you perform them as I did and you
should be working when you are done.

Let us know if you need anything further.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/



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



Re: [PHP] undef func - any more clues ?

2013-05-13 Thread Jim Lucas

On 05/12/2013 10:34 AM, georg wrote:

Hi
Im not really following, I have done:
pecl list-all ; but dont find anything that has to do with ODBC

so still stuck with Apache error log saying : no such function (or eqiv
speak) odbc_connect()
tnx
Georg



I am using a CentOS 6.4 system as a work station.  So, with that said, 
the systems are similar, but still different enough that you need to 
make a few changes regarding the package names to get things working.


I also have Apache installed the I develop with.  These are the steps 
that I performed, and the order I performed them in, to get odbc working 
at the CLI and with Apache.


Here first is an example of what I got when trying to call 
odbc_connect() without the proper packages installed from the CLI.


[root@jim ~]# php -r odbc_connect();
PHP Fatal error:  Call to undefined function odbc_connect() in Command 
line code on line 1


Fatal error: Call to undefined function odbc_connect() in Command line 
code on line 1



Search for the correct package.
[root@jim ~]$ yum list php* | grep -i odbc
php-odbc.x86_64  5.3.3-22.el6 base

Install found package... (change the package name if needed)
[root@jim ~]# yum install php-odbc

...

Total download size: 428 k
Installed size: 1.2 M
Is this ok [y/N]: y

...

Running Transaction
  Installing : unixODBC-2.2.14-12.el6_3.x86_64   1/2
  Installing : php-odbc-5.3.3-22.el6.x86_64  2/2
  Verifying  : php-odbc-5.3.3-22.el6.x86_64  1/2
  Verifying  : unixODBC-2.2.14-12.el6_3.x86_64   2/2

Installed:
  php-odbc.x86_64 0:5.3.3-22.el6

Dependency Installed:
  unixODBC.x86_64 0:2.2.14-12.el6_3

Complete!

Update your locate database
[root@jim ~]# updatedb

Search for the recently installed package
[root@jim ~]# locate odbc.so | grep php
/usr/lib64/php/modules/odbc.so
/usr/lib64/php/modules/pdo_odbc.so

Re-run the first test - ah it is found...
[root@jim ~]# php -r odbc_connect();
PHP Warning:  odbc_connect() expects at least 3 parameters, 0 given in 
Command line code on line 1


Warning: odbc_connect() expects at least 3 parameters, 0 given in 
Command line code on line 1



Once you have this, you know that everything in place to get it working 
with Apache.


Now to test in the web server.  This is what I received when I viewed my 
test script via Apache and my browser.


URL: http://localhost/odbc_test.php

Fatal error: Call to undefined function odbc_connect() in 
/var/www/html/odbc_test.php on line 3



Now, to get it working with Apache, all I had to do was restart the web 
server.


[root@jim html]# service httpd restart
Stopping httpd:[  OK  ]
Starting httpd:[  OK  ]

Now, refreshing the above page gives me this.

Warning: odbc_connect() expects at least 3 parameters, 0 given in 
/var/www/html/odbc_test.php on line 3


So, it is now working.

Review my steps above, make sure you perform them as I did and you 
should be working when you are done.


Let us know if you need anything further.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



[PHP] Re: Sync CSV files with MySQL Database.

2013-05-11 Thread Jim Giner

On 5/11/2013 12:57 AM, Carlos Sura wrote:

Hello mates,

Perhaps this seems to be a silly question, but it is not to me, here is the
scenario:

I know how to import CSV files with PHP to a MySQL database, the thing is,
that CSV file is automatically feed by a third-party application, I want to
do something to add just the new records, not all the records again.

Any idea or example, will be really appreciated.

Thanks!

So - just how are you doing your import now?  If you are breaking down 
the csv record into fields before adding it to the db, then it would 
be simple to take the 'key' fields and check your database before adding 
each record, no?


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



[PHP] Re: array_map() with multiple callback functions

2013-05-08 Thread Jim Giner

On 5/7/2013 5:29 PM, George Langley wrote:

Hi all. I want to apply strtolower() AND trim() to all items in an array. But I 
don't see a way to call multiple callbacks with the array_map() function.
Are my two choices the following:

// 1) nesting two array_map() calls
$cleanData = array_map('trim',(array_map('strtolower',$rawData)));


// 2) call my own function with array_walk()
$cleanData = array_walk('myCleaner',$rawData);

function myCleaner($passedData){
$cleanData = array_map('strtolower',$passedData);
$cleanData = array_map('trim',$cleanData);
}
//(Of course, wouldn't bother with a function, just to call array_map twice...)

Just seeing if there's a better way than having to go through the array twice 
to apply each callback separately. Thanks,

Not sure if you have an answer to this yet, so I'll present my simpler 
approach.


foreach ($my_array as $v)
{
   $v = trim($v);
   $v = strtolower($v);
}

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



Re: [PHP] generate onfly PDF

2013-05-04 Thread Jim Giner

On 5/4/2013 6:31 PM, Rafnews wrote:

On 04.05.2013 23:05, Tedd Sperling wrote:

On May 4, 2013, at 5:00 PM, Ashley Sheridan a...@ashleysheridan.co.uk
wrote:

Rafnews raf.n...@gmail.com wrote:
Is there a solution to generate onfly PDF from HTML page, and from data

user typed in form (let's say like a template) without using PECL ?
i read that is hosting does not allow such extension, we can not
generate PDF, so i would rather get a solution without such library.

Moreover i'm searching a solution free and that i can supply with my
web
components.
I created a component that should be able to generate PDF files quite
often as service for user.

Have a look at fpdf, its a class that doesn't need any special
server-side support. Its basic, but is pretty good.

Thanks,
Ash

Ash is right, here's an example I provide my students:

http://rebel.lcc.edu/sperlt/citw185/examples/pdf/

Everything is there.

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com









AFAIK fpdf needs zlib and gd extensions.
gd extension is almost everywhere enabled as extension, however i'm not
sur zlib is enabled on most of servers...

What do you think about that ?

Al.

Well?  Check your hoster - do they provide it or not?

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



  1   2   3   4   5   6   7   8   9   10   >