Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Why does this code doesn't update my database?

Links for php scripts

Moderators: macek, egami, gesf

Why does this code doesn't update my database?

Postby ismaelvc » Tue Jun 24, 2014 6:42 am

Hello everyone! Im a noob in PHP, and I can't make this program update my database. This is the code: http://bit.ly/1jL3vSq

Code: Select all
<html>

<head>
<title>Actualizacion completada.</title>
<META name='robot' content='noindex, nofollow'>
</head>

<body>

<?php

$Id_Inv   = $_POST['Id_Inv'];
$Producto = $_POST['Producto'];
$Sabor    = $_POST['Sabor'];
$Cantidad = $_POST['Cantidad'];
$Id_Prov  = $_POST['Id_Prov'];

$conexion = mysql_connect('localhost', 'root', '12345');

mysql_select_db('usuarios');

$sSQL = mysql_query("Update inventario
                    SET
                    Producto='{$Producto}',
                    Sabor='{$Sabor}',
                    Cantidad='{$Cantidad}',
                    Id_Prov='{$Id_Prov}',
                    WHERE Id_Inv= '{$Id_Inv}'");

mysql_close($conexion);

echo "
<p>Los datos han sido actualizados con exito.</p>

<p><a href='javascript:history.go(-1)'>VOLVER ATRÁS</a></p>

<p><a href='javascript:history.go(-2)'>INICIO</a></p>
";

?>

</body>

</html>


First I thought it was a matter of wrong string interpolation, (that I had to use {}, for correct interpolation), but doing, some tests, I don't think so anymore, do you guys have any idea? :help:

Thanks in advance!
ismaelvc
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Jun 24, 2014 6:38 am

Re: Why does this code doesn't update my database?

Postby robertoshayerlyra » Fri Jun 27, 2014 5:53 am

connections can be annoying.
The problem is figuring out the exact point where things go wrong.
Tip: Try to break your problems to find out exactly where the problem lies.
First: change your mixed sql expression for a full text expression:

"Update inventario SET Producto='abc', sabor='bacon', Cantidad='123', Id_Prov='456', WHERE Id_Inv= '890'"

Ops: there is a comma before WHERE??

Good luck
robertoshayerlyra
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jun 27, 2014 5:43 am


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.