Solved

PHP form not inserting into Oracle Database

Posted on 2003-10-31
5
221 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now