PHP - Insert data in mySQL (under Joomla 3.x)

0

Good!

I want to do something quite simple, save in my database information that I have in php variables collected from a form (mysql database and code executed under Joomla3)

With the code that I leave you always shows me a syntax error (which I can not find). Before I had the error "Unkow column" x "on field list", but I saw that it was to enclose a variable of an INT field in quotes. I removed the quotes and now syntax error appears.

How can I solve it? Thanks!

I leave you the structure and the PHP code:

    
asked by Nicolau Roca 04.10.2017 в 02:38
source

1 answer

0

The inverted quotes (') is part of the syntax used from the same MySQL PHPMyAdmin. Now, since this query is being used from PHP to run in MySQL, I recommend removing these quotes from the fields and using the single quotes (') or double (") strong> used in PHP for string or date values, example:

$variable = 'cadena';
$query = "INSERT INTO Tabla VALUES('valor', '" + $variable + "')";
    
answered by 05.10.2017 / 17:33
source