Jump to content
Sign in to follow this  
MarkT

UPDATE query not working

Recommended Posts

Hi All,

Unfortunately, My update query isn't working for a new CMS I'm creating.

mysqli_query($con2,"UPDATE system SET sys_alert='{$alert}'");

 

Is the query, but I think it's getting confused with the table name being called system

 

Would anyone be able to help? It's surrounded by an IF statement, which I know is functional as it is emailing me with the new alert variable (shown in query), and the old alert.

 

I appreciate any assistance you can provide.

 

Thanks in advance :)

Share this post


Link to post
Share on other sites

Fixed it,

The query was being ended early by a ' in the input field.

I solved it by using a STR replace

$alert = $_POST['alert'];$new2 = str_replace("'", "'", $alert);
Then using {$new2} as my variable,
Edited by MarkT

Share this post


Link to post
Share on other sites

That is not the correct way to protect against SQL injection. Look into using prepared statements with MySQLi, and then you won't need to use things like str_replace.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...