-3

I want to insert JS variable value into database

echo $date = "<script>document.write(sessionStorage.getItem('ss_date_month'))</script>"."<br>";

this is how I'm getting the variable and trying to save in database, it echo the value of $date

     $sql44 = "INSERT INTO `pickup`
           ( `address`, `add_line_2`, `driver_message`, `time`, `price`, `s_m_l`)
           VALUES ( '$s_pickup_address', '$s_florr_building_fp', '$s_driver_message_fp', '$date', '$price', 'NULL')";

           $run_query = mysqli_query($con, $sql44);
           if ($run_query) {
               echo "query chal gyi";
          }        
    else{
        die("Connection Failed". mysqli_error($con));
    }

Output:
10 April // value of $date.

Error:

Connection FailedYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ss_date_month')) ', 'pricee', 'NULL')' at line 3

recnac
  • 3,744
  • 6
  • 24
  • 46

1 Answers1

0

Change

echo $date = "<scri...

to

echo "date = $date", "<scri...

What you have is changing $date.

Rick James
  • 135,179
  • 13
  • 127
  • 222