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 );

Link to comment
Share on other sites

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()

Edited by Psycho
Link to comment
Share on other sites

  • 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()

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.