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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:32:46+00:00 2026-06-04T22:32:46+00:00

I have a MySQL stored routine that has an IN parameter that is of

  • 0

I have a MySQL stored routine that has an IN parameter that is of type INTEGER (IN p_user_id INTEGER). If the user is creating a new user I pass p_user_id in as ” otherwise if the user is updating a user, I pass in the user_id of the user being edited. My issue with this is that when p_user_id is coming in as ” it is getting converted to 0. I’ve dumped the user id out right before PHP sends the value to MySQL (and the value is ”) and dumped it out right at the beginning of the MySQL routine and the p_user_id is now 0. Can I get some insight for how to handle this so that I can have the p_user_id IN parameter be NULL. Thanks in advance!

PHP Code:

<?php 
session_start();

$functionCalled = $_GET['function'];

function userMaintMerge()
{   
    $userMaintUserId = $_GET['userMaintUserId'];
    $userMaintStep = $_GET['userMaintStep'];
    $userMaintFirstName = $_GET['userMaintFirstName'];
    $userMaintMI = $_GET['userMaintMI'];
    $userMaintLastName = $_GET['userMaintLastName'];
    $userMaintUserType = $_GET['userMaintUserType'];
    $userMaintSchoolId = $_GET['userMaintSchoolId'];
    $userMaintGrade = $_GET['userMaintGrade'];
    $userMaintLogin = $_GET['userMaintLogin'];
    $userMaintLogin = $_GET['userMaintPassword1'];

    $mysqli = new mysqli($_SESSION['dbaddress'],$_SESSION['user'],$_SESSION['dbpword'],$_SESSION['database']);
    if ($mysqli->connect_errno) 
    {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    if (!$SelectUser = $mysqli->query("call MergeUser('$userMaintUserId','$userMaintStep','$userMaintFirstName','$userMaintMI','$userMaintLastName','$userMaintUserType','$userMaintSchoolId','$userMaintGrade','$userMaintLogin','$userMaintPassword1',@error)")) 
    {
        echo "CALL failed: (" . $mysqli->errno . ") " . $mysqli->error;
    }
}
?>

MySQL stored routine:

CREATE DEFINER=`root`@`localhost` PROCEDURE `MergeUser`(IN  p_user_id      INTEGER
,IN  p_step         VARCHAR(10)
,IN  p_first_name   VARCHAR(100)
,IN  p_mi           VARCHAR(5)
,IN  p_last_name    VARCHAR(100)
,IN  p_user_type    INTEGER
,IN  p_school_id    VARCHAR(25)
,IN  p_grade        VARCHAR(2)
,IN  p_login        VARCHAR(25)
,IN  p_password     VARCHAR(25)
,OUT p_error        VARCHAR(1) 
)
BEGIN

    insert into rjh_log values ('',p_user_id,sysdate());

    IF p_step = 'add' THEN

        INSERT INTO USERS
                    ( USER_ID
                    , LOGIN
                    , FIRST_NAME
                    , MI
                    , LAST_NAME
                    , USER_TYPE_ID
                    , GRADE
                    , SCHOOL_ID
                    , PASSWORD
                    , ACTIVE_FLAG
                    ) 
             VALUES ( NULL
                    , p_login
                    , p_first_name
                    , p_mi
                    , p_last_name
                    , p_user_type
                    , p_grade
                    , p_school_id
                    , p_password
                    , 'Y'
                    ) ;

    ELSE

        UPDATE USERS
           SET LOGIN = p_login
             , FIRST_NAME = p_first_name
             , MI = p_mi
             , LAST_NAME = p_last_name
             , USER_TYPE_ID = p_user_type
             , GRADE = p_grade
             , SCHOOL_ID = p_school_id
             , PASSWORD = p_school_id
         WHERE USER_ID = p_user_id;

    END IF;

END
  • 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-04T22:32:47+00:00Added an answer on June 4, 2026 at 10:32 pm
    $userMaintUserId = ($_GET['userMaintUserId'] == "" ? "NULL" : $_GET['userMaintUserId']);
    $userMaintStep = ($_GET['userMaintStep'] == "" ? "NULL" : $_GET['userMaintStep']);
    $userMaintFirstName = ($_GET['userMaintFirstName'] == "" ? "NULL" : $_GET['userMaintFirstName']);
    $userMaintMI = ($_GET['userMaintMI'] == "" ? "NULL" : $_GET['userMaintMI']);
    $userMaintLastName = ($_GET['userMaintLastName'] == "" ? "NULL" : $_GET['userMaintLastName']);
    $userMaintUserType = ($_GET['userMaintUserType'] == "" ? "NULL" : $_GET['userMaintUserType']);
    $userMaintSchoolId = ($_GET['userMaintSchoolId'] == "" ? "NULL" : $_GET['userMaintSchoolId']);
    $userMaintGrade = ($_GET['userMaintGrade'] == "" ? "NULL" : $_GET['userMaintGrade']);
    $userMaintLogin = ($_GET['userMaintLogin'] == "" ? "NULL" : $_GET['userMaintLogin']);
    $userMaintLogin = ($_GET['userMaintPassword1'] == "" ? "NULL" : $_GET['userMaintPassword1']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MYSQL stored procedure SP1() that returns a result set. I want
I have a mysql 5.1, stored procedure that takes TEXT input which is supposed
I need to pass an array of strings as parameter to a MySQL stored
I have created a project that uses mysql stored procedures and views. I have
I have a java program that is calling a MySQL stored procedure that is
I have a MySQL stored procedure that uses a temporary table. Assume that my
I have a MySQL table that contains datetime data stored in it. I need
Well I have this MySQL stored procedure that I wrote and if I run
I have a MySQL stored routine where I'd like to use a temporary data
I'm trying to get a output parameter from MySQL stored procedure, let's have look

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.