Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

For my html script, I'm trying to call a perl script using a form action, as seen below at line 157. However, I keep getting the error message "(process:2754): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed" whenever I try to use the form, which is supposed to return the results from the perl script(shown below the html). Can anyone explain to me what I'm doing wrong, and how to fix this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ut +f-8" /> <title>Project Page</title> </head> <body> <h1>Main Project Page</h1> <p> Relational databases are used in many large websites t +o quickly sort through information. In this case, the amount of information is more easily man +agable;<br /> when dealing with larger amounts, however, relational databases can be quite useful for organization. +<br /><br /> Below are the tables for which you can search for information from further down:</p> <table border = "2" cellpadding = "3" cellspacing = "4" wi +dth = "95%" > <caption>employees</caption> <tr> <th width = "10%">id</th> <th width = "20%">firstname</th> <th width = "20%">lastname</th> <th width = "15%">annual_salary</th> <th width = "30%">date_first_employed</th> </tr> <tr> <td width = "10%">1</td> <td width = "20%">Alan</td> <td width = "20%">White</td> <td width = "15%">100000</td> <td width = "30%">2004-09-03</td> </tr> <td width = "10%">2</td> <td width = "20%">Jake</td> <td width = "20%">Michaels</td> <td width = "15%">80000</td> <td width = "30%">2007-11-18</td> <tr> <td width = "10%">3</td> <td width = "20%">Jessica</td> <td width = "20%">Stirling</td> <td width = "15%">120000</td> <td width = "30%">1999-03-28</td> </tr> <tr> <td width = "10%">4</td> <td width = "20%">Jim</td> <td width = "20%">Schmim</td> <td width = "15%">60000</td> <td width = "30%">2012-05-17</td> </tr> </table> <br /> <br /> <table border = "2" cellpadding = "3" cellspacing = "4 +" width = "95%" > <caption>employee_contacts</caption> <tr> <th width = "20%">contact_id</th> <th width = "20%">email_address</th> <th width = "25%">home_phone_number</th> <th width = "30%">emergency_phone_number</th> </tr> <tr> <td width = "20%">Alan W.</td> <td width = "20%">Alan@mail.com</td> <td width = "25%">650-939-8504</td> <td width = "30%">650-249-7128</td> </tr> <tr> <td width = "20%">Jake M.</td> <td width = "20%">Jake@mail.com</td> <td width = "25%">650-421-7730</td> <td width = "30%">650-855-2217</td> </tr> <tr> <td width = "20%">Jessica S.</td> <td width = "20%">Jessica@mail.com</td> <td width = "25%">650-419-2350</td> <td width = "30%">650-273-8530</td> </tr> <tr> <td width = "20%">Jim S.</td> <td width = "20%">Jim@mail.com</td> <td width = "25%">650-769-8230</td> <td width = "30%">650-289-6530</td> </tr> </table> <br /> <br /> <p> The tables above are linked by this followi +ng table:</p> <br /> <br /> <table border = "2" cellpadding = "3" cellspacing += "4" width = "20%"> <caption>table_link</caption> <th width = "5%">id</th> <th width = "15%">contact_id</th> <tr> <td width = "5%">1</td> <td width = "15%">Alan W.</td> </tr> <tr> <td width = "5%">2</td> <td width = "15%">Jake M.</td> </tr> <tr> <td width = "5%">3</td> <td width = "15%">Jessica S.</td> </tr> <tr> <td width = "5%">4</td> <td width = "15%">Jim S.</td> </tr> </table> <p>The following fields can be used to search +for information <br /> found in the tables above: </p> <br /> <form action = "localhost/home/phillip/Documen +ts/Aptana Studio 3 Workspace/project/scriptdone5.pl" METHOD = "post" +target = "_blank"> Employee name:<input type = "text" size = +"25" maxlength = "25" name = "name"><br /><br /> </form> <br /><br /> <form action = "" METHOD = "post"> Employee id:<input type = "text" size = "2 +5" maxlength = "25" name = "id"><br /><br /> </form> <br /><br /> <form action = "" METHOD = "post"> Employee email address:<input type = "text +" size = "25" maxlength = "25" name = "email_address"><br /><br /> </form> <br /><br /> <form action = "" METHOD = "post"> Date first employed:<input type = "text" s +ize = "25" maxlength = "25" name = "date_first_employed"><br /><br /> </form> </body> </html> #!/usr/bin/perl use DBI; use warnings; my $firstname = $in{name}; my $db = "project_database"; my $host = "localhost"; my $user = "root"; my $pw = "steampunk333"; my $source = "DBI:mysql: database = project_database; host = localhost +;"; my $contactid; my $dbh; print "Content-type:text/html\n\n"; $dbh = DBI->connect($source,$user,$pw) or die "Can't connect to database: $DBI::errstr\n"; my $qfirstname = dbh->quote($firstname); if ($firstname eq "Alan") {$contactid = "Alan W.";} elsif ($firstname eq "Jake") {$contactid = "Jake M.";} elsif ($firstname eq "Jessica") {$contactid = "Jessica S.";} elsif ($firstname eq "Jim") {$contactid = "Jim S.";} else {$contactid = "0"; print "<p><br />Error: No Matches were found for your search. Did you +include capital letters?</p><br /><br />";} if($contactid ne "0") {print "<br /><br /><p>This is the information returned from your quer +y:</p><br /><br />";} my $qcontactid = dbh->quote($contactid); my $sth = $dbh->prepare("SELECT lastname, date_first_employed, annual_ +salary FROM employees WHERE firstname = $qfirstname, SELECT * FROM employee_contacts WHERE contact_id = $qcontactid"); $sth->execute( ); while (($lastname, $date_first_employed, $annual_salary, $date_first_e +mployed, $email_address, $home_phone_number, $emergency_phone_number) = $sth->f +ethrow_array()) { print "<p>Employee ID: $id<br /><br />Last Name: $lastname<br /><b +r /> Date First Employed: $date_first_employed<br /><br /> Annual Salary: $annual_salary<br /><br />Contact ID: $contactid<br + /><br /> Email Address: $email_address<br /><br />Home Phone Number: $home_ +phone_number<br /><br /> Emergency Phone Number: $emergency_phone_number</p><br /><br />"; } $sth->finish( ); $dbh->disconnect( );

In reply to Calling a PERL script from an html form by steampunk333

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-17 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found