gpt4 book ai didi

mysql - Perl、HTML 和 MySQL 我的程序哪里出错了?

转载 作者:行者123 更新时间:2023-12-01 00:11:30 24 4
gpt4 key购买 nike

<分区>

是的,我是一名学生,是的,这是一项作业,但我只是需要一些帮助来清理问题。我不打算让别人帮我做作业。

所以我有一个数据库,里面有 5 本书,有 6 个不同的数据列。我正在尝试制作一个可以搜索该数据库并将结果返回到表中的 perl 程序。我必须添加一种将它们添加到购物车的方法,但稍后会出现。

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";



}

请帮忙!

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com