[PHP] Error checking ON

2013-07-17 Thread Tedd Sperling
Hi gang:

Considering:

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

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

This is what I do for error checking:

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

Is this:

1. Sufficient?

2. An overkill?

3. OK?

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

Cheers,

tedd

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


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



Re: [PHP] Error checking ON

2013-07-17 Thread Daniel Brown
On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote:
 Hi gang:

 Considering:

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

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

 This is what I do for error checking:

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

 Is this:

 1. Sufficient?

 2. An overkill?

 3. OK?

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

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

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



Re: [PHP] Error checking ON

2013-07-17 Thread Tedd Sperling
On Jul 17, 2013, at 11:55 AM, Daniel Brown danbr...@php.net wrote:
 On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote:
 This is what I do for error checking:
 
ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'On');
ini_set('log_errors', 'On');
ini_set('error_log', 'error_log');
 
 Is this:
 
 1. Sufficient?
 
 2. An overkill?
 
 3. OK?
 
 4. OR, better served with this (and provide an example).
 
That's standard practice.  Sometimes, though, it isn't enough, and
 we find ourselves using Derick's Xdebug, mod_top, or performing an
 strace on either the execution or attached to a process.  For nearly
 all cases, though, that's sufficient without being overkill (except
 for production cases).
 

Daniel:

Thanks -- I always wondered about that.

Cheers,

tedd

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

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

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



Re: [PHP] Error checking ON

2013-07-17 Thread Jim Lucas

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

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

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

This is what I do for error checking:

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

Is this:

1. Sufficient?

2. An overkill?

3. OK?

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


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



Daniel:

Thanks -- I always wondered about that.

Cheers,

tedd

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

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



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


--
Jim Lucas

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

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



[PHP] Error checking on file upload

2005-08-19 Thread Peppy
I've been working on a script for uploading a file to a Unix server. I'm 
testing the script and have it coded for error messages using a switch 
statement.  One error that I am getting is case 2 The file is bigger than this 
form allows and I am wondering what might cause me to get the error for case 1 
The file is bigger than this PHP installation allows.

Thank you,
Althea


form enctype=multipart/form-data action=getfile.php method=POST
!-- MAX_FILE_SIZE must precede the file input field --
input type=hidden name=MAX_FILE_SIZE value=5 /

!-- Name of input element determines name in $_FILES array --
Send this file: input name=userfile type=file /
br /br /
input type=submit value=Send File /
/form

-
$uploaddir = '/home/httpd/vhosts/foxedge.net/httpdocs/lvs/phpclass/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo 'pre';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo File is valid, and was successfully uploaded.\n;
} else {
   echo Possible file upload attack!\n;
switch ($_FILES['userfile'] ['error'])
 {  case 1:
   print 'p The file is bigger than this PHP installation 
allows/p';
   break;
case 2:
   print 'p The file is bigger than this form allows/p';
   break;
case 3:
   print 'p Only part of the file was uploaded/p';
   break;
case 4:
   print 'p No file was uploaded/p';
   break;
   
 }
}

echo 'Here is some more debugging info:';
print_r($_FILES);

echo /pre;




Re: [PHP] Error checking on file upload

2005-08-19 Thread Steve Slotnick
In your php.ini there are settings for upload_max_filesize and also 
post_max_size. These would be causes for case 2. More information: 
http://us3.php.net/features.file-upload


On 8/19/05, Peppy  [EMAIL PROTECTED] wrote:
 
 I've been working on a script for uploading a file to a Unix server. I'm 
 testing the script and have it coded for error messages using a switch 
 statement. One error that I am getting is case 2 The file is bigger than 
 this form allows and I am wondering what might cause me to get the error 
 for case 1 The file is bigger than this PHP installation allows.
 
 Thank you,
 Althea
 
 
 form enctype=multipart/form-data action=getfile.php method=POST
 !-- MAX_FILE_SIZE must precede the file input field -- 
 input type=hidden name=MAX_FILE_SIZE value=5 /
 
 !-- Name of input element determines name in $_FILES array --
 Send this file: input name=userfile type=file / 
 br /br /
 input type=submit value=Send File /
 /form
 
 -
 $uploaddir = 
 '/home/httpd/vhosts/foxedge.net/httpdocs/lvs/phpclass/uploads/'; 
 $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
 
 echo 'pre';
 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
 echo File is valid, and was successfully uploaded.\n; 
 } else {
 echo Possible file upload attack!\n;
 switch ($_FILES['userfile'] ['error'])
 { case 1:
 print 'p The file is bigger than this PHP installation allows/p';
 break;
 case 2:
 print 'p The file is bigger than this form allows/p';
 break;
 case 3:
 print 'p Only part of the file was uploaded/p';
 break;
 case 4:
 print 'p No file was uploaded/p';
 break;
 
 }
 }
 
 echo 'Here is some more debugging info:';
 print_r($_FILES);
 
 echo /pre;
 
 
 



Re: [PHP] Error checking on file upload

2005-08-19 Thread Steve Slotnick
Sorry, I meant case 1.

- Steve

On 8/19/05, Steve Slotnick [EMAIL PROTECTED] wrote:
 
 In your php.ini there are settings for upload_max_filesize and also 
 post_max_size. These would be causes for case 2. More information: 
 http://us3.php.net/features.file-upload
 
 
 On 8/19/05, Peppy  [EMAIL PROTECTED] wrote:
  
  I've been working on a script for uploading a file to a Unix server. I'm 
  testing the script and have it coded for error messages using a switch 
  statement. One error that I am getting is case 2 The file is bigger than 
  this form allows and I am wondering what might cause me to get the error 
  for case 1 The file is bigger than this PHP installation allows.
  
  Thank you,
  Althea
  
  
  form enctype=multipart/form-data action=getfile.php method=POST
  !-- MAX_FILE_SIZE must precede the file input field -- 
  input type=hidden name=MAX_FILE_SIZE value=5 /
  
  !-- Name of input element determines name in $_FILES array --
  Send this file: input name=userfile type=file / 
  br /br /
  input type=submit value=Send File /
  /form
  
  -
  $uploaddir = 
  '/home/httpd/vhosts/foxedge.net/httpdocs/lvs/phpclass/uploads/'; 
  $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  
  echo 'pre';
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
  echo File is valid, and was successfully uploaded.\n; 
  } else {
  echo Possible file upload attack!\n;
  switch ($_FILES['userfile'] ['error'])
  { case 1:
  print 'p The file is bigger than this PHP installation allows/p';
  break;
  case 2:
  print 'p The file is bigger than this form allows/p';
  break;
  case 3:
  print 'p Only part of the file was uploaded/p';
  break;
  case 4:
  print 'p No file was uploaded/p';
  break;
  
  }
  }
  
  echo 'Here is some more debugging info:';
  print_r($_FILES);
  
  echo /pre;
  
  
  
  



Re: [PHP] Error checking on file upload

2005-08-19 Thread Peppy
Steve,

Thanks a bunch. Must have been dead brain today.  I knew that as well as
could look it up using phpinfo().

Althea

In your php.ini there are settings for upload_max_filesize and also
post_max_size. These would be causes for case 2. More information:
http://us3.php.net/features.file-upload


On 8/19/05, Peppy  [EMAIL PROTECTED] wrote:

 I've been working on a script for uploading a file to a Unix server. I'm
 testing the script and have it coded for error messages using a switch
 statement. One error that I am getting is case 2 The file is bigger than
 this form allows and I am wondering what might cause me to get the error
 for case 1 The file is bigger than this PHP installation allows.

 Thank you,
 Althea


 form enctype=multipart/form-data action=getfile.php method=POST
 !-- MAX_FILE_SIZE must precede the file input field --
 input type=hidden name=MAX_FILE_SIZE value=5 /

 !-- Name of input element determines name in $_FILES array --
 Send this file: input name=userfile type=file /
 br /br /
 input type=submit value=Send File /
 /form

 -
 $uploaddir =
 '/home/httpd/vhosts/foxedge.net/httpdocs/lvs/phpclass/uploads/';
 $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

 echo 'pre';
 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
 echo File is valid, and was successfully uploaded.\n;
 } else {
 echo Possible file upload attack!\n;
 switch ($_FILES['userfile'] ['error'])
 { case 1:
 print 'p The file is bigger than this PHP installation allows/p';
 break;
 case 2:
 print 'p The file is bigger than this form allows/p';
 break;
 case 3:
 print 'p Only part of the file was uploaded/p';
 break;
 case 4:
 print 'p No file was uploaded/p';
 break;

 }
 }

 echo 'Here is some more debugging info:';
 print_r($_FILES);

 echo /pre;





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



Re: [PHP] error checking woes

2005-08-01 Thread Kristen G. Thorson

Jack,

Read below:



Jack Jackson wrote:


Hi,
Now that the drop down is working properly (thanks!!), I am trying to 
validate, and having LOTS of trouble. After being ceaselessly derided 
last night on an irc channel for my dimwitedness, I am still not any 
closer.


The code which works is this:

function GetQuestionsDropdown($cat){
//first get all the questions

$sql = SELECT * FROM questions WHERE questions.q_cat=$cat AND 
questions.q_style=1;


$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {
   //if the form has been submitted, and the question 
unanswered

//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){





How does this funtion have access to $message?  You need to a) make it 
global or b) pass it in.




echo div class='error';
}
   //Make a question set div wrapper
echo div class='q_set'\n;
//State the question
echo div class='question';
echo $row['q_text'] . /div;
echo \n\n;
echo  div class='answer';
echo \n;
   //Create the dropdown for the answers
echo '  select name=' . $row['q_name'] . '';
echo \n;
   //get all of the answers for THIS question
$ans_sql = select * from answers where answers.q_id= . 
$row['q_id'];

$ans_result = mysql_query($ans_sql);

echo option value=\\Select from this list/option\n;
while($ans_row = mysql_fetch_assoc($ans_result)) {
   //list the answers for THIS question
echo option ;
echo value=\ . $ans_row['a_id'] . \;

if  ($row['q_name'] == $ans_row['a_id']) {
echo  selected;
}

echo  . $ans_row['a_answer'] . /option;
echo \n;
}
echo '  /select' . \n . ' /div' . \n;
echo /div!--q_set--\n\n;
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo /div!--/error--;
}
}
}//function GetQuestionsDropdown


NOW I have to validate after it's submitted. I am trying to look and 
see, if $_POST[$row['q_name']] is empty then make message of the same 
name = 1, so if


   if(empty($_POST['partners'])) {
   $message['partners'] = '1'
}

Then when I restate the dropdown function, and it shows the questions 
again,  those error checking things I built in will

a) show a div class=error around questions with a message
b) pre-select the previously selected answers (because I have put 
in the thing in the dropdown which says


 if ($row['q_name'] == $ans_row['a_id']) { echo  selected;}


The validate code I was trying, the subject of such howling on IRC 
(and I know it doesn't work, but not why) was:


function ValidatePost($cat){
//first get the q_names
$sql = SELECT * FROM questions WHERE q_cat=$cat;
$result = mysql_query($sql);

//go through the question set
while($row = mysql_fetch_assoc($result)) {
  if(empty($_POST[$row['q_name']])){
  $message[$row['q_name']] == 1;





You want $message = 1 here.  = = is for comparison.

You're setting $message inside a function.  This means it doesn't exist 
outside this scope!




  }
}
}//function ValidatePost

Can anyone tell me what I am doing wrong?

Thanks!
JJ





Hope this helps you get somewhere,

kgt



Re: [PHP] error checking woes

2005-08-01 Thread Jack Jackson



Kristen G. Thorson wrote:

Thanks for the  ==  !

But I had set $message global within the buld-checkbox function, so that 
part of it does work. . . .







Jack,

Read below:



Jack Jackson wrote:


Hi,
Now that the drop down is working properly (thanks!!), I am trying to 
validate, and having LOTS of trouble. After being ceaselessly derided 
last night on an irc channel for my dimwitedness, I am still not any 
closer.


The code which works is this:

function GetQuestionsDropdown($cat){
//first get all the questions

$sql = SELECT * FROM questions WHERE questions.q_cat=$cat AND 
questions.q_style=1;


$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {
   //if the form has been submitted, and the question 
unanswered

//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){






How does this funtion have access to $message?  You need to a) make it 
global or b) pass it in.




echo div class='error';
}
   //Make a question set div wrapper
echo div class='q_set'\n;
//State the question
echo div class='question';
echo $row['q_text'] . /div;
echo \n\n;
echo  div class='answer';
echo \n;
   //Create the dropdown for the answers
echo '  select name=' . $row['q_name'] . '';
echo \n;
   //get all of the answers for THIS question
$ans_sql = select * from answers where answers.q_id= . 
$row['q_id'];

$ans_result = mysql_query($ans_sql);

echo option value=\\Select from this list/option\n;
while($ans_row = mysql_fetch_assoc($ans_result)) {
   //list the answers for THIS question
echo option ;
echo value=\ . $ans_row['a_id'] . \;

if  ($row['q_name'] == $ans_row['a_id']) {
echo  selected;
}

echo  . $ans_row['a_answer'] . /option;
echo \n;
}
echo '  /select' . \n . ' /div' . \n;
echo /div!--q_set--\n\n;
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo /div!--/error--;
}
}
}//function GetQuestionsDropdown


NOW I have to validate after it's submitted. I am trying to look and 
see, if $_POST[$row['q_name']] is empty then make message of the same 
name = 1, so if


   if(empty($_POST['partners'])) {
   $message['partners'] = '1'
}

Then when I restate the dropdown function, and it shows the questions 
again,  those error checking things I built in will

a) show a div class=error around questions with a message
b) pre-select the previously selected answers (because I have put 
in the thing in the dropdown which says


 if ($row['q_name'] == $ans_row['a_id']) { echo  selected;}


The validate code I was trying, the subject of such howling on IRC 
(and I know it doesn't work, but not why) was:


function ValidatePost($cat){
//first get the q_names
$sql = SELECT * FROM questions WHERE q_cat=$cat;
$result = mysql_query($sql);

//go through the question set
while($row = mysql_fetch_assoc($result)) {
  if(empty($_POST[$row['q_name']])){
  $message[$row['q_name']] == 1;






You want $message = 1 here.  = = is for comparison.

You're setting $message inside a function.  This means it doesn't exist 
outside this scope!




  }
}
}//function ValidatePost

Can anyone tell me what I am doing wrong?

Thanks!
JJ





Hope this helps you get somewhere,

kgt




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



Re: [PHP] error checking woes- SOLVED

2005-07-31 Thread Jack Jackson
I did the smart thing last night: nothing. I read some PHP books and 
then realized that the answer to my error checking was a lot less 
complex, once again, than I had initially suspected. I finally ended up 
with:



 //error checking
foreach($_POST as $qname=$value) {
if(empty($value)){
$message[$qname]=1;
}
}


I cannot believe what I started with and what I ended up with.

Thanks as usual for the help!!

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



[PHP] error checking a null array

2005-07-31 Thread Jack Jackson

hi,
I have checkboxes beging dynamically generated. to seperate tasks in 
error checking I have added he arrays not just to $_POST but to 
$_POST[cb]  so names (derived from question numbers) are for example:


$_POST[cb][7]

A dump of $_POST would therefore include something like

[cb]=  array(1) { [7]=  array(1) { [0]=  string(3) 124 } }

 So I did this:

//error checking for checkboxes 
foreach ($cb as $cbkey = $cbvalue)
   {
  foreach($cbvalue as $cbkey2=$cb_answers)
  {
 if( !array_key_exists($_POST[$cbkey], $cb));
 {
 $message[$cbkey]=1;
 }
   }
   }

This almost works. The problem is that if someone doesn't check a 
checkbox, NOTHING related to the checkbox gets sent to $_POST; if I 
insert a hidden value of something, then that hidden value gets passed 
whether the user inputs something or not, since I need an entirely 
server-side solution. Is there a way to send something to tell the error 
checker whether for example $_POST[cb][7] is empty or null, so I can set 
the error message to one if it's empty?


Dump of $_POST with no checkboxes checked
$_POST:
array(4) { [action]= string(7) process [cat]= string(1) 2 
[rs]= array(3) { [5]= string(0)  [6]= string(0)  [9]= 
string(0)  } [b]= string(8) Continue }


Dump of $_POST with checkboxes checked

array(5) { [action]=  string(7) process [cat]=  string(1) 2 
[cb]=  array(2) { [7]=  array(5) { [0]=  string(1) 3 [1]= 
string(3) 124 [2]=  string(3) 125 [3]=  string(3) 127 [4]= 
string(3) 131 } [8]=  array(3) { [0]=  string(3) 141 [1]= 
string(3) 145 [2]=  string(1) 4 } } [rs]=  array(3) { [5]= 
string(0)  [6]=  string(0)  [9]=  string(0)  } [b]= 
string(8) Continue }



Thanks so much In advance

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



[PHP] error checking woes

2005-07-30 Thread Jack Jackson

Hi,
Now that the drop down is working properly (thanks!!), I am trying to 
validate, and having LOTS of trouble. After being ceaselessly derided 
last night on an irc channel for my dimwitedness, I am still not any closer.


The code which works is this:

function GetQuestionsDropdown($cat){
//first get all the questions

$sql = SELECT * FROM questions WHERE questions.q_cat=$cat AND 
questions.q_style=1;


$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {

//if the form has been submitted, and the question unanswered
//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){
echo div class='error';
}

//Make a question set div wrapper
echo div class='q_set'\n;
//State the question
echo div class='question';
echo $row['q_text'] . /div;
echo \n\n;
echo  div class='answer';
echo \n;

//Create the dropdown for the answers
echo '  select name=' . $row['q_name'] . '';
echo \n;

//get all of the answers for THIS question
$ans_sql = select * from answers where answers.q_id= . $row['q_id'];
$ans_result = mysql_query($ans_sql);

echo option value=\\Select from this list/option\n;
while($ans_row = mysql_fetch_assoc($ans_result)) {

//list the answers for THIS question
echo option ;
echo value=\ . $ans_row['a_id'] . \;

if  ($row['q_name'] == $ans_row['a_id']) {
echo  selected;
}

echo  . $ans_row['a_answer'] . /option;
echo \n;
}
echo '  /select' . \n . ' /div' . \n;
echo /div!--q_set--\n\n;
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo /div!--/error--;
}
}
}//function GetQuestionsDropdown


NOW I have to validate after it's submitted. I am trying to look and 
see, if $_POST[$row['q_name']] is empty then make message of the same 
name = 1, so if


   if(empty($_POST['partners'])) {
   $message['partners'] = '1'
}

Then when I restate the dropdown function, and it shows the questions 
again,  those error checking things I built in will

a) show a div class=error around questions with a message
	b) pre-select the previously selected answers (because I have put in 
the thing in the dropdown which says


 if ($row['q_name'] == $ans_row['a_id']) { echo  selected;}


The validate code I was trying, the subject of such howling on IRC (and 
I know it doesn't work, but not why) was:


function ValidatePost($cat){
//first get the q_names
$sql = SELECT * FROM questions WHERE q_cat=$cat;
$result = mysql_query($sql);

//go through the question set
while($row = mysql_fetch_assoc($result)) {

  if(empty($_POST[$row['q_name']])){

  $message[$row['q_name']] == 1;
  }
}
}//function ValidatePost

Can anyone tell me what I am doing wrong?

Thanks!
JJ

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



Re: [PHP] error checking woes

2005-07-30 Thread Jack Jackson


Okay, last attempt before I hit my head against wall. I thought perhaps 
to add the error check to the dropdown function itself:




function GetQuestionsDropdown($cat){
//first get all the questions

$sql = SELECT * FROM questions WHERE questions.q_cat=$cat AND 
questions.q_style=1;


$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {

//if the form has been submitted, and the question unanswered
//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){
echo div class='error';
}

//Make a question set div wrapper
echo div class='q_set'\n;
//State the question
echo div class='question';
echo $row['q_text'] . /div;
echo \n\n;
echo  div class='answer';
echo \n;

//Create the dropdown for the answers
echo '  select name=' . $row['q_name'] . '';
echo \n;

//get all of the answers for THIS question
$ans_sql = select * from answers where answers.q_id= . $row['q_id'];
$ans_result = mysql_query($ans_sql);

echo option value=\\Select from this list/option\n;
while($ans_row = mysql_fetch_assoc($ans_result)) {

//list the answers for THIS question
echo option ;
echo value=\ . $ans_row['a_id'] . \;

if  ($row['q_name'] == $ans_row['a_id']) {
echo  selected;
}

echo  . $ans_row['a_answer'] . /option;
echo \n;
}
echo '  /select' . \n . ' /div' . \n;
echo /div!--q_set--\n\n;
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo /div!--/error--;
}
//error checking
if ( !strcmp($action,'process') ) {
  if(empty($_POST[$row['q_name']])){
  $message[$row['q_name']] == 1;
  }
}


}
}//function GetQuestionsDropdown




it didn't work either.










Jack Jackson wrote:

Hi,
Now that the drop down is working properly (thanks!!), I am trying to 
validate, and having LOTS of trouble. After being ceaselessly derided 
last night on an irc channel for my dimwitedness, I am still not any 
closer.


The code which works is this:

function GetQuestionsDropdown($cat){
//first get all the questions

$sql = SELECT * FROM questions WHERE questions.q_cat=$cat AND 
questions.q_style=1;


$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {
   
//if the form has been submitted, and the question unanswered

//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){
echo div class='error';
}
   
//Make a question set div wrapper

echo div class='q_set'\n;
//State the question
echo div class='question';
echo $row['q_text'] . /div;
echo \n\n;
echo  div class='answer';
echo \n;
   
//Create the dropdown for the answers

echo '  select name=' . $row['q_name'] . '';
echo \n;
   
//get all of the answers for THIS question

$ans_sql = select * from answers where answers.q_id= . $row['q_id'];
$ans_result = mysql_query($ans_sql);

echo option value=\\Select from this list/option\n;
while($ans_row = mysql_fetch_assoc($ans_result)) {
   
//list the answers for THIS question

echo option ;
echo value=\ . $ans_row['a_id'] . \;

if  ($row['q_name'] == $ans_row['a_id']) {
echo  selected;
}

echo  . $ans_row['a_answer'] . /option;
echo \n;
}
echo '  /select' . \n . ' /div' . \n;
echo /div!--q_set--\n\n;
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo /div!--/error--;
}
}
}//function GetQuestionsDropdown


NOW I have to validate after it's submitted. I am trying to look and 
see, if $_POST[$row['q_name']] is empty then make message of the same 
name = 1, so if


   if(empty($_POST['partners'])) {
   $message['partners'] = '1'
}

Then when I restate the dropdown function, and it shows the questions 
again,  those error checking things I built in will

a) show a div class=error around questions with a message
b) pre-select the previously selected answers (because I have put in 
the 

[PHP] Error checking

2005-05-23 Thread Michael Satterwhite

I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors for me?


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



Re: [PHP] Error checking

2005-05-23 Thread Philip Hallstrom

I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors for me?


take a read through here...

http://us2.php.net/errorfunc

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



Re: [PHP] Error checking

2005-05-23 Thread John Nichel

Michael Satterwhite wrote:

I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors for 
me?




display_errors = On

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Error checking

2005-05-23 Thread Michael Satterwhite

John Nichel wrote:

Michael Satterwhite wrote:


I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors 
for me?




display_errors = On


Thanks for the reply.

My config file does have
display_errors = On

I should have put that in my first email. I would have felt *VERY* 
stupid if I'd forgotten that one - and I do sometimes have enought brain 
freeze to forget things like this. Unfortunately, it's already set.


Thanks again.
---Michael

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



Re: [PHP] Error checking

2005-05-23 Thread Christophe Chisogne
Michael Satterwhite a écrit :
 in /etc/php4/apache, I have the setting

I guess you mean /etc/php4/apache/php.ini

 error_reporting  =  E_ALL  ~E_NOTICE

You'll get all errors but warnings (ex unused var). What you want is

error_reporting  =  E_ALL 

Ch.

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



Re: [PHP] Error checking

2005-05-23 Thread Michael Satterwhite

Philip Hallstrom wrote:

I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors 
for me?



take a read through here...

http://us2.php.net/errorfunc


I just read it again (I'd read it before I posted the first message), 
and I don't see *ANYTHING* I'm missing. Obviously, I am missing 
something, but I don't see it. The significant parameters seem to be

error_reporting
and
display_errors

My php.ini has
error_reporting = E_ALL  ~E_NOTICE
display_errors = On (I've also tried display_errors = 1)

A documentation reference is always appreciated (at least by me), and I 
thank you for suggesting I read it again. This time, however, I seem to 
be too dense to see it.


Thanks again
---Michael

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



Re: [PHP] Error checking - Fixed

2005-05-23 Thread Michael Satterwhite
But I have no idea how. I made a series of changes trying to figure out 
what I missed. Most of the changes didn't look like they'd do anything - 
but the error reporting started working.


I then tried changing things back - at least I thought I did. The error 
checking continued to work.


I *HATE* it when I have a problem I can't put my finger on. The 
important thing is that it is working, though.


I want to thank those who helped me out.
---Michael


Michael Satterwhite wrote:

I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors for 
me?




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



Re: [PHP] Error checking

2005-05-23 Thread Janet Valade

Michael Satterwhite wrote:


Philip Hallstrom wrote:


I'm using Apache and PHP4 under debian.

in /etc/php4/apache, I have the setting
error_reporting  =  E_ALL  ~E_NOTICE

but I don't get any errors - even when I've clearly used an undefined 
variable. What else might need to be set to get PHP to report errors 
for me?




You won't see the notice for an undefined variable with this setting. 
You have notices turned off. You will only see warnings and fatal 
errors. If you want to see notices, you need to use the following setting:


error_reporting  =  E_ALL

Janet



--
Janet Valade -- janet.valade.com
--
Janet Valade -- janet.valade.com

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



Re: [PHP] error checking with fread

2003-03-06 Thread Marek Kilimajer
add this check

John Taylor-Johnston wrote:

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

What about error checking if the file contains something as I include below? Is that enough? Is this the right way?

?php
$filename = /usr/local/something.txt;
$handle = fopen ($filename, r);
if(!$handle) die('could not open file for reading');

$contents = fread ($handle, filesize ($filename));
fclose ($handle);
if ($contents){echoformtextarea$contents/textarea/form;}
else{echo no contents there;}
?
 



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


[PHP] error checking with fread

2003-03-05 Thread John Taylor-Johnston
http://www.php.net/manual/en/function.fread.php

What about error checking if the file contains something as I include below? Is that 
enough? Is this the right way?

?php
$filename = /usr/local/something.txt;
$handle = fopen ($filename, r);
$contents = fread ($handle, filesize ($filename));
fclose ($handle);

if ($contents){echoformtextarea$contents/textarea/form;}
else{echo no contents there;}
?


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