MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2000, 10:28 AM
DaveVN DaveVN is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 6 DaveVN User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello all,

Thanks a lot for your kindness and time!

I used to use DBI very fine in Linux system. Now I use UNIX and it drives me crazy by little bugs that I can never figure out. Please help me!

I just say
use DBI;
use Strict;

then I connect to the database, print something, disconnect, then exit by "exit;" Then after the "exit;" statement, I have all the function definitions. The last line of my file is an empty line.

It worked, but one day I moved the "exit;" statement, and then put it back, it don't work anymore. It always give me this error and all the errors following this reason "syntax error in file job.pl at line 3, next 2 tokens "use DBI""

I took out everything, and started over to make a very very simple file just to have the "use DBI;" and the connection. It still doesn't work.

I guess that I missed an empty space somewhere. Is there anything you can suggest for me to check. I really really appreciate your kindness and time.

Best regards,

Dave.
Desparately wait for your help.

Reply With Quote
  #2  
Old August 31st, 2000, 10:45 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
It's tough to say what the problem is without seeing the whole source, but it sounds like you've simply got some bad Perl syntax. Try the following to see if it works:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
use DBI;

print "Successfully loaded DBI";
[/code]

If it doesn't print out "Successfully loaded DBI" or displays any errors, there's something iffy going on. To be honest, it's practically impossible to diagnose without at least some of the source, if not all. Your best bet is to post it up here for everyone to look at (if it's huge, just post up the stuff up to your subroutine defs or something). Remember to x out any passwords before you post! :-)

One thing, I'm sure this was just a typo as you posted, but use strict; is _all_ lower case -- use Strict will not work (you'll get an error about not being able to find Strict.pm in @INC).

Reply With Quote
  #3  
Old September 4th, 2000, 11:15 PM
DaveVN DaveVN is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 6 DaveVN User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you Christucker2. I really appreciate if you can find anything not right. I don't want you guys to do the work for me. But I am just stuck and have no way out. I have tried my best for 10 days and still stuck. I truly deeply appreciate any help.

Million thanks. This used to work just fine.

Dave.
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#! /usr/bin/perl

use DBI;
use strict;

my %INPUT;
my %INPUT_TO_COL;
my %INPUT_TO_QUOTE;
my ($sth, $dbh);
my ($namevalues,$namevalue,$name,$value,$valueToColons, $valueToQuotes);
my @namevalues;

&parseForm;
&printHeader;

$dbh = DBI->connect('DBI:mysql:employee') or die "Couldn't connect to database:".DBI->errstr;

my %BodyStates=(
'reviewJobForm'=>&createReviewPageBody,
'submitJobForm'=>&createThankYouPageBody,
);

if ($BodyStates{$INPUT{sig}}) {
$BodyStates{$INPUT{sig}}->();
}
else
{
print "We appologize. We can not find the page.";
}

&printFooter;
$dbh->disconnect ();
exit;

#########################################
#
#
#########################################
sub parseForm
{
# Start parsing data
read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});
@namevalues = split(/&/, $namevalues);
foreach $namevalue (@namevalues) {
($name, $value) = split(/=/, $namevalue);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/nn/<br><br>/g;
$value =~ s/n/<br>/g;
$value =~ s/<!--(.|n)*-->//g;

#Convert double quote to :::
#and single quote to ::
if ($INPUT_TO_COL{$name}) {
$valueToColons = $value;
$valueToColons =~ s/"/:::/g;
$valueToColons =~ s/'/::/g;
$INPUT_TO_COL{$name} .= ",$valueToColons";
}
else
{
$valueToColons = $value;
$valueToColons =~ s/"/:::/g;
$valueToColons =~ s/'/::/g;
$INPUT_TO_COL{$name} = $valueToColons;
}

#Convert ::: back to double quote
# and :: to single quote
if ($INPUT_TO_QUOTE{$name}) {
$valueToQuotes = $value;
$valueToQuotes =~ s/:::/"/g;
$valueToQuotes =~ s/::/'/g;
$INPUT_TO_QUOTE{$name} .= ",$valueToQuotes";
}
else
{
$valueToQuotes = $value;
$valueToQuotes =~ s/:::/"/g;
$valueToQuotes =~ s/::/'/g;
$INPUT_TO_QUOTE{$name} = $valueToQuotes;
}

#Exact input
if ($INPUT{$name}) {
$INPUT{$name} .= ",$value";
}
else
{
$INPUT{$name} = $value;
}

}#end of foreach loop


}#close parsing data
#########################################
#
#
#########################################
sub createReviewPageBody
{
print "<center><TABLE width=550 valign=top cellpadding=0 cellspacing=0>

<TR>
<TD width=550 valign=top cellpadding=0 cellspacing=0><BR>
<TABLE width=550 valign=top cellpadding=0 cellspacing=0>
<TR>
<TD width=250 valign=top cellpadding=0 cellspacing=0>
<font color="#000088"><B>Contact Information </B></font><BR>
</TD>
<TD width=50 valign=top cellpadding=0 cellspacing=0>*
</TD>
<TD width=250 valign=top cellpadding=0 cellspacing=0>
<font color="#000088"><B>Interest</B></font><BR>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD cellpadding=0 cellspacing=0>
<HR>
</TD>
</TR>
<TR>
<TD width=550 valign=top cellpadding=0 cellspacing=0>
<TABLE width=550 valign=top cellpadding=0 cellspacing=0>
<TR>
<TD width=250 valign=top>
$INPUT{title}*$INPUT{firstname}*$INPUT{lastname}<BR>
$INPUT{address}<BR>

($INPUT{phone1})*$INPUT{phone2}-$INPUT{phone3}<BR>
$INPUT{email} <BR>
Preferred contact by $INPUT{preferred}<BR>
</TD>
<TD width=50 valign=top >*</TD>
<TD width=250 valign=top>

Interest: $INPUT{interest} <BR>

</TD>
</TR>
</TABLE>
<BR>


</TD>
</TR>
<TR>
<TD width=630 valign=top><font color="#000088"><B>Resume</B></font><HR><BR>
<PRE>$INPUT{resume}</PRE>
<BR><BR>
</TD>
</TR>
<TR>
<TD width=630 valign=top><font color="#000088"><B>Cover Letter</B></font><HR><BR>
<PRE>$INPUT{letter}</PRE>

</TD>
</TR>
<TR>
<TD width=630 valign=top> <BR><BR><HR><BR>
<!-- hidden form to for edit or submit -->
<FORM NAME="form1" ACTION="/cgi-bin/jobs/job.pl" METHOD=POST>
<INPUT TYPE=hidden name="title" value="$INPUT_TO_COL{title}"><BR>
<INPUT TYPE=hidden name="firstname" value="$INPUT_TO_COL{firstname}">
<INPUT TYPE=hidden name="lastname" value="$INPUT_TO_COL{lastname}">
<INPUT TYPE=hidden name="address" value="$INPUT_TO_COL{address}">
<INPUT TYPE=hidden name="phone1" value="$INPUT_TO_COL{phone1}">
<INPUT TYPE=hidden name="phone2" value="$INPUT_TO_COL{phone2}">
<INPUT TYPE=hidden name="phone3" value="$INPUT_TO_COL{phone3}">
<INPUT TYPE=hidden name="email" value="$INPUT_TO_COL{email}">
<INPUT TYPE=hidden name="preferred" value="$INPUT_TO_COL{preferred}">
<INPUT TYPE=hidden name="interest" value="$INPUT_TO_COL{interest}">
<INPUT TYPE=hidden name="resume" value="$INPUT_TO_COL{resume}">
<INPUT TYPE=hidden name="letter" value="$INPUT_TO_COL{letter}">
<INPUT TYPE=hidden name="sig" value="submitJobForm">
<INPUT TYPE=button NAME="goback" VALUE="Back" onClick="goback()">
<INPUT TYPE=submit VALUE="Submit" >
<INPUT TYPE=button NAME="cancel" VALUE="Cancel" onClick="cancelbutton()">
<BR><BR>
</FORM>

</TD>
</TR>
</TABLE></center>";
}

#########################################
#
#
#########################################
sub createThankYouPageBody
{
my $contactTitle = $dbh->quote("$INPUT_TO_QUOTE{title}");
my $firstname = $dbh->quote("$INPUT_TO_QUOTE{firstname}");
my $lastname = $dbh->quote("$INPUT_TO_QUOTE{lastname}");
my $address = $dbh->quote("$INPUT_TO_QUOTE{address}");
my $areaCode = $dbh->quote("$INPUT_TO_QUOTE{phone1}");
my $cityCode = $dbh->quote("$INPUT_TO_QUOTE{phone2}");
my $phone = $dbh->quote("$INPUT_TO_QUOTE{phone3}");
my $email = $dbh->quote("$INPUT_TO_QUOTE{email}");
my $preferred = $dbh->quote("$INPUT_TO_QUOTE{preferred}");
my $resume = $dbh->quote("$INPUT_TO_QUOTE{resume}");
my $letter = $dbh->quote("$INPUT_TO_QUOTE{letter}");

$sth = $dbh->prepare(qq{INSERT INTO RESUME (RESUME_contactTitle, RESUME_firstname,RESUME_lastname,
RESUME_address, RESUME_areaCode, RESUME_cityCode,
RESUME_phone, RESUME_email, RESUME_preferred,
RESUME_resume, RESUME_letter)
VALUES ($contactTitle,$firstname,$lastname,$address,$areaCode,$cityCode,$phone,$email,
$preferred,$resume, $letter)
});


$sth->execute()
or die "Couldn't execute statement:".$sth->errstr;

$sth->finish();


print "<TABLE cellspacing=0 cellpadding=0 width="100%">
<TR>
<TD cellspacing=0 cellpadding=0 width="1" bgcolor="#FFCC00">
<IMG SRC="http://mydomain.com/images/bluedot.gif" >
</TD>

<TD cellspacing=0 cellpadding=0 width="147" bgcolor="#FFFFCC" valign=top><BR><BR><BR>

<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <BR><BR>

</TD>
<TD cellspacing=0 cellpadding=0 width="2" bgcolor="#FFCC00">
<IMG SRC="http://mydomain.com/images/bluedot.gif">
</TD>
<TD cellspacing=0 cellpadding=0 width="30" >* </TD>
<TD cellspacing=0 cellpadding=0 width="515" valign=top>
<TABLE cellspacing=0 cellpadding=0 width="515" valign=top >
<TR>
<TD cellspacing=0 cellpadding=0 width="515" valign=top>
<BR><font color="#000077" size=4><B>Thank you!</B></font><BR><BR>
<font color="">
Thank you, $INPUT_TO_QUOTE{title}*$INPUT_TO_QUOTE{firstname}*
$INPUT_TO_QUOTE{lastname}, for your interest in mydomain. We will contact you when we
have the appropriate positions.
Your resume record will remain active in our database for three months. Please feel free
to resubmit your resume after that period.<BR><BR>

Best regards,<BR><BR>


mydomain, LLC.<BR><BR></font>
</TD>
</TR>
</TABLE>
</TD>
<TD width=60>*</TD>
</TR>
</TABLE>";
}
#########################################
#
#
#########################################
sub printJavaScript
{

print "
<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function goback ()
{
window.history.go(-1);
}
function cancelbutton ()
{
if (confirm ("Are you sure you want to cancel your resume submission?"))
{
location.replace("contact.html");
}
}
</SCRIPT>";
}
#########################################
#
#
#########################################

sub printHeader
{
print "<HEAD>
<TITLE>mydomain Contact Information</TITLE>
<STYLE type="text/css">
a:link{color:"blue";text-decoration:none}

a:visited{color:"blue";text-decoration:none}

a:hover{color:red;text-decoration:none}

a:active{color:"#12E508";text-decoration:none}
</STYLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">";

&printJavaScript ;

print "</HEAD>
<BODY BGCOLOR="#FFFFFF" marginheight="2" marginwidth="2" topmargin="2" leftmargin="2" >
<table border="0" width="775" cellpadding="0" cellspacing="0" valign=top>
<tr>
<td border="0" width="635" cellpadding="0" cellspacing="0" valign=top >

<table border="0" width="635" cellpadding="0" cellspacing="0" valign=top >
<tr>
<td border="0" cellpadding="0" cellspacing="0" >
<table border="0" cellpadding="0" cellspacing="0" valign=top>
<tr>
<td border="0" cellpadding="0" cellspacing="0" valign=top>
<IMG SRC="http://mydomain.com/images/bluemydomainlabel.gif" border=0>
<A NAME="0">*</A> * * * *
</td>
<td border="0" cellpadding="0" cellspacing="0" valign=bottom>
<center><font size=3 color="#269ee8"><i>We collect prices, you collect money...</i></font></center><BR>
*
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td border="0" width="635" cellpadding="0" cellspacing="0" valign=top align=center >
**

</td>
</tr>
</table>

</td>
<td bgcolor="white" cellpadding="0" cellspacing="0" valign=top border=0>
*
</td>
</tr>
</table>

<table width="775" cellpadding="0" cellspacing="0" valign=top border=0 bgcolor="black">
<tr>

<td width="775" cellpadding="0" cellspacing="0" valign=top border=0 bgcolor="black">
<center>
<A HREF="http://mydomain.com">
<font color="#FFFFFF" size=1><B>HOME</B></font></A>****
<A HREF="/newusers.html">
<font color="#FFFFFF" size=1><B>NEW USERS</B></font></A>****
<A HREF="/services.html">
<font color="#FFFFFF" size=1><B>SERVICES</B></font></A>**
<A HREF="/talkboard.html">
<font color="#FFFFFF" size=1><B>TALK BOARD</B></font></A>****
<A HREF="/findstore.html">
<font color="#FFFFFF" size=1><B>FIND STORES</B></font></A>****
<A HREF="/livehelp.html">
<font color="#FFFFFF" size=1><B>LIVE HELP</B></font></A>****
<A HREF="/contact.html">
<font color="#FFFFFF" size=1><B>CONTACT US</B></font></A></B></font>
</center>
</td>

</tr>
</table>
<TABLE WIDTH="775" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFCC00">
<TR>

<TD ALIGN="CENTER" WIDTH="775" BORDER="0" CELLSPACING="0" CELLPADDING="0" >
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER">


<TR>
<TD BGCOLOR="#666633" COLSPAN="3"><IMG SRC="http://mydomain.com/images/bluedot.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
</TR>
<TR>
<TD BGCOLOR="#999966" COLSPAN="3"><IMG SRC="http://mydomain.com/images/bluedot.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
</TR>

<FORM ACTION="">
<TR>
<TD WIDTH="775" BORDER="0" CELLSPACING="0" CELLPADDING="0" ><center>
<B>Search</B> **

<SELECT>
<OPTION>Internet Services
<OPTION>Hardware
<OPTION>Software
<OPTION>Electronics
<OPTION>Office Supplies
<OPTION>Telecom & Wireless
<OPTION>Magazines
<OPTION>Apparel & Accessories
<OPTION>Sports & Leisure
<OPTION>Gifts & Flowers
<OPTION>Jewelry & Accessories
<OPTION>Home & Garden


</SELECT>**<INPUT TYPE=text size=15 name=search>**<IMG SRC="http://mydomain.com/images/gobutton.gif">
</center>
</TD>

</TR>
</FORM>

</TABLE>
</TD>

</TR>
<TR>
<TD BGCOLOR="#999966" COLSPAN="3"><IMG SRC="http://mydomain.com/images/bluedot.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
</TR>
<TR>
<TD BGCOLOR="#666633" COLSPAN="3"><IMG SRC="http://mydomain.com/images/dot.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>
</TR>
</TABLE>";
}
#########################################
#
#
#########################################
sub printFooter
{
print "
<table cellspacing=0 cellpadding=0 width="775">
<tr>
<td width="775" bgcolor="black" cellpadding="0" cellspacing="0" align=center height=25>
<B>
<font color="white" size=3>FAQs****
Advertising****
Join mydomain****
Discussion board****
News list**</font></B>
</td>
</tr>
<tr><td valign=bottom width=775 cellpadding="0" cellspacing="0">
<center>
<table valign=bottom width=600 cellpadding="0" cellspacing="0">
<tr>
<td valign=bottom width=600 cellpadding="0" cellspacing="0">
<BR><CENTER>
<A HREF=""><font size=3>100 Hots</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Clearance</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Free Values</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Live Help</font></A>*
<BR>
<A HREF=""><font size=3>Home</font></A>*<font color="green">|</font>
<A HREF=""><font size=3>Company Info</font></A>*<font color="green">|</font>
<A HREF=""><font size=3>Partners</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Customer Service</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Your Privacy</font></A>*
<font color="green" >|</font>
<A HREF=""><font size=3>Copyright</font></A>
*
<font color="green" >|</font>
<A HREF=""><font size=3>Contact</font></A>*
<br><font size=3>
© 2000 mydomain, LLC.</font></center>
</td></tr>
</table>
</center>
</td></tr>
</table>

</body>
</html>";
}
[/code]


[This message has been edited by DaveVN (edited September 05, 2000).]

Reply With Quote
  #4  
Old September 5th, 2000, 12:23 AM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
good god, please use the CODE tags

Reply With Quote
  #5  
Old September 5th, 2000, 05:31 AM
des des is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 73 des User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Don't know if this is what your looking for
I put this line <print "Content-type: text/htmlnn";>
in and am getting a connection and a web page printed out " we collect prizes you collect money"


use DBI;
use strict;

print "Content-type: text/htmlnn";

Reply With Quote
  #6  
Old September 5th, 2000, 12:45 PM
DaveVN DaveVN is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 6 DaveVN User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Des,

Thanks a lot. I tried it. It worked! I used to use CGI.pm, so that's why I didn't print the Content line.

Your help is greatly deeply appreciated!!!

Dave


[This message has been edited by DaveVN (edited September 05, 2000).]

[This message has been edited by DaveVN (edited September 05, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > DBI with UNIX. Help please!!! Newbie.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT