Help

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Help

Post by rica4th07 »

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.....
Last edited by rica4th07 on Tue Feb 16, 2010 2:13 am, edited 1 time in total.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help

Post by papa »

Use the code tags please.

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"); <---
 
Just took a quick look.
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

oh thx a lot im little bit of a tired thx...
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

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
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help

Post by papa »

Code: Select all

unset($numOfError):
Should be:

Code: Select all

unset($numOfError);
Also a good way of coding is to use intendation:

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
 
 
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

<?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
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

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.....
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help

Post by papa »

Define action in the beginning of your script

<?php
$action = "";
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

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...
rica4th07
Forum Newbie
Posts: 8
Joined: Mon Feb 15, 2010 6:36 am

Re: Help

Post by rica4th07 »

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">
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Re: Help

Post by emmbec »

Mods, shouldn't this be moved to some other forum? And shouldn't CODE TAGS be used instead?

rica4th07, read the rules please so it can be easier for us to help you. :D
Post Reply