My previous answer showed you how to do interpolation, and more importantly, how to avoid interpolation by using placeholders. You're still doing interpolation wrong, and more importantly, still not using placeholders.

These lines:

my $sth = $dbh->prepare('Select * from users where name = "$name"'); $sth->execute();

Are still wrong, for two reasons. First, because single quotes don't do variable interpolation, even if you embed double quotes within them:

my $var = "Hello"; my $other = '$var world'; # Wrong. my $outro = '"$var" world'; # Still wrong. my $right = "$var world"; # Correct.

This is documented briefly in perlintro: Basic Syntax Overview, and in more detail in perlop.

But you don't need interpolation, and shouldn't even be using it, because it's error-prone at best, and unsafe at worst when using it to construct queries. Instead, use placeholders. I showed you how in my previous answer, but your code changed slightly, so I'll demonstrate again, this time in consideration of the modified code:

my $sth = $dbh->prepare( 'SELECT * FROM users WHERE name = ?' ); $sth->execute( $name );

I referred you earlier to the documentation for DBI. This time I'll link to the exact section within that document where you should focus your reading:

Placeholders and Bind Values


Dave


In reply to Re: Returning values from mysql with cgi by davido
in thread Returning values from mysql with cgi by Chaotic Jarod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.