Help
Moderator: General Moderators
Help
can you help me??? about this code nid imediately!!!!
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") { <----------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 22
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum']
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php")
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError):
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php);
} // endelse
} elseif ($action == "delete") { <--------------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 75
/* ... */
}
?>
<?php
if (!isset($numOfError)) {
$action = $_GET['action']; <--------Notice: Undefined index: action in /opt/lampp/htdocs/sample2/sample.php on line 82
$id = $_GET['id']; <--------------------Notice: Undefined index: id in /opt/lampp/htdocs/sample2/sample.php on line 83
...over at formentry.php ...
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
...
} elseif ($action == "add") {
$dateField = "";
...
}
}
?>
pls help me im just starting to learn php.....
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") { <----------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 22
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum']
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php")
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError):
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php);
} // endelse
} elseif ($action == "delete") { <--------------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 75
/* ... */
}
?>
<?php
if (!isset($numOfError)) {
$action = $_GET['action']; <--------Notice: Undefined index: action in /opt/lampp/htdocs/sample2/sample.php on line 82
$id = $_GET['id']; <--------------------Notice: Undefined index: id in /opt/lampp/htdocs/sample2/sample.php on line 83
...over at formentry.php ...
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
...
} elseif ($action == "add") {
$dateField = "";
...
}
}
?>
pls help me im just starting to learn php.....
Last edited by rica4th07 on Tue Feb 16, 2010 2:13 am, edited 1 time in total.
Re: Help
Use the code tags please.
Just took a quick look.
Code: Select all
// validate and double
$anyNum = $_POST['anyNum']; <--
...
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php"); <---
Re: Help
Parse error: syntax error, unexpected ':', expecting ';' in /opt/lampp/htdocs/sample2/sample.php on line 66
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum'];
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php");
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError):
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php);
} // endelse
} elseif ($action == "delete") {
/* ... */
}
?>
another prob pls help.... thx
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum'];
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php");
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError):
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php);
} // endelse
} elseif ($action == "delete") {
/* ... */
}
?>
another prob pls help.... thx
Re: Help
Code: Select all
unset($numOfError):Code: Select all
unset($numOfError);Code: Select all
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError);
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php"); <-- also parse error before
} // endelse
Re: Help
<?php
if (!isset($numOfError)) {
$action = $_GET['action'];
$id = $_GET['id'];
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
... <-------------------------- the error is in here....
} elseif ($action == "add") {
$dateField = "";
...
}
}
?>
Parse error: syntax error, unexpected '.' in /opt/lampp/htdocs/sample2/sample.php on line 88
help me pls coz im a newbie in php nid some help
if (!isset($numOfError)) {
$action = $_GET['action'];
$id = $_GET['id'];
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
... <-------------------------- the error is in here....
} elseif ($action == "add") {
$dateField = "";
...
}
}
?>
Parse error: syntax error, unexpected '.' in /opt/lampp/htdocs/sample2/sample.php on line 88
help me pls coz im a newbie in php nid some help
Re: Help
rica4th07 wrote:can you help me??? about this code nid imediately!!!!
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") { <----------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 22
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum']
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php")
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError):
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php);
} // endelse
} elseif ($action == "delete") { <--------------- Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 75
/* ... */
}
?>
<?php
if (!isset($numOfError)) {
$action = $_GET['action']; <--------Notice: Undefined index: action in /opt/lampp/htdocs/sample2/sample.php on line 82
$id = $_GET['id']; <--------------------Notice: Undefined index: id in /opt/lampp/htdocs/sample2/sample.php on line 83
...over at formentry.php ...
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
...
} elseif ($action == "add") {
$dateField = "";
...
}
}
?>
pls help me im just starting to learn php.....
Re: Help
sir the error is in there nothing happend
<?php
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 22
same error.... sir
i stock in here and dont know what to do....
thx 4 d help...
<?php
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
Notice: Undefined variable: action in /opt/lampp/htdocs/sample2/sample.php on line 22
same error.... sir
i stock in here and dont know what to do....
thx 4 d help...
Re: Help
can u help me?? pls identify the errors thx....
sorry im a newbie in here nid some tutorials.....
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum'];
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php");
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError);
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php");
} // endelse
} elseif ($action == "delete") {
/* ... */
}
?>
<?php
if (!isset($numOfError)) {
$action = $_GET['action'];
$id = $_GET['id'];
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
} elseif ($action == "add") {
$dateField = "";
}
}
?>
...over at formentry.php
<?php
if (isset($msg)) {
echo $msg;
}
?>
<script language="JavaScript">
<!--
function validForm(thisForm) {
if (thisForm.s.value =="") {
alert("you must a string");
thisForm.s.focus():
return false:
}
if ( thisForm.n.value <= 0) {
alert("Number must be greater than 0");
thisForm.n.focus();
return false;
}
if ( (thisform.projectCost.value =="") || isNaN(thisForm.projectCost.value) ) {
alert("Project Cost field must have a number or 0");
thisForm.projectCost.focus();
return false;
}
/* is you want to allow user to enter a number or nothing at all, then remove
the check for "": */
if ( isNaN(thisForm.projectCost.value) ) {
alert("Project Cost field must be a number");
return false;
}
/* using isNan() -- "is Not a Number" -- is more effective than this next version
becuse this 2nd version will not aler when user enters something like
453,344 --'cuz as long as user enters a number in the first few entiries, it
*/
if ( !((thisForm.n2.value > 0) || (thisForm.n2.value <= 0)) ) {
alert("You must enter a number" );
return false;
}
return true;
}
//-->
</script>
...
<FORM onSubmit="return validForm(this)" ACTION="praction.php" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
sorry im a newbie in here nid some tutorials.....
<?php
function isIntegerVip($n) {
$n2 = (int) $n;
$s = (string) $n;
$s2 = (string) $n2;
if ($s == $s2) {
return true;
} else {
return false;
}
}
function isValidDateVip($dateToCheck) {
$date_elements = exploe("/", $dateToCheck);
if (checkdate($date_elements[0], $date_elements[1], $date_elements[2])) {
return true;
} else {
return false;
}
}
if ($action == "add" OR $action == "edit") {
$numOfError = 0;
$msg = "";
// validate integer
$intEntry = $_POST['intEntry'];
if (!isIntegerVip($intEntry)) {
$numOfError = $numOfError + 1;
$msg = $msg . "intEntry field must be an integer. ";
}
// validate and double
$anyNum = $_POST['anyNum'];
if (is_numeric($anyNum)) {
$numOfError = $numOfError + 1;
$msg = $msg . "anyNum field must be a number. ";
}
// validate blank field
$txtField = $_POST['txtfield'];
if (trim($txtField) == "") {
$numOfError = $numOfError + 1;
$msg = $msg . "txtField must not be blank. ";
}
// validate date field
$dateField = $_POST['dateField'];
if (!isValidDateVip($dateField)) {
$numOfError = $numOfError + 1;
$msg = $msg . "dateField field must be a valid date. ";
}
if($numOfError > 0) {
/* if validation catches error, let user
enter corrected fields
*/
include_once("formentry.php");
} else {
/* if no more validation errors, move on
to processing. In case you need to go back
to formentry.php with no more validation
errors, make sure to unset $numOfErrors so it doesn't
assume there are errors:
*/
unset($numOfError);
if ($action == "add") {
mysql_querry("INSERT...");
} elseif ($action == "edit") {
mysql_query("UPDATE...");
}
include_once("listentry.php");
} // endelse
} elseif ($action == "delete") {
/* ... */
}
?>
<?php
if (!isset($numOfError)) {
$action = $_GET['action'];
$id = $_GET['id'];
if ($action == "edit") {
$result = mysql_querry("SELECT...");
$row = @mysql_fetch_object($result);
$dateField = date("n/j/y", strtotime($row->dateField));
} elseif ($action == "add") {
$dateField = "";
}
}
?>
...over at formentry.php
<?php
if (isset($msg)) {
echo $msg;
}
?>
<script language="JavaScript">
<!--
function validForm(thisForm) {
if (thisForm.s.value =="") {
alert("you must a string");
thisForm.s.focus():
return false:
}
if ( thisForm.n.value <= 0) {
alert("Number must be greater than 0");
thisForm.n.focus();
return false;
}
if ( (thisform.projectCost.value =="") || isNaN(thisForm.projectCost.value) ) {
alert("Project Cost field must have a number or 0");
thisForm.projectCost.focus();
return false;
}
/* is you want to allow user to enter a number or nothing at all, then remove
the check for "": */
if ( isNaN(thisForm.projectCost.value) ) {
alert("Project Cost field must be a number");
return false;
}
/* using isNan() -- "is Not a Number" -- is more effective than this next version
becuse this 2nd version will not aler when user enters something like
453,344 --'cuz as long as user enters a number in the first few entiries, it
*/
if ( !((thisForm.n2.value > 0) || (thisForm.n2.value <= 0)) ) {
alert("You must enter a number" );
return false;
}
return true;
}
//-->
</script>
...
<FORM onSubmit="return validForm(this)" ACTION="praction.php" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">