MarcWagner Posted October 24, 2016 Share Posted October 24, 2016 Hello there, I'm having an issue with GetSQLValueString. It worked before (PHP 5) but now in PHP7 it doesn't. Maybe it is deprecated? (i couldn't find any infos on that). I'm trying to update a record. Some of the code follows: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) { $updateSQL = sprintf("UPDATE t_cliente SET tipo_client=%s, nome=%s, morada=%s, nif=%s, cod_postal=%s, telemovel=%s, email=%s WHERE ID=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['morada'], "text"), GetSQLValueString($_POST['nif'], "int"), GetSQLValueString($_POST['cod'], "text"), GetSQLValueString($_POST['telefone'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['ID'], "int")); $Result1 = mysqli_query($con, $updateSQL) or die(mysqli_error()); GetSQLValueString seems to always output NULL and thus the update fails. Thanks for the help!Note: I updated some functions, like mysql_query to mysqli_query. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted October 24, 2016 Share Posted October 24, 2016 Do yourself a favor and get rid of the ancient Dreamweaver garbage code. Since ~10 years, we use prepared statements: $customer_stmt = $database_connection->prepare(' UPDATE t_cliente SET tipo_client = ?, nome = ?, morada = ?, nif = ?, cod_postal = ?, telemovel = ?, email = ? WHERE id = ? '); $customer_stmt->bind_param( 'ississsi', $_POST['tipo'], $_POST['nome'], $_POST['morada'], $_POST['nif'], $_POST['cod'], $_POST['telefone'], $_POST['email'], $_POST['ID'] ); $customer_stmt->execute(); 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.