Help with Error from a simple Create databasetable.
Posted: Fri Mar 19, 2004 10:28 am
Below is the code for the html page:
Below is the PHP code to set up the table:
Below is the Error:
Notice: Use of undefined constant table_name - assumed 'table_name' on line 2
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 2
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Any Ideas?
Code: Select all
<html>
<head>
<title>Create a Database Table: Step 1</title>
</head>
<body>
<h1>Step 1: Name and Number </h1>
<form method="POST" action="do_showfielddef.php">
<p><strong>Table Name:</strong><br>
<input type="text" name="table_name" size=30></p>
<p><strong>Number of Fields:</strong><br>
<input type="text" name="num_fields" size=5></p>
<p><input type="submit" name="submit" value="Go to Step 2"></p>
</form>
</body>
</html>Code: Select all
<?php
if ((!$_POST[table_name]) || (!$_POST[num_fields])) {
header("Location: http://127.0.0.1/testing/show_createtable.html");
exit;
}
$form_block = "
<FORM METHOD="POST" ACTION="do_createtable.php">
<INPUT TYPE="hidden" NAME="table_name" VALUE="$_POST[table_name]">
<TABLE CELLSPACING=5 CELLPADDING=5>
<TR>
<TH>FIELD NAME</TH><TH>FIELD TYPE</TH><TH>FIELD LENGTH</TH></TR>";
for ($i=0; $i < $_POST[num_fields]; $i++) {
$form_block .="
<TR>
<TD ALIGN=CENTER><INPUT TYPE="text" NAME="field_name[]" SIZE="30"></TD>
<TD ALIGN=CENTER>
<SELECT NAME = "field_type[]">
<OPTION VALUE="char">char</OPTION>
<OPTION VALUE="date">date</OPTION>
<OPTION VALUE="float">float</OPTION>
<OPTION VALUE="int">int</OPTION>
<OPTION VALUE="text">text</OPTION>
<OPTION VALUE="varchar">varchar</OPTION>
</SELECT>
</TD>
<TD ALIGN=CENTER><INPUT TYPE="text" NAME="field_length[]" SIZE="5"></TD>
</TR>";
}
$form_block .="
<TR>
<TD ALIGN=CENTER COLSPAN=3><INPUT TYPE="submit" VALUE="Create Table"></TD>
</TR>
</TABLE>
</FORM>";
?>
<html>
<head>
<title>Create a Database Table: Step 2</title>
</head>
<body>
<H1>Define fields for <? echo "$_POST[table_name]"; ?></H1>
<? echo "$form_block"; ?>
</body>
</html>Notice: Use of undefined constant table_name - assumed 'table_name' on line 2
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 2
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Notice: Use of undefined constant num_fields - assumed 'num_fields' on line 12
Any Ideas?