Hi Guys,
I am trying to create an editable table of a MySQL query where every
field can be updated. My example script is at:
http://nana46.coconia.net/test4.php however I am currently getting
Parse errors.
Am I missing anything obvious in my code below?
Thanks
A
<HTML>
<TITLE>test 4</title>
<form method='post' action='test4.p hp'>
<?php
function check_mysql()
{
if (mysql_errno() > 0)
{
die("<BR> MySQL error " . mysql_errno() . ": " .
mysql_error());
}
}
$db = mysql_connect(" coconia.net", "nana46_nana46" , "hello");
if (!$db)
{
die("Failed to open connection to MySQL server.");
}
mysql_select_db ("nana46_nana46 ");
check_mysql();
$requete = "SELECT id,lowerval,upp erval,result FROM fig_lookup";
$resulta = mysql_query($re quete) or die (mysql_error()) ;
echo '<table border="2" cellpadding="0" cellspacing="0" width="100%">';
$edit = "<img src='edit.gif' border='0' alt='Edit record'>";
echo "<table border='2'>";
echo "<td>id</td>";
echo "<td>Lowerv al</td>";
echo "<td>Upperv al</td>";
echo "<td>Result </td></tr>";
if($mode == "Update")
{
for ($i=0; $i<count($_POST['id']); $i++)
{
////LINE 39////// mysql_query ("UPDATE fig_lookup SET
lowerval='{'$_P OST['f2'][$i]}',upperval='{' $_POST['f3'][$i]}',result='{'$_ POST['f4'][$i]}'
WHERE id='{'$_POST['f1'][$i]}'");
}
}
while ($l = mysql_fetch_arr ay($resulta, MYSQL_ASSOC))
{ ?>
<tr>
<td><input type="text" name="f1[]" value="<?=$l["id"]?>"></td>
<td><input type="text" name="f2[]" value="<?=$l["lowerval"]?>"></td>
<td><input type="text" name="f3[]" value="<?=$l["upperval"]?>"></td>
<td><input type="text" name="f4[]" value="<?=$l["result"]?>"></td></tr>
<?
}
echo "</tr>";
echo "</table>";
?>
<input type='submit' name=mode value='Update'>
</form>
</HTML>
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in /home/www/nana46.coconia. net/test4.php on line 39
(line 39 is mysql_query line - marked in code)
I am trying to create an editable table of a MySQL query where every
field can be updated. My example script is at:
http://nana46.coconia.net/test4.php however I am currently getting
Parse errors.
Am I missing anything obvious in my code below?
Thanks
A
<HTML>
<TITLE>test 4</title>
<form method='post' action='test4.p hp'>
<?php
function check_mysql()
{
if (mysql_errno() > 0)
{
die("<BR> MySQL error " . mysql_errno() . ": " .
mysql_error());
}
}
$db = mysql_connect(" coconia.net", "nana46_nana46" , "hello");
if (!$db)
{
die("Failed to open connection to MySQL server.");
}
mysql_select_db ("nana46_nana46 ");
check_mysql();
$requete = "SELECT id,lowerval,upp erval,result FROM fig_lookup";
$resulta = mysql_query($re quete) or die (mysql_error()) ;
echo '<table border="2" cellpadding="0" cellspacing="0" width="100%">';
$edit = "<img src='edit.gif' border='0' alt='Edit record'>";
echo "<table border='2'>";
echo "<td>id</td>";
echo "<td>Lowerv al</td>";
echo "<td>Upperv al</td>";
echo "<td>Result </td></tr>";
if($mode == "Update")
{
for ($i=0; $i<count($_POST['id']); $i++)
{
////LINE 39////// mysql_query ("UPDATE fig_lookup SET
lowerval='{'$_P OST['f2'][$i]}',upperval='{' $_POST['f3'][$i]}',result='{'$_ POST['f4'][$i]}'
WHERE id='{'$_POST['f1'][$i]}'");
}
}
while ($l = mysql_fetch_arr ay($resulta, MYSQL_ASSOC))
{ ?>
<tr>
<td><input type="text" name="f1[]" value="<?=$l["id"]?>"></td>
<td><input type="text" name="f2[]" value="<?=$l["lowerval"]?>"></td>
<td><input type="text" name="f3[]" value="<?=$l["upperval"]?>"></td>
<td><input type="text" name="f4[]" value="<?=$l["result"]?>"></td></tr>
<?
}
echo "</tr>";
echo "</table>";
?>
<input type='submit' name=mode value='Update'>
</form>
</HTML>
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in /home/www/nana46.coconia. net/test4.php on line 39
(line 39 is mysql_query line - marked in code)
Comment