SQL query does not run

0

I have a table [texts] in phpmyadmin like this:

Column [column1] - > Type [int (20)] - > Null [no] - > Default [None]

Column [column2] - > Type [text] - > Null [no] - > Default [None]

. .

The first column is used as the primary key. My intention is simply to add a new line, this is the code that I have arranged in two php files.

File1.php php

$dbhost="localhost";    // host del MySQL (generalmente localhost)

$dbusuario="usuario1";      // Nombre de usuario para la BD

$dbpassword="123456";   // password del usuario

$db="BD1";          // Nombre de la BD


    function EjecutarSQL($query){
     global     $dbhost,$dbusuario,$dbpassword,$db;
     $conexion = mysql_connect( $dbhost, $dbusuario, $dbpassword);
     mysql_select_db($db, $conexion);
     $resp=mysql_query($query,$conexion);
     mysql_close($conexion);
     return $resp;
    }

file2.php

    <?php
     require_once APP_ROOT_DIR . '/archivo1.php';
    $Var1=$array1['colum1'];
    EjecutarSQL("INSERT INTO 'textos' ('columna1') VALUES ($Var1)");
    ?>

The case is that the sentence is executed but the line is not created in the database. If I add an echo ($ query) in the function ExecuteSQL this returns a line that is correct and if I copy-paste this line in phpmyadmin it executes and adds the line in the table correctly. I do not understand why the code does not work correctly.

    
asked by Quarkbite 19.10.2017 в 08:46
source

0 answers