-3

I am new on the Platform and also new in Programming. So you need it to explain it to me on the easy way. Normally i Programm microchips and have nothing to do with DBs. ^^


I just du for myself a Homepage and try to do all by myself. Now i try to Update my "Backend" Settings in the Database over a the "POST" Methode.

UPDATE controll SET ticket_new = $_POST["chagne_tickets_new"] WHERE language = $_POST["Change_language"]

Thats just e example how i want it but i have no idea how to do it. i also tried it like that: $Change_ticket_post = $_POST["Change_tickets_new"] $Change_language = $_POST["Change_language"] UPDATE controll SET ticket_new =". $Change_ticket_post. " WHERE language =". $Change_language;

Also that doesn`t works and i got a FATAL ERROR also.

Nopus
  • 3
  • 2
  • 1
    please show thew full code(and full error messages); i suspect it s how the variables are quoted, but its hard to tell without the full php –  Jun 19 '16 at 22:28

1 Answers1

-1

You are doing it wrong.

First of all, it's best practice to use ' (single quotes) to wrap array keys.

So, you should do like this:

<?php
$Change_ticket_post = $_POST['Change_tickets_new'];
$Change_language =    $_POST['Change_language'];

Second, the values in a MySQL query should be wrapped within ' (single quotes) too.

So, your query would be:

<?php
$query = "UPDATE controll SET ticket_new='$Change_ticket_post' WHERE language='$Change_language';

And most of all, you need to learn a lot.

Coding best practices: http://www.php-fig.org/psr/psr-1/

http://www.php-fig.org/psr/psr-2/

SQL Injection: How can I prevent SQL injection in PHP?

Sanitize & escape user data: What's the best method for sanitizing user input with PHP?

Community
  • 1
  • 1