예 저는 학생입니다. 예. 과제입니다.하지만 도움을 청하는 데 도움이 필요합니다. 나는 누군가가 나를 위해 숙제를하려고하지 않는다.Perl, HTML 및 MySQL은 어디에서 중단 되었습니까?
그래서 6 개의 서로 다른 데이터 열이 포함 된 데이터베이스가 5 권 있습니다. 그 데이터베이스를 검색하고 결과를 테이블로 반환 할 수있는 펄 프로그램을 만들려고합니다. 카트에 카트를 추가하는 방법을 추가해야하지만 나중에 나옵니다.
Perl의 문제점은 "내부 서버 오류"가 발생하는 이유를 확인하는 방법을 모르는 것입니다. 응용 프로그램은 Perl 페이지로 이동하므로 그 점을 추측합니다.
#!/usr/bin/perl
use warnings; # allow for warnings to be sent if error's occur
use CGI qw(:standard); # not a 100% sure what the rest of these mean but they are like #includs in C++, libraries for reference in the code
use DBI;
use DBD::mysql; #database data will come from mysql
my $dbh = DBI->connect("DBI:mysql:DATABASE NAME", "USERNAME", "PASS REMOVED") or
die("Could not make connection to database: $DBI::errstr"); # connect to the database with address and pass or return error
$term = $SEARCHTERM[]; #set the search char to $term
$term =~ tr/A-Z/a-z/; #set all characters to lowercase for convenience of search
$sql = "SELECT * FROM Books WHERE Title LIKE %$term% OR Description LIKE %$term% OR Author LIKE %$term%" or die ("$term may have not worked"); #set the query string to search the database
$sth = $dbh->prepare($sql); # prepare to connect to the database
$sth->execute # connect to the database
or die "SQL Error: $DBI::errstr\n"; #or return an error
while (@data = $sth->fetchrow_array) { #while we are grabbing he queried data do a table setup and set variables for table
print "<table width=\"100%\" border=\"0\"> ";
$title = $data[0];
$desc = $data[1];
$author = $data[2];
$pub = $data[3];
$isbn = $data[4];
$photo = $data[5];
print "<tr> <td width=50%>Title: $title</td> <td width=50% rowspan=5>$photo</td></tr><tr><td>Discreption Tags: $desc</td></tr><tr><td></td></tr><tr><td>Author: $author</td></tr><tr><td>ISBN: $isbn</td>
</tr></table> \n";
}
도와주세요!
스택 오버플로이 질문에 대한 적절한 장소가 아니다 : 2
옵션 :
옵션 1 ... 누군가가 제목 "푸의 바"에 대한 검색이 경우 발생하는 고려 . 우리는 코드 디버깅을하지 않습니다. 자신 만의 디버깅이 필요하고 왜 무언가가 예상대로 작동하지 않는지 잘 모르겠 으면 관련 코드 *를 게시하십시오 (코드 벽을 게시 한 다음 독자적으로 디버깅을하지 않은 경우). 모든 오류 메시지를 포함하여 실제로 수행 할 작업과 예상 작업에 대한 설명. See [stack overflow] (http://stackoverflow.com/about). –
실제 질문은 '내가 펄 스크립트에서 501 오류를 어떻게 추적합니까?'라고 들리는 것 같습니다. 아마도 아파치 로그를 확인 하시겠습니까? – bchurchill
모든 CGI 프로그램은 다른 것을 인쇄하기 전에 머리글을 내야합니다. 최소한의 헤더는'print "Content-type : text/html \ n \ n" "이지만 [CGI]의'header' 메소드를 더 잘 사용합니다 (https://metacpan.org/module/MARKSTOS/CGI.pm- 3.63/lib/CGI.pm) - 예를 보려면 개요를 참조하십시오. 클라이언트가 500을 얻는 동안 'die'가 실행되면 로그에서 메시지를 찾을 수 있습니다. – amon