Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Don't ask to ask, just ask
 
PerlMonks  

Re: Cannot run a simple script?help im new

by matthewb (Curate)
on Mar 01, 2005 at 06:57 UTC ( [id://435375]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Cannot run a simple script?help im new

all i keep getting is 500 internal error, i cannot understand why this is happening???

You've received some good advice and clearly some kind of CGI tutorial would help you out.

The obvious reason that your script won't compile, however, is that you are using strict (recommended) but not then using my to declare your variables.



MB

Replies are listed 'Best First'.
Re^2: Cannot run a simple script?help im new
by ginda (Initiate) on Mar 01, 2005 at 23:25 UTC
    Thanks all for your help
    I have tried to implement what you guys have advised heres the code:

    #!c:/perl/bin/perl -wT

    use strict;
    use CGI;
    use CGI::Carp qw(fatalsToBrowser);
    use vars qw($Query $sth $dbh $Value @results @row);
    $Query = new CGI( );
    use DBI;
    $dbh = DBI->connect('DBI:mysql:exelstock')
    or die "Cannot connect: " . $DBI::errstr;

    $Value = $Query->param('input');


    $sth = $dbh->prepare("SELECT * FROM stock WHERE name=$Value");
    $sth = $dbh->execute();
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<BODY>\n";
    while (@results = $sth->fetchrow_array) { print "@row\n";
    }
    $sth = $dbh->finish();
    $dbh->disconnect();
    print "</HTML>\n";
    print "</BODY>\n";


    Heres the error i get now...any ideas???

    Can't locate object method "execute" via package "DBI::db" at c:\PROGRA~1\APACHE~1\apache\cgi-bin\project2.cgi line 23.

      That's simply because, as the error message says, DBI::db doesn't have an execute method. Try changing it from $sth = $dbh->execute(); to $sth->execute();

      Also, please use code tags when posting code. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://435375]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.