PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
facets
Forum Contributor
Posts: 273 Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit
Post
by facets » Wed May 11, 2005 12:18 am
Hey Gang,
Could some one point me in the right direction.
I thought I was setting the variables with the $_GET lines below.
Cheers, Will
Code: Select all
<?
include "../includes/functions.inc";
include "../includes/common_db.inc";
$link_id = db_connect($db_materials);
// Set global variables to easier names
$description = $_GET['description'];
$basisWeight = $_GET['basisWeight'];
$sql_add = "INSERT INTO austock values('','$description','$basisWeight','','','','','','','','','','','','','','','','','','')";
mysql_query($sql_add) or die(mysql_error());
?>
<form method='get' action='<?php echo $_SERVER['PHP_SELF']; ?>'>
<table class=\"sample\"><tr>
<td width=200px colspan=2 valign=top >Description</td>
<td width=200px colspan=3><input type='text' name='description' SIZE="20"></td></tr>
<tr><td width=200px colspan=2 valign=top>Basis Weight</td>
<td width=200px colspan=3><input type='text' name='basisWeight' SIZE="20"></td></tr>
<tr><td width=200px colspan=2 valign=top>Caliper</td>
<td width=200px colspan=3><input type='text' name='caliper' SIZE="20"></td></tr>
<tr><td width=200px colspan=2 valign=top>Wet Tensile Strength CD</td>
<td width=50px colspan=2><input type='text' name='wetTensileStrenghtCD' value="<?php echo $wetTensileStrenghtCD ?>" SIZE="20"></td></tr>
<tr><td width=200px colspan=2 valign=top>Dry Tensile Strength CD</td>
<td width=50px colspan=2><input type='text' name='wetTensileStrenghtMD' value="<?php echo $wetTensileStrenghtMD ?>" SIZE="20"></td</tr>
<tr><td width=100px colspan=2 valign=top><input type='reset' class='btn' value='Reset Face Stock'></td>
<td width=100px colspan=3><input type='submit' name='addFs' class='btn' value='Add Face Stock'></td></tr>
</form>
<?
?>
andre_c
Forum Contributor
Posts: 412 Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah
Post
by andre_c » Wed May 11, 2005 12:25 am
what's the exact error?
MaxBlast-PHP
Forum Newbie
Posts: 9 Joined: Fri Mar 25, 2005 1:11 am
Post
by MaxBlast-PHP » Wed May 11, 2005 12:26 am
First of are you getting any errors?
second of all why do you have at the end
that might be your problem try something like
facets
Forum Contributor
Posts: 273 Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit
Post
by facets » Wed May 11, 2005 12:48 am
Sorry guys..
Code: Select all
Notice: Undefined index: description in c:\program files\easyphp1-8\www\materialsregister\newtest.php on line 16
Notice: Undefined index: basisWeight in c:\program files\easyphp1-8\www\materialsregister\newtest.php on line 17
php_wiz_kid
Forum Contributor
Posts: 181 Joined: Tue Jun 24, 2003 7:33 pm
Post
by php_wiz_kid » Wed May 11, 2005 1:12 am
What is your error_reporting set to in your php.ini? It might be that it's set to E_ALL and in that case you need to check if your global variables (_GET, _POST, etc...) exist using isset. If they don't exist it'll error out giving you an undefined index warning. Here's what I do:
Code: Select all
function set_make_null(&$global) {
if(!isset($global)) {
$global = "";
}
}
Pass the global variables that are erroring out into the function and see if that helps at all.
facets
Forum Contributor
Posts: 273 Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit
Post
by facets » Wed May 11, 2005 1:16 am
Sure..
I guess what i'm asking is what is the correct way (read 'standards') of handling globals with globals=off and reporting E_ALL
Obviously I can add the following to remove the notices.
//error_reporting(E_ALL & ~E_NOTICE).
Cheers!
php_wiz_kid
Forum Contributor
Posts: 181 Joined: Tue Jun 24, 2003 7:33 pm
Post
by php_wiz_kid » Wed May 11, 2005 1:17 am
I run PHP with E_ALL and after I asked around a while back the "pro's" told me that setting the global to empty or null is the best, most secure practice. That's just what I've enquired throught his forum.
facets
Forum Contributor
Posts: 273 Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit
Post
by facets » Wed May 11, 2005 1:43 am
If I add
Code: Select all
if(isset($_GET['commented']))
{
echo('Your comment has been posted.');
include "../includes/functions.inc";
include "../includes/common_db.inc"; and
Code: Select all
}
else {
?>
<form method='get' action='<?php echo $_SERVER['PHP_SELF']; ?>'>
<input type='hidden' name=commented value='set'>
The notice's disappear but I don't know why.
Can anyone fill me in?
tia..
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Wed May 11, 2005 3:25 am
the isset() function checks to see if a variable is set, hence the name, does the variable exists. if your case if the variable comment isset then do your echo for comment has been submitted. if comment hasn't been set (in other words doesn't exist)then it will echo your html code.