Problem with PHP function and parameters

0

I have a problem and that is that my function does not receive the parameters of the call of the function on the page that registers the articles. see below:

I get the following error:

  

Fatal error: Uncaught ArgumentCountError: Too few arguments to function saveArticle (), 0 passed in C: \ xampp \ htdocs \ DHTML \ the_real_final \ admin.php on line 59 and exactly 4 expected in C: \ xampp \ htdocs \ DHTML \ the_real_final \ engine \ Functions.php: 190 Stack trace: # 0 C: \ xampp \ htdocs \ DHTML \ the_real_final \ admin.php (59): saveArticle () # 1 {main} thrown in C: \ xampp \ htdocs \ DHTML \ the_real_final \ engine \ Functions.php on line 190

This is the .php page where I call the function: Where it says keepArticles (....);

<?php
/*Incluimos el arhivo del header.php*/
include_once("header.php");
?> 

<div class="w3-agile-contact-grids">
            <div class="left-form-w3-agileMIO">
<?php 
    if($_POST)
      {
        //echo"<h2>Formul&aacute;rio enviado</h2>";
        //Recibimos los datos del formulario
        $NombreArt=$_POST['txtNombreArticulo'];
        $Precio=$_POST['txtPrecio'];
       /*No recogemos la foto pues no es obligatoria*/
        $Codigo=$_POST['txtCodigo'];


        //echo" $Nombre $Direccion $Edad $Telefono $Sexo";

         if(empty($NombreArt))
        {
          echo"<h2>Digite nombre del articulo</h2>";
        }
        if(empty($Precio))
        {
          echo"<h2>Debe poner el precio</h2>";
        }

        if(empty($Codigo) )
        {
          echo"<h2>Debe llenar</h2>";
        }


        if(!empty($_FILES['txtFotoArticulo']['name'])){
                    /*Si hay un archivo enviado, guardamos su nombre en         una variable*/
                    $FotoArt=$_FILES['txtFotoArticulo']['name'];

                    /*Reemplazamos los espacios en blanco por _ en el nombre del archivo*/
                    $FotoArt=str_replace(" ","_",$FotoArt);
                    /*Movemos el archivo temporal desde el directorio temporal(tmp) hasta nuestro directorio para los archivos*/
                    move_uploaded_file($_FILES['txtFotoArticulo']['tmp_name'],'images/upload/'.$FotoArt);
                    chmod('images/upload/'.$FotoArt,0644);
                }       

          if( 
                    (!empty($NombreArt)) && (!empty($Precio)) && (!empty($Codigo)) 
                )
              {
                /*Incluimos el archivo que tiene todas las funciones*/
                include_once("motor/Funciones.php");
                guardarArticulo($NombreArt,$Precio,$Codigo,$FotoArt);

            }

            else 
                          {
                            echo "<h3 id='fallo'>Ha habido un fallo...</h3>
                            <h2 class='validacionphph2'>Faltan campos por completar o llenar </h2>
                                <span id='spanlogin'><a href='Registrate.php' id='log'  class='validacionphph2'>Volver a intentar</a></span>";

                          }



      } else
                  {
                    echo"<h2 class='validacionphph2'>Ning&uacute;n dato enviado</h2>";
                  }





?>

    </div>
    </div>



<?php
/*Incluimos el arhico del footer.php*/
include_once("footer.php");
?> 

And this is the function in the .php that receives the parameters:

function guardarArticulo($NombreArt,$Precio,$Codigo,$FotoArt)
{       
//Incluimos el archivo de Conexion
include_once("motor/Conexion.php");
//Nos conectamos al servidor
$Conectarme=Conectar();

//los de inseet el primero es el campo de la tabla de comentario no id lo de parentesis son las tablas como tal en la base de datos
//values son las variables que crees para guardadr los campos de la base de datos ya estan crradas hay que copiar y pegar.
    $Guardar="
        INSERT INTO articulo (NombreDeArticulo, precio, codigo, fotoart )
        VALUES ('$NombreArt', '$Precio', '$Codigo', '$FotoArt') 
    ";


    if(mysqli_query($Conectarme, $Guardar))
    {
      echo "<div>Hemos recibido su foto <a href='admin.php'> Registrar otro</a></div>";

    }
    else
    {
      echo "<div class='Mensaje'>Uff! No hemos podido guardar la foto</div>";

    }       
    /*Cerramos la conexion*/
    mysqli_close($Conectarme);      

}
    
asked by Francisco Castle 25.11.2017 в 03:44
source

0 answers