Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:38:21+00:00 2026-06-03T21:38:21+00:00

I have two webpages, the one that you fill the information and another that

  • 0

I have two webpages, the one that you fill the information and another that processes it.
My firstpage is plain and simple HTML with jQuery and AJAX, as soon as the user clicks a button, it executes the following piece of code:

$("#registrar-tienda").click(function() {
    var categoria = $("#categoria").val();
    var nombre = $("#nombre").val();
    var direccion = $("#direccion").val();
    var codigo_postal = $("#codigo").val();
    var poblacion = $("#poblacion").val();
    var provincia = $("#provincia").val();
    var latitud = $("#latitud").val();
    var longitud = $("#longitud").val();
    var telefono = $("#telefono").val();
    var categoria = $("#categoria").val();
    var email = $("#email").val();
    var web = $("#web").val();
    var eco_punto = $("#eco-punto").val();
    var compra_minima = $("#compra-minima").val();
    var maximo_acumulable = $("#maximo-acumulable").val();
    var cliente_hash = $("#cliente-hash").val();
    alert(nombre+direccion+codigo_postal+poblacion+provincia+latitud+longitud+telefono+email+web+eco_punto+compra_minima+maximo_acumulable+cliente_hash);
    $.ajax({
        type:"POST",
        url:"modulos/tiendas/operaciones.php",
        data:{categoria:categoria,nombre:nombre,direccion:direccion,codigo_postal:codigo_postal,poblacion:poblacion,provincia:provincia,latitud:latitud,longitud:longitud,telefono:telefono,categoria:categoria,email:email,web:web,eco_punto:eco_punto,compra_minima:compra_minima,maximo_acumulable:maximo_acumulable,cliente_hash:cliente_hash}
        }).done(function(msg) {
        if(msg == "Tienda agregada") {
            document.location.reload(true);
        } else {
            document.getElementById("errores").innerHTML = msg;
            }
        });
});

I have no trouble with that specific part of the web page, it sends the variable, and if notice I’m confirming that by an alert dialog, and all the information is valid and correct.

The problem comes with the PHP web page,
I have a span tag in my HTML that reports errors if any.
When I click submit, it only shows:

Error: Array()

I put that error string if the transaction is not executed, but I’m not sure why it isn’t executed, and the errorInfo() method only reports: Array()

My PHP Code is as follows:

<?php
require('../../includes/etc/connection.php');
isset($_POST['categoria']) or die ("No hay categoria definida");
isset($_POST['nombre']) or die("No hay nombre de negocio");
isset($_POST['direccion']) or die("No hay direccion de negocio");
isset($_POST['poblacion']) or die ("No hay poblacion de negocio");
isset($_POST['codigo_postal']) or die("No hay codigo postal de negocio");
isset($_POST['provincia']) or die("No hay provincia");
isset($_POST['latitud']) or die("No hay latitud");
isset($_POST['longitud']) or die("No hay longitud");
isset($_POST['telefono']) or die("Sin telefono");
isset($_POST['categoria']) or die("No hay categoria");
isset($_POST['eco_punto']) or die("No hay valor del ecopunto");
isset($_POST['maximo_acumulable']) or die("No hay maximo acumulable");
isset($_POST['compra_minima']) or die("No hay compra minima");
isset($_POST['cliente_hash']) or die("Se tiene que seleccionar un cliente");

if($_POST['nombre'] == "Nombre del establecimiento"): die(0); endif;
if($_POST['direccion'] == "Direccion"): die(0); endif;
if($_POST['poblacion'] == "Poblacion"): die(0); endif;
if($_POST['codigo_postal'] == "Codigo Postal"): die(0); endif;
if($_POST['provincia'] == "Provinicia"): die(0); endif;
if($_POST['telefono'] == "Telefono"): die(0); endif;
if($_POST['email'] == "E-mail"): die(0); endif;

$hash = md5($_POST['nombre'].$_POST['latitud'].$_POST['longitud'].date("Y-m-d H:M:s"));
$fecha_registro = date("Y-m-d");
$strSQL = "INSERT INTO `negocios`(`hash`,`cliente_hash`,`fecha_registro`,`nombre`,`apellido`,`direccion`,`codigo_postal`, `poblacion`, `provincia`, `latitud`,`longitud`,`telefono`, `email`, `web`,`categoria`,`valor_ecopunto`,`maximo_acumulable`,`compra_minima`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; 
if(!($sth = $dbh->prepare($strSQL))) {
    die("Statement not prepared:".$dbh->errorInfo());
}

if(!$dbh->beginTransaction()){
    die ("Transaction didn't begin: ".$dbh->errorInfo());
}

$sth->bindParam(1,$hash,PDO::PARAM_STR,32) or die("Not binded");
$sth->bindParam(2,$_POST['cliente_hash'],PDO::PARAM_STR,32) or die("Not binded");
$sth->bindParam(3,$_POST['fecha_registro'],PDO::PARAM_STR,15) or die("Not binded");;
$sth->bindParam(4,$_POST['nombre'],PDO::PARAM_STR,150) or die("Not binded");;
$sth->bindParam(5,$_POST['direccion'],PDO::PARAM_STR,150) or die("Not binded");;
$sth->bindParam(6,$_POST['codigo_postal'],PDO::PARAM_INT,9) or die("Not binded");;
$sth->bindParam(7,$_POST['poblacion'],PDO::PARAM_STR,50) or die("Not binded");;
$sth->bindParam(8,$_POST['provincia'],PDO::PARAM_STR,50) or die("Not binded");;
$sth->bindParam(9,$_POST['latitud'],PDO::PARAM_STR,10) or die("Not binded");;
$sth->bindParam(10,$_POST['longitud'],PDO::PARAM_STR,10) or die("Not binded");;
$sth->bindParam(11,$_POST['telefono'],PDO::PARAM_STR,20) or die("Not binded");;
$sth->bindParam(12,$_POST['email'],PDO::PARAM_STR,100) or die("Not binded");;
$sth->bindParam(13,$_POST['web'],PDO::PARAM_STR,100) or die("Not binded");;
$sth->bindParam(14,$_POST['categoria'],PDO::PARAM_INT,2) or die("Not binded");;
$sth->bindParam(15,$_POST['eco_punto'],PDO::PARAM_INT,4) or die("Not binded");;
$sth->bindParam(16,$_POST['maximo_acumulable'],PDO::PARAM_INT,4) or die("Not binded");;
$sth->bindParam(17,$_POST['compra_minima'],PDO::PARAM_INT,5) or die("Not binded");;
if(!$sth->execute()){
    die("Error: ".$sth->errorInfo());  // Error reported in the HTML webpage
}
$dbh->commit();
echo "Tienda Agregada";
?>

At firs I thought that I wasn’t receiving POST variables, but if I add a:

print_r($_POST);

It prints the POST array with all the right values

It doesn’t seem to be complaining about anything, but the transaction is not commited to the database.

On the other hand, I have other web pages that follow the same logic, the same code, and those pages work as expected.

It is also the first time I’m using PDO, I usually used MySQLi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:38:22+00:00Added an answer on June 3, 2026 at 9:38 pm

    PDO’s errorInfo returns an array, not a string. Use var_export or print_r to turn it into a string.


    Additionally, in my opinion it’s a good idea to set PDO’s error mode to throw exceptions when a query cannot be executed, instead of checking each query’s result. Then you can wrap an entire transaction in a try/catch and rollback the transaction if something goes wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web pages that I am trying to send information between. One
I have two different div elements on two different webpages that use two different
I have two tables that I'm querying from. In one table, there are fields
I have a web application that consists of two websites - one running on
I have two files, one containing an array in PHP that is echo ed
I have a webpage with two side by side overflowing divs that split the
I have some localization problems in my webpage. There are basically two problems (that
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have two web pages: one consists of four asp.net text boxes and one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.