I can not update a specific column in DB

I am using input type color as i want to save selected color to DB.
I can see color which I did choose in console (check js), but something  gets wrong with ajax as I can not get echo "nnnnnnnn", but just "mmmmmmmmmmm" (check php).
So I might not debug forward in case of other errors.


php
<?php
echo "mmmmmmmmm"; 
if(isset($_POST["uColorIsSet"])){
 echo "nnnnnnnnnnnn";    
include_once("/wp-content/themes/n4/php_includes/db_conx.php");
$uColor2 = mysqli_real_escape_string($db_conx,$_POST['uColor2']);
$sql = "UPDATE users SET yourColor='$uColor2' WHERE username='$u'";
$query = mysqli_query($db_conx, $sql);
}
?>

Open in new window

and js
function updateAll2(event) {
var uColorIsSet=0;
 var uColor2 = event.target.value;
 console.log("selected color"+uColor2);
$.ajax({
  method:"POST",
  url: '/wp-content/themes/n4/nF4/user.php',
  data:  {
    "uColorIsSet":1,
    "uColor2":uColor2
    },
    datatype: "text",
    success: function(strdate){
   
      console.log("aaaaaaaaaaaaaa");
     
     },
     error: function(error, txtStatus) {
      console.log(txtStatus+" error on load of canvas on user page");
      console.log('error');
    }
 });
}

Open in new window


Can you see from data that I  provided what is the problem?


Just for  Info: I am doing the initial setting of color as next.
      
$sql = "INSERT INTO users (yourColor)    VALUES ('$c')";

Open in new window

Ivan GolubarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
Have you made any other changes to your code when posting this example? I just tried your code and it worked fine for me.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ivan GolubarAuthor Commented:
I have other code also but ,

 success: function(strdate){
   
      console.log("aaaaaaaaaaaaaa");
     
     }

Open in new window

   
How is possible to get answer in console and no changes in DB?
0
gr8gonzoConsultantCommented:
I don't think I understand what you're asking, but if you don't want to change the DB, comment out the code that changes it.
0
Ivan GolubarAuthor Commented:
Sorry for bad question. I will ask differently.

How is it possible that I am  getting  answer in console to confirm me that ajax was executed successfully, but then   there were no changes in DB?
0
Ivan GolubarAuthor Commented:
I am using now :
$db_conx=mysqli_connect("localhost","xxxxxxxx","yyyyyyyy","zzzzzzzz")or die ("no connection"); 

Open in new window


instead of
include_once("/wp-content/themes/n4/php_includes/db_conx.php");

Open in new window


and is working.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.