Jump to content

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

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.