mlummus Posted May 5, 2010 Share Posted May 5, 2010 Does anyone see the error in the code below? I am receiving the program's error code "Error in placing data in database." It may be something simple - I am fairly new to this. Thanks in advance for your help. $db = mysqli_connect('server', 'user', 'password'); mysqli_select_db($db, "database"); $query = "UPDATE student SET id='$id', name_last='$name_last', name_first='$name_first', email='$email', class='$class', major='$major', living='$living WHERE id='$id'"; $result = mysqli_query($db, $query); if ($result) { echo "student updated in database.</h2>"; } else { echo "<h2> Error in placing data in database </h2>"; } mysqli_close($db); Quote Link to comment https://forums.phpfreaks.com/topic/200812-mysql-update-help/ Share on other sites More sharing options...
jwk811 Posted May 5, 2010 Share Posted May 5, 2010 $query = "UPDATE student SET id='$id', name_last='$name_last', name_first='$name_first', email='$email', class='$class', major='$major', living='$living WHERE id='$id'"; you forgot the quote after $living Quote Link to comment https://forums.phpfreaks.com/topic/200812-mysql-update-help/#findComment-1053663 Share on other sites More sharing options...
mlummus Posted May 5, 2010 Author Share Posted May 5, 2010 Thanks jwk811. By the way, does anyone know of a program out there that helps you find these kinds of syntax errors? Quote Link to comment https://forums.phpfreaks.com/topic/200812-mysql-update-help/#findComment-1053669 Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2010 Share Posted May 5, 2010 The program that exists to find syntax errors like that is the program that is running in your brain. Because only the programmer who wrote the code or query knows the intent or goal of the code or query, there is no computer program that can specifically find what is wrong with code or a query when the programmer leaves something out. If you were using mysqli_error() it would tell you that mysql found a syntax error and where it was discovered at in the query, but that is often after the point where the programmer left out some syntax and is often a generic error message because, again, the language parser does not know what the programmer is trying to accomplish and cannot tell him specifically what he left out or what to do to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/200812-mysql-update-help/#findComment-1053681 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.