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";
?>

Kindly post the SQL part only.

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

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>';

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 ?

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);

ok, tell me what happens when you execute this ?

getting any error ?

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

but you are inserting a record , right ?

Is the record getting stored in database ?

Please check in backend .

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

is franchise_name getting inserted properly into the table.

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...

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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.