rleahong Posted June 9, 2013 Share Posted June 9, 2013 PHP CODE NOT WORKING $LABELNAM = $_POST['LABELNAM']; $LABELCOD = $_POST['LABELCOD']; $SQLLABEL = " UPDATE LABEL " . " SET LABELNAM = $LABELNAM " . " WHERE LABELCOD = $LABELCOD "; RESULTS = mysql_query( $SQLLABEL, $CON ); Quote Link to comment Share on other sites More sharing options...
davidannis Posted June 9, 2013 Share Posted June 9, 2013 On the last line the variable should be $results and the connection variable should be before the query variable. You should also sanitize the data before the query. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 9, 2013 Share Posted June 9, 2013 (edited) 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 June 9, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
davidannis Posted June 10, 2013 Share Posted June 10, 2013 No it shouldn't.You are thinking of mysqli_query() Oops, my bad. I almost exclusively use mysqli. Should have advised the OP to switch to mysqli since mysql is deprecated. Quote Link to comment Share on other sites More sharing options...
rleahong Posted August 5, 2013 Author Share Posted August 5, 2013 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() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.