Thread: POST vs GET

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Piscataway, NJ, USA
    Posts
    10
    Rep 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
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Piscataway, NJ, USA
    Posts
    10
    Rep 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.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    Try printing $statement (see what it contains)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    15
    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) &#0124; &#0124; print "$dbh->errstr";
    $rv = $sth->execute | | print "$dbh->errstr";

    [This message has been edited by JonLed (edited September 09, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo