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

  • Home
  • SEARCH
  • 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 6364421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:09:41+00:00 2026-05-25T00:09:41+00:00

$j = new DB(); $j->SetSqlCommnd(DELETE FROM cpd_colaborator_access WHERE col_cod = .$_POST[colaborator].); $j->Exec(); for($i =

  • 0
$j = new DB();
$j->SetSqlCommnd("DELETE FROM cpd_colaborator_access
           WHERE col_cod = ".$_POST["colaborator"]."");
$j->Exec();



for($i = 0; $i < count($_POST["page"]); $i++) 
{        
     $j = new DB();
     $j->SetSqlCommnd("INSERT INTO cpd_colaborator_access (access_id,col_cod)
                VALUES (".$_POST["page"][$i].",".$_POST["colaborator"].")");
     $j->Exec();  
}

I tried to represent this php code up, on this procedure below, passing an array as parameter “p_pages” and a id “p_colaborator”;

CREATE DEFINER=`root`@`localhost` PROCEDURE `delegar_paginas`(
IN p_colaborator INT,
IN p_pages INT
)
BEGIN
DECLARE A INT(200);
DECLARE I INT(0);
IF (p_colaborator <> '') THEN
  DELETE FROM cpd_colaborator_access
  WHERE col_cod = p_colaborator;
  WHILE (I<@A) DO  
    IF(p_pages(0,I) <> '')THEN
      INSERT INTO cpd_colaborator_acess (acess_id,col_cod)
      VALUES (p_pages(0,I),p_colaborator);  
    ELSE
      SET I = A;
    END IF;
  END WHILE;
END IF;
END;

I am beginner to stored procedures, someone knows what may be wrong here ?

  • 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-05-25T00:09:43+00:00Added an answer on May 25, 2026 at 12:09 am

    I’m a little confused as to what datatypes p_colaborator and p_pages are supposed to be – you declare them both as INT in the parameter line, but you treat p_colaborator as a string, and p_pages as an array (of strings?), but it’s inserted into an ID field.

    MySQL doesn’t support arrays in procedures, but there are lots of work arounds (http://stackoverflow.com/questions/595371/pass-array-into-a-stored-procedure).

    So, this procedure makes some assumptions:

    • p_colaborator is a string (varchar(255)).
    • p_pages is a comma-separated list of numbers (as in ‘1,2,3,4’).

    With those assumptions, this procedure should do the trick:

    DROP PROCEDURE delegar_paginas;
    
    DELIMITER //
    
    CREATE PROCEDURE delegar_paginas(IN p_colaborator VARCHAR(255), IN p_pages VARCHAR(255))
    BEGIN
    IF (p_colaborator <> '') THEN
      DELETE FROM cpd_colaborator_access WHERE col_cod = p_colaborator;
      SET @ins = CONCAT('(', REPLACE(p_pages, ',', CONCAT(', "', p_colaborator, '"), (')), ', ', p_colaborator, ')');
      SET @SQL = CONCAT('INSERT INTO cpd_colaborator_acess (acess_id,col_cod) VALUES ', @ins);
      SELECT @SQL;
      PREPARE stmt FROM @SQL;
      EXECUTE stmt;
    END IF;
    END;
    //
    
    DELIMITER ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New question, but really close to need to refresh page in jquery mobile .
New to Tsung and Erlan and have run into an issue I haven't been
New to PHP- If I have PHP getting a picture name from a form:
New class is a subclass of the original object It needs to be php4
New to javascript/jquery and having a hard time with using this or $(this) to
New to xml. Looking for XPath to search a xml file with python ElementTree
New to silverlight. Traditionally if I were to design a wizard-like process where a
New to both Ruby and Rails but I'm book educated by now (which apparently
New to WCF, but familiar with COM+ - can I wrap a WCF service
New to Linux programming in general. I am trying to communicate with a kernel

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.