Jump to content

MySQL Update help


mlummus

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/200812-mysql-update-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/200812-mysql-update-help/#findComment-1053681
Share on other sites

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.