Jump to content

PHP CODE NOT UPDATING MYSQL DATABASE TABLE


rleahong

Recommended Posts

PHP CODE NOT WORKING

 

$LABELNAM      = $_POST['LABELNAM'];

$LABELCOD      = $_POST['LABELCOD'];

 

$SQLLABEL = " UPDATE LABEL " .

                        " SET LABELNAM       = $LABELNAM " .

                        " WHERE LABELCOD = $LABELCOD ";

 

 

RESULTS     = mysql_query( $SQLLABEL, $CON );

Also, unless the values are integers, you need to enclose them in quotes for the query

$LABELNAM = $_POST['LABELNAM'];
$LABELCOD = $_POST['LABELCOD'];

$query = "UPDATE LABE
          SET LABELNAM = '$LABELNAME'
          WHERE LABELCOD = '$LABELCOD' ";

$result = mysql_query($SQLLABEL, $CON);

if(!$result)
{
    die("Query: $query<br>Error: " . mysql_error());
}

 . . .  the connection variable should be before the query variable.

 No it shouldn't.You are thinking of mysqli_query()

  • 1 month later...

Also, unless the values are integers, you need to enclose them in quotes for the query

$LABELNAM = $_POST['LABELNAM'];
$LABELCOD = $_POST['LABELCOD'];

$query = "UPDATE LABE
          SET LABELNAM = '$LABELNAME'
          WHERE LABELCOD = '$LABELCOD' ";

$result = mysql_query($SQLLABEL, $CON);

if(!$result)
{
    die("Query: $query<br>Error: " . mysql_error());
}

LABELCOD IS AN INTEGER

 

 

 No it shouldn't.You are thinking of mysqli_query()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.