[PHP] Switch Statement

2013-09-28 Thread Ethan Rosenberg

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



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

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

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



Re: [PHP] Switch Statement

2013-09-28 Thread Ethan Rosenberg

On 09/28/2013 10:53 PM, Aziz Saleh wrote:

Ethan, can you do a var_dump instead of print_r. It might be that next_step
has spaces in it causing the switch to not match.

Aziz



snip

Aziz -

Used var_dump no further information

Ethan


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



Re: [PHP] Re: Permissions

2013-08-27 Thread Ethan Rosenberg


On 08/27/2013 03:07 AM, David Robley wrote:

Ashley Sheridan wrote:


On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:


Ethan Rosenberg wrote:


Dear List -

Tried to run the program, that we have been discussing, and received a
403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was able
to remove the bit. [it doesn't show above]

How do I extricate myself from the hole into which I have planted
myself?

TIA

Ethan


This is in no way a php question, as the same result will happen no
matter what you ask apache to serve from that directory.

You have the directory permissions set to 776 not 777.
--
Cheers
David Robley

Steal this tagline and I'll tie-dye your cat!





776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What


I beg to differ here. If the x bit isn't set on a directory, that will
prevent scanning of the directory; in this case apache will be prevented
from scanning the directory and will return a 403.


It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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



I checked with the -Z option

ethan@rosenberg:/var/www$ ls -lZ StoreInventory.php
-rwxrwsr-t 1 ethan ethan ? 4232 Aug 27 00:18 StoreInventory.php

Ethan

PS David-

I promise that I will not steal your tag line.  My short hair American 
tabby cat [Gingy Feline Rosenberg]is too nice to have anything done to her.


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



Re: [PHP] Re: Permissions

2013-08-27 Thread Ethan Rosenberg


On 08/27/2013 01:52 PM, Ethan Rosenberg wrote:


On 08/27/2013 03:07 AM, David Robley wrote:

Ashley Sheridan wrote:


On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:


Ethan Rosenberg wrote:


Dear List -

Tried to run the program, that we have been discussing, and received a
403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was
able
to remove the bit. [it doesn't show above]

How do I extricate myself from the hole into which I have planted
myself?

TIA

Ethan


This is in no way a php question, as the same result will happen no
matter what you ask apache to serve from that directory.

You have the directory permissions set to 776 not 777.
--
Cheers
David Robley

Steal this tagline and I'll tie-dye your cat!





776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What


I beg to differ here. If the x bit isn't set on a directory, that will
prevent scanning of the directory; in this case apache will be prevented
from scanning the directory and will return a 403.


It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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



I checked with the -Z option

ethan@rosenberg:/var/www$ ls -lZ StoreInventory.php
-rwxrwsr-t 1 ethan ethan ? 4232 Aug 27 00:18 StoreInventory.php

Ethan

PS David-

I promise that I will not steal your tag line.  My short hair American
tabby cat [Gingy Feline Rosenberg]is too nice to have anything done to her.

This has really morphed into a Debian issue.  I have sent it to the 
Debian list.  I will keep you informed.


Ethan

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



[PHP] Re: Permissions

2013-08-27 Thread Ethan Rosenberg


On 08/27/2013 03:31 PM, Steven Post wrote:

On Tue, 2013-08-27 at 13:43 -0400, Ethan Rosenberg wrote:

Dear List -

I apologize for this needle in a haystack  but...

This was originally posted on the PHP list, but has changed into a
Debian question...

Tried to run the program, that we have been discussing,{on the PHP list}
and received a 403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was able
to remove the bit. [it doesn't show above]

I made the following stupid mistakes...
note commands from the root prompt have a su appended

467  chown -R ethan:www-data wwwsu
469  chown -R ethan:www-data wwwsu
470  chmod -R g+s www   su
471  chgrp -R  www  su
477  chgrp -R ethan www su  
480  chmod -R 766 www   su
482  chmod g-S www  su
485  chmod -S www   su
486  chmod g S www  su
487  chmod gS www   su
488  chmod S wwwsu
489  chmod 776 www  su
492  chmod 776 -R www   su
494  chmod -s -R wwwsu
504  chmod 666 StoreInventory.php
512  chmod 3775 StoreInventory.php

I now have

ethan@rosenberg:/var/www$ ls -la StoreInventory.php
-rwxrwsr-t 1 ethan ethan 4232 Aug 27 00:18 StoreInventory.php

ethan@rosenberg:/var$ ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

and still have the 403 error.

How do I extricate myself from the hole into which I have planted myself?



The problem appears to be that Apache does not have access to the file.
Looking at the permissions of the file it should work, however, apache
is not able to go into your /var/www folder. Either you need to set
www-data as the owner of the directory, or as the group owner, or,
possibility number 3, give execute rights to 'others' on that folder.

Pick one (you might need to be root for the first 2 in your situation):
1) chown www-data /var/www
2) chgrp www-data /var/www
3) chmod -R o+X /var/www

Note the capital 'X' on option 3, this gives execute permissions on
folders only, not files, as the -R means all files and subdirectories as
well.

The 't' is known as the sticky bit if I recall correctly, set with 1 on
the first number in a 4 number chmod command, for details see [1].
I guess in your case you can use 0664 for the files and 0775 for
directories (or 0640 and 0750 if you set owner or group back to
www-data)

Best regards,
Steven



you wrote about a 403 error, so I assume you invoke the script by
calling a webserver via browser.
In that case the webserver needs the permission to access /var/www and
to read StoreInventory.php.

By default the webserver runs as user/group www-data (it can be changed
in the webservers config-file(s)).

Try this:

#chown -R ethan:www-data /var/www
#chmod 775 /var/www
#chmod 640 /var/www/StoreInventory.php

Your ls should return something like this:

$ls -hal /var/www
drwxr-x--- 1 ethan www-data 4.0K Jun 3 20:35 .
-rw-r- 1 ethan www-data 623 Jun 3 20:35 StoreInventory.php


If that does not work you might check the configuration- and log-files
of your webserver.

Dear List -

I had to go to a meeting but before I left I tried one last thing -

 chmod 000 www
 chmod 0777 www
rosenberg:/var# ls -ld www
drwxrwxrwx 37 ethan ethan 20480 Aug 27 17:30 www

 chown ethan StoreInventory.php
 chgrp ethan StoreInventory.php
 chmod 000 StoreInventory.php
 chmod 777 StoreInventory.php
ethan@rosenberg:/var/www$ ls -la StoreInventory.php
-rwxrwxrwx 1 ethan ethan 4232 Aug 27 17:25 StoreInventory.php

when I returned...

IT WORKS!!!

Thanks to all.

Ethan

--
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-26 Thread Ethan Rosenberg


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






--
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-26 Thread Ethan Rosenberg, PhD


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


--
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-26 Thread Ethan Rosenberg, PhD



Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com

On 08/26/2013 07:33 PM, David Robley wrote:

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


Note that touch and chmod don't return any output, so echoing the result of
a system call for those commands will give an empty string.

You should be checking the values of $ret for each execution of system to
see whether the command was successful or not - the return status of the
executed command will be written to this variable. I'd guess that touch is
returning 13 - permission denied.

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

Check the permissions for directory /var/www; you'll probably find it is
writable by the user you log on as, but not by the user that apache/php runs
as, which is often www - a user with limited privileges.

As other(s) have pointed out, there are php functions to do what you want
without introducing the possible insecurities involved with system et al.



David -

touch returned 1
 /chmod returned 1

rosenberg:/var/www# ls orders.txt
ls: cannot access orders.txt: No such file or directory

rosenberg:/var# ls -ld www
drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www

TIA

Ethan

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



[PHP] Permissions

2013-08-26 Thread Ethan Rosenberg

Dear List -

Tried to run the program, that we have been discussing, and received a 
403 error.


rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was able 
to remove the bit. [it doesn't show above]


How do I extricate myself from the hole into which I have planted myself?

TIA

Ethan




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



[PHP] exec and system do not work

2013-08-25 Thread Ethan Rosenberg

Dear List -

I'm lost on this one -

This works -

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

This does -

echo exec(ls -l);

This does not -

if( !file_exists(/var/www/orders.txt));
{
   $out = system(touch /var/www/orders.txt, $ret);
   $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

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



[PHP] Mysqli Extension

2013-08-19 Thread Ethan Rosenberg

Dear List -

My mysqli extension seems to have gone away.

$host = 'localhost';
$user = 'root';
$password = 'SdR3908';
echo hello2br /;
var_dump(function_exists('mysqli_connect'));// this returns boo(false)
$db = 'Store';
$cxn = mysqli_connect($host,$user,$password,$db);

I tried to reinstall -

rosenberg:/home/ethan#  apt-get install php5-common libapache2-mod-php5 
php5-cli

Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php5 is already the newest version.
libapache2-mod-php5 set to manually installed.
php5-cli is already the newest version.
php5-cli set to manually installed.
php5-common is already the newest version.
php5-common set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

It did not help.

TIA

Ethan

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



[PHP] Regex

2012-07-27 Thread Ethan Rosenberg

Dear list -

I've tried everything  and am still stuck.

A regex that will accept numbers, letters, comma, period and no other 
characters


Thanks.

Ethan Rosenberg



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



[PHP] SQL Injection

2012-06-08 Thread Ethan Rosenberg

Dear List -

I am aware of a long email trail on this subject, but there does not 
seem to be a resolution.


Is it possible to have a meeting of the minds to come up with (an) 
appropriate method(s)?


Thanks.

Ethan Rosenberg



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



[PHP] IDE

2012-05-06 Thread Ethan Rosenberg

Dear List -

Is there any IDE which will let me step thru my code AND give the 
opportunity to enter data; eg, when a form should be displayed allow 
me to enter data into the form and then proceed?  I realize the forms 
are either HTML and/or Javascript, but there must be a 
work-around.  I is exceedingly tedious to use echo print var_dump print_r.


Thanks.

Ethan



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



Re: [PHP] IDE

2012-05-06 Thread Ethan Rosenberg

At 06:45 PM 5/6/2012, Simon Schick wrote:

On Mon, May 7, 2012 at 12:33 AM, Ethan Rosenberg eth...@earthlink.net wrote:

 Dear List -

 Is there any IDE which will let me step thru my code AND give the
 opportunity to enter data; eg, when a form should be displayed allow me to
 enter data into the form and then proceed? Â I realize the forms are either
 HTML and/or Javascript, but there must be a work-around. Â I is exceedingly
 tedious to use echo print var_dump print_r.

 Thanks.

 Ethan



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


Hi, Ethan

The only thing I can come up with, that would really help you, since
you're just working with var_dump and print_r, is a php-debugger.

The common debugger for php are Zend Debugger and xdebug.

Nearly every IDE can be connected to them and if you set it up
correctly you can browse through your side (using your favourite
browser) and activate the debugger just by setting a cookie. For
several browsers there are plugins that set the cookie by clicking an
icon.
I'm talking about nearly every IDE because I saw a screenshot of
someone debugging a php-script using xdebug and vi :)

Just the first two links I found on google ...
* http://xdebug.org/docs/install
* 
http://www.thierryb.net/pdtwiki/index.php?title=Using_PDT_:_Installation_:_Installing_the_Zend_Debugger


Is that what you need?

I'm personally using PhpStorm and a VM with Debian, PHP 5.3 and xdebug
to debug my scripts and am perfectly fine with that. I can send you my
whole xdebug-config if you want :)

The stuff with javascript sounds like something automated to me ...
But I don't think you're talking about auto-form-fill and stuff like
that, are you?

Bye
Simon

===
Simon -

Thanks.


I don't think you're talking about auto-form-fill and stuff like
that, are you?


No, I am not.

Please send me your xdebug-config file.

Thanks

Ethan



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



[PHP] PHP Database Problems -- Code Snippets - Any more Ideas?

2012-05-04 Thread Ethan Rosenberg
 type=\text\ 
name=\MedRec\ value=\ $_GLOBALS[mdr]\ /;
echo nbspnbsp Weight: input type=\decimal\ 
name=\Weight\ //inputbr /br /br /br / nbspnbspnbspnbsp ;

echo Notes: br / ;
echo textarea style=\overflow: scroll\; cols=\60\ 
rows=\10\ wrap=\hard\ name=\Notes\ /textarea /inputp /;

echo input type=\submit\ value = \Submit\/br /br /;
echo  input type=hidden name=\datain\ value='already';

echo input type = \reset\ //center;
   echo /form;


   }

} /*  End Step10 */


case step4:
{
   if (!isset($_POST['datain']))
   {
$_POST['datain'] = 5;
   }



   if( $_POST['datain'] == already)
   {

date_default_timezone_set('America/New_York');


$Date  = date('Ymd');
$Date2 = date('d M Y');
$sql1 = select MedRec, Height from Intake3 where 
(MedRec = $MDRold);

$result4 = mysqli_query($cxn, $sql1);
$row4 = mysqli_fetch_array($result4, MYSQLI_BOTH);
$Height = $row4[1];
$Weight = $_POST['Weight'];
$Notes  = $_POST['Notes'];

$sql5 = select MedRec, Weight from Visit3 where (MedRec 
= $MDRold);

$result5 = mysqli_query($cxn, $sql5);
$row5 = mysqli_fetch_array($result5, MYSQLI_BOTH);
$BMI = ($Weight*703)/($Height*$Height);
$BMI = round($BMI,1);

$fptr1 = fopen(/home/ethan/PHP/HRecnumSite, r+);
fscanf($fptr1,%d %s,$Num, $Site);
$sql2 =  INSERT INTO Visit3(Indx, Site, MedRec, Notes, 
Weight, BMI, Date) VALUES(null, '$Site', '$MDRold', '$Notes',

   $Weight, $BMI, '$Date');

$result6 = mysqli_query($cxn, $sql2);
$MDRcheck = $MDRold;
$row2 = mysqli_fetch_array($result6, MYSQLI_BOTH);

?

?

center
table border=4 cellpadding=5 cellspacing=55 rules=all 
frame=box

   tr class=\heading\
   thIndex/th
   thSite/th
   thMedical Record/th
   thNotes/th
   thWeight/th
   thBMI/td
   thDate/td
   /tr


?php

   $sql3 = select max(Indx) from Visit3;
   $result7 = mysqli_query($cxn, $sql3);
   $row7 = mysqli_fetch_array($result7, MYSQLI_BOTH);
   $Indx = $row7[0];

   echo tr\n;
   echo td $Indx /td\n;
   echo td $Site /td\n;
   echo td $_GLOBALS[mdr] /td\n;
   echo td $Notes /td\n;
   echo td $Weight /td\n;
   echo td $BMI /td\n;
   echo td $Date2 /td\n;
   echo /tr\n;


   while($row8 = mysqli_fetch_array($result2, MYSQLI_BOTH))
   {
global $finished;
echo tr\n;
echo td $row8[0] /td\n;
echo td $_GLOBALS[mdr] /td\n;
echo td $row8[2] /td\n;
echo td $row8[3] /td\n;
echo td $row8[4] /td\n;
echo td $row8[5] /td\n;
echo td $row8[6] /td\n;
echo /tr\n;
echo br /row8br /; print_r($row8[1]);

   }
echo /table;
$flag = 1;

   }
} /* end step4 */
} /* End Switch */

WELCOME SCREEN:

function show_welcome()
{

   $first_name = isset($_REQUEST[Fname])  ? $_REQUEST[Fname] : ;
   $last_name  = isset($_REQUEST[Lname])  ? $_REQUEST[Lname] : ;
   $medrec = isset($_REQUEST[MedRec]) ? $_REQUEST[MedRec] : ;
   $phone  = isset($_REQUEST[Phone])  ? $_REQUEST[Phone] : ;
   $height = isset($_REQUEST[Height]) ? $_REQUEST[Height] : ;

   echo form  method=\post\;
   echo  centerSite: input type=\text\ name=\Site\ 
value=\AA\ //input;
   echo  Record Number: input type=\text\ 
name=\MedRec\  value=', $medrec, ' //input;
   echo  First Name: input type=\text\ name=\Fname\ 
value=', $first_name, ' /;
   echo  Last Name: input type=\text\ name=\Lname\ 
value=', $last_name, ' //inputbr /br /;
   printf(Two Capital Letters\t\t\t   Five 
Numbers\t\t\t\t  Text - No Numbers\t\t\t Text - No Numbers\n\n\n);
   echo  Phone: input type=\text\ name=\Phone\ value=', 
$phone, ' //input;
   echo  Height: input type=\decimal\ name=\Height\ 
value=', $height, ' //inputbr /br /;

   printf(XXX-XXX-\t\t\tInches\n\n);
   echo  Maleinput type=\radio\ name=\Sex\ value = 
\Male\ checked;
   echo  Femaleinput type=\radio\ name=\Sex\ value = 
\Female\ br /br /br /;

   echo  input type=\submit\  /br /br /;
   echo  input type=\reset\ value = \Clear Form\  //center;
   echo  input type=hidden name='welcome_already_seen'
  value='already_seen';

}
?

I hope this helps.

Ethan

























--
Ethan Rosenberg, PhD
Pres/CEO
Hygeia Biomedical Research, Inc
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
mailto:erosenb...@hygeiabiomedical.comerosenb...@hygeiabiomedical.com



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




--
PHP General Mailing List (http

Re: [PHP] PHP Database Problems -- Code Snippets

2012-05-03 Thread Ethan Rosenberg

At 06:47 PM 5/2/2012, Matijn Woudt wrote:
On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg 
eth...@earthlink.net wrote:  Dear list -   
Sorry for the attachment. Â Here are code 
snippets --- Ethan, I don't want to sound rude, 
but it appears to me you don't have any 
understanding of what you're doing. It might 
help if you understand what the code is doing... 
Let me explain.   GET THE DATA FROM 
INTAKE3:   Â  Â function handle_data()  Â  Â 
{  Â  Â  Â  global $cxn;  Â  Â  Â  $query = 
select * from Intake3 where  1; 
      if(isset($_Request['Sex']) 
trim($_POST['Sex']) != '' ) $_Request does not 
exists, you're looking for $_REQUEST. And why 
are you mixing $_REQUEST and $_POST here?  
      {             if 
($_REQUEST['Sex'] === 0)  Â  Â  Â  Â  Â  Â 
{  Â  Â  Â  Â  Â  Â  Â  $sex = 'Male';  
           }             else  
           {                $sex = 
'Female';  Â  Â  Â  Â  Â  Â }  Â  Â  Â  }   
   } What is the point of the handle_data 
function above? It doesn't do anything.  Â  Â 
$allowed_fields = array  Â  Â  Â  ( Â 'Site' 
=$_POST['Site'], 'MedRec' = $_POST['MedRec'], 
'Fname' =  $_POST['Fname'], 'Lname' = 
$_POST['Lname'] ,  Â  Â  Â  Â  Â  Â  'Phone' = 
$_POST['Phone'] , 'Sex' = $_POST['Sex'] Â , 
'Height'  = $_POST['Height'] Â );   Â  Â 
if(empty($allowed_fields))  Â  Â {  
         echo ouch;     }      
$query = select * from Intake3  where  1 
;   Â  Â foreach ( $allowed_fields as $key = 
$val )  Â  Â {  Â  Â  Â  if ( (($val != '')) 
)      {        $query .=  AND ($key  
= '$val') ;  Â  Â }  Â  Â  Â  $result1 = 
mysqli_query($cxn, $query);  Â  Â } First, this 
will allow SQL injections, because you insert 
the values directly from the browser. Second, 
you should move the last line ($result1=...), 
outside of the foreach loop, now you're 
executing the query multiple times. Third, you 
should check if $result1 === FALSE, in case the 
query fails   Â  Â $num = 
mysqli_num_rows($result1);  Â  Â if(($num = 
mysqli_num_rows($result1)) == 0) Doing the same 
thing twice?  Â  Â {  ?  Â  Â br /br 
/centerbp style=color: red; 
font-size:14pt; No Records  Retrieved 
#1/center/b/style/p  ?php  Â  Â 
exit();  Â  Â }   DISPLAY THE INPUT3 
DATA:   THIS SEEMS TO BE THE ROUTINE THAT 
IS FAILINGÂ  Â centerbSearch 
Results/b/centerbr /   Â  Â 
centertable border=4 cellpadding=5 
cellspacing=55 Â rules=all  Â 
frame=box  Â  Â tr class=\heading\  
   thSite/th     thMedical 
Record/th  Â  Â thFirst Name/th  Â  Â 
thLast Name/th  Â  Â thPhone/td  Â  Â 
thHeight/td  Â  Â thSex/td  Â  Â 
thHistory/td  Â  Â /tr   ?php   
      while ($row1 = 
mysqli_fetch_array($result1, MYSQLI_BOTH))  
      {             print_r($_POST); 
Doesn't really make sense to print $_POST 
here..  Â  Â  Â  Â  Â  Â  Â  global 
$MDRcheck;  Â  Â  Â  Â  Â  Â  Â  $n1++;  
              echo br /n1 br /;echo 
$n1;  Â  Â  Â  Â  Â  Â {  
              if (($n1  2)  ($MDRcheck 
== $row1[1]))  Â  Â  Â  Â  Â  Â  Â  {  
                   echo 2==  ;  
                   echo $MDRcheck;  
                   echo td $row1[0] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[1] /td\n;  
                   echo td $row1[2] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[3] /td\n;  
                   echo td $row1[4] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[5] /td\n;  
                   echo td $row1[6] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[7] /td\n;  
                   echo /tr\n;  
              }  
              elseif (($n1  2)  
($MDRcheck != $row1[1]))  
              {  
                   echo 2!=  ;   
                   echo 
$MDRcheck;Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 
continue; continue doesn't do anything here.  
              }  
              elseif ($n1 == 2)  
              {   
                   define( MDR ,  
$row1[1]);  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
br /row1 br;echo $row1[1];  
                   echo tr\n;   
                   $_GLOBALS['mdr']= 
$row1[1];  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 
$_POST['MedRec'] = $row1[1]; You're not supposed 
to set variables in $_POST...  
                   $MDRold = 
$_GLOBALS['mdr']; It appears you want the old 
value of mdr, if so, then you should do this 
before you set it again 2 lines above..  
                   echo td $row1[0] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[1] /td\n;  
                   echo td $row1[2] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[3] /td\n;  
                   echo td $row1[4] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[5] /td\n;  
                   echo td $row1[6] 
/td\n;  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
td $row1[7] /td\n;  
                   echo /tr\n;  
    Â

[PHP] PHP Database Problems

2012-05-02 Thread Ethan Rosenberg

 have a database

mysql describe Intake3;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| Site   | varchar(6)  | NO   | PRI | |   |
| MedRec | int(6)  | NO   | PRI | NULL|   |
| Fname  | varchar(15) | YES  | | NULL|   |
| Lname  | varchar(30) | YES  | | NULL|   |
| Phone  | varchar(30) | YES  | | NULL|   |
| Height | int(4)  | YES  | | NULL|   |
| Sex| char(7) | YES  | | NULL|   |
| Hx | text| YES  | | NULL|   |
++-+--+-+-+---+
8 rows in set (0.00 sec)

mysql describe Visit3;
++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| Indx   | int(4)   | NO   | PRI | NULL| auto_increment |
| Site   | varchar(6)   | YES  | | NULL||
| MedRec | int(6)   | YES  | | NULL||
| Notes  | text | YES  | | NULL||
| Weight | int(4)   | YES  | | NULL||
| BMI| decimal(3,1) | YES  | | NULL||
| Date   | date | YES  | | NULL||
++--+--+-+-++

and a program to enter and extract data.

I can easily extract data from the database. However, if I try to 
enter data, it goes into the incorrect record.  Following are some 
screenshots.  The program is attached.  [pardon the comical 
names.  This is a test, and any resemblance to true names is not 
intentional]


Let us say that I wish to deal with Medical Record 1:


This it data from Intake3:
Site Medical Record First Name Last Name Phone Height Sex History
AA 1 David Dummy 845 365-1456 66 Male c/o obesity. Various 
treatments w/o success


This is data from Visit3:
Index Site Medical Record Notes Weight BMI Date
2322 AA 1 Second Visit. 170 27.4 2010-01-20
2326 AA 1 Third visit. Small progress, but pt is very happy. 165 
26.6 2010-02-01



I then request to enter additional data:

Site Medical Record First Name Last Name Phone Height Sex History
AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his 
friends that he is obese. Normal BMI = 23.

Index Site Medical Record Notes Weight BMI Date

Notice that it is entered into record 10003

The data is First Try

Index Site Medical Record Notes Weight BMI Date
2590 AA 10003 First Try 189 31.4 02 May 2012

Help and advice, please.

Thanks.

Ethan

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

[PHP] PHP Database Problems -- Code Snippets

2012-05-02 Thread Ethan Rosenberg
\ 
name=\Weight\ //inputbr /br /br /br / nbspnbspnbspnbsp ;

echo Notes: br / ;
echo textarea style=\overflow: scroll\; cols=\60\ 
rows=\10\ wrap=\hard\ name=\Notes\ /textarea /inputp /;

echo input type=\submit\ value = \Submit\/br /br /;
echo  input type=hidden name=\datain\ value='already';

echo input type = \reset\ //center;
   echo /form;


   }

} /*  End Step10 */


case step4:
{
   if (!isset($_POST['datain']))
   {
$_POST['datain'] = 5;
   }



   if( $_POST['datain'] == already)
   {

date_default_timezone_set('America/New_York');


$Date  = date('Ymd');
$Date2 = date('d M Y');
$sql1 = select MedRec, Height from Intake3 where 
(MedRec = $MDRold);

$result4 = mysqli_query($cxn, $sql1);
$row4 = mysqli_fetch_array($result4, MYSQLI_BOTH);
$Height = $row4[1];
$Weight = $_POST['Weight'];
$Notes  = $_POST['Notes'];

$sql5 = select MedRec, Weight from Visit3 where (MedRec 
= $MDRold);

$result5 = mysqli_query($cxn, $sql5);
$row5 = mysqli_fetch_array($result5, MYSQLI_BOTH);
$BMI = ($Weight*703)/($Height*$Height);
$BMI = round($BMI,1);

$fptr1 = fopen(/home/ethan/PHP/HRecnumSite, r+);
fscanf($fptr1,%d %s,$Num, $Site);
$sql2 =  INSERT INTO Visit3(Indx, Site, MedRec, Notes, 
Weight, BMI, Date) VALUES(null, '$Site', '$MDRold', '$Notes',

   $Weight, $BMI, '$Date');

$result6 = mysqli_query($cxn, $sql2);
$MDRcheck = $MDRold;
$row2 = mysqli_fetch_array($result6, MYSQLI_BOTH);

?

?

center
table border=4 cellpadding=5 cellspacing=55 rules=all 
frame=box

   tr class=\heading\
   thIndex/th
   thSite/th
   thMedical Record/th
   thNotes/th
   thWeight/th
   thBMI/td
   thDate/td
   /tr


?php

   $sql3 = select max(Indx) from Visit3;
   $result7 = mysqli_query($cxn, $sql3);
   $row7 = mysqli_fetch_array($result7, MYSQLI_BOTH);
   $Indx = $row7[0];

   echo tr\n;
   echo td $Indx /td\n;
   echo td $Site /td\n;
   echo td $_GLOBALS[mdr] /td\n;
   echo td $Notes /td\n;
   echo td $Weight /td\n;
   echo td $BMI /td\n;
   echo td $Date2 /td\n;
   echo /tr\n;


   while($row8 = mysqli_fetch_array($result2, MYSQLI_BOTH))
   {
global $finished;
echo tr\n;
echo td $row8[0] /td\n;
echo td $_GLOBALS[mdr] /td\n;
echo td $row8[2] /td\n;
echo td $row8[3] /td\n;
echo td $row8[4] /td\n;
echo td $row8[5] /td\n;
echo td $row8[6] /td\n;
echo /tr\n;
echo br /row8br /; print_r($row8[1]);

   }
echo /table;
$flag = 1;

   }
} /* end step4 */
} /* End Switch */

WELCOME SCREEN:

function show_welcome()
{

   $first_name = isset($_REQUEST[Fname])  ? $_REQUEST[Fname] : ;
   $last_name  = isset($_REQUEST[Lname])  ? $_REQUEST[Lname] : ;
   $medrec = isset($_REQUEST[MedRec]) ? $_REQUEST[MedRec] : ;
   $phone  = isset($_REQUEST[Phone])  ? $_REQUEST[Phone] : ;
   $height = isset($_REQUEST[Height]) ? $_REQUEST[Height] : ;

   echo form  method=\post\;
   echo  centerSite: input type=\text\ name=\Site\ 
value=\AA\ //input;
   echo  Record Number: input type=\text\ 
name=\MedRec\  value=', $medrec, ' //input;
   echo  First Name: input type=\text\ name=\Fname\ 
value=', $first_name, ' /;
   echo  Last Name: input type=\text\ name=\Lname\ 
value=', $last_name, ' //inputbr /br /;
   printf(Two Capital Letters\t\t\t   Five 
Numbers\t\t\t\t  Text - No Numbers\t\t\t Text - No Numbers\n\n\n);
   echo  Phone: input type=\text\ name=\Phone\ value=', 
$phone, ' //input;
   echo  Height: input type=\decimal\ name=\Height\ 
value=', $height, ' //inputbr /br /;

   printf(XXX-XXX-\t\t\tInches\n\n);
   echo  Maleinput type=\radio\ name=\Sex\ value = 
\Male\ checked;
   echo  Femaleinput type=\radio\ name=\Sex\ value = 
\Female\ br /br /br /;

   echo  input type=\submit\  /br /br /;
   echo  input type=\reset\ value = \Clear Form\  //center;
   echo  input type=hidden name='welcome_already_seen'
  value='already_seen';

}
?

I hope this helps.

Ethan

























--
Ethan Rosenberg, PhD
Pres/CEO
Hygeia Biomedical Research, Inc
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
mailto:erosenb...@hygeiabiomedical.comerosenb...@hygeiabiomedical.com



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



[PHP] foreach

2012-04-05 Thread Ethan Rosenberg

Dear Lists -

I know I am missing something fundamental - but I have no idea where 
to start to look.


Here are code snippets:

I have truncated the allowed_fields to make it easier to debug.

 $allowed_fields = array(  'Site' ='POST[Site]', 'MedRec' = 
'$_POST[MedRec]', 'Fname' = '$_POST[Fname]'   );

 echo post #1\n;
 print_r($_POST);

RESPONSE:

 post #1
Array
(
[Site] = AA
[MedRec] = 10002
[Fname] =
[Lname] =
[Phone] =
[Height] =
[welcome_already_seen] = already_seen
[next_step] = step10
)



//  $allowed_fields = array(Site, MedRec, 
Fname, Lname, // previous statement of $allowed_fields

  //  Phone, Sex, Height);



Key Site, Value POST[Site]
Key MedRec, Value $_POST[MedRec]
Key Fname, Value $_POST[Fname]



foreach ($allowed_fields as $key = $val) {
print Key $key, Value $val\n;
}


if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
if ($_REQUEST['Sex'] === 0)
{
$sex = 'Male';
}
else
{
$sex = 'Female';
}
}
 }
echo Post#2;
print_r($_POST);
   if(empty($allowed_fields))
//RESPONSE

Post#2Array
(
[Site] = AA
[MedRec] = 10002
[Fname] =
[Lname] =
[Phone] =
[Height] =
[welcome_already_seen] = already_seen
[next_step] = step10
)



   {
 echo ouch;
   }

foreach ( $allowed_fields as $key = $val ) //This is line 198
{
if ( ! empty( $_POST['val'] ) )
{
print Key $key, Value $val\n;
$cxn = mysqli_connect($host,$user,$password,$db);
$value = mysql_real_escape_string( $_POST[$fld] );
$query .=  AND $fld = '$_POST[value]' ;
   echo #1 $query; //never echos the query
}
}

These are the messages I receive on execution of the script:

Notice: Undefined variable: allowed_fields in 
/var/www/srchrhsptl5.php on line 198
Warning: Invalid argument supplied for foreach() in 
/var/www/srchrhsptl5.php on line 198


Advice and help, please.

Thank you.

Ethan Rosenberg




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



[PHP] Converting string to array index

2011-11-05 Thread Ethan Rosenberg

Dear list -

I have an associative array that will return a string representing an 
array index.  I now need to convert this string into an actual array index.


$test1 = array
(
e1 = [4][7],
e2 = [5][8]
);

so.. $z = $test1['e1'];
z has the value of [4][7].  I need to convert this string to an array 
index so I can use it in $results[4][7].


How do I do it?

Thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian squeeze(sid)]  




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



[PHP] Error in variable assignment

2011-04-11 Thread Ethan Rosenberg

Dear list -

I an writing a script that will simulate a chess board.  On a move 
from e2 to e6 [see below] the variable in e2 is never assigned to 
e6.  Here are some code snippets:


?php
session_start();
session_name(Chess);
error_reporting(1);
 if ($_SESSION['flag'] != 1)
{
$flag = 1;
echo br /startingbr /;
 $results = array(array(Br, Bn, Bb, Bq, Bk, Bb, Bn, 
Br),array(Bp, Bp, Bp, Bp, Bp, Bp, Bp, Bp),
array(, , , , , , , 
),array(, , , , , , , ),array(, , , , , 
, , ),
array(, , , , , , , 
),array(Wp, Wp, Wp, Wp, Wp, Wp, Wp, Wp),
array(Wr, Wn, Wb, Wq, Wk, Wb, 
Wn, Wr));


$_SESSION['results'] = $results;
for($i = 0; $i 8; $i++)
{
for ($j = 0; $j  8; $j++)
printf(%s , $results[$i][$j]);
printf(br /);
}

$_SESSION[flag] = $flag;

snip

$board = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = $results[0][0],
b8 = $results[0][1],
c8 = $results[0][2],
d8 = $results[0][3],
e8 = $results[0][4],
f8 = $results[0][5],
g8 = $results[0][6],
h8 = $results[0][7],
a7 = $results[1][0],
b7 = $results[1][1],
c7 = $results[1][2],
d7 = $results[1][3],
e7 = $results[1][4],
f7 = $results[1][5],
g7 = $results[1][6],
h7 = $results[1][7],
a6 = $results[2][0],
b6 = $results[2][1],
c6 = $results[2][2],
d6 = $results[2][3],
e6 = $results[2][4],
f6 = $results[2][5],
g6 = $results[2][6],
h6 = $results[2][7],
a5 = $results[3][0],
b5 = $results[3][1],
c5 = $results[3][2],
d5 = $results[3][3],
e5 = $results[3][4],
f5 = $results[3][5],
g5 = $results[3][6],
h5 = $results[3][7],
a4 = $results[4][0],
b4 = $results[4][1],
c4 = $results[4][2],
d4 = $results[4][3],
e4 = $results[4][4],
f4 = $results[4][5],
g4 = $results[4][6],
h4 = $results[4][7],
a3 = $results[5][0],
b3 = $results[5][1],
c3 = $results[5][2],
d3 = $results[5][3],
e3 = $results[5][4],
f3 = $results[5][5],
g3 = $results[5][6],
h3 = $results[5][7],
a2 = $results[6][0],
b2 = $results[6][1],
c2 = $results[6][2],
d2 = $results[6][3],
e2 = $results[6][4],
f2 = $results[6][5],
g2 = $results[6][6],
h2 = $results[6][7],
a1 = $results[7][0],
b1 = $results[7][1],
c1 = $results[7][2],
d1 = $results[7][3],
e1 = $results[7][4],
f1 = $results[7][5],
g1 = $results[7][6],
h1 = $results[7][7],
);


$board2 = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = [0][0],
b8 = [0][1],
c8 = [0][2],
d8 = [0][3],
e8 = [0][4],
f8 = [0][5],
g8 = [0][6],
h8 = [0][7],
a7 = [1][0],
b7 = [1][1],
c7 = [1][2],
d7 = [1][3],
e7 = [1][4],
f7 = [1][5],
g7 = [1][6],
h7 = [1][7],
a6 = [2][0],
b6 = [2][1],
c6 = [2][2],
d6 = [2][3],
e6 = [2][4],
f6 = [2][5],
g6 = [2][6],
h6 = [2][7],
a5 = [3][0],
b5 = [3][1],
c5 = [3][2],
d5 = [3][3],
e5 = [3][4],
f5 = [3][5],
g5 = [3][6],
h5 = [3][7],
a4 = [4][0],
b4 = [4][1],
c4 = [4][2],
d4 = [4][3],
e4 = [4][4],
f4 = [4][5],
g4 = [4][6],
h4 = [4][7],
a3 = [5][0],
b3 = [5][1],
c3 = [5][2],
d3 = [5][3],
e3 = [5][4],
f3 = [5][5],
g3 = [5][6],
h3 = [5][7],
a2 = [6][0],
b2 = [6][1],
c2 = [6][2],
d2 = [6][3],
e2 = 

Re: [PHP] Closing Session - Apache

2011-04-01 Thread Ethan Rosenberg

At 05:04 AM 4/1/2011, Richard Quadling wrote:

On 31 March 2011 23:16, Ethan Rosenberg eth...@earthlink.net wrote:

 snip
 Dan -

 I'm a newbie...

 1] What should the line in the Apache configuration file be? Just to be
 sure, the file is: /etc/apache2/apache2.conf, correct?


--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY


Thanks.

To set up subdomains w/ Apache..
127.0.0.1 localhost development subdomain.development

 Don't worry about it being an FQDN.  Prior to checking with the
 router or DNS servers, all modern systems check the hosts file.  Then
 just add a reference to each in your Apache configuration file and
 restart Apache.  Boom.  Done

Can someone help w/ this:

What should the line in the Apache configuration file be? Just to be
sure, the file is: /etc/apache2/apache2.conf, correct?

Ethan 




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



[PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

Dear List -

Thanks for your help.

How do I close a session form the terminal?  I need the ability to do 
this for debugging.  I often have more than one session open at the 
same time, so creating a program with session_start() and 
session_unset() or session_destoy() would probably not work.


Ethan 




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



Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 01:30 PM 3/31/2011, Daniel Brown wrote:

On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg eth...@earthlink.net wrote:
 Dear List -

 Thanks for your help.

 How do I close a session form the terminal?  I need the ability to do this
 for debugging.  I often have more than one session open at the 
same time, so

 creating a program with session_start() and session_unset() or
 session_destoy() would probably not work.

Can you rephrase the question, Ethan, or give more details?  From
the way it sounds, you're concerned that destroying a session will
have implications for other sessions as well, which is not the case
(unless all sessions are shared).  For example, if you have Chrome,
Firefox, and Internet Exploder all active, the sessions should be
different, if even from the very same computer.  However, multiple
tabs in the same browser will generally be the same session (unless
it's something like Chrome's Incognito feature).

--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

=
Thanks.


Multiple tabs in the same browser will generally be the same session.


That is what I have.

Ethan

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

Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 02:12 PM 3/31/2011, Ashley Sheridan wrote:

On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:

 At 01:30 PM 3/31/2011, Daniel Brown wrote:
 On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg 
eth...@earthlink.net wrote:

   Dear List -
  
   Thanks for your help.
  
   How do I close a session form the terminal?  I need the 
ability to do this

   for debugging.  I often have more than one session open at the
  same time, so
   creating a program with session_start() and session_unset() or
   session_destoy() would probably not work.
 
  Can you rephrase the question, Ethan, or give more details?  From
 the way it sounds, you're concerned that destroying a session will
 have implications for other sessions as well, which is not the case
 (unless all sessions are shared).  For example, if you have Chrome,
 Firefox, and Internet Exploder all active, the sessions should be
 different, if even from the very same computer.  However, multiple
 tabs in the same browser will generally be the same session (unless
 it's something like Chrome's Incognito feature).
 
 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/
 =
 Thanks.

 Multiple tabs in the same browser will generally be the same session.

 That is what I have.

 Ethan

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


If they're all in the same browser, then what distinguishes them from
one another? If you could use that and add some sort of array in the
session with entries bearing to what tabs you have open then you could
use that to 'close' sessions. Why do you need multiple tabs open to the
same site anyway, maybe if you explained what it is you're trying to
achieve, we might help with a better way?

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



Ash -

I can be working on more than one program simultaneously and have one 
tab open w/ program A and another w/ program B.  The site in 
reference is http://localhost;


I hope this helps.

Ethan


MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg

At 05:37 PM 3/31/2011, Ethan Rosenberg wrote:

At 04:51 PM 3/31/2011, Daniel Brown wrote:

On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg eth...@earthlink.net wrote:

 
 Ash -

 I can be working on more than one program simultaneously and have one tab
 open w/ program A and another w/ program B.  The site in reference is
 http://localhost;

 I hope this helps.

Ah, but running on the same domain, the session will be common.
Right.  Killing a session will kill it in both programs, as you
already know, but there's no native way to do one for one
[file|directory].  Your best bet, if at all possible, is to separate
by subdomains (which you can do on localhost, too, by modifying your
hosts file to alias like so:

127.0.0.1 localhost development subdomain.development

Don't worry about it being an FQDN.  Prior to checking with the
router or DNS servers, all modern systems check the hosts file.  Then
just add a reference to each in your Apache configuration file and
restart Apache.  Boom.  Done.

--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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

=


Dan -

Thanks.

Two questions:

1] What is the URL for the sub domain?

2] How do kill a session from the command line?

Ethan



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



Re: [PHP] Closing Session

2011-03-31 Thread Ethan Rosenberg



snip
127.0.0.1 localhost development subdomain.development

Don't worry about it being an FQDN.  Prior to checking with the
router or DNS servers, all modern systems check the hosts file.  Then
just add a reference to each in your Apache configuration file and
restart Apache.  Boom.  Done.

--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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

=


Dan -

I'm a newbie...

1] What should the line in the Apache configuration file be? Just to 
be sure, the file is: /etc/apache2/apache2.conf, correct?


2] Back to the original questionhow do I kill a session from the terminal?

Thanks.

Ethan



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



Re: [PHP] Permission Denied - Help Requested - Solved

2011-03-30 Thread Ethan Rosenberg

At 12:07 AM 3/30/2011, Adam Richardson wrote:

On Tue, Mar 29, 2011 at 8:21 PM, Ethan Rosenberg eth...@earthlink.netwrote:

 At 05:33 PM 3/29/2011, Adam Richardson wrote:

 
  Thanks.
 
  What do you see if you run this?   Can't open or create file!
 
  Ethan


 OK,

 If you're running PHP as an Apache module, by default it won't have
 permissions to write to the directory (this is by design to avoid security
 issues.) You can do something like the following:


   1. Create a directory for writing files outside of your public directory

   (let's call it uploads.)
   2. Change the group associated with the directory to Apache:

   sudo chgrp -R www-data /home/username/path/to/uploads
   3. Change the permissions on the directory so the group has write

   permissions:
   sudo chmod -R 2775 /home/username/path/to/uploads
   4. Then try the script again.


 See if that works.

 Adam

 --
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.com

 

 Thanks -

 The directory is output_files, which is a subdirectory of /var/www
 I'm getting a message invalid owner on the command chown Apache
 output_files.  Also with the -R option, and with apache as the owner, also
 with the chgrp.  All these commands are run as root..


 Help and advice please.

 Ethan


Hi Ethan,

I might be missing something.

Did you set up the user Apache? On a standard install for Debian (using
apt-get), apache is usually set up as the user/group www-data:
http://wiki.debian.org/Apache

http://wiki.debian.org/ApacheThe root user typically owns the /var/www
directory. I usually set up virtual hosts within one of the other accounts
and then change the group on a directory outside of the public directory
specifically set aside for uploads and run the commands I sent.

However, in the case of your example, I believe you can just run the 2
commands I sent on the /var/www/output_files directory and you should be
able to write the files.

sudo chgrp -R www-data /var/www/output_files
sudo chmod -R 2775 /var/www/output_files

Hope this helps, and sorry if I misunderstood something in your
configuration or troubleshooting.

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com



Adam -

Thanks.

Works beautifully.

Ethan 




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



[PHP] Session Variables - Error

2011-03-30 Thread Ethan Rosenberg

Dear List -

Thanks for your help.

Here is another one.

I cannot get my session variables to work. The program will print out 
a chess board and show the positions of the pieces after the move


Here are code snippets: The program is chess2.php


?php  session_start();
error_reporting(1);
if (!isset($_SESSION['results'])){ //this always returns as not set.
print_r($_SESSION);
echo starting;
$results = array(array(Br, Bn, Bb, Bq, Bk, Bb, Bn, 
Br),array(Bp, Bp, Bp, Bp, Bp, Bp, Bp, Bp),
array(, , , , , , , 
),array(, , , , , , , ),array(, , , , , 
, , ),
array(, , , , , , , 
),array(Wp, Wp, Wp, Wp, Wp, Wp, Wp, Wp),
array(Wr, Wn, Wb, Wq, Wk, Wb, 
Wn, Wr));


$_SESSION['results'] = $results;
print_r($_SESSION);
}
else
{
 $results = $_SESSION['results'];
 echo br /starting valuesbr /;
 print_r($results);
}
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html xmlns=http://www.w3.org/1999/xhtml;
body
.
.
.
.
.
form method=post action=chess2.php
Move Frominput type=text 
name=move_from/inputbr /br /
Move To  input type=text 
name=move_to/inputbr /br /

input type=submit value=Enter Move/input
/form


?php
print_r($_POST);

$from_before = '$'. $_POST[move_from];
echobr /;
echo from_before = ; print_r($from_before);
echobr /;
$to = '$'. $_POST[move_to];
echo to = $to;
//$to = $from;
$from = '' ;
echobr /;
echo from after = $from;
echobr /;
echo to after = $to;

$board = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = $results[0][0],
b8 = $results[0][1],
c8 = $results[0][2],
d8 = $results[0][3],
e8 = $results[0][4],
f8 = $results[0][5],
.
.
.
.
f1 = $results[7][5],
g1 = $results[7][6],
h1 = $results[7][7],
);
for($i = 0; $i 8; $i++) //  I get the correct results here
{
for ($j = 0; $j  8; 
$j++)

printf(%s , $results[$i][$j]);
printf(br /);
}
$_SESSION['results'] = $results;

/body/html

Ethan 




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



[PHP] Sessions - More Info

2011-03-30 Thread Ethan Rosenberg

Dear List -

Thank you for your help in the past.  This an update on my session problems.

Here is a simple test program.  It never increments the session 
counter; ie, does not detect that $_SESSION has been set.


?php  session_start();  ?

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html xmlns=http://www.w3.org/1999/xhtml;
html
body

?php


if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo Views=. $_SESSION['views'];
?
/body
/html

I have no idea what is wrong.

I need to make my session variables work so that I can finish a project.

Help and advice, please.

Ethan Rosenberg

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] Sessions - More Info - SOLVED

2011-03-30 Thread Ethan Rosenberg

At 07:28 PM 3/30/2011, Ashley Sheridan wrote:

On Wed, 2011-03-30 at 19:20 -0400, Ethan Rosenberg wrote:

 Dear List -

 Thank you for your help in the past.  This an update on my 
session problems.


 Here is a simple test program.  It never increments the session
 counter; ie, does not detect that $_SESSION has been set.

 ?php  session_start();  ?

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 html
 body

 ?php


 if(isset($_SESSION['views']))
 $_SESSION['views']=$_SESSION['views']+1;
 else
 $_SESSION['views']=1;
 echo Views=. $_SESSION['views'];
 ?
  /body
 /html

 I have no idea what is wrong.

 I need to make my session variables work so that I can finish a project.

 Help and advice, please.

 Ethan Rosenberg

 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]





That code works perfectly for me, only thing I would change is the

$_SESSION['views']=$_SESSION['views']+1;

line to

$_SESSION['views']++;

for readability. If you're using Firefox, grab the Firebug plugin, which
should show you the headers that are being sent to and from the server
to the browser. From that, you might get an idea why the sessions don't
seem to be working. Just to make sure, turn on display_errors in your
php.ini file and restart Apache. Some whitespace (space or new line, for
example) before that first ?php line could cause the headers to send
and the sessions headers to fail (headers already sent error) which
would give you the problems you're seeing now. Also, some editors have
issues with the BOM (byte order marker) which could cause white-space to
be perceived where there is none. If you are sure there isn't any, then
try saving the script with a different character encoding to test if it
is the BOM causing problems.

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


++
Ash -

Thanks.

What did it was to 1] explicitly declare the character set and 2] 
close and restart Apache.


Ethan 




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



Re: [PHP] Permission Denied - Help Requested

2011-03-29 Thread Ethan Rosenberg

At 01:40 PM 3/29/2011, Adam Richardson wrote:

On Mon, Mar 28, 2011 at 11:43 PM, Ethan Rosenberg eth...@earthlink.netwrote:

 At 11:14 PM 3/28/2011, Adam Richardson wrote:

 On Mon, Mar 28, 2011 at 11:03 PM, Ethan Rosenberg mailto:
 eth...@earthlink.neteth...@earthlink.net wrote:
 At 01:32 AM 3/28/2011, Hans Åhlin wrote:
 Do you have SELinux installed?

 2011/3/28 Ethan Rosenberg mailto:eth...@earthlink.net
 eth...@earthlink.net:

  Dear List -
 
  Thanks for all your help in the past. Â Here is another one...
 
  I am getting a Permission Denied message when I try to run a PHP
 script. Â I
  just changed the mode on the directory and the files to 777. Â This
 problem
  arose when I changed the permissions. Â I thought I was solving a
 problem,
  because I could not open a file for writing. Â I was not receiving error
  messages, but no file was created.
 
  Help and advice, please.
 
  Ethan Rosenberg
 
 
 
 **
  Hans Åhlin
 Â Â  Tel: +46761488019
 Â Â  icq: 275232967
 Â Â  http://www.kronan-net.com/http://www.kronan-net.com/
 Â Â  irc://http://irc.freenode.net:6667irc.freenode.net:6667 - TheCoin

 **


 Hans -

 Sorry, I did not include my signature, which includes all the requested
 information.

 Here it is

 Ethan
 ==
 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]


 The problem persists.  I cannot write to a file from PHP.

 Any more suggestions?

 Thanks.

 Ethan


 Hi Ethan,

 Are you using suPHP or suExec? I believe the server chokes on 777
 permissions in those cases.

 Have you checked the permissions in the command line (sorry for the basic
 question, but just making sure I know what you've already done?)

 Also, can we see some of the code you're using to handle the file
 processing?

 Thanks,

 Adam

 --
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.comhttp://nephtaliproject.com


 +

 Adam -

 Thanks.

  1] Pardon my ignorance but I do not understand this - Are you using suPHP
 or suExec?


suPHP and suExec are two modules that allow PHP to run with the permissions
of the user, making it easy to write files to disk. However, suPHP (and I
believe suExec, but I can't remember for sure) does not like 777
permissions.





 2] I changed the permissions to 755 and the Permission Denied message
 went away.


Check!





 3] Have you checked the permissions in the command line? Yes


Check!





 4] Here are some code snippets:

 $fptr1 = fopen(chessboard, r+);  //this works
 $fptr2 = fopen('chessboard', 'w'); //this deletes the file, as it should
 for($i = 0; $i 8; $i++)
{
for ($j = 0; $j  8; $j++)
fprinf($fptr2, %s , $results[$i][$j]);
fprinf($fptr2, \n);

} //this never writes, so I am left with an empty file


Can you try a simplified form that checks for success along the way? How
about something like the code below to see how far it gets (I haven't
tested, but it should be close):

?php

// let's make sure you see the E_WARNING errors if present for file
functions
error_reporting(-1);
// set var for later
$cost = 120.89;

if (!($fp = fopen(test.txt, 'w'))) {
echo Can't open or create file!;
} else if (!($len = fprintf($fp, In the year 3000, a Coke will cost %01.2f,
with tax., $cost))) {
echo Can't write to file!;
} else if (!(fclose($fp))) {
echo Can't properly close file!;
}

?

What do you see if you run this?

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


+++
Thanks.

What do you see if you run this?   Can't open or create file!

Ethan






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



Re: [PHP] Permission Denied - Help Requested

2011-03-29 Thread Ethan Rosenberg

At 03:49 PM 3/29/2011, Al wrote:



On 3/29/2011 3:06 PM, Ethan Rosenberg wrote:

At 01:40 PM 3/29/2011, Adam Richardson wrote:
On Mon, Mar 28, 2011 at 11:43 PM, Ethan 
Rosenberg eth...@earthlink.netwrote:


 At 11:14 PM 3/28/2011, Adam Richardson wrote:

 On Mon, Mar 28, 2011 at 11:03 PM, Ethan Rosenberg mailto:
 eth...@earthlink.neteth...@earthlink.net wrote:
 At 01:32 AM 3/28/2011, Hans �hlin wrote:
 Do you have SELinux installed?

 2011/3/28 Ethan Rosenberg mailto:eth...@earthlink.net
 eth...@earthlink.net:

  Dear List -
 
  Thanks for all your help in the past. Â Here is another one...
 
  I am getting a Permission Denied message when I try to run a PHP
 script. Â I
  just changed the mode on the directory and the files to 777. Â This
 problem
  arose when I changed the permissions. Â I thought I was solving a
 problem,
  because I could not open a file for 
writing. Â I was not receiving error

  messages, but no file was created.
 
  Help and advice, please.
 
  Ethan Rosenberg
 
 
 
 **
  Hans �hlin
 Â Â Tel: +46761488019
 Â Â icq: 275232967
 Â Â http://www.kronan-net.com/http://www.kronan-net.com/
 Â Â 
irc://http://irc.freenode.net:6667irc.freenode.net:6667 - TheCoin


 **


 Hans -

 Sorry, I did not include my signature, which includes all the requested
 information.

 Here it is

 Ethan
 ==
 MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]


 The problem persists. I cannot write to a file from PHP.

 Any more suggestions?

 Thanks.

 Ethan


 Hi Ethan,

 Are you using suPHP or suExec? I believe the server chokes on 777
 permissions in those cases.

 Have you checked the permissions in the 
command line (sorry for the basic

 question, but just making sure I know what you've already done?)

 Also, can we see some of the code you're using to handle the file
 processing?

 Thanks,

 Adam

 --
 Nephtali: A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.comhttp://nephtaliproject.com


 +

 Adam -

 Thanks.

 1] Pardon my ignorance but I do not understand this - Are you using suPHP
 or suExec?


suPHP and suExec are two modules that allow PHP to run with the permissions
of the user, making it easy to write files to disk. However, suPHP (and I
believe suExec, but I can't remember for sure) does not like 777
permissions.





 2] I changed the permissions to 755 and the Permission Denied message
 went away.


Check!





 3] Have you checked the permissions in the command line? Yes


Check!





 4] Here are some code snippets:

 $fptr1 = fopen(chessboard, r+); //this works
 $fptr2 = fopen('chessboard', 'w'); //this deletes the file, as it should
 for($i = 0; $i 8; $i++)
 {
 for ($j = 0; $j  8; $j++)
 fprinf($fptr2, %s , $results[$i][$j]);
 fprinf($fptr2, \n);

 } //this never writes, so I am left with an empty file


Can you try a simplified form that checks for success along the way? How
about something like the code below to see how far it gets (I haven't
tested, but it should be close):

?php

// let's make sure you see the E_WARNING errors if present for file
functions
error_reporting(-1);
// set var for later
$cost = 120.89;

if (!($fp = fopen(test.txt, 'w'))) {
echo Can't open or create file!;
} else if (!($len = fprintf($fp, In the year 3000, a Coke will cost %01.2f,
with tax., $cost))) {
echo Can't write to file!;
} else if (!(fclose($fp))) {
echo Can't properly close file!;
}

?

What do you see if you run this?

Adam

--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


+++
Thanks.

What do you see if you run this? Can't open or create file!

Ethan






Run this. Make certain this script and test.txt 
are in the same dir. If not, use full path to your file.


clearstatcache();

$array= stat(test.txt);

print_r($array);//This will tell you what's going on.

Incidentally, consider using file_get_contents() 
and file_put_contents() Much easier to use and faster.


+


Al -

Thanks.

Here is what I ran and the output.  I do not know 
enough PHP to interpret the output.


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 
Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
body
?php
error_reporting(1);
clearstatcache();

$array= stat(test.txt);

print_r($array);//This will tell you what's going on.
// Output
/* Array ( [0] = 2050 [1] = 876877 [2] = 33188 
[3] = 1 [4] = 1001 [5] = 1001 [6] = 0 [7] = 
30 [8] = 1301430589 [9] = 1301430589 [10] = 
1301430589 [11] = 4096 [12] = 8 [dev] = 2050 
[ino] = 876877 [mode] = 33188 [nlink] = 1 
[uid] = 1001 [gid] = 1001 [rdev] = 0 [size] = 
30 [atime] = 1301430589 [mtime] = 1301430589 
[ctime] = 1301430589 [blksize] = 4096 [blocks] = 8 ) */

?
/body
/html


Help and advice, please.

Ethan




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

Re: [PHP] Permission Denied - Help Requested

2011-03-29 Thread Ethan Rosenberg

At 05:33 PM 3/29/2011, Adam Richardson wrote:


 Thanks.

 What do you see if you run this?   Can't open or create file!

 Ethan


OK,

If you're running PHP as an Apache module, by default it won't have
permissions to write to the directory (this is by design to avoid security
issues.) You can do something like the following:


   1. Create a directory for writing files outside of your public directory
   (let's call it uploads.)
   2. Change the group associated with the directory to Apache:
   sudo chgrp -R www-data /home/username/path/to/uploads
   3. Change the permissions on the directory so the group has write
   permissions:
   sudo chmod -R 2775 /home/username/path/to/uploads
   4. Then try the script again.

See if that works.

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com



Thanks -

The directory is output_files, which is a subdirectory of /var/www
I'm getting a message invalid owner on the command chown Apache 
output_files.  Also with the -R option, and with apache as the 
owner, also with the chgrp.  All these commands are run as root..


Help and advice please.

Ethan 




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



Re: [PHP] Permission Denied

2011-03-28 Thread Ethan Rosenberg

At 01:32 AM 3/28/2011, Hans Åhlin wrote:

Do you have SELinux installed?

2011/3/28 Ethan Rosenberg eth...@earthlink.net:
 Dear List -

 Thanks for all your help in the past. Â Here is another one...

 I am getting a Permission Denied message 
when I try to run a PHP script. Â I

 just changed the mode on the directory and the files to 777. Â This problem
 arose when I changed the permissions. Â I thought I was solving a problem,
 because I could not open a file for writing. Â I was not receiving error
 messages, but no file was created.

 Help and advice, please.

 Ethan Rosenberg



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





--


**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**


Hans -

Sorry, I did not include my signature, which 
includes all the requested information.


Here it is

Ethan
==
MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]



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




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



Re: [PHP] Permission Denied - Help Requested

2011-03-28 Thread Ethan Rosenberg

At 01:32 AM 3/28/2011, Hans Åhlin wrote:

Do you have SELinux installed?

2011/3/28 Ethan Rosenberg eth...@earthlink.net:
 Dear List -

 Thanks for all your help in the past. Â Here is another one...

 I am getting a Permission Denied message 
when I try to run a PHP script. Â I

 just changed the mode on the directory and the files to 777. Â This problem
 arose when I changed the permissions. Â I thought I was solving a problem,
 because I could not open a file for writing. Â I was not receiving error
 messages, but no file was created.

 Help and advice, please.

 Ethan Rosenberg



**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**


Hans -

Sorry, I did not include my signature, which 
includes all the requested information.


Here it is

Ethan
==
MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]


The problem persists.  I cannot write to a file from PHP.

Any more suggestions?

Thanks.

Ethan

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



MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Permission Denied

2011-03-27 Thread Ethan Rosenberg

Dear List -

Thanks for all your help in the past.  Here is another one...

I am getting a Permission Denied message when I try to run a PHP 
script.  I just changed the mode on the directory and the files to 
777.  This problem arose when I changed the permissions.  I thought I 
was solving a problem, because I could not open a file for 
writing.  I was not receiving error messages, but no file was created.


Help and advice, please.

Ethan Rosenberg



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



Re: [PHP] Re: Array Search - Solved

2011-03-26 Thread Ethan Rosenberg

At 01:31 PM 3/25/2011, João Cândido de Souza Neto wrote:

It´s a job to array_key_exists  function.

--
João Cândido de Souza Neto

Ethan Rosenberg eth...@earthlink.net escreveu na mensagem
news:0lim00hi3ihny...@mta4.srv.hcvlny.cv.net...
 Dear List -

 Here is a code snippet:

 $bla = array(g1 = $results[7][6],
h1  = $results[7][7]);
 print_r($bla);
 $value = h1;
$locate1 = array_search($value, $bla);
echo This is locate ; print_r($locate1);
if(in_array($value, $bla)) print_r($bla);

 Neither the array_search or the in_array functions give any results. I
 have tried it with both h1 and h1;

 $results[7][6]  = Wn;
 $results[7][7]  =  Wr;

 This is a chess board  where g1 and h1 are the coordinates and the results
 array contains the pieces at that coordinate.

 What am I doing wrong?

 Advice and comments please.

 Thanks.

 Ethan Rosenberg




Thank you.  It works!!

Ethan


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




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



[PHP] Array Search

2011-03-25 Thread Ethan Rosenberg

Dear List -

Here is a code snippet:

$bla = array(g1 = $results[7][6],
   h1  = $results[7][7]);
print_r($bla);
$value = h1;
   $locate1 = array_search($value, $bla);
   echo This is locate ; print_r($locate1);
   if(in_array($value, $bla)) print_r($bla);

Neither the array_search or the in_array functions give any results. 
I have tried it with both h1 and h1;


$results[7][6]  = Wn;
$results[7][7]  =  Wr;

This is a chess board  where g1 and h1 are the coordinates and the 
results array contains the pieces at that coordinate.


What am I doing wrong?

Advice and comments please.

Thanks.

Ethan Rosenberg 




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



[PHP] Displaying Results

2011-02-15 Thread Ethan Rosenberg

Dear List -

 I have a form.  In one field, the customer types the name of a 
product.  The first seven(7) results of the MySQL query that the 
entry generates should be displayed as a clickable drop down list.


How do I do it?

Thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] PEAR PHP

2011-01-30 Thread Ethan Rosenberg

At 03:29 AM 1/30/2011, Thijs Lensselink wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/30/2011 05:43 AM, Ethan Rosenberg wrote:
 Dear list -

 I enter the command pear list, and get errors.  See below --

 ethan@rosenberg:/usr/lib/php5$ ls -l
 total 12
 drwxr-xr-x 2 root root 4096 Jan  6 00:53 20090626+lfs
 drwxr-xr-x 2 root root 4096 Jul 18  2010 libexec
 -rwxr-xr-x 1 root root  596 Jan  5 08:09 maxlifetime

 ethan@rosenberg:/usr/lib/php5$ pear list
 PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/lib/php5/20090626+lfs/msql.so' -
 /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No
 such file or directory in Unknown on line 0
 font color=#ff
 Warning: PHP Startup: Unable to load dynamic library
 '/usr/lib/php5/20090626+lfs/msql.so' -
 /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No
 such file or directory in Unknown on line 0
 /fontInstalled packages, channel pear.php.net:
 =
 Package  Version State
 Archive_Tar  1.3.7   stable
 Console_Getopt   1.2.3   stable
 PEAR 1.9.1   stable
 Structures_Graph 1.0.3   stable
 Validate_US  0.5.4   beta
 XML_Util 1.2.1   stable

 ethan@rosenberg:/usr/lib/php5$ cd 20090626+lfs

 ethan@rosenberg:/usr/lib/php5/20090626+lfs$ ls -l
 total 560
 -rw-r--r-- 1 root root  95596 Jan  5 08:09 gd.so
 -rw-r--r-- 1 root root  38272 Jan  5 08:09 mcrypt.so
 -rw-r--r-- 1 root root 109220 Jan  5 08:09 mysqli.so
 -rw-r--r-- 1 root root  42352 Jan  5 08:09 mysql.so
 -rw-r--r-- 1 root root  26116 Jan  5 08:09 pdo_mysql.so
 -rw-r--r-- 1 root root  87588 Jan  5 08:09 pdo.so
 -rw-r--r-- 1 root root 141336 Aug 19 04:04 suhosin.so

 ethan@rosenberg:/usr/lib/php5/20090626+lfs$

 Help and advice, please.

 Thanks.

 Ethan

 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]



msql.so is missing. So either install it. Or comment it out in php.ini

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

++
Thank you.

You are correct, msql is not installed.

1] How do I install it?  apt-get install does not find the package.

2] Excuse my ignorance, what is a dynamic extension?

Ethan



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



Re: [PHP] PEAR PHP

2011-01-30 Thread Ethan Rosenberg

At 01:51 PM 1/30/2011, Ashley Sheridan wrote:

Ashley Sheridan a...@ashleysheridan.co.uk wrote:

Ethan Rosenberg eth...@earthlink.net wrote:

At 03:29 AM 1/30/2011, Thijs Lensselink wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/30/2011 05:43 AM, Ethan Rosenberg wrote:
  Dear list -
 
  I enter the command pear list, and get errors.  See below --
 
  ethan@rosenberg:/usr/lib/php5$ ls -l
  total 12
  drwxr-xr-x 2 root root 4096 Jan  6 00:53 20090626+lfs
  drwxr-xr-x 2 root root 4096 Jul 18  2010 libexec
  -rwxr-xr-x 1 root root  596 Jan  5 08:09 maxlifetime
 
  ethan@rosenberg:/usr/lib/php5$ pear list
  PHP Warning:  PHP Startup: Unable to load dynamic library
  '/usr/lib/php5/20090626+lfs/msql.so' -
  /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object
file:
No
  such file or directory in Unknown on line 0
  font color=#ff
  Warning: PHP Startup: Unable to load dynamic library
  '/usr/lib/php5/20090626+lfs/msql.so' -
  /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object
file:
No
  such file or directory in Unknown on line 0
  /fontInstalled packages, channel pear.php.net:
  =
  Package  Version State
  Archive_Tar  1.3.7   stable
  Console_Getopt   1.2.3   stable
  PEAR 1.9.1   stable
  Structures_Graph 1.0.3   stable
  Validate_US  0.5.4   beta
  XML_Util 1.2.1   stable
 
  ethan@rosenberg:/usr/lib/php5$ cd 20090626+lfs
 
  ethan@rosenberg:/usr/lib/php5/20090626+lfs$ ls -l
  total 560
  -rw-r--r-- 1 root root  95596 Jan  5 08:09 gd.so
  -rw-r--r-- 1 root root  38272 Jan  5 08:09 mcrypt.so
  -rw-r--r-- 1 root root 109220 Jan  5 08:09 mysqli.so
  -rw-r--r-- 1 root root  42352 Jan  5 08:09 mysql.so
  -rw-r--r-- 1 root root  26116 Jan  5 08:09 pdo_mysql.so
  -rw-r--r-- 1 root root  87588 Jan  5 08:09 pdo.so
  -rw-r--r-- 1 root root 141336 Aug 19 04:04 suhosin.so
 
  ethan@rosenberg:/usr/lib/php5/20090626+lfs$
 
  Help and advice, please.
 
  Thanks.
 
  Ethan
 
  MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]
 
 

msql.so is missing. So either install it. Or comment it out in
php.ini

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

You are correct, msql is not installed.

1] How do I install it?  apt-get install does not find the package.

2] Excuse my ignorance, what is a dynamic extension?

Ethan



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

I noticed you mis-typed mysql as msql there, did you try apt-get mysql
or msql? Mysql comes with every Linux distro I've ever used, so it
should be there in your standard repositories.


Thanks
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

Sorry, I misread the error messages there, ignore that last message!


Thanks
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

++
Ashley -

I make more mistakes reading emails than you do!!

Would you [or anyone else on this list] please help me with my questions

1] How do I install it? [msql NOT mysql] apt-get install does not 
find the package.


2] Excuse my ignorance, what is a dynamic extension?

Thanks.

Ethan



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



[PHP] PEAR PHP

2011-01-29 Thread Ethan Rosenberg

Dear list -

I enter the command pear list, and get errors.  See below --

ethan@rosenberg:/usr/lib/php5$ ls -l
total 12
drwxr-xr-x 2 root root 4096 Jan  6 00:53 20090626+lfs
drwxr-xr-x 2 root root 4096 Jul 18  2010 libexec
-rwxr-xr-x 1 root root  596 Jan  5 08:09 maxlifetime

ethan@rosenberg:/usr/lib/php5$ pear list
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/lib/php5/20090626+lfs/msql.so' - 
/usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: 
No such file or directory in Unknown on line 0

font color=#ff
Warning: PHP Startup: Unable to load dynamic library 
'/usr/lib/php5/20090626+lfs/msql.so' - 
/usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: 
No such file or directory in Unknown on line 0

/fontInstalled packages, channel pear.php.net:
=
Package  Version State
Archive_Tar  1.3.7   stable
Console_Getopt   1.2.3   stable
PEAR 1.9.1   stable
Structures_Graph 1.0.3   stable
Validate_US  0.5.4   beta
XML_Util 1.2.1   stable

ethan@rosenberg:/usr/lib/php5$ cd 20090626+lfs

ethan@rosenberg:/usr/lib/php5/20090626+lfs$ ls -l
total 560
-rw-r--r-- 1 root root  95596 Jan  5 08:09 gd.so
-rw-r--r-- 1 root root  38272 Jan  5 08:09 mcrypt.so
-rw-r--r-- 1 root root 109220 Jan  5 08:09 mysqli.so
-rw-r--r-- 1 root root  42352 Jan  5 08:09 mysql.so
-rw-r--r-- 1 root root  26116 Jan  5 08:09 pdo_mysql.so
-rw-r--r-- 1 root root  87588 Jan  5 08:09 pdo.so
-rw-r--r-- 1 root root 141336 Aug 19 04:04 suhosin.so

ethan@rosenberg:/usr/lib/php5/20090626+lfs$

Help and advice, please.

Thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] Pear Problems

2011-01-27 Thread Ethan Rosenberg

At 01:54 AM 1/27/2011, Adam Richardson wrote:

On Thu, Jan 27, 2011 at 1:01 AM, Ethan Rosenberg eth...@earthlink.netwrote:

 Dear List -

 I am executing the command pear list.

 This is what I get -

 ethan@rosenberg:/usr/bin$ pear list
 PHP:  syntax error, unexpected '' in /etc/php5/cli/php.ini on line 510
 Installed packages, channel pear.php.net:
 =
 Package  Version State
 Archive_Tar  1.3.7   stable
 Console_Getopt   1.2.3   stable
 PEAR 1.9.1   stable
 Structures_Graph 1.0.3   stable
 Validate_US  0.5.4   beta
 XML_Util 1.2.1   stable
 ethan@rosenberg:/usr/bin$

 This is line 510

 Default Value: E_ALL  ~E_NOTICE


That line should likely be commented out (it was probably originally
commented out and then somebody accidentally uncommented.)  Most php.ini
files follow the convention (notice that there's no colon in the example):
some_name = some_value

Happy coding,

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com



Adam -

Thanks.

Please take a look at php.ini in the vicinity of line 510.  You will 
see the construct to which I refer.  Can you explain what is going 
on?  I do not think it is a problem with commenting out a line.


Any ideas from the rest of the list?

Ethan


MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Pear Problems

2011-01-26 Thread Ethan Rosenberg

Dear List -

I am executing the command pear list.

This is what I get -

ethan@rosenberg:/usr/bin$ pear list
PHP:  syntax error, unexpected '' in /etc/php5/cli/php.ini on line 510
Installed packages, channel pear.php.net:
=
Package  Version State
Archive_Tar  1.3.7   stable
Console_Getopt   1.2.3   stable
PEAR 1.9.1   stable
Structures_Graph 1.0.3   stable
Validate_US  0.5.4   beta
XML_Util 1.2.1   stable
ethan@rosenberg:/usr/bin$

This is line 510

Default Value: E_ALL  ~E_NOTICE

Advice and help please.

Thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Installing PEAR

2011-01-25 Thread Ethan Rosenberg

Dear List --

How do install PEAR on Linux?  I installed lynx and as root, I ran 
the command lynx -source http://pear.php.net/go-pear | php.  It 
seemed to install, but the command pear did not work.  From the root 
directory I ran the command find . -name pear.  There was no file 
found.  I also tried Pear, with the same results.


Help and advice, please.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] Installing PEAR

2011-01-25 Thread Ethan Rosenberg

At 12:25 PM 1/25/2011, Nilesh Govindarajan wrote:

On 01/25/2011 10:32 PM, Ethan Rosenberg wrote:
 Dear List --

 How do install PEAR on Linux?  I installed lynx and as root, I ran the
 command lynx -source http://pear.php.net/go-pear | php.  It seemed to
 install, but the command pear did not work.  From the root directory I
 ran the command find . -name pear.  There was no file found.  I also
 tried Pear, with the same results.

 Help and advice, please.

 Ethan

 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]



If you are using php from the repositories, there must be a pear package
as well in the repos. Check for them.

--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com

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


Thanks.

As far as I can tell, the PHP is installed directly on my computer.  Now what?

Ethan 




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



Re: [PHP] Installing PEAR

2011-01-25 Thread Ethan Rosenberg

At 01:44 PM 1/25/2011, Shawn McKenzie wrote:

On 01/25/2011 11:25 AM, Nilesh Govindarajan wrote:
 On 01/25/2011 10:32 PM, Ethan Rosenberg wrote:
 Dear List --

 How do install PEAR on Linux?  I installed lynx and as root, I ran the
 command lynx -source http://pear.php.net/go-pear | php.  It seemed to
 install, but the command pear did not work.  From the root directory I
 ran the command find . -name pear.  There was no file found.  I also
 tried Pear, with the same results.

 Help and advice, please.

 Ethan

 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]



 If you are using php from the repositories, there must be a pear package
 as well in the repos. Check for them.


Yes, I'm on Ubuntu and just used 'apt-get install php-pear'.

--
Thanks!
-Shawn
http://www.spidean.com

--



Used apt-get install php-pear.

It works!!

Thanks to all.

Ethan


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




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



[PHP] Formatting

2011-01-25 Thread Ethan Rosenberg

Dear list -

I have a program with the following statement:  $out = system('ls 
-l', $retval);  The output is a string.  How do I format the output 
to be in the Linux format, that is in columns.  I cannot think of a 
way to use explode to do it.


Advice and comments, please.

Thanks

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Craigslist Jobs

2011-01-11 Thread Ethan Rosenberg

Dear List -

I am a NEWBIE, so .

How do I handle Craigslist postings? Is there anything special I 
should do?  Any advice for other web sites?


At this point I am talking about small jobs.

1] My payment.  Should I ask for something up front?  If so how much?

2] How do I protect myself so that I do not deliver code and not get paid.

3] What is a reasonable hourly rate?

4] Any other information that I should know?

Many thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Two forms on one page - THE ANSWER

2011-01-04 Thread Ethan Rosenberg

Jim -

Much thanks to you for solving a problem with which I have been 
struggling for the last two weeks.


Here is the code:
===
?php session_start(); ?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

?php
switch ( @$_POST['next_step'] )
 {
 case 'step1':
echo 'Your kittens name is '.htmlspecialchars($_POST['cat']);
 echo FORM
form method=post action=
input type=hidden name=next_step value=step2 /
br /Enter your date of birth, in mm/dd/ format: br /
input type=text name=dob /
input type=submit name=submit value=Submit /
/form
FORM;

 break;

 case 'step2':
if ( empty($_POST['dob']) )
die('DOB was not set in session...');
if ( !preg_match('!^\d{2}/\d{2}/\d{4}$!', $_POST['dob'], $m) )
die('DOB was not properly formated, please try again.');
 // calculate timestamp corresponding to date value
$dateTs = strtotime($_POST['dob']);
 // calculate timestamp corresponding to 'today'
$now = strtotime('today'); $dateArr = explode('/', @$_POST['dob']);
 // check that the value entered is a valid date
if ( !checkdate($dateArr[0], $dateArr[1], $dateArr[2]) )
die('ERROR: Please enter a valid date of birth');
  // check that the date entered is earlier than 'today'
if ( $dateTs = $now )
die('ERROR: Please enter a date of birth earlier 
than today');

  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
$ageDays = floor(($now - $dateTs) / 86400);
$ageYears = floor($ageDays / 365);
$ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
echo You are approximately $ageYears years and $ageMonths 
months old.;


  break;
case 'step1':
default:

echo FORM
form method=post action=
input type=hidden name=next_step value=step1 /
Enter your kitten's name: br /
input type=text name=cat /
input type=submit name=submit value=Submit Kitten /
/form
FORM;

}
?
=
Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



[PHP] Two forms on one page

2011-01-03 Thread Ethan Rosenberg

Dear List -

I would like to have two(2) forms in one PHP script.  I would like to 
have the forms appear sequentially; ie, that the first form would 
appear, the data would be entered, and then the second form would 
appear, the data would be entered, and the script would exit.


The code below displays both forms simultaneously.  After the data is 
entered for the first form, the second form appears again.  After the 
data is entered for the second form, the script displays the 
statement  from the first form.


Would you please help me correct the script so that it will perform 
as required.


Thanks.

Here is the code:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

!-- kitten.php  Two forms in one program --

htmlbody
?php
global $todo;

// if form not yet submitted
// display form
if ( isset($_POST['cat'])  $_POST['submit'] === 'Submit Ktten' )
die();


if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit' )
agerdo();
else
{
echo form method=\post\;
echo Enter your date of birth, in mm/dd/ format: br /;
echo input type=\text\ name=\dob\ /;
echo input type=\submit\ name=\submit\ value=\Submit\ /;
echo /form;
}


function agerdo()

{
  global $todo;
//  echo $todo;
  // process form input
  // split date value into components
  $dateArr = explode('/', $_POST['dob']);

  // calculate timestamp corresponding to date value
  $dateTs = strtotime($_POST['dob']);

  // calculate timestamp corresponding to 'today'
  $now = strtotime('today');

  // check that the value entered is in the correct format
  if ( sizeof($dateArr) != 3 )

die('ERROR: Please enter a valid date of birth');

  // check that the value entered is a valid date
  if ( !checkdate($dateArr[0], $dateArr[1], $dateArr[2]) )

die('ERROR: Please enter a valid date of birth');


  // check that the date entered is earlier than 'today'
  if ( $dateTs = $now )
die('ERROR: Please enter a date of birth earlier than today');
  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo You are approximately $ageYears years and $ageMonths months old.;
}

if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit Kitten' )
catdo();
if ( !isset($_POST['cat'])) // $_POST['submit'] === 'Submit Kitten' )

{
echo HTML
form method=post onsubmit=catdo();
Enter your kitten's name: br /
input type=text name=cat /
input type=submit name=submit value=Submit Kitten /
/form
HTML;
}

function catdo()
{


$name_cat = $_POST['cat'];
echo Your Kitten is $name_cat;
exit();
}


?

/body/html
===
Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)] 




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



[PHP] Two forms on one page

2011-01-03 Thread Ethan Rosenberg

Oooops - left out the text that was supposed to be in the quotes.

Dear List -

I would like to have two(2) forms in one PHP script.  I would like to 
have the forms appear sequentially; ie, that the first form would 
appear, the data would be entered, and then the second form would 
appear, the data would be entered, and the script would exit.


The code below displays both forms simultaneously.  After the data is 
entered for the first form, the second form appears again.  After the 
data is entered for the second form, the script displays the 
statement Enter your date of birth, in mm/dd/ format:   from 
the first form.


Would you please help me correct the script so that it will perform 
as required.


Thanks.

Here is the code:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

!-- kitten.php  Two forms in one program --

htmlbody
?php
global $todo;

// if form not yet submitted
// display form
if ( isset($_POST['cat'])  $_POST['submit'] === 'Submit Ktten' )
die();


if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit' )
agerdo();
else
{
echo form method=\post\;
echo Enter your date of birth, in mm/dd/ format: br /;
echo input type=\text\ name=\dob\ /;
echo input type=\submit\ name=\submit\ value=\Submit\ /;
echo /form;
}


function agerdo()

{
  global $todo;
//  echo $todo;
  // process form input
  // split date value into components
  $dateArr = explode('/', $_POST['dob']);

  // calculate timestamp corresponding to date value
  $dateTs = strtotime($_POST['dob']);

  // calculate timestamp corresponding to 'today'
  $now = strtotime('today');

  // check that the value entered is in the correct format
  if ( sizeof($dateArr) != 3 )

die('ERROR: Please enter a valid date of birth');

  // check that the value entered is a valid date
  if ( !checkdate($dateArr[0], $dateArr[1], $dateArr[2]) )

die('ERROR: Please enter a valid date of birth');


  // check that the date entered is earlier than 'today'
  if ( $dateTs = $now )
die('ERROR: Please enter a date of birth earlier than today');
  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo You are approximately $ageYears years and $ageMonths months old.;
}

if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit Kitten' )
catdo();
if ( !isset($_POST['cat'])) // $_POST['submit'] === 'Submit Kitten' )

{
echo HTML
form method=post onsubmit=catdo();
Enter your kitten's name: br /
input type=text name=cat /
input type=submit name=submit value=Submit Kitten /
/form
HTML;
}

function catdo()
{


$name_cat = $_POST['cat'];
echo Your Kitten is $name_cat;
exit();
}


?

/body/html
===
Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)]  




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



Re: [PHP] Regex for telephone numbers

2010-12-31 Thread Ethan Rosenberg

At 07:11 AM 12/31/2010, Nathan Rixham wrote:

Ethan Rosenberg wrote:
FYI [to all the list] -- I thank all for their input.  I only 
needed US phones, and I am forcing the user of the form to conform 
to xxx-xxx- as the input format.


out of interest, why are you forcing you're users to conform to that 
input format? you could simply strip all non-numeric chars then 
format how you like to save, thus giving users a looser, more 
friendly, experience.

+
Nathan -

This expression will be used to search a database which will contain 
patient data resulting from medical research.  At the initial visit a 
medical record number will be assigned to the patient.  Other 
information will be collected at that point; eg,  the telephone 
number. At subsequent visits, the patient will be referenced by 
his/hers medical record number.  If the patient either forgot their 
clinic card, or cannot remember their medical record number, a search 
will be performed.  One of the many parameters that can be used in 
the search is the phone number. It is easier if all the data has a 
fixed format.  The form for  the initial visit will use a regex that 
will validate the phone number. As  the research will be performed in 
the US, only US numbers have to be validated.


Hope this helps.

Ethan




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



[PHP] Job Search

2010-12-31 Thread Ethan Rosenberg

Dear list -

I am an entry level data base programmer [PHP/MySQL HTTP/CSS] looking 
for work in the NY metropolitan area.  Any ideas?


Should we have a job search board?

Ethan



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



Re: [PHP] Regex for telephone numbers

2010-12-31 Thread Ethan Rosenberg

At 09:27 AM 12/31/2010, a...@ashleysheridan.co.uk wrote:

Sorry for top-post, on phone.

What about mobile phone numbers (cell phones you call them in the 
US) do they conform to the same format? I know there have been times 
myself when I've been without a landline number leaving me with only 
my mobile as a means of contact.


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

- Reply message -
From: Ethan Rosenberg eth...@earthlink.net
Date: Fri, Dec 31, 2010 14:03
Subject: [PHP] Regex for telephone numbers
To: Nathan Rixham nrix...@gmail.com
Cc: php-general@lists.php.net php-general@lists.php.net


At 07:11 AM 12/31/2010, Nathan Rixham wrote:
Ethan Rosenberg wrote:
FYI [to all the list] -- I thank all for their input.  I only
needed US phones, and I am forcing the user of the form to conform
to xxx-xxx- as the input format.

out of interest, why are you forcing you're users to conform to that
input format? you could simply strip all non-numeric chars then
format how you like to save, thus giving users a looser, more
friendly, experience.
+
Nathan -

This expression will be used to search a database which will contain
patient data resulting from medical research.  At the initial visit a
medical record number will be assigned to the patient.  Other
information will be collected at that point; eg,  the telephone
number. At subsequent visits, the patient will be referenced by
his/hers medical record number.  If the patient either forgot their
clinic card, or cannot remember their medical record number, a search
will be performed.  One of the many parameters that can be used in
the search is the phone number. It is easier if all the data has a
fixed format.  The form for  the initial visit will use a regex that
will validate the phone number. As  the research will be performed in
the US, only US numbers have to be validated.

Hope this helps.

Ethan




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





Ash -

In contrast to some non-US phone numbers, all the numbers here [cell 
and landline] have the same format.


Ethan 




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



Re: [PHP] Regex for telephone numbers

2010-12-30 Thread Ethan Rosenberg

At 07:27 PM 12/29/2010, Josh Kehn wrote:



On Dec 29, 2010, at 7:12 PM, Ethan Rosenberg eth...@earthlink.net wrote:

 Dear List -

 Thank you for all your help in the past.

 Here is another one

 I would like to have a regex  which would validate that a 
telephone number is in the format xxx-xxx-.


 Thanks.

 Ethan

 MySQL 5.1  PHP 5  Linux [Debian (sid)]


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


You can't, phone numbers are more complex then that. You could use 
\d{3}-\d{3}-\d{4} to match that basic pattern for all numbers though.


Regards,

-Josh
___
http://joshuakehn.com






Sent from my iPod

Josh -

I used use \d{3}-\d{3}-\d{4}.

It works beautifully!!

FYI [to all the list] -- I thank all for their input.  I only needed 
US phones, and I am forcing the user of the form to conform to 
xxx-xxx- as the input format.


Ethan




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



Re: Fwd: Fwd: Re: [PHP] goto - My comments

2010-12-30 Thread Ethan Rosenberg

At 02:38 PM 12/27/2010, Jim Lucas wrote:

On 12/27/2010 10:42 AM, Ethan Rosenberg wrote:
snip


 Now, here is the real puzzler

 The purpose of this routine is to be able to have two(2) forms on 
one page,but
 not simultaneously.Additionally, l do not wish to call a separate 
program every
 time a new form is used.  The assumption is that the second form 
depends on the

 entries in the first form.  I realize this is not the case here.

 The age request and the kitten form both appear on the page 
together.  How do I
 accomplish having them appear separately?  If it requires Java 
Script or jQuery,

 what is the code to be used?


 snip



The key is to look at the value of the submit button.  This needs to 
be unique.


Change around your logic a little and you will have it.

?php

// if form not yet submitted
// display form
if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit' ) {
  // process form input
  // split date value into components
  $dateArr = explode('/', $_POST['dob']);

  // calculate timestamp corresponding to date value
  $dateTs = strtotime($_POST['dob']);

  // calculate timestamp corresponding to 'today'
  $now = strtotime('today');

  // check that the value entered is in the correct format
  if ( sizeof($dateArr) != 3 ) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the value entered is a valid date
  if ( !checkdate($dateArr[0], $dateArr[1], $dateArr[2]) ) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the date entered is earlier than 'today'
  if ( $dateTs = $now ) {
die('ERROR: Please enter a date of birth earlier than today');
  }

  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo You are approximately $ageYears years and $ageMonths 
months old.;


} else if ( isset($_POST['submit'])  $_POST['submit'] === 'Submit 
Kitten' ) {


$name_cat = $_POST['cat'];
echo Your Kitten is $name_cat;

} else {

echo HTML

form method=post action=agecalc3.php
Enter your date of birth, in mm/dd/ format: br /
input type=text name=dob /
input type=submit name=submit value=Submit /
/form
br /br /
form method=post action=agecalc3.php
Enter your kitten's name: br /
input type=text name=cat /
input type=submit name=submit value=Submit Kitten /
/form

HTML;

}

?

Jim Lucas



Jim -

Thanks.

Would you please look at the code you wrote again.  I must have 
botched it, because both the age and kitten form still are on the 
same page.  The age page should appear, the data should be accepted 
and then the kitten page should appear.


Ethan


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




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



[PHP] Regex for telephone numbers

2010-12-29 Thread Ethan Rosenberg

Dear List -

Thank you for all your help in the past.

Here is another one

I would like to have a regex  which would validate that a telephone 
number is in the format xxx-xxx-.


Thanks.

Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)] 




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



[PHP] goto - My comments

2010-12-18 Thread Ethan Rosenberg

Dear List -

Thanks to all for your EXCELLENT comments.  I definitly agree that 
goto is a command to be avoided at all costs.  In this case, I could 
not figure out how to acheive the desired result without the 
goto.  So being a newbie, I humbly request that you show [and at 
the same time teach] me how to rewrite the code to eleiminate the goto.


Additionally, would you please do the same for the code I list 
below.  This code runs perfectly.

==
This is the form:

html
head
titleData Search/title
centerh4/bData Search/h3/center
/head
body

form action=srchrhsptl2.php method=post

centerSite: input type=text name=Site value=AA /
Record Number: input type=text name=MedRec  /
First Name: input type=text name=Fname /
Last Name: input type=text name=Lname /br /br /
Phone: input type=text name=Phone /
Height: input type=decimal name=Height //inputbr /br /
Maleinput type=radio name=Sex value = 0/input
Femaleinput type=radio name=Sex value = 1/inputbr /br /br /
input type=submit /br /br /
input type=reset value = Clear Form  //center
/form

/body
/html

***
This is the program -

htmlbody
titleSearch of Data/title
pre
?php

require '/var/www/pass.inc';

$db = hospital2;

$cxn = mysqli_connect($host,$user,$password,$db);

$ste = $_POST['Site'];
$req = $_POST['MedRec'];
$fnm = $_POST['Fname'];
$lnm = $_POST['Lname'];
$phn = $_POST['Phone'];
$hgt = $_POST['Height'];
//$sex = $_REQUEST['Sex'];
//print_r($_POST);

$sitedone = 0;
$recdone = 0;
$fnmdone = 0;
$lnmdone = 0;
$phndone = 0;
$hgtdone = 0;
$sexdone = 0;

$sql1 =  select * from  Intake3 where ;
if(isset($_POST['Site'])  trim($_POST['Site']) != '')
{
$sql1 = $sql1 . site = '$ste';
$sitedone = 1;
goto end;
}


 if(isset($_POST['MedRec']) trim($_POST['MedRe']) != '')
{
$sql1 = $sql1 . MedRec = '$req';
$recdone = 1;
goto end;
}

if(isset($_POST['Fname']) trim($_POST['Fname']) != '')
{
$sql1 = $sql1 . Fname = '$fnm;
$fnmdone = 1;
goto end;
}

if(isset($_POST['Lname']) trim($_POST['Lname']) != '')
{
$sql1 = $sql1 . Lname  = '$lnm';
$lnmdone = 1;
goto end;
}

if(isset($_POST['Phone']) trim($_POST['Phone']) != '')
{
$sql1 = $sql1 . Phone = '$phn';
$phndone = 1;
}

if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
if ($_REQUEST[Sex] == 0)
$sex = 'Male';
else
$sex = 'Female';

$sql1 = $sql1 .   = '$sex';
$sexdone = 1;
}

if(isset($_POST['Hx']) trim($_POST['Hx']) != '')
{
$sql1 = $sql1 . Hx  = '$hx';
$done = 1;
}


end:

if ($sitedone == 1)
goto recder;
if ($sitedone == 0)
{
if(isset($_POST['Site'])  trim($_POST['Site']) != '')
{
$sql1 = $sql1 .(Site = '$ste');
goto recder;
}
}

recder:
if ($recdone == 1)
goto fnmer;
if ($recdone == 0)
{
if(isset($_POST['MedRec']) trim($_POST['MedRec']) != '')
{
$sql1 = $sql1 .(MedRec = '$req');
$recdone = 1;
goto fnmer;
}
}


fnmer:
if($fnmdone == 1)
goto lnmer;
if($fnmdone == 0)
{
if(isset($_POST['Fname']) trim($_POST['Fname']) != '')
{
$sql1 = $sql1 .(Fname = '$fnm');
$fnmdone = 1;
goto lnmer;
}
}

lnmer:
if($lnmdone == 1)
goto phner;
if($lnmdone == 0)
{
if(isset($_POST['Lname']) trim($_POST['Lname']) != '')
{
$sql1 = $sql1 .(Lname = '$lnm');
$lnmdone = 1;
goto phner;
}
}

phner:
if($phndone == 1)
goto hgter;
if($phndone == 0)
{
if(isset($_POST['Phone']) trim($_POST['Phone']) != '')
{
$sql1 = $sql1 .(Phone = '$phn');
$phndone = 1;
goto hgter;
}
}

hgter:
if($hgtdone == 1)
goto sexer;
if($hgtdone == 0)
{
if(isset($_POST['Height']) trim($_POST['Height']) != '')
{
$sql1 = $sql1 .(Height = '$hgt');
$hgtdone = 1;
goto sexer;
}
}

sexer:
if($sexdone == 1)
goto ender;
if($sexdone == 0)
{
if(isset($_REQUEST['Sex']) trim($_REQUEST['Sex']) != '')
{
$sql1 = $sql1 .(sex = '$sex');
$done = 1;
goto ender;
}
}



ender:

$sql1 = $sql1 . ;;
printf(br /);
//printf($sql1);
$result = mysqli_query($cxn, $sql1);

if(($num = mysqli_num_rows($result)) == 0)
die (No Records Retrieved);
?
centerbSearch Results/b/centerbr /

centertable border=4 cellpadding=5 
cellspacing=55  rules=all frame=box

tr class=\heading\
thSite/th
thMedical Record/th
thFirst Name/th
thLast Name/th
thPhone/td
thHeight/td
thSex/td
thHistory/td
/tr

?php
//  printf(br /To exit, click the EXIT button below.br /br 
/);
//  printf(%s\t%s\t%s\t%s\t%sbr /,Site,Record, Weight, 
Height, BMI);

while($row = mysqli_fetch_array($result))

{

[PHP] Problems w/ goto

2010-12-17 Thread Ethan Rosenberg

Dear List -

I am sending this again since it does not seem to have posted.

Ethan
+++
Dear List -

Thank you with your excellent help in the past.  Here is another puzzler

I am trying to write a program that can have two(2) independent forms 
in one PHP file.  When I run the code below [from PHP - A Beginner's 
Guide], to which I have added a second form, it freezes.  Without the 
goto statements, it runs.  When it does run, it displays both forms 
on one Web screen. What I desire is for the first form to be 
displayed, the data entered and then the second form displayed.  In 
an actual, not test program like this one, the data in the second 
form would be dependent on the first form.


What did I do wrong?

Thanks in advance.

Here is the code:


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   DTD/xhtml1-transitional.dtd
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
  head
titleProject 4-4: Age Calculator/title
  /head
  body
h2Project 4-4: Age Calculator/h2
?php
// if form not yet submitted
// display form

$ender = 0;
begin:

if($ender == 1)
exit();
if (!isset($_POST['dob']))
{
start1:

echo   form method=\post\ action=\agecalc2.php\;
echo   Enter your date of birth, in mm/dd/ format: br /;
echo   input type=\text\ name=\dob\ /;
echo   p;
echo   input type=\submit\ name=\submit\ value=\Submit\ /;
echo   /form;

goto begin;
// if form submitted
// process form input
}
else
{
starter:
if (isset($_POST['cat']))
goto purr;
  // split date value into components
  $dateArr = explode('/', $_POST['dob']);

  // calculate timestamp corresponding to date value
  $dateTs = strtotime($_POST['dob']);

  // calculate timestamp corresponding to 'today'
  $now = strtotime('today');

  // check that the value entered is in the correct format
  if (sizeof($dateArr) != 3) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the value entered is a valid date
  if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the date entered is earlier than 'today'
  if ($dateTs = $now) {
die('ERROR: Please enter a date of birth earlier than today');
  }

  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo You are approximately $ageYears years and $ageMonths months old.;
  goto meow;
 }

meow:
if (!isset($_POST['dob']))
goto begin;
if (!isset($_POST['cat']))
{


echo   form method=\post\ action=\agecalc2.php\;
echo   br /br /Enter your kitten's name: br /;
echo   input type=\text\ name=\cat\ /;
echo   p;
echo   input type=\submit\ name=\submit\ value=\Submit 
Kitten\ /;

echo /form;

}
else
{
purr:
$name_cat = $_POST['cat'];

echo Your Kitten is $name_cat;
$ender = 1;
}
if ($ender == 0)
goto begin;
first_step:
?

  /body
/html



Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)]  




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



[PHP] Closing Browser

2010-12-02 Thread Ethan Rosenberg

Dear List -

How do I close the browser window, with a script [shell or Perl], 
after I exit PHP?


Thanks.

Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)] 




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



[PHP] Eclipse Manual

2010-11-22 Thread Ethan Rosenberg

Dear list -

Does anyone have a URL for the manual for Eclipse/PHP.

Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)] 




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



Re: [PHP] Questions from a Newbie

2010-10-19 Thread Ethan Rosenberg

Tamara -

Thanks.

No error_log.

This works ...

htmlbody
?php phpinfo(); ?
/body/html

Ethan
++
At 02:23 AM 10/19/2010, Tamara Temple wrote:

On Oct 18, 2010, at 11:01 PM, Ethan Rosenberg wrote:



I've added the code you suggest, and I still get a blank screen.
Should I be explicitly be using mysqli functions; eg mysqli_connect?

Odd you should still get a blank screen and nothing in the error_log...

Does phpinfo() work?


Ethan

At 11:00 PM 10/18/2010, you wrote:

Where do you set $host, $user and $password?

You should add the following after the new mysqli statement:

if ($mysqli-connect_error) {
   die('Connect Error (' . $mysqli-connect_errno . ') '
   . $mysqli-connect_error);
}

Tamara Temple
-- aka tamouse__
mailto:tam...@tamaratemple.comtam...@tamaratemple.com


May you never see a stranger's face in the mirror.

On Oct 18, 2010, at 4:09 PM, Ethan Rosenberg wrote:


At 05:37 PM 10/17/2010, Tamara Temple wrote:

gah, i botched that up.

For the first part, you want the following:

   $cxn = new mysql($host, $user, $password);
   $res = $cxn-query(create database test22:);
   if (!$res) {
   die(Failed to create database test22:  . 
$cxn- error());

   }

Then, reopen the connection with the new data base:

   $cxn = new mysql($host, $user, $password, test22);

Then the following code will work.


Tamara Temple
   -- aka tamouse__
mailto:tam...@tamaratemple.comtam...@tamaratemple.com


May you never see a stranger's face in the mirror.

On Oct 17, 2010, at 4:26 PM, Tamara Temple wrote:



On Oct 17, 2010, at 1:22 PM, Ethan Rosenberg wrote:

At 01:41 AM 10/17/2010, Tommy Pham wrote:

 I cannot get the following to work.  In my Firefox [Iceweasel]
browser, I
 enter the following URL: [w/ the http]


Whenever you get a blank screen running a php application, the
place
to look is the http server's error_log. This is frequently found
in / var/log/httpd/error_log or /var/log/apache2/error_log. (If
your
system is hosted someplace else, it could very easily be in a
different place). Typically you need root permission to read this
file. Tail the file after you run your PHP script to see the most
recent errors.


 The code  contained in the file CreateNew.php is:

 /*
   *  Create Database test22
   */
   htmlbody
 ?php
 $cxn = mysqli_connect($host,$user,$password);


Better to use the OO approach:

   $cxn = new mysqli($host, $user, $password);


 echoCreate database test22;


Instead of echo statements (which would just echo the contents to
the output, i.e., your browser, you want to assign them to a
variable, such as:

  $sql = create database test22; use test22;

Then you need to execute the sql statement:

   $res = $cxn-query($sql);
   if (!$res) {
   die(Could not create database test22:  . 
$cxn- error());

   }


 echoCreate table Names2


   $sql = create table Names2


 (
  RecordNum Int(11) Primary Key Not null default=1
auto_increment,
  FirstName varchar(10),
  LastName varchar(10),
  Height  decimal(4,1),
  Weight0 decimal(4,1),
  BMI decimal(3,1)
  Date0 date
 );


 ; // to close off the php statement
   $res = $cxn-query($sql);
   if (!$res) {
   die(Could not create table Names2:  . $cxn- error());
   }



 echo   Create table Visit2


   $sql = create table Visit2


 (
  Indx Int(7) Primary Key Not null auto_increment,
  Weight decimal(4,1) not null,
  StudyDate date not null,
  RecordNum Int(11)
 );


   ; // again, to close off the php statement
   $res = $cxn-query($sql);
   if (!$res) {
   die(Could not create table Visit2:  . $cxn- error());
   }



  $sql= SHOW DATABASES;


This doesn't work in a programmatic setting.

Terminate the database connection:

   $cxn-close();


 ?
 /body/html



 I would also like to be able to add data to a table, using
PHP,
which I
can do
 in MySQL as:
 load data infile '/home/ethan/Databases/tester21.dat.' replace
into table
 Names fields escaped by '\\' terminated by '\t'  lines
terminated by '\n'
;


That's a specific feature of the mysql program. You'd have to
write
something in php to be able to parse the file and insert the data.
There are examples all over the net. Then you would need to set up
sql insert or replace statements to actually get the data into the
data base using mysqli::query. There are numerous examples of this
as well.

Here's one example:

?php

   $host = localhost;
   $user = root;
   $pwd = rootpassword;
   $db = test22;
   $table = table_to_insert_into;

   $cxn = new mysql($host, $user, $pwd, $db);

   $filename = tab-delimited.txt;
   $contents = file($filename); // returns the contents of
the file
into an array, one line of file per array

   $columns = explode(\t, $contents[0]); // get the column
names
from the first line

RE: [PHP] Questions from a Newbie

2010-10-19 Thread Ethan Rosenberg

Dear List -

The error log only exists if he configures it properly and the script has
error.  IE: log_errors  error_log.

I already had done that prior to the post.  That came from the 
manual, the necessary section thereof which had been read.


Now what?

Ethan
++
At 08:31 AM 10/19/2010, Tommy Pham wrote:

 -Original Message-
 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: Tuesday, October 19, 2010 12:05 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Questions from a Newbie

 Tamara -

 Thanks.

 No error_log.


The error log only exists if he configures it properly and the script has
error.  IE: log_errors  error_log.  Like I said, Ethan should start from
the beginning of the manual.  It covers the configuration of PHP in addition
to the fundamentals of PHP.

 This works ...

 htmlbody
 ?php phpinfo(); ?
 /body/html

 Ethan
 ++
 At 02:23 AM 10/19/2010, Tamara Temple wrote:
 On Oct 18, 2010, at 11:01 PM, Ethan Rosenberg wrote:
 
 
 I've added the code you suggest, and I still get a blank screen.
 Should I be explicitly be using mysqli functions; eg mysqli_connect?
 Odd you should still get a blank screen and nothing in the error_log...
 
 Does phpinfo() work?
 
 Ethan
 
 At 11:00 PM 10/18/2010, you wrote:
 Where do you set $host, $user and $password?
 
 You should add the following after the new mysqli statement:
 
 if ($mysqli-connect_error) {
 die('Connect Error (' . $mysqli-connect_errno . ') '
 . $mysqli-connect_error); }
 
 Tamara Temple
 -- aka tamouse__
 mailto:tam...@tamaratemple.comtam...@tamaratemple.com
 
 
 May you never see a stranger's face in the mirror.
 
 On Oct 18, 2010, at 4:09 PM, Ethan Rosenberg wrote:
 
 At 05:37 PM 10/17/2010, Tamara Temple wrote:
 gah, i botched that up.
 
 For the first part, you want the following:
 
 $cxn = new mysql($host, $user, $password);
 $res = $cxn-query(create database test22:);
 if (!$res) {
 die(Failed to create database test22:  .
  $cxn- error());
 }
 
 Then, reopen the connection with the new data base:
 
 $cxn = new mysql($host, $user, $password, test22);
 
 Then the following code will work.
 
 
 Tamara Temple
 -- aka tamouse__
 mailto:tam...@tamaratemple.comtam...@tamaratemple.com
 
 
 May you never see a stranger's face in the mirror.
 
 On Oct 17, 2010, at 4:26 PM, Tamara Temple wrote:
 
 
 On Oct 17, 2010, at 1:22 PM, Ethan Rosenberg wrote:
 At 01:41 AM 10/17/2010, Tommy Pham wrote:
   I cannot get the following to work.  In my Firefox
   [Iceweasel]
 browser, I
   enter the following URL: [w/ the http]
 
 Whenever you get a blank screen running a php application, the
 place to look is the http server's error_log. This is frequently
 found in / var/log/httpd/error_log or /var/log/apache2/error_log.
 (If your system is hosted someplace else, it could very easily be
 in a different place). Typically you need root permission to read
 this file. Tail the file after you run your PHP script to see the
 most recent errors.
 
   The code  contained in the file CreateNew.php is:
  
   /*
 *  Create Database test22
 */
 htmlbody
   ?php
   $cxn = mysqli_connect($host,$user,$password);
 
 Better to use the OO approach:
 
 $cxn = new mysqli($host, $user, $password);
 
   echoCreate database test22;
 
 Instead of echo statements (which would just echo the contents to
 the output, i.e., your browser, you want to assign them to a
 variable, such as:
 
$sql = create database test22; use test22;
 
 Then you need to execute the sql statement:
 
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create database test22:  .
  $cxn- error());
 }
 
   echoCreate table Names2
 
 $sql = create table Names2
 
   (
RecordNum Int(11) Primary Key Not null default=1
 auto_increment,
FirstName varchar(10),
LastName varchar(10),
Height  decimal(4,1),
Weight0 decimal(4,1),
BMI decimal(3,1)
Date0 date
   );
 
   ; // to close off the php statement
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create table Names2:  . $cxn-
error());
 }
 
  
   echo   Create table Visit2
 
 $sql = create table Visit2
 
   (
Indx Int(7) Primary Key Not null auto_increment,
Weight decimal(4,1) not null,
StudyDate date not null,
RecordNum Int(11)
   );
 
 ; // again, to close off the php statement
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create table Visit2:  . $cxn-
error());
 }
 
  
$sql= SHOW DATABASES;
 
 This doesn't work in a programmatic setting.
 
 Terminate the database connection:
 
 $cxn-close();
 
   ?
   /body/html
 
   I would also like to be able to add data to a table, using
 PHP,
 which I

RE: [PHP] Questions from a Newbie - Please Help

2010-10-19 Thread Ethan Rosenberg

Dear List -

I've checked the php.ini file [again] and cannot find any errors.

I wrote a PHP script to open a non-existent data base, and receive no error.

At this point, I am out of options.

Let's all look at the code, and tell me 1]where the error is and 
2]any corrections or additions to the ini file.


For personal reasons, which I cannot explain in a public forum, I am 
under extreme pressure to learn PHP ASAP.


Thank you.

Ethan
+++

At 08:31 AM 10/19/2010, Tommy Pham wrote:

 -Original Message-
 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: Tuesday, October 19, 2010 12:05 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Questions from a Newbie

 Tamara -

 Thanks.

 No error_log.


The error log only exists if he configures it properly and the script has
error.  IE: log_errors  error_log.  Like I said, Ethan should start from
the beginning of the manual.  It covers the configuration of PHP in addition
to the fundamentals of PHP.

 This works ...

 htmlbody
 ?php phpinfo(); ?
 /body/html

 Ethan
 ++
 At 02:23 AM 10/19/2010, Tamara Temple wrote:
 On Oct 18, 2010, at 11:01 PM, Ethan Rosenberg wrote:
 
 
 I've added the code you suggest, and I still get a blank screen.
 Should I be explicitly be using mysqli functions; eg mysqli_connect?
 Odd you should still get a blank screen and nothing in the error_log...
 
 Does phpinfo() work?
 
 Ethan
 
 At 11:00 PM 10/18/2010, you wrote:
 Where do you set $host, $user and $password?
 
 You should add the following after the new mysqli statement:
 
 if ($mysqli-connect_error) {
 die('Connect Error (' . $mysqli-connect_errno . ') '
 . $mysqli-connect_error); }
 
 Tamara Temple
 -- aka tamouse__
 mailto:tam...@tamaratemple.comtam...@tamaratemple.com
 
 
 May you never see a stranger's face in the mirror.
 
 On Oct 18, 2010, at 4:09 PM, Ethan Rosenberg wrote:
 
 At 05:37 PM 10/17/2010, Tamara Temple wrote:
 gah, i botched that up.
 
 For the first part, you want the following:
 
 $cxn = new mysql($host, $user, $password);
 $res = $cxn-query(create database test22:);
 if (!$res) {
 die(Failed to create database test22:  .
  $cxn- error());
 }
 
 Then, reopen the connection with the new data base:
 
 $cxn = new mysql($host, $user, $password, test22);
 
 Then the following code will work.
 
 
 Tamara Temple
 -- aka tamouse__
 mailto:tam...@tamaratemple.comtam...@tamaratemple.com
 
 
 May you never see a stranger's face in the mirror.
 
 On Oct 17, 2010, at 4:26 PM, Tamara Temple wrote:
 
 
 On Oct 17, 2010, at 1:22 PM, Ethan Rosenberg wrote:
 At 01:41 AM 10/17/2010, Tommy Pham wrote:
   I cannot get the following to work.  In my Firefox
   [Iceweasel]
 browser, I
   enter the following URL: [w/ the http]
 
 Whenever you get a blank screen running a php application, the
 place to look is the http server's error_log. This is frequently
 found in / var/log/httpd/error_log or /var/log/apache2/error_log.
 (If your system is hosted someplace else, it could very easily be
 in a different place). Typically you need root permission to read
 this file. Tail the file after you run your PHP script to see the
 most recent errors.
 
   The code  contained in the file CreateNew.php is:
  
   /*
 *  Create Database test22
 */
 htmlbody
   ?php
   $cxn = mysqli_connect($host,$user,$password);
 
 Better to use the OO approach:
 
 $cxn = new mysqli($host, $user, $password);
 
   echoCreate database test22;
 
 Instead of echo statements (which would just echo the contents to
 the output, i.e., your browser, you want to assign them to a
 variable, such as:
 
$sql = create database test22; use test22;
 
 Then you need to execute the sql statement:
 
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create database test22:  .
  $cxn- error());
 }
 
   echoCreate table Names2
 
 $sql = create table Names2
 
   (
RecordNum Int(11) Primary Key Not null default=1
 auto_increment,
FirstName varchar(10),
LastName varchar(10),
Height  decimal(4,1),
Weight0 decimal(4,1),
BMI decimal(3,1)
Date0 date
   );
 
   ; // to close off the php statement
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create table Names2:  . $cxn-
error());
 }
 
  
   echo   Create table Visit2
 
 $sql = create table Visit2
 
   (
Indx Int(7) Primary Key Not null auto_increment,
Weight decimal(4,1) not null,
StudyDate date not null,
RecordNum Int(11)
   );
 
 ; // again, to close off the php statement
 $res = $cxn-query($sql);
 if (!$res) {
 die(Could not create table Visit2:  . $cxn-
error());
 }
 
  
$sql= SHOW DATABASES;
 
 This doesn't work in a programmatic

RE: [PHP] mytr...@mail.us auto responder

2010-10-18 Thread Ethan Rosenberg

At 12:07 PM 10/18/2010, Tommy Pham wrote:

 -Original Message-
 From: Steve Staples [mailto:sstap...@mnsi.net]
 Sent: Monday, October 18, 2010 6:59 AM
 To: php-general
 Subject: [PHP] mytr...@mail.us auto responder

 I think I recall seeing a post about this earlier, but can this PLEASE get
 removed, or use an email account that doesn't require me to be friends with
 you??

 Granted, a simple reply would get rid of it, but why use an account that
 requires authorization in the first place?

 snipped at english
 -- english ---

 Confirmation is required to send your message to mytr...@mail.ua


 My antispam system detected your message as possible SPAM, because
 your address is not listed in my address book (white list).

 To confirm that your message is not a spam, please open the following
 link:
 http://www.mytrash.mail.ua/confirm/1287409388.H34971P12680.mx.mail.u
 a

 After that your address will be automatically added into my address book
 and you will be able to send me messages from Steve Staples
 sstap...@mnsi.net without any additional checks.

 You can also use my personal webpage and send me a message anytime:
 http://www.mytrash.mail.ua.

 Thank you,
 sender owner mytr...@mail.ua
 /snip


 sorry if I am coming across rude or anything.


I don't think you do.  Moreover, I think it's a scam to try to get 
your e-mail address upon reply so they can then spam you since it's 
a 'confirmed e-mail address' ... .  I honestly think this address 
should just be removed from the list, IMHO.


Regards,
Tommy


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



Dear List -

Address confirmation is a commonly used to prevent Spam, since 
spammers use false email addressed. I would like to remind you that 
this is used by this mail list and  I do the same as do may 
companies.  If I choose not to read the email, I delete the email and 
the address.  I also have the option to not add the book sender to my 
address book.  The Spam filter I use is provided by earthlink and 
similar filters are used by most ISPs.


I hope  this clarifies the issue.

Ethan



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



RE: [PHP] Questions from a Newbie

2010-10-17 Thread Ethan Rosenberg



At 01:41 AM 10/17/2010, Tommy Pham wrote:

 -Original Message-
 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: Saturday, October 16, 2010 10:01 PM
 To: php-general@lists.php.net
 Subject: [PHP] Questions from a Newbie

 Dear List -

 Here are some questions, which I am sure are trivial, but I am a newbie,
and
 cannot find the answers online

 I cannot get the following to work.  In my Firefox [Iceweasel] browser, I
 enter the following URL: [w/ the http]

   localhost/CreateNew.php All I get is a blank browser screen.

 The code  contained in the file CreateNew.php is:

 /*
   *  Create Database test22
   */
   htmlbody
 ?php
 $cxn = mysqli_connect($host,$user,$password);
 echoCreate database test22;
 echoCreate table Names2
 (
  RecordNum Int(11) Primary Key Not null default=1
auto_increment,
  FirstName varchar(10),
  LastName varchar(10),
  Height  decimal(4,1),
  Weight0 decimal(4,1),
  BMI decimal(3,1)
  Date0 date
 );

 echo   Create table Visit2
 (
  Indx Int(7) Primary Key Not null auto_increment,
  Weight decimal(4,1) not null,
  StudyDate date not null,
  RecordNum Int(11)
 );

  $sql= SHOW DATABASES;
 ?
 /body/html

 If I search for test22 or Visit2, nothing is found.

 I would also like to be able to add data to a table, using PHP, which I
can do
 in MySQL as:
 load data infile '/home/ethan/Databases/tester21.dat.' replace into table
 Names fields escaped by '\\' terminated by '\t'  lines terminated by '\n'
;

 Thanks in advance.

 Ethan
 ===
 Using Debian(sid)


You're reinventing the wheel that's been rolling along very smoothly for a
long time... Google 'phpmyadmin'.  Also, read this entire section [1].

Regards,
Tommy

[1] http://www.php.net/manual/en/book.mysqli.php


Tommy -

Thanks.

As I stated, I am a newbie.

1] I am trying to shorten the learning curve by asking some 
questions, which I understand are probably trivial.  A whole MySQLi 
list of functions at this point is to much for me.  I have to break 
the problem into manageable parts.


2] It has been my experience that using a GUI does not teach the 
whole subject.  Linux, which is the OS I use cannot be run from a GUI.


In the code being discussed, I wish to create a database and add two 
tables.  I also note a MySQL statement that can be used to add data 
to an existing table, and wish to be able to execute this statement 
using PHP.


So, therefore..

Let us try to answer the following two(2) questions:

a] What changes [other than moving the simicolons] have to be made to 
correct the code.


b] What books can you suggest to help w/ MySQL and PHP?  I already 
have the SQL, MySQL  PHP, and HTML books in the . for Dummies 
series.  I need something with a little more depth and detail.


Thanks to all for your excellent help.

Ethan

 Using Debian(sid)
 




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



[PHP] Questions from a Newbie

2010-10-16 Thread Ethan Rosenberg

Dear List -

Here are some questions, which I am sure are trivial, but I am a 
newbie, and cannot find the answers online


I cannot get the following to work.  In my Firefox [Iceweasel] 
browser, I enter the following URL: [w/ the http]


 localhost/CreateNew.php All I get is a blank browser screen.

The code  contained in the file CreateNew.php is:

/*
 *  Create Database test22
 */
 htmlbody
?php
$cxn = mysqli_connect($host,$user,$password);
echoCreate database test22;
echoCreate table Names2
(
RecordNum Int(11) Primary Key Not null default=1 auto_increment,
FirstName varchar(10),
LastName varchar(10),
Height  decimal(4,1),
Weight0 decimal(4,1),
BMI decimal(3,1)
Date0 date
);

echo   Create table Visit2
(
Indx Int(7) Primary Key Not null auto_increment,
Weight decimal(4,1) not null,
StudyDate date not null,
RecordNum Int(11)
);

$sql= SHOW DATABASES;
?
/body/html

If I search for test22 or Visit2, nothing is found.

I would also like to be able to add data to a table, using PHP, which 
I can do in MySQL as:
load data infile '/home/ethan/Databases/tester21.dat.' replace into 
table Names fields escaped by '\\' terminated by '\t'  lines 
terminated by '\n' ;


Thanks in advance.

Ethan
===
Using Debian(sid)  




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