August 28, 2016 at 1:42 pm
i have two pages the first one select.php shows 4 records when i can modify one value in each one but when i try to modify and goes to the second page upload.php an error ocurres.
i try the update in php my admin and it works
Error in query:
UPDATE lc_t_configuracion SET valor = '11:12' WHERE id_conf =6 LIMIT 1
select.php
<code>
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_admin = "localhost";
$database_admin = "xxx";
$username_admin = "xxx";
$password_admin = "xxx";
$admin = mysql_pconnect($hostname_admin, $username_admin, $password_admin) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db("xxx") or die("Unable to select database");
$sql = "SELECT * FROM lc_t_configuracion where id_conf between 6 and 9 ORDER BY id_conf";
$result = mysql_query($sql) or die($sql."
".mysql_error());
$i = 0;
echo '<table width="50%">';
echo '<tr>';
echo '<td>ID</td>';
echo '<td>Concepto</td>';
echo '<td>Valor</td>';
echo '</tr>';
echo "<form name='form_update' method='post' action='update.php'>";
while ($lc_t_configuracion = mysql_fetch_array($result)) {
echo '<tr>';
echo "<td>{$lc_t_configuracion['id_conf']}<input type='hidden' name='id_conf[$i]' value='{$lc_t_configuracion['id_conf']}' /></td>";
echo "<td>{$lc_t_configuracion['concepto']}</td>";
echo "<td><input type='text' size='40' name='valor[$i]' value='{$lc_t_configuracion['valor']}' /></td>";
echo '</tr>';
++$i;
}
echo '<tr>';
echo "<td><input type='submit' value='submit' /></td>";
echo '</tr>';
echo "</form>";
echo '</table>';
?>
</code>
update.php
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update Table</title>
</head>
<body>
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_admin = "localhost";
$database_admin = "xxx";
$username_admin = "xxx";
$password_admin = "xxx";
$admin = mysql_pconnect($hostname_admin, $username_admin, $password_admin) or trigger_error(mysql_error(),E_USER_ERROR);
$size = count($_POST['valor']);
$i = 0;
while ($i < $size) {
$valor= $_POST['valor'][$i];
$id_conf = $_POST['id_conf'][$i];
$query = "UPDATE lc_t_configuracion SET valor = '$valor' WHERE id_conf =$id_conf LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
echo "$valor
<em>Updated!</em>
";
++$i;
}
?>
</body>
</html>
</code>
Please help me
August 28, 2016 at 1:46 pm
Welcome to SSC.
We're not PHP programmers here, so please help us out by
a) Identifying the statement(s) which generate the error(s)
b) Cutting and pasting the exact text of the error message.
August 28, 2016 at 1:51 pm
a) Identifying the statement(s) which generate the error(s)
$query = "UPDATE lc_t_configuracion SET valor = '$valor' WHERE id_conf =$id_conf ORDER by id_conf DESC LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
echo "$valor<br /><br /><em>Updated!</em><br /><br />";
++$i;
b) Cutting and pasting the exact text of the error message.
***** Error in query: UPDATE lc_t_configuracion SET valor = '11:12' WHERE id_conf =6 LIMIT 1 *****
August 28, 2016 at 1:58 pm
pedro.imex (8/28/2016)
a) Identifying the statement(s) which generate the error(s)$query = "UPDATE lc_t_configuracion SET valor = '$valor' WHERE id_conf =$id_conf ORDER by id_conf DESC LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
echo "$valor<br /><br /><em>Updated!</em><br /><br />";
++$i;
b) Cutting and pasting the exact text of the error message.
***** Error in query: UPDATE lc_t_configuracion SET valor = '11:12' WHERE id_conf =6 LIMIT 1 *****
I've just realised that you are posting MySQL code, whereas this is a forum for Microsoft SQL Server. You will probably get more help if you can find yourself a MySQL forum.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply