|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
Try printing $statement (see what it contains)
|
|
#4
|
|||
|
|||
|
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).] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > POST vs GET |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|