The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
POST vs GET
Discuss POST vs GET in the Perl Programming forum on Dev Shed. POST vs GET Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 6th, 2000, 10:52 PM
|
|
Junior Member
|
|
Join Date: Sep 2000
Location: Piscataway, NJ, USA
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
When you submit a form, you can specify the method to be either POST or GET.. now it seems the difference among them is obvious, however ... what is the difference?
the search engine i created uses GET.. and basically I have a perl script which uses..
$CGI->param("fieldname").. to retrieve the stuff from the form, and then it takes this variable and puts into an SQL statement which is then sent to the mySQL database and processes and returns query.
Recently I've been trying to do the same thing, but instead of searching the database I want to add data to the database, using SQL insert statements.. Now I don't understand why my code doesn't work, because the script is able to extract the fields from the submited form and print them out on the screen.. however, the actual SQL statement doesn't execute because nothing gets added to a database.
So I was wondering, is this in anyway related to the GET/POST of the form. Theoretically GET shoudl work as long as its able to extract those variables.
I also don't get any error message regarding compilation errors or anything liek that.. so syntax is A-ok..
the SQL portion is as follows, why won't this addd to the database???
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#### attempt connection
$dbh = DBI->connect("DBI:mysql:$db", "$username", "$password");
#or die "can't connect to the database: $dbh->errstrn";
# this is the SQL statement the program executes
$statement = "INSERT INTO graphics (url, query, height, width, artistname, artisturl, email, category) VALUES ('$url', '$query', '$height', '$width', '$artistname', '$artisturl', '$email', '$category')";
#### The prepare and execute statement.
$sth = $dbh->prepare($statement);
$rv = $sth->execute;
[/code]
THanks
|

September 6th, 2000, 11:04 PM
|
|
Junior Member
|
|
Join Date: Sep 2000
Location: Piscataway, NJ, USA
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I know this script connects to the database because i just copied and pasted the connection part from a script that actually works and interacts w/the database. so thtas not the problem.
|

September 7th, 2000, 02:51 PM
|
|
Junior Member
|
|
Join Date: Jul 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Try printing $statement (see what it contains)
|

September 9th, 2000, 07:03 PM
|
|
Contributing User
|
|
Join Date: Aug 2000
Location: Indiana
Posts: 614
  
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 14
|
|
|
You're forgetting that you have to view the sql error manually. it wont give a perl error:
#### The prepare and execute statement.
$sth = $dbh->prepare($statement) | | print "$dbh->errstr";
$rv = $sth->execute | | print "$dbh->errstr";
[This message has been edited by JonLed (edited September 09, 2000).]
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|