Unexpected T-string
Moderator: General Moderators
-
darkfreaks
- Forum Commoner
- Posts: 59
- Joined: Sat Sep 09, 2006 3:59 pm
Unexpected T-string
it says there is an unexpected t-string in line 12 of my php file, i cant find it help me guys.
line 12: $form_block ="
line 12: $form_block ="
You haven't properly closed your string.
should be
Code: Select all
line 12: $form_block ="Code: Select all
line 12: $form_block ="";-
darkfreaks
- Forum Commoner
- Posts: 59
- Joined: Sat Sep 09, 2006 3:59 pm
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
darkfreaks
- Forum Commoner
- Posts: 59
- Joined: Sat Sep 09, 2006 3:59 pm
Everah | Please use
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
//validate important input
if ((!$_POST[table_name]) || (!$_POST[num_fields])) {
header ("location:show_createtable.html");
exit;
}
//begin creating form for display
$form_block ="";
<form method="post" action="show_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>";
//count from 0 until you reach the number of fields for
($i = 0; $i < $_POST[num_fields]; $i++) {
//add to the form , one row for each field
$form_block ="";
<TR>
<TD ALIGN=CENTER>
<input type="text" name="field_name[]" size=30></TD>
<TD ALIGN=CENTER>
<select name="field_type[]">
<option value="field">field</option>
<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>
<p>";
}
//finish up the form</p>
$form_block .= "
<TR>
<TD ALIGN=CENTER COLSPAN=3><input type="submit" value="Create Table"></TD>
</TR>
</TABLE>
</FORM>";
?>
<html>
<head>
<title>Cteate Table Step 2</title>
<body>
<h1>Define fields for <? echo $_POST[table_name]; ?>
</h1>
<? echo $form_block ?>
</body>
</html>Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]the whole <form .... text should be part of the string stored in $form_block.
The first " tells php that a string literal begins. The next unescaped " ends the string.
So what doestell php? You can see how the syntaxhighlither changes the color after <form method=". It does not consider post as part of the string; neither does php.
tryThere are two more identical error sources.
Code: Select all
$s = "abc"; ?>So what does
Code: Select all
$form_block ="
<form method="post" action="show_createtable.php">try
Code: Select all
$form_block = '
<form method="post" action="show_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>';missing for($i = 0; $i < $_POST[num_fields]; $i++) {
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Try this one (there are still things in this that need attention, but it is a little better than the originally posted code):
Code: Select all
<?php
//validate important input
if ((!$_POST['table_name']) || (!$_POST['num_fields'])) {
header ("location:show_createtable.html");
exit;
}
//begin creating form for display
$form_block = '
<form method="post" action="show_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>';
//count from 0 until you reach the number of fields for
for ($i = 0; $i < $_POST['num_fields']; $i++) {
//add to the form , one row for each field
$form_block = '
<TR>
<TD ALIGN=CENTER>
<input type="text" name="field_name[]" size=30></TD>
<TD ALIGN=CENTER>
<select name="field_type[]">
<option value="field">field</option>
<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>
';
}
//finish up the form</p>
$form_block .= '
<TR>
<TD ALIGN=CENTER COLSPAN=3><input type="submit" value="Create Table"></TD>
</TR>
</TABLE>
</FORM>';
?>
<html>
<head>
<title>Cteate Table Step 2</title>
<body>
<h1>Define fields for <? echo $_POST['table_name']; ?>
</h1>
<? echo $form_block ?>
</body>
</html>-
darkfreaks
- Forum Commoner
- Posts: 59
- Joined: Sat Sep 09, 2006 3:59 pm
hehe
hmmm seems ive got to code better syntax next time too man errors.
anyways it doesnt give me any errors just page cant be found.
anyways it doesnt give me any errors just page cant be found.
-
darkfreaks
- Forum Commoner
- Posts: 59
- Joined: Sat Sep 09, 2006 3:59 pm
hmmm
Everah | Please use
i can see it on the page err?
and where it says define fields it says
\' . $_POST[\'table_name\'] . \'
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
now it works but at the top is some of the codeCode: Select all
//validate important input if ((!$_POST['table_name']) || (!$_POST['num_fields'])) { header ("location:show_createtable.html"); exit; } //begin creating form for display $form_block = '
FIELD NAME FIELD TYPE FIELD LENGTH
'; //count from 0 until you reach the number of fields for for ($i = 0; $i < $_POST['num_fields']; $i++) { //add to the form , one row for each field $form_block = ' field char date float int text varchar
'; } //finish up the form
$form_block .= 'and where it says define fields it says
\' . $_POST[\'table_name\'] . \'
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
What is your question? And please, when you post code, highlight it then click the PHP button just above the input area. Thanks.
Code: Select all
//validate important input
if ((!$_POST['table_name']) || (!$_POST['num_fields'])) {
header ("location:show_createtable.html");
exit;
}
//begin creating form for display
$form_block = '
FIELD NAME FIELD TYPE FIELD LENGTH
';
//count from 0 until you reach the number of fields for
for ($i = 0; $i < $_POST['num_fields']; $i++)
{
//add to the form , one row for each field
$form_block = ' field char date float int text varchar ';
}
//finish up the form
$form_block .= '