Solved

PHP form not inserting into Oracle Database

Posted on 2003-10-31
5
225 Views
Last Modified: 2013-12-12
This is similar to my MySql query a few days ago. I have this form set up to insert into an Oracle 9 database. I haven't messed with .htaccess or anything, and it never seems to enter the block where it puts data into the database. I tried the same code with pre-defined data values and it worked fine.



<HTML>
<TITLE>ORACLE form</TITLE>
<BODY>

<?php
if($_POST['submit'] == "Submit")
{
      echo "inside this block";   /* checks if it is inside the block */
      $iDBConn = ocilogon("DBNAME", "DB_PASSWORD", "DB_SERVER");
      if (!$iDBConn)
            echo ('fail');
      $strID;
      $strTESTDATA;
      
      $insertentries = "insert into TEST values ( :strID, :strTESTDATA )";
      $iStatement = @OCIParse($iDBConn, $insertentries);
      
      @OCIBindByName($iStatement, ':strID', &$_POST['strID']);
      @OCIBindByName($iStatement, ':strTESTDATA', &$_POST['strTESTDATA']);
      @OCIExecute($iStatement, OCI_DEFAULT);
      
      $arrError = OCIError($iStatement);
      if ($arrError['code'])
              { print $arrError['message'];
                  OCIRollback($iDBConn);
                  exit; }
      
      OCICommit($iDBConn);
}
?>

<?php
echo "
<form name=\"test\" method=\"post\" action=\"form.php\">
<input type=\"hidden\" name=\"strID\" value=\"null\">
testdata: <input type=\"text\" name=\"strTESTDATA\">
<input type=\"submit\" name=\"Submit\" value=\"Submit\">
</form>";
?>

</BODY>
</HTML>
0
Comment
Question by:TXLonghorn
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 100 total points
ID: 9660555

is it failing this condition?

if($_POST['submit'] == "Submit")

if so, adding a var_dump($_POST) might help to see what data you have to work with..
0
 

Author Comment

by:TXLonghorn
ID: 9660598
Where exactly do I add it?
0
 
LVL 14

Expert Comment

by:ThG
ID: 9660624

between <?php and if ( ...
0
 

Author Comment

by:TXLonghorn
ID: 9660712
Thanks for the info about the dump command... found two bugs:

in           if($_POST['submit'] == "Submit")

'submit' should have been 'Submit'

and        value=\"null\"

should have been value=\"\"

Something tells me the var_dump command will make debugging a whole lot easier for me.
0
 
LVL 14

Expert Comment

by:ThG
ID: 9660795
yes it does, var_dump and print_r (for arrays) are very useful commands.
bye
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question