Jump to content

Recommended Posts

I'm going to guess that your $sname variable contains some sql special characters and since you don't appear to be escaping that variable before putting it into the query statement, you are getting an sql syntax error.

 

Why are you building a query statement using two different methods of putting values into it, one for $sname and a different one for $sid? Consistency does count in programming.

 

There's around a half-dozen three-quarters of a dozen of different things that could cause your query to not update the database. If everything is perfect up to the point of the code you did post, that query should work.

 

Here's a list of the things that could prevent your update query from working -

  1. You don't have a database connection at the point where you are running the query.
  2. You haven't selected any database or have selected the wrong one.
  3. The php code where the query is at is not being executed.
  4. The query is failing with an error due to a wrong table or column name.
  5. The query is failing due to some sql special characters in the $sname variable.
  6. The WHERE clause is false because $sid is empty or doesn't match any id in your table.
  7. The wrong column is being used in the WHERE clause. Is the column you are trying to match id? or is it something else?
  8. The values you are updating the columns to are not compatible with the column type.
  9. The value you are updating the columns to are the same as what they already are.
  10. any more that I forgot to think of...

It's up to you to troubleshoot what your code and your data are doing on your server to pin down why something does not work. You need to devise tests to check each of these possible reasons to either eliminate it as the cause of the problem or to find that it is the cause of the problem.

Link to comment
https://forums.phpfreaks.com/topic/268735-update_not_working/#findComment-1380834
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.