469,964 Members | 1,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Undefined index: errors

[client 127.0.0.1] PHP Notice: Undefined index: name in
/home/www/reformcagunlaws.com/new.php on line 6
[client 127.0.0.1] PHP Notice: Undefined index: address in
/home/www/reformcagunlaws.com/new.php on line 7
[client 127.0.0.1] PHP Notice: Undefined index: city in
/home/www/reformcagunlaws.com/new.php on line 8
[client 127.0.0.1] PHP Notice: Undefined index: county in
/home/www/reformcagunlaws.com/new.php on line 9
[client 127.0.0.1] PHP Notice: Undefined index: zip in
/home/www/reformcagunlaws.com/new.php on line 10
[client 127.0.0.1] PHP Notice: Undefined index: phone in
/home/www/reformcagunlaws.com/new.php on line 11
[client 127.0.0.1] PHP Notice: Undefined index: email in
/home/www/reformcagunlaws.com/new.php on line 12
[client 127.0.0.1] PHP Notice: Undefined index: volunteer in
/home/www/reformcagunlaws.com/new.php on line 13
[client 127.0.0.1] PHP Notice: Undefined index: contacted in
/home/www/reformcagunlaws.com/new.php on line 14
[client 127.0.0.1] PHP Notice: Undefined index: delivered in
/home/www/reformcagunlaws.com/new.php on line 15

-bash-2.05b$ cat new.php
<?
$user="root";
#$password="password";
$database="rcgl-petitions";

$name=$_POST['name'];
$address=$_POST['address'];
$city=$_POST['city'];
$county=$_POST['county'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$volunteer=$_POST['volunteer'];
$contacted=$_POST['contacted'];
$delivered=$_POST['delivered'];

#mysql_connect(localhost,$user,$password);
mysql_connect('localhost',$user);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO petitions VALUES
('','$name','$address','city','county','zip','$pho ne','$email','$volunteer','contacted','deliverd')" ;
mysql_query($query);

mysql_close();
?>

--
* John Oliver http://www.john-oliver.net/ *
* Reform California gun laws - http://www.reformcagunlaws.com/ *
* http://www.gunownersca.com - http://www.crpa.org/ *
* San Diego shooters come to http://shooting.forsandiego.com/ *
Dec 1 '05 #1
4 6942
EmC
John Oliver ha scritto:
[client 127.0.0.1] PHP Notice: Undefined index: name in
/home/www/reformcagunlaws.com/new.php on line 6
[client 127.0.0.1] PHP Notice: Undefined index: address in
/home/www/reformcagunlaws.com/new.php on line 7
[client 127.0.0.1] PHP Notice: Undefined index: city in
/home/www/reformcagunlaws.com/new.php on line 8
[client 127.0.0.1] PHP Notice: Undefined index: county in
/home/www/reformcagunlaws.com/new.php on line 9
[client 127.0.0.1] PHP Notice: Undefined index: zip in
/home/www/reformcagunlaws.com/new.php on line 10
[client 127.0.0.1] PHP Notice: Undefined index: phone in
/home/www/reformcagunlaws.com/new.php on line 11
[client 127.0.0.1] PHP Notice: Undefined index: email in
/home/www/reformcagunlaws.com/new.php on line 12
[client 127.0.0.1] PHP Notice: Undefined index: volunteer in
/home/www/reformcagunlaws.com/new.php on line 13
[client 127.0.0.1] PHP Notice: Undefined index: contacted in
/home/www/reformcagunlaws.com/new.php on line 14
[client 127.0.0.1] PHP Notice: Undefined index: delivered in
/home/www/reformcagunlaws.com/new.php on line 15

-bash-2.05b$ cat new.php
<?
$user="root";
#$password="password";
$database="rcgl-petitions";

$name=$_POST['name'];
$address=$_POST['address'];
$city=$_POST['city'];
$county=$_POST['county'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$volunteer=$_POST['volunteer'];
$contacted=$_POST['contacted'];
$delivered=$_POST['delivered'];

#mysql_connect(localhost,$user,$password);
mysql_connect('localhost',$user);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO petitions VALUES
('','$name','$address','city','county','zip','$pho ne','$email','$volunteer','contacted','deliverd')" ;
mysql_query($query);

mysql_close();
?>

hallo,
try to declare your variables by double quoting
$name=$_POST["name"]; instead of $name=$_POST['name'];
Hope this can help you.
Bye.
Enrico
Dec 1 '05 #2
*** John Oliver escribió/wrote (01 Dec 2005 21:05:38 GMT):
[client 127.0.0.1] PHP Notice: Undefined index: name in
/home/www/reformcagunlaws.com/new.php on line 6 $name=$_POST['name'];
A notice is not an error. You've just configured PHP to warn you when you
use an non initialized variable. Try:

$name = isset($_POST['name']) ? $_POST['name'] : NULL;
$query = "INSERT INTO petitions VALUES
('','$name','$address','city','county','zip','$pho ne','$email','$volunteer','contacted','deliverd')" ;
mysql_query($query);


Read some documentation about SQL-Injection.
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Dec 1 '05 #3
On Thu, 1 Dec 2005 22:44:09 +0100, Alvaro G. Vicario wrote:
$query = "INSERT INTO petitions VALUES
('','$name','$address','city','county','zip','$pho ne','$email','$volunteer','contacted','deliverd')" ;
mysql_query($query);


Read some documentation about SQL-Injection.


I know jack squat about MySQL and PHP. That's right out of some online
tutorial I found. And, since it doesn't seem to work...

I need a tutorial or something I can follow along that isn't going to
lie to me about how to do things ;-)

--
* John Oliver http://www.john-oliver.net/ *
* Reform California gun laws - http://www.reformcagunlaws.com/ *
* http://www.gunownersca.com - http://www.crpa.org/ *
* San Diego shooters come to http://shooting.forsandiego.com/ *
Dec 2 '05 #4
EmC said the following on 01/12/2005 21:27:
John Oliver ha scritto:

<SNIP>

hallo,
try to declare your variables by double quoting
$name=$_POST["name"]; instead of $name=$_POST['name'];


This will make precisely zero difference.

--
Oli
Dec 2 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by lawrence | last post: by
5 posts views Thread by news.bigpond.com | last post: by
7 posts views Thread by Coder Droid | last post: by
3 posts views Thread by number1yan | last post: by
9 posts views Thread by simple12 | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.