Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi, Whithin the following code I'm getting into trouble
$db->sqlInsert("commentaire", ref_emetteur => "1", ref_article => "$article", question => "$question", text => "$text", date => "$date $time");
package db
sub sqlInsert { my $table = shift || ''; my(%data)=@_; my($names,$values); $dbh||=sqlConnect(); foreach (keys %data) { if (/^-/) { $values.="\n ".$data{$_}.","; s/^-//; } else { $values.="\n ".$dbh->quote($data{$_}).","; } $names.="$_,"; } chop($names); chop($values); my $sql="INSERT INTO $table ($values) VALUES ($names)\n"; #$sql = $dbh->quote ($sql); print "Content-type: text/html\n\n"; print "$sql <br />"; if(!$dbh->do($sql)) { my $err=$dbh->errstr; } }
when I print the resultat of the query on the browser it's give me the following sql
INSERT INTO MyDB=HASH(0xa22d970) ( 'text', 'question', 'ref_emetteur', + 'date', NULL) VALUES (,1,commentaire, this is the description ,2013-05-31 15:16:29)
it's like the commentaire field appear in the values list and the ref_article doesn't be included but a NULL field is defined any idea ? thxx In fact after doing some test on the hash, It's appear that everytime a key / value disapear
$db->sqlInsert("commentaire", ref_article => "$article", question => "$question", text => "$text", ref_emetteur => "1", date => "$date $time"); sub sqlInsert { my $table = shift || ''; my(%data)=@_; print "Content-type: text/html\n\n"; while ( my ($key, $value) = each(%data) ) { print "$value<br/>"; } }
print out
text date ref_article ref_emetteur

In reply to regular expression trouble by *alexandre*

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-12-03 23:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found