hi all, can someone please help out.i am using php to insert data into an oracle 11g database.i have a table bus which has a foreign key franchisee name,i want when i am filling in the form,at the text box containing the franchisee name instead of inputting anything i have a drop down fetched from the db from which i can select the franchisee name and submit the form.the code i am using is shown below,it is nt giving me any result..if u can pliz help

<?php
	error_reporting(E_ALL);
	ini_set('display_errors', '1');

	// If submit button has been pressed.....
if (isset($_POST['submit']))
{
	// Connect to the database
	$c = @oci_connect('scott','tiger')
			or die("Could not connect to Oracle server !!");
			
	
			
	// Retrieve the posted new bus information.
	$fleet_number = $_POST['fleet_number'];
	$registration_number = $_POST['registration_number'];
	$model= $_POST['model'];
	$franchisee_id= $_POST['franchisee_id'];
	

	// Insert the bus information into the Bus table
	$s = oci_parse($c, "insert into bus(fleet_number,registration_number,model,franchisee_name)
						$fran = mysql_query("SELECT * FROM franchisee");
						echo '<select name="franchisee_name" TABINDEX="18"><OPTION>'; 
						echo "</OPTION>"; 
						while ($row_item = mysql_fetch_array($franchisee_name)){ 
						$fname = $row_item["fname"]; 
						echo "<OPTION value=\"$fname\">$fname</OPTION>"; 
						} 
						echo '</SELECT>';					
					values('$fleet_number','$registration_number','$model','$franchisee_id')");
					
	$result = oci_execute($s);
	
	// Display an appropriate message on either success or failure
	if ($result)
	{
		echo "<p>Bus successfully inserted!</p>";
		//oci_commit($C);
	}
	else
	{
		echo "<p>There was a problem inserting the Bus!</p>";
		var_dump(oci_error($s));
	}
	oci_close($c);
}
	// Include the isertion form
	include "insertbus.php";
?>
Re: select tag in oracle 80 80

Kindly post the SQL part only.

I am not sure from this code where is the INSERT statement .

Re: select tag in oracle 80 80

the sql part is

$fran = oci_query("SELECT * FROM franchisee");
echo '<select name="franchisee_name" TABINDEX="18"><OPTION>'; 
echo "</OPTION>"; 
while ($row_item = oci_fetch_array($franchisee_name)){ 
$fname = $row_item["fname"]; 
echo "<OPTION value=\"$fname\">$fname</OPTION>"; 
} 
echo '</SELECT>';
Re: select tag in oracle 80 80

I am not aware of how you do things in PHP, but i was expecting some INSERT statement as part of SQL.

or are you calling any stored object like a prodecure ?

Re: select tag in oracle 80 80

like i had shown in the full code the insert statement is there bt i will put it again

// Insert the bus information into the Bus table
	$s = oci_parse($c, "insert into bus(fleet_number,registration_number,model,franchisee_name)
$fran = mysql_query("SELECT * FROM franchisee");
echo '<select name="franchisee_name" TABINDEX="18"><OPTION>'; 
echo "</OPTION>"; 
while ($row_item = mysql_fetch_array($franchisee_name)){ 
$fname = $row_item["fname"]; 
echo "<OPTION value=\"$fname\">$fname</OPTION>"; 
} 
echo '</SELECT>';					
					values('$fleet_number','$registration_number','$model','$franchisee_id')");
					
	$result = oci_execute($s);
Re: select tag in oracle 80 80

ok, tell me what happens when you execute this ?

getting any error ?

Re: select tag in oracle 80 80

When i execute this the browser does not display anything<just a blank page

Re: select tag in oracle 80 80

but you are inserting a record , right ?

Is the record getting stored in database ?

Please check in backend .

Re: select tag in oracle 80 80

yes the record is being inserted in the database,i have tried checking where i went wrong but am not getting,the select code have i put it in the correct place?should it be part of the insert statement?bcoz thats why i am suspecting the mistake cud be

Re: select tag in oracle 80 80

is franchise_name getting inserted properly into the table.

Re: select tag in oracle 80 80

Hi maichy,

first thing if were using same code as your last post, please recheck it.
you have to take care of quotes as in line 2 you didn't close that quote and bracket also. I think only this kind of small mistakes only lead you for blank pages.. (as in HTML we will not get any error if there is any)..

so try again with keep mind on this suggestion and you would get your desired output...

Re: select tag in oracle 80 80

no,because the script is not being displayed on the browser

Re: select tag in oracle 80 80

yep,
This script should not display in browser...
It is PHP Script not a java script .. so definately scprit will not show in browser...
you have to manipulate in your code in .php file and then again run on php engine...

so do it ...

Be a part of the DaniWeb community

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