Page 1 of 1

Parse Error

Posted: Fri Mar 11, 2011 10:35 am
by Vinnar
Hay guys

Quick question

Code: Select all

function am_query_display_quick($page,$order ='DATE DESC'){
global $email;
$conn = db_connect_2();
$max_per_page = 50;
$color1 = "tableRowOdd";
$color2 = "tableRowEven";
$RowCount = 0;
$start_row = $page*$max_per_page;
$result = $conn->query("SELECT pro,pro_update,ana,ana_update,cell,cell_update,cellother,cellother_update,gen,gen_update,genother,genother_update,author,author_update,other,other_update
FROM mailing_list
WHERE email = '$email'
ORDER BY $order LIMIT $start_row, $max_per_page;");

echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n";
echo "\t<tr><th>Edit Queries</th><th>Promoter
Locus</th><th>Update?</th><th>Anatomical Area</th><th>Update?</th><th>Cell
Type</th><th>Update?</th><th>Other Cell Type</th><th>Update?</th><th>Genetic
Background</th><th>Update?</th><th>Other Gen.
Back.</th><th>Update?</th><th>Author</th><th>Update?</th><th>Other</th><th>Update?</th>\r\n";
if($result->num_rows){
while ($row = $result->fetch_array()){
$RowCount ++;
$row_color = ($RowCount % 2) ? $color1 : $color2;
echo "\t<tr class=\"$row_color\"><td><input type="submit" name="edit_mail" value = "Edit Queries"></td><td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td>
<td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td>
<td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td>
<td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td>
</tr>";
}
} ...

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

it is referring to this line:

Code: Select all

echo "\t<tr class=\"$row_color\"><td><input type="submit" name="edit_mail" value = "Edit Queries"></td><td>{$row['pro']}</td><td>{$row['pro_update']}</td> ...
All i want is to just add a "Edit Queries" button right at the beginning of the row, but this parse error stops me from doing that

Please help

Re: Parse Error

Posted: Fri Mar 11, 2011 10:38 am
by Jonah Bron
You forgot to escape the quotes on the type, name, and value attributes.

Re: Parse Error

Posted: Fri Mar 11, 2011 11:04 am
by Vinnar
Thanks for the quick reply

By the way, one more question related to parse error arises

Code: Select all

if($result->num_rows){
while ($row = $result->fetch_array()){
$RowCount ++;
$row_color = ($RowCount % 2) ? $color1 : $color2;
echo "<form method = \"post\" action=\"<? echo $_SERVER['PHP_SELF'] ?>\">";
echo "\t<tr class=\"$row_color\"><td><input type=\"submit\" name=\"edit_mail\" value = \"Edit Queries\"></td>
<td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td>
<td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td>
<td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td>
<td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td>
</tr>";
echo "</form>";
}
}
echo "</table>";

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

it's pointing to this line:

Code: Select all

echo "<form method = \"post\" action=\"<? echo $_SERVER['PHP_SELF'] ?>\">";
I tried to escape the double quotes, but i am suspecting the problem mainly comes from the echo statement... How should i format this?

Also, am i placing <form></form> at the right place?

Thanks guys

Re: Parse Error

Posted: Fri Mar 11, 2011 11:13 am
by Jonah Bron

Code: Select all

echo "<form method = \"post\" action=\"<? echo $_SERVER['PHP_SELF'] ?>\">";
It doesn't work that way. You are putting PHP tags inside of a string, which is incorrect. Do it like this:

Code: Select all

echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\">"; 
http://php.net/types.string