Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP beginner Pls. Help?

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
Dear Experts,

I'm having an error, what's wrong with my code.

Notice: Undefined variable: ID in C:\Inetpub\ on line 15

Notice: Undefined variable: Name in C:\Inetpub\ on line 15

Notice: Undefined variable: Address in C:\Inetpub\ on line 15
could not complete your query



Heres my add.php below
------------------------------------------------------------
<?php

$host = &quot;localhost&quot;;
$user = &quot;joel&quot;;
$pass = &quot;&quot;;
$database = &quot;personal&quot;;
$table = &quot;tblpersonal&quot;;

echo &quot;<B>This is a list of items I have in my table named $table</B> <hr>&quot;;

// Connecting to the Database
$connection = @mysql_connect($host, $user, $pass) or die(&quot;could not connect to server&quot;);

@mysql_select_db($database, $connection);

$query = &quot;INSERT INTO $table('ID','Name','Address')VALUES('$ID','$Name','$Address')&quot;;

// Query the Database
$result = @mysql_query($query) or die(&quot;could not complete your query&quot;);

?>

------------------------------------------------------------
and here's my add.htm



<html>

<head>

<title>Add</title>
</head>

<body>

<form method=&quot;POST&quot; action =&quot;add.php&quot;>
<input type=&quot;text&quot; name=&quot;ID&quot; size=&quot;20&quot;></p>
<p><input type=&quot;text&quot; name=&quot;Name&quot; size=&quot;20&quot;></p>
<p><input type=&quot;text&quot; name=&quot;Address&quot; size=&quot;20&quot;></p>
<p><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;></p>
</form>

</body>

</html>

------------------------------------------------------------

Joel,
 
This looks like as if register_globals would be off and yet you are trying to use the form variables as globals. Try using $_POST['ID'], $_POST['Name'] and $_POST['Address'] instead. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top