From the database everything is OK. "SELECT * FROM wallpapers;" works fine through the same PDO. But for some reason, nothing happens.

public static function addWallpaper( $wallpaper_name ) { $query = 'INSERT INTO wallpapers (name) VALUES (":wallpaper_name");'; $prepare = self::$_connection->prepare( $query ); $prepare->bindValue( ":wallpaper_name", $wallpaper_name ); $prepare->execute(); } 
  • The problem was that php had no rights to write to the folder where the database is located. - asheee


1 answer 1

 public static function addWallpaper( $wallpaper_name ) { $query = 'INSERT INTO wallpapers (name) VALUES (:wallpaper_name);'; $prepare = self::$_connection->prepare( $query ); $prepare->bindValue( ":wallpaper_name", $wallpaper_name ); $prepare->execute(); } 
  • If you write the INSERT INTO wallpapers (name) VALUES (somefile.name) directly into the database; That DB will answer with an error: there is no column somefile.name. By this, I decided to put quotes. Tried and without, nothing changes - asheee
  • one
    at binde values, it is automatically placed in quotes if it is a string and, accordingly, the placeholder does not need to be surrounded by quotes, this code works for me - inso
  • does not work. even if you write 'INSERT INTO wallpapers (name) VALUES (' value.png ');' then the value.png string does not appear in the database asheee