Hello everyone, I have a PHP form that connects to an oracle DB and should send data to the database when the form is submitted, but I can't figure out why it's not loading any of the data into the database, everything seems to be correct (though this is my first time attempting something like this, so I am likely wrong).

Is there something wrong with the way in which I've structured this page, or something wrong with the way I'm binding variables? Why isn't this properly working?

Note: I changed the connect string to a fake one for security.

Any tips and helps would be greatly appreciated, thanks!

> <?php
> //ini_set('display_errors', 'On');
> //error_reporting(E_ALL | E_STRICT);
> //include("insert.php");
> 
>   $conn = oci_connect("user", "password", "//path/to");
>   if (!$conn) {
>      $m = oci_error();
>      echo $m['message'], "\n";
>      exit;
>   }
>   else {
>      print "You are connected to the VTC database!<br/>";
>   }
> $issueType = $_POST['issueType'];
> $summary = $_POST['summary'];
> $endPointName = $_POST['endPointName'];
> $contactFirstName = $_POST['contactFirstName'];
> $contactLastName = $_POST['contactLastName'];
> $contactEmail = $_POST['contactEmail'];
> $contactPhone = $_POST['contactPhone'];
> $description = $_POST['description'];
> $solution = $_POST['solution'];
> $ticketNumber = $_POST['ticketNumber'];
> $resolved = $_POST['resolved'];
> $agency = $_POST['agency'];
> 
> $insert = 'INSERT INTO VTC_HELPDESK_ISSUES(ISSUE_TYPE,ISSUE_SHORT,ENDPOINT_NAME,CONTACT_FIRST_NAME,CONTACT_LAST_NAME,CONTACT_EMAIL,CONTACT_PHONE,ISSUE_DESC,SOLUTION,OTHER_COMPANY_TICKET_NUM,RESOLVED,AGENCY  ) '.
>        'VALUES(9, :issueType, :summary, :endPointName, :contactFirstName, :contactLastName, :contactEmail, :contactPhone, :description, :solution, :ticketNumber, :resolved, :agency)';
> 
> $send = oci_parse($conn, $insert);
> 
> //Binding makes it harder to submit anything directly to the Oracle DB
> oci_bind_by_name($send, ':issueType', $issueType);
> oci_bind_by_name($send, ':summary', $summary);
> oci_bind_by_name($send, ':endPointName', $endPointName);
> oci_bind_by_name($send, ':contactFirstName', $contactFirstName);
> oci_bind_by_name($send, ':contactLastName', $contactLastName);
> oci_bind_by_name($send, ':contactEmail', $contactEmail);
> oci_bind_by_name($send, ':contactPhone', $contactPhone);
> oci_bind_by_name($send, ':description', $description);
> oci_bind_by_name($send, ':solution', $solution);
> oci_bind_by_name($send, ':ticketNumber', $ticketNumber);
> oci_bind_by_name($send, ':resolved', $resolved);
> oci_bind_by_name($send, ':agency', $agency);
> 
> oci_execute($send);
> 
> ?>
> 
> <!DOCTYPE html>
> <html>
>   <head>
>     <!--<title>VTC Issues Entry</title>-->
>     <meta charset="utf-8" />
>   </head>
> 
>   <body>
> 
> <form>
>   <fieldset id = "vtcForm">
>       <form action="form.php" id="insert" method="post">
> 
>   <!--Issue Type-->
>   <label for="issueType"><b>Issue Type</b><br/></label>
>   <select name="issueType" id = "issueType">
>     <option>Support</option>
>     <option>Hardware</option>
>     <option>External Call</option>
>     <option>Other</option>
>   </select> 
>   <br/><br/>
> 
>   <!--Short Description-->
>   <!--<form method="post" action="">-->
>   <b>Summary of the Issue</b><br/>
>   <textarea name="summary" id = "summary" cols="50" rows="10">
>   </textarea>
>   <!--<input type="submit" value="Submit" />
>   </form>-->
>   <br/><br/>
> 
>   <!--Endpoint Name-->
>   <?php print '<label for="testOption"><b>Test Option</b><br/></label>
>     <select name="endPointName" id = "endPointName">';
    $conn = oci_connect("user", "password", "//path/to");>   $query = 'select endpoint_name from endpoint_ref';
>   $stid = oci_parse($conn, $query);
>   $result = oci_execute($stid); 
>   while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
>      foreach ($row as $item) {
>          print '<option>'.($item !== null ? htmlentities($item, ENT_QUOTES) : '&nbsp').'</option>'; // but you should include an id or something for the option value
>      }
>   }
>   print '</select>';?>
>   <br/><br/>
> 
>   <!--Contact Name-->
>   <label for="contactFirstName"><b>Contact Name</b><br/></label>
>   <input type = "text"
>     name = "contactFirstName"
>     id = "contactFirstName"
>     value = "Herp Derp" 
>   />
>   <br/><br/>
> 
> <!--Contact Name-->
>   <label for="contactLastName"><b>Contact Name</b><br/></label>
>   <input type = "text"
>     name = "contactLastName"
>     id = "contactLastName"
>     value = "Derp" 
>   />
>   <br/><br/>
> 
>   <!--Contact Email-->
>   <label for="contactEmail"><b>Contact E-Mail</b><br/></label>
>   <input type = "text"
>     name = "contactEmail"
>     id = "contactEmail"
>     value = "Herp@Derp.com" 
>   />
>   <br/><br/>
> 
>   <!--Contact Phone Number-->
>   <label for="contactPhone"><b>Contact Phone Number</b><br/></label>
>   <input type = "text"
>     name = "contactPhone"
>     id = "contactPhone"
>     value = "0123456789" 
>   />
>   <br/><br/>
> 
>   <!--Description of Issue-->
>   <b>Full Description of Issue</b><br/>
>   <textarea name="description" cols="50" rows="10">
>   </textarea>
>   <br/><br/>
> 
>   <!--Description of Solution-->
>   <b>Solution</b><br/>
>   <textarea name="solution" cols="50" rows="10">
>   </textarea>
>   <br/><br/>
> 
>   <!--Ticket Number Reference-->
>   <label for="ticketNumber"><b>Ticket Number Reference</b><br/></label>
>   <input type = "text"
>     name = "ticketNumber"
>     id = "ticketNumber"
>     value = "9876543210" 
>   />
>   <br/><br/>
> 
>   <!--Resolved-->
>   <label for="resolved"><b>Resolved?</b><br/></label>
>   <select name="resolved" id = "resolved">
>     <option>Yes</option>
>     <option>No</option>
>   </select> 
>   <br/><br/>
> 
>   <!--Agency-->
>   <label for="agency"><b>Agency</b><br/></label>
>   <select name="agency" id = "agency">
>     <option>1</option>
>     <option>2</option>
>     <option>3</option>
>   </select> 
>   <br/><br/>
> 
>   </fieldset>
>   <input type="submit" value=" Submit " name='insert' />
> </form>
> 
>   </body>
> </html>
Member Avatar for LastMitch

@Navlag

I have a PHP form that connects to an oracle DB and should send data to the database when the form is submitted, but I can't figure out why it's not loading any of the data into the database, everything seems to be correct (though this is my first time attempting something like this, so I am likely wrong).

You never mention which line has an error. When you Insert a data to the DB it will give you an error of which line.

Read this about how to INSERT:

http://www.oracle.com/technetwork/articles/seliverstov-multirows-098120.html

Read also this about PHP & ORACLE:

http://www.orafaq.com/wiki/PHP_FAQ

Weird, I did turn on error reporting and I never got one in the page, the data just never shows up in the database.

Check all the parameters are you using in query, and match them with database.

Hey guys, thanks for the help. If anyone's still interested, I got it to produce some errors.

First of all all, it's warning me that there are undefined indexes.

The major error though, is:

Warning: oci_execute(): ORA-00913: too many values in /srv/www/htdocs/vtc/form.php on line 47

Actually I fixed that one, by changing up the insert query a bit, but now I get:

ORA-01031: insufficient privileges

Ideas?

Member Avatar for LastMitch

@Navlag

ORA-01031: insufficient privileges

Ideas?

You're on the right track now because errors are appearing. This is a good sign because you are close to solving this issue.

Read and follow the instructions (unless you don't have access to that):

http://www.dba-oracle.com/t_ora_01031_insufficient_privileges.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.