Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Error HY093
matjajko
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 29.06.2018

Ostrzeżenie: (0%)
-----


Witam, otóż borykam się z pewnym problemem i nie wiem co jest nie tak... Dajmy na to parametry funkcji to $table = 'users', $col = 'name' i $value = 'test'. Problem w tym, że wyskakuje komunikat:

Kod
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in XXXX on line XX
PDO::errorCode(): HY093


Kod
function addTo($table,$col,$value)
    {
        
        
        
        
        if($query = $this->connection->prepare("INSERT INTO :table (:col)
        VALUES (':value')")){
                
            echo gettype($table);
            echo gettype($col);
            echo gettype($value);
            $query->bindParam(':table',$table);
            $query->bindParam(':col',$col);
            $query->bindParam(':value',$value);
            $query->execute();
            echo "\nPDO::errorCode(): ", $query->errorCode();
        }
        
    }


Co może być nie tak?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 16:46