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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:48:41+00:00 2026-05-24T12:48:41+00:00

I’ve been banging my head over this issue for about 5 hours now, I’m

  • 0

I’ve been banging my head over this issue for about 5 hours now, I’m really frustrated and need some assistance.

I’m writing a Perl script that pulls jobs out of a MySQL table and then preforms various database admin tasks. The current task is “creating databases”. The script successfully creates the database(s), but when I got to generating the config file for PHP developers it blows up.

I believe it is an issue with referencing and dereferencing variables, but I’m not quite sure what exactly is happening. I think after this function call, something happens to
$$result{‘databaseName’}. This is how I get result: $result = $select->fetchrow_hashref()

Here is my function call, and the function implementation:

Function call (line 127):

generateConfig($$result{'databaseName'}, $newPassword, "php");

Function implementation:

sub generateConfig {
    my($inName) = $_[0];
    my($inPass) = $_[1];
    my($inExt)  = $_[2];

    my($goodData) = 1;
    my($select)   = $dbh->prepare("SELECT id FROM $databasesTableName WHERE name = '$inName'");
    my($path)     = $documentRoot.$inName."_config.".$inExt;
    $select->execute();

    if ($select->rows < 1 ) {
            $goodData = 0;
    }

    while ( $result = $select->fetchrow_hashref() )
    {
            my($insert) = $dbh->do("INSERT INTO $configTableName(databaseId, username, password, path)".
                                   "VALUES('$$result{'id'}', '$inName', '$inPass', '$path')");

    }

    return 1;
    }

Errors:

Use of uninitialized value in concatenation (.) or string at ./dbcreator.pl line 142.
Use of uninitialized value in concatenation (.) or string at ./dbcreator.pl line 154.

Line 142:

        $update = $dbh->do("UPDATE ${tablename}
                        SET ${jobStatus}='${newStatus}' 
                        WHERE id = '$$result{'id'}'");

Line 154:

 print "Successfully created $$result{'databaseName'}\n";

The reason I think the problem comes from the function call is because if I comment out the function call, everything works great!

If anyone could help me understand what’s going on, that would be great.

Thanks,

p.s. If you notice a security issue with the whole storing passwords as plain text in a database, that’s going to be addressed after this is working correctly. =P

Dylan

  • 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-24T12:48:42+00:00Added an answer on May 24, 2026 at 12:48 pm

    You do not want to store a reference to the $result returned from fetchrow_hashref, as each subsequent call will overwrite that reference.

    That’s ok, you’re not using the reference when you are calling generate_config, as you are passing data in by value.

    Are you using the same $result variable in generate_config and in the calling function? You should be using your own ‘my $result’ in generate_config.

          while ( my $result = $select->fetchrow_hashref() )
          #       ^^  #add my
    

    That’s all that can be said with the current snippets of code you’ve included.

    Some cleanup:

    1. When calling generate_config you are passing by value, not by reference. This is fine.
    2. you are getting an undef warning, this means you are running with ‘use strict;’. Good!
    3. create lexical $result within the function, via my.
    4. While $$hashr{key} is valid code, $hashr->{key} is preferred.
    5. you’re using dbh->prepare, might as well use placeholders.

      sub generateConfig {
        my($inName, inPass, $inExt) = @_;
      
        my $goodData = 1;
        my $select   = $dbh->prepare("SELECT id FROM $databasesTableName WHERE name = ?");
        my $insert   = $dbh->prepare("
                          INSERT INTO $configTableName(
                            databaseID
                            ,username
                            ,password
                          ,path) 
                          VALUES( ?, ?, ?, ?)" );
        my $path     = $documentRoot . $inName . "_config." . $inExt;
        $select->execute( $inName );
      
        if ($select->rows < 1 ) {
              $goodData = 0;
        }
      
        while ( my $result = $select->fetchrow_hashref() )
        {
          insert->execute( $result->{id}, $inName, $inPass, $path );
        }
      
       return 1;
      

      }

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but

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.