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 8350051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:11:33+00:00 2026-06-09T08:11:33+00:00

I have the following code: <?php // Conexion a MySQL $mysql_link = mysql_connect( ‘localhost’,

  • 0

I have the following code:

<?php

// Conexion a MySQL



$mysql_link = mysql_connect( 'localhost', 'root', '010101' );

if  (!$mysql_link) {
    die('No se pudo conectar a la DB: ' . mysql_error());

}

$mysql_db = mysql_select_db('test', $mysql_link);

if (!$mysql_db) {
die ('No se pudo seleccionar DB: ' . mysql_error());
    }

$mysql_doc_query = "INSERT INTO documents (name, wfid, docid, archivo) VALUES     ('{$CodDoc}: {$documentoNombre} de {$DNI}', '{$workflowNombre}', '{$documentoNombre}',     '{$archivoNombre}' );
      INSERT INTO keywords (document_id, keyword, value) VALUES (LAST_INSERT_ID(),     'DNI', '{$DNI}' ), (LAST_INSERT_ID(), 'Cuit Empleador',
      '{$cuitEmpleador}' ), (LAST_INSERT_ID(), 'DigitalizadoPor', '{$usuario}' ),
  (LAST_INSERT_ID(), 'Direccion IP', '{$IP}' ), (LAST_INSERT_ID(), 'Ubicacion',     CONCAT('pdfs/',LAST_INSERT_ID(),'.pdf') );";

   // Insert en mysql
 $log = fopen('/dev/shm/log.txt', 'w');
  if( $log ) {
      fwrite( $log, $mysql_doc_query );
  }

  mysql_query("START TRANSACTION");
  if (mysql_query($mysql_doc_query) == TRUE)
  {
      mysql_query("COMMIT");
  echo "\nCOMMIT!";
  }
    else {
      mysql_query("ROLLBACK");
      echo "\nROLLBACK!";
  }
  mysql_close($mysql_link);
fclose ($log);
?>

It’s always giving me ROLLBACK but I don’t understand why.

Any clue on this? The code generated in the log.txt archive can be executed in PHP MY ADMIN without problems. (I know the variables aren’t referenced but this is part of a larger script).

Thanks a lot.

  • 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-09T08:11:35+00:00Added an answer on June 9, 2026 at 8:11 am

    mysql_query() only supports one statement at a time. You are executing multiple INSERT statements in one go:

    $mysql_doc_query = "INSERT INTO documents (name, wfid, docid, archivo) VALUES     ('{$CodDoc}: {$documentoNombre} de {$DNI}', '{$workflowNombre}', '{$documentoNombre}',     '{$archivoNombre}' );
          // Oops, new statement here! mysql_query() can't do that.
          INSERT INTO keywords (document_id, keyword, value) VALUES (LAST_INSERT_ID(),     'DNI', '{$DNI}' ), (LAST_INSERT_ID(), 'Cuit Empleador',
          '{$cuitEmpleador}' ), (LAST_INSERT_ID(), 'DigitalizadoPor', '{$usuario}' ),
      (LAST_INSERT_ID(), 'Direccion IP', '{$IP}' ), (LAST_INSERT_ID(), 'Ubicacion',     CONCAT('pdfs/',LAST_INSERT_ID(),'.pdf') );";
    

    This could be debugged with mysql_error() inside your ROLLBACK block:

      if (mysql_query($mysql_doc_query) == TRUE)
      {
          mysql_query("COMMIT");
      echo "\nCOMMIT!";
      }
      else {
        echo "Error in query: " . mysql_error();
        mysql_query("ROLLBACK");
        echo "\nROLLBACK!";
      }
    

    If you need to do two INSERTs, you will need two separate calls to mysql_query(), and check for errors after each one. On failure of either, do your ROLLBACK.

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

Sidebar

Related Questions

I have the following code in php: <?php $con = mysql_connect(localhost,john,john); mysql_select_db(data, $con); if
I have the following php code : $db_host = localhost; $db_user = root; $db_pass
In my Zend Framework app, I have following code: index.php $app_started_time = time(); layout.phtml
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
I have the following PHP code, and for the life of me I can't
I have the following php code: $k=1; for($i=0; $i < 5; $i++) { $stmt
I have the following php code: $k=1; for($i=0; $i < 5; $i++) { $stmt
I have the following PHP Code #The facebook message $fh = fopen('comments.txt', 'r') or
I have the following PHP code // Check if the upload is setted if

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.