Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Store dynamic value in jsp

843840Sep 13 2008 — edited Sep 14 2008
hi,
i have two page i pass value from one page to another and got it. now i want to store that dynamic value which i pass. i store it and got it my problem is that when page submit then value become null.
i have three submit button.

my code is
<%@ page import ="javax.servlet.*;"  %>
<%@ page import ="javax.servlet.http.*;" %>
<%@ page import ="java.io.*;" %>
<%@ page import ="java.sql.*;" %>
<%!   Connection con = null;
    ResultSet rs;
    Statement stmt = null;
    String query = null;
    ResultSet rs1;
    Statement stmt1 = null;
    String query1 = null;
    ResultSet rs2;
    Statement stmt2 = null;
    String query2 = null;
%>

<input type="hidden" value="<%=request.getParameter("ID")%>" name="id_4_add" />
<%String datamt = request.getParameter("id_4_add");%>
<input type="hidden" value="<%=datamt%>" name="id_4_" />
<%String datamt1 = request.getParameter("id_4_");%>
<input type="hidden" value="<%=datamt1%>" name="id_4_1" />
<%String datamt2 = request.getParameter("id_4_1");%>

<%
            String data1 = request.getParameter("ID");
            String grp_name = request.getParameter("param1");
            out.println(data1);
            out.println(grp_name);
%>
<%    try {
                String username = "root";
                String password = "root";
                String url = "jdbc:mysql://localhost/eureka_final?user=root&password=root";
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con = DriverManager.getConnection(url, username, password);
            } catch (Exception e) {
// out.println("Sorry failed to connect to the Database. " + e.getMessage());
            }
%>
<%
            java.util.Date utilDate = new java.util.Date();
            java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
            String teacher_id = "";
            Object usr_name = session.getValue("Username");
            Object ur_type = session.getValue("Usertype");

            stmt = con.createStatement();
///Teacher user
            if (ur_type == "teacher") {
                try {
                    String search_teacher = "select tchr_id from teacher where username = '" + usr_name + "'  ";
                    rs = stmt.executeQuery(search_teacher);
                    if (rs != null) {
                        while (rs.next()) {
                            teacher_id = rs.getString("tchr_id");
                        //      String teacher_Nm = rs.getString("username");
                        }
                    }
                } catch (Exception e) {
                    out.println(e.getMessage());
                } finally {
                    rs.close();
                    stmt.close();
                }
            }

//Admin user 
            if (ur_type == "admin") {
                stmt = con.createStatement();
                try {
                    String search_teacher = "select other_id from other_user where username = '" + usr_name + "'  ";
                    rs = stmt.executeQuery(search_teacher);
                    if (rs != null) {
                        while (rs.next()) {
                            teacher_id = rs.getString("other_id");
                        //      String teacher_Nm = rs.getString("username");
                        }
                    }
                } catch (Exception e) {
                    out.println(e.getMessage());
                } finally {
                    rs.close();
                    stmt.close();
                }
            }
%>
<%          if ("D".equals(request.getParameter("hidMode")) && con != null) {
                String chk_value;
                try {
                    stmt = con.createStatement();
                    query = "update student set groups = '' WHERE student_id='" + request.getParameter("hidSelDel") + "'";
                    stmt.executeUpdate(query);
                    response.sendRedirect("search_grp_try.jsp?ID1=" + datamt + " ");
                } catch (Exception e) {
// out.println("Sorry failed to delete values from the database table. " + e.getMessage());
                }
            }
            if ("U".equals(request.getParameter("hidMode")) && con != null) {
                try {
                    stmt = con.createStatement();
                    query = "UPDATE create_group SET group_name = '" + request.getParameter("txtBookName") + "', group_type = '" + request.getParameter("txtSynopsis") + "', group_details = '" + request.getParameter("txtAuthorName") + "' WHERE group_id = '" + request.getParameter("hidBookID") + "'";
                    stmt.executeUpdate(query);
                    response.sendRedirect("search_grp_try.jsp");
                } catch (Exception e) {
//out.println("Sorry failed to delete values from the database table. " + e.getMessage());
                }
            }
            /*  if ("I".equals(request.getParameter("hidMode")) && con != null) {
            String gp_name  = request.getParameter("txtBookName");
            String gp_type  = request.getParameter("txtSynopsis");
            String gp_detail  = request.getParameter("txtAuthorName");
            String publishername = request.getParameter("txtPublisherName");
            
            try {
            if (gp_name.length() > 0 && gp_type.length() > 0 && gp_detail.length() > 0) {
            stmt = con.createStatement();
            query = "INSERT INTO create_group (group_name, group_type, create_date, group_details,group_creator_id) VALUES ('" + gp_name + "','" + gp_type + "','" + sqlDate + "','" + gp_detail + "','" + teacher_id + "')";
            //String query = "INSERT INTO create_group (group_name, group_type, create_date, group_details,group_creator_id) VALUES ('" + gp_name + "','" + gp_type + "','" + sqlDate + "','" + gp_detail + "','" + teacher_id + "')";
            stmt.executeUpdate(query);
            response.sendRedirect("search_grp_try.jsp");
            } else {
            out.println("Group creation details cannot be left blank.");
            }
            } catch (Exception e) {
            //out.println("Sorry failed to insert values into the Database table. " + e.getMessage());
            }
            }*/
            out.println("<HTML>");
            out.println("<HEAD>");
            out.println("<SCRIPT LANGUAGE='JavaScript'>");
            out.println("function setMode() {");
            out.println("document.frmBook.txtBookName.value='';");
            out.println("document.frmBook.txtSynopsis.value='';");
            out.println("document.frmBook.txtAuthorName.value='';");
            out.println("document.frmBook.txtPublisherName.value='';");
            out.println("}");
            out.println("function setDelMode()");
            out.println("{");
            out.println("document.frmBook.hidMode.value='D';");
            out.println("formDeleteValues('hidSelDel');");
            out.println("}");
            out.println("function formDeleteValues(hidden)");
            out.println("{");
            out.println("var selValues = '';");
            out.println("for (i=0;i<document.forms[0].elements.length;i++)");
            out.println("{");
            out.println("if(document.forms[0].elements.type == \"checkbox\")");
out.println("{");
out.println("if (document.forms[0].elements[i].checked == true) {");
out.println("selValues = selValues + document.forms[0].elements[i].value + \",\";");
out.println("}");
out.println("}");
out.println("}");
out.println("if (selValues.length < 1)");
out.println("{");
out.println("alert(\"Please choose records you wish to delete.\");");
out.println("}");
out.println("else");
out.println("{");
out.println("selValues = selValues.substring(0,selValues.length-1);");
out.println("eval(\"document.forms[0].\"+hidden+\".value = '\" +selValues+\"';\");");
out.println("document.forms[0].submit();");
out.println("}");
out.println("}");
out.println("function setEditMode(BookID,BookName, Synopsis, AuthorName)");
out.println("{");
out.println("document.frmBook.hidBookID.value = BookID;");
out.println("document.frmBook.txtBookName.value = BookName;");
out.println("document.frmBook.txtSynopsis.value = Synopsis;");
out.println("document.frmBook.txtAuthorName.value = AuthorName;");
// out.println("document.frmBook.txtPublisherName.value = PublisherName;");
out.println("document.frmBook.hidMode.value='U';");
out.println("}");
%>
function copyField()
{
document.forms["frmBook"].id_4_.value = document.forms["frmBook"].id_4_add.value;

return true;
}

<%
out.println("</SCRIPT>");
out.println("<TITLE>Create Group</TITLE>");
out.println("</HEAD>");
%>
<BODY style="background-color:#EFEFEF; solid:#cccccc;">
<FORM ACTION='search_grp_try.jsp' METHOD='get' NAME='frmBook' >

<table style=" width:100%; " align="center" >
<tr>
<td height="20%" width="40%">
<jsp:include page="../toparea1.jsp">
<jsp:param name="" value="" />
</jsp:include>
</td>
</tr>
</table>
<table style=" width:100%; height:250px;" align="center" >
<tr>
<td width="20%" valign="top" >
<jsp:include page="../side_menu_bar.jsp" >
<jsp:param name="side" value="sidemenu" />
</jsp:include>
</td>

<INPUT NAME="hidMode" TYPE="hidden" VALUE="<%=request.getParameter("ID")%>">
<%

String id_passes = request.getParameter("hidMode");
out.println("<INPUT NAME='hidSelDel' TYPE='hidden'>");
out.println("<INPUT NAME='hidBookID' TYPE='hidden'>");

out.println("<TD valign='top'>");

out.println("</TD>");

// }
if (con != null) {
try {
stmt = con.createStatement();
query = "select student_id,username,std_Fname,std_Lname,groups from student where groups LIKE '%" + data1 + "%'";
rs = stmt.executeQuery(query);
out.println("<TR ALIGN='center' WIDTH='30%' COLSPAN='10'>");
out.println("<TABLE ALIGN='center' BORDER='1' BORDERCOLOR='skyblue' CELLPADDING='0' CELLSPACING='0' WIDTH='430px' NAME='tblSecondChild'>");
out.println("<TR BGCOLOR='black'>");
out.println("<TD WIDTH='12%' ALIGN='center'><INPUT NAME='cmdDelete' TYPE='button' VALUE='Delete' onClick='setDelMode();'></TD>");
out.println("<TD><FONT COLOR='#FFFFFF'>Group Name</FONT></TD>");
out.println("<TD><FONT COLOR='#FFFFFF'>Group Type</FONT></TD>");
out.println("<TD><FONT COLOR='#FFFFFF'>Group Detail</FONT></TD>");

out.println("</TR>");
if (rs != null) {
while (rs.next()) {
out.println("<TR>");
out.println("<TD><INPUT TYPE='checkbox' NAME='chk" + rs.getString("student_id") + "' VALUE='" + rs.getString("student_id") + "'></TD>");
out.println("<TD STYLE=\"cursor:pointer\" onMouseDown=\"setEditMode('" + rs.getString("student_id") + "', '" + rs.getString("username") + "', '" + rs.getString("std_Fname") + "', '" + rs.getString("std_Lname") + "');\">" + rs.getString("username") + "</TD>");
out.println("<TD STYLE=\"cursor:pointer\" onMouseDown=\"setEditMode('" + rs.getString("student_id") + "', '" + rs.getString("username") + "', '" + rs.getString("std_Fname") + "', '" + rs.getString("std_Lname") + "');\">" + rs.getString("std_Fname") + "</TD>");
out.println("<TD STYLE=\"cursor:pointer\" onMouseDown=\"setEditMode('" + rs.getString("student_id") + "', '" + rs.getString("username") + "', '" + rs.getString("std_Fname") + "', '" + rs.getString("std_Lname") + "');\">" + rs.getString("std_Lname") + "</TD>");
%>


<% // out.println("<TD STYLE=\"cursor:pointer\" onMouseDown=\"setEditMode('" + rs.getString("group_id") + "', '" + rs.getString("group_name") + "', '" + rs.getString("group_type") + "', '" + rs.getString("group_details") + "') + "');\">" + rs.getString("PublisherName") + "</TD>");
out.println("</TR>");
}
}
out.println("</TABLE>");
} catch (Exception e) {
out.println("Sorry Failed to execute the query. " + e.getMessage());
}
}
%>
</tr>
</table>
<a href="cr_grp.jsp">back</a>

<table>
<%! String srch_name1 = "";%><% srch_name1 = request.getParameter("search_stu");%>
<tr><td><input type="text" id="search_stu" name="search_stu" value="<%=srch_name1%>" size="42" /></td>

<td> <input type="submit" id="cmSearchStu_group" name="cmSearchStu_group" value="Search Student" />
</td></tr>
</table>


<input type="hidden" id="search_stu_store" name="search_stu_store" value="<%=request.getParameter("ID")%>" size="42" />
<input type="hidden" id="search_stu_store_name" name="search_stu_store_name" value="<%=request.getParameter("param1")%>" size="42" />
<%! String vl_data;
String student_Nm1;
String group_ID_from_student;
PreparedStatement ps;
%>
<%
//Pass Id and Group name

////////end pass value////////

if (request.getParameter("cmSearchStu_group") != null) {
String scondPass = request.getParameter("search_stu_store");
String scondPassName = request.getParameter("search_stu_store_name");
String srch_name = request.getParameter("search_stu");
out.println(srch_name);
stmt = con.createStatement();
try {
//student where groups LIKE '%" + data1 + "%'";
String search_stud = "select username,student_id,groups from student where std_Lname LIKE '%" + srch_name + "%' or std_Mname LIKE '%" + srch_name + "%' or username LIKE '%" + srch_name + "%' or std_Fname LIKE '%" + srch_name + "%' or city_c LIKE '%" + srch_name + "%' or state_c LIKE '%" + srch_name + "%' or pincode_c LIKE '%" + srch_name + "%' or city_p LIKE '%" + srch_name + "%'or state_p LIKE '%" + srch_name + "%' or pincode_p LIKE '%" + srch_name + "%' or std_DOB LIKE '%" + srch_name + "%' or std_gender LIKE '%" + srch_name + "%' or std_bloodGroup LIKE '%" + srch_name + "%' or std_addmission_no LIKE '%" + srch_name + "%' or std_transport LIKE '%" + srch_name + "%' or std_medicalNotes LIKE '%" + srch_name + "%' or std_home_no LIKE '%" + srch_name + "%' or std_emergency_no LIKE '%" + srch_name + "%' or std_email LIKE '%" + srch_name + "%' or std_parentemail LIKE '%" + srch_name + "%' or std_nationality LIKE '%" + srch_name + "%' or student_id LIKE '%" + srch_name + "%' or groups LIKE '%" + srch_name + "%' ";
rs = stmt.executeQuery(search_stud);
if (rs != null) {
while (rs.next()) {
String std_id1 = rs.getString("student_id");
student_Nm1 = rs.getString("username");
group_ID_from_student = rs.getString("groups");
// response.sendRedirect("search_grp_try.jsp?ID1="+scondPass+"&parameter1="+scondPassName+"#srch_grp_stud ");
%>

<input type="checkbox" name="<%=std_id1%>" value="<%=std_id1%>"/>
<INPUT MAXLENGTH="255" NAME="txtstud_name" TYPE="text" VALUE="<%=student_Nm1%>" >
<% String chkBxVal = request.getParameter(std_id1);
out.println(chkBxVal);
out.println(id_passes);
out.println(std_id1);

// out.println(m);
if ((chkBxVal != null)) {
try {
query2 = "update student set groups = " + scondPass + " WHERE student_id='" + std_id1 + "'";
ps = con.prepareStatement(query2);
ps.executeUpdate();
String sendTo = "search_group.jsp?id='" + request.getParameter("ID") + "' ";
response.sendRedirect(sendTo);
} catch (Exception e) {
out.println(e.getMessage());
}
}
}
}

} catch (Exception e) {
out.println(e.getMessage());
} finally {
rs.close();
stmt.close();
// con.close();
}
}
%>

<% if (request.getParameter("Add_student") != null) {
String scondPass = request.getParameter("search_stu_store");
String scondPassName = request.getParameter("search_stu_store_name");
%>
<input type="hidden" id="search_stu_str_name" name="search_stu_str_name" value="<%=request.getParameter("param1")%>" size="42" />
<%String srch_name = request.getParameter("search_stu");
String valueGetd = request.getParameter("search_stu_str_name");

stmt = con.createStatement();
try {
String search_stud = "select username,student_id,groups from student where std_Lname = '" + srch_name + "' or std_Mname ='" + srch_name + "' or username='" + srch_name + "' or std_Fname='" + srch_name + "' or city_c='" + srch_name + "' or state_c='" + srch_name + "' or pincode_c='" + srch_name + "' or city_p='" + srch_name + "'or state_p='" + srch_name + "' or pincode_p='" + srch_name + "' or std_DOB='" + srch_name + "' or std_gender='" + srch_name + "' or std_bloodGroup='" + srch_name + "' or std_addmission_no='" + srch_name + "' or std_transport='" + srch_name + "' or std_medicalNotes='" + srch_name + "' or std_home_no='" + srch_name + "' or std_emergency_no='" + srch_name + "' or std_email='" + srch_name + "' or std_parentemail='" + srch_name + "' or std_nationality='" + srch_name + "' or student_id='" + srch_name + "' or groups='" + srch_name + "' ";
rs = stmt.executeQuery(search_stud);
if (rs != null) {
while (rs.next()) {
String std_id1 = rs.getString("student_id");
student_Nm1 = rs.getString("username");
group_ID_from_student = rs.getString("groups");
// response.sendRedirect("search_grp_try.jsp?ID1="+scondPass+"&parameter1="+scondPassName+"#srch_grp_stud ");
%>

<input type="checkbox" name="<%=std_id1%>" value="<%=std_id1%>"/>
<INPUT MAXLENGTH="255" NAME="txtstud_name" TYPE="text" VALUE="<%=student_Nm1%>" >
<% String chkBxVal = request.getParameter(std_id1);

String symbl = " ; ";
/* if((group_ID_from_student).equals(null)){
group_ID_from_student="";
}
else{
*/ String merge_grp = group_ID_from_student + symbl;
String final_merge = merge_grp + datamt1;
if ((chkBxVal != null)) {
try {
query2 = "update student set groups = '" + final_merge + "' WHERE student_id='" + std_id1 + "'";
ps = con.prepareStatement(query2);
ps.executeUpdate();
} catch (Exception e) {
out.println(e.getMessage());
}
}
// }
}
}

} catch (Exception e) {
out.println(e.getMessage());
} finally {
rs.close();
stmt.close();
con.close();
}
// response.sendRedirect("search_grp_try.jsp?ID1=" + id_passes + "&parameter1=" + scondPassName + "#srch_grp_stud ");

}
%>
<input type="submit" id="Add_student" name="Add_student" value="Add" />
<table style="width:100%; height:100px; " align="center" >
<td >
<%@ include file="../pagefooter.jspf" %>
</td>
</table>
<input type="text" value="<%=request.getParameter("ID")%>" name="id_4_add5" />
<%String datamt4 = request.getParameter("id_4_add5");%>
<input type="text" value="" name="id_4_" />
<input type="submit" onclick="return copyField();" />
<% out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");

%>
reply me                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

Comments

The PHP OCI8 extension and PDO_OCI adapter use Oracle Call Interface APIs. If you use either of these two layers, you will need to build PHP with Oracle libraries which have these APIs. These libraries are included in the Oracle Database $ORACLE_HOME/lib directory, or are available with Oracle Client (installed via Oracle Installer), or in Oracle Instant Client (installed via ZIP or RPM).

For some notes on installing with OHS, see https://blogs.oracle.com/opal/entry/building_php_53_with_oracle_ht or info on the older version is in the Underground PHP & Oracle Manual.
947904
I'm following the article:
http://www.oracle.com/technetwork/articles/dsl/inst-php-apache-windows-098333.html
starting with:
Download the FastCGI component mod_fcgid-2.3.6-win32-x86.zip
from httpd.apache.org/download.cgi#mod_fcgid
since I already have OHS.
However when I Unzip the latest version of mod_fcgid for my OS the mod_fcgid.so and mod_fcgid.pdb files never appeared.
What do I do now?
You possibly got the source code? The http://httpd.apache.org/download.cgi page doesn't have a link to the current Window's fcgid binaries (perhaps they are waiting for a build of the latest version?) If you look at links to other Apache Window binaries, you can navigate to that directory and locate the 2.3.6 fcgid binary zip, e.g. from http://apache.cs.utah.edu//httpd/binaries/win32/

Let us know how it goes with OHS. I'm curious to know if it works on Windows.
user13168263
CJ,

Appreciate you trying to help us with this.

We followed this... http://www.oracle.com/technetwork/articles/dsl/inst-php-apache-windows-098333.html

But, when we restarted the HTTP server, we received this error in the log:

Apache.exe: Syntax error on line 206 of D:\\oracle\\product\\fmwfr\\frinst1\\config\\OHS\\ohs1/httpd.conf: Cannot load D:/oracle/product/fmwfr/Oracle_FR1/ohs/modules/mod_fcgid.so into server: %1 is not a valid Win32 application.

Any ideas?

Thanks,
Kyle
user13168263
Do we need to install Instant Client since our db is on a different server?
947904
We got that error message after we tried to restart the OHS server after placing the mod_fcgid.so into the
...\Oracle_FR1\ohs\modules folder and pointing to this file in the
...\frinst\config\OHS\ohs1\httpd.conf file.
Yes you will need Instant Client if you have no Oracle database libraries on the machine where PHP is installed.

You could try the old non-fastcgi installation, but I suspect you'll have similar binary compatibility issues. These are common on Windows. The OHS, mod_fcgid and PHP binaries are all built separately, giving potential binary version issues as the tool chains vary. For a while PHP binaries were not compatible with Apache binaries at all. People commonly see 32 bit vs 64 bit issues too.

My best bet for you would be to install standalone Apache with PHP using a different port, and set up a reverse proxy to it from OHS or vice versa.

My favorite option is to use Linux.
947904
Is Zend Core an option?
Zend Server is a convenient way to install PHP & Apache. It's not integrated with OHS in anyway. ZS is the successor to Zend Core.
949352
I struggled with getting conned to oracle for a while until I figured it out. We run IIS 6 on Windows 2003. You need to set up the instant client libaries in a folder (set the path in your windows environment variables) then you need to install Visual Studio C++ express. PHP will not install oci8 properly because there are missing dll files which installing VS C++ express will fix. once you see oci8 come up in you phpinfo() you should be good to go. You should be able to connect like this...

define('ORACLE_USERNAME','your_username');
define('ORACLE_PASSWORD', 'your_password');

// IP - PORT - DATABASE INSTANCE

define('ORACLE_HOST','123.456.789.123:4567/dev'); // Testing

//OPEN ORACLE CONNECTION

$conn = oci_connect(ORACLE_USERNAME, ORACLE_PASSWORD, ORACLE_HOST);
947904
We are still trying to get the test page to come up using the mod_fastcgi that came with OHS. Besides adding the line:
LoadModule fastcgi_module ".../modules/mod_fastcgi.so" what else does the httpd.conf file have to me modified?
947904
Can we use mod_php (DSO) instead of mod_fastcgi or mod_fcgid? Can we downlaod php4 and install the dll's in an apache folder to do this with OHS present and if not is there anyway that we can get mod_php to work?
947904
Can we get mod_php (DSO) to work with OHS and if so how would we do that? The mod_php module with php4 loads many dll's in a httpd file in an apache folder and the apache that comes with OHS loads many modules in a httpd file in an ohs1 folder so how could we get mod_php to work if possible?
I expect it won't work but it should be simple to test. The last customer who tried this didn't succeed - and migrated to Linux.
1 - 14
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 12 2008
Added on Sep 13 2008
2 comments
212 views