[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Drop/Create Table

I have a form that the user is supposed to select criteria, click the submit button and a temporary table is dropped then a new table by the same name is created with the requested information.  The problem is that it doesn't appear to be calling drop or create table.  The query works correctly directly in the database.  I don't see what I'm missing.  Thank you.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="refresh" content="text/html;charset=utf-8"/>
</head>
<body>
 <form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
    

     <input type="submit" name="getAudit" value="Select Audit">
<select class="mainSelect" id="type" style="width: 150px;" name="type">
                    <?php
                   
                    $auditQuery = "SELECT * FROM auditType ORDER BY auditTypeName ";
                    $auditList = mysql_query($auditQuery) or die(mysql_error());
                     while($auditListRow = mysql_fetch_array($auditList))
                        {
                        $auditTypeKey = $auditListRow['auditTypeKey'];
                        $auditTypeName = $auditListRow['auditTypeName'];
                        echo "<option value=\"$auditTypeKey\">$auditTypeName</option>\n";
                        }
                        ?>
                </select>
       <select class="mainSelect" id="branch" style="width: 150px;" name="branch">
                     <?php

                    $branch = "SELECT * FROM branch ORDER BY branchName ";
                    $branchList = mysql_query($branch) or die(mysql_error());
                     while($branchRow = mysql_fetch_array($branchList))
                        {
                        $branchKey = $branchRow['branchKey'];
                        $branchName = $branchRow['branchName'];
                        echo "<option value=\"$branchKey\">$branchName</option>\n";
                        }
                        ?>
                </select>
     <input class="mainText" id="begin" name="begin" style="width:100px;" type="date" value="Enter Begin Date"/>
       <input class="mainText" style="width:100px" id="end" name="end" type="date" value="Enter End Date"/>
       <br/>
      
      
</form>

</body>

Open in new window

<?php
error_reporting(E_ALL);

        $userIDKey=$userListRow['id'];
        include 'include/userConnect.php';

        $beginDate=mysql_real_escape_string($_POST['begin']);
        $endDate=mysql_real_escape_string($_POST['end']);
        $auditTypeKey=mysql_real_escape_string($_POST['type']);
        $branchKey=mysql_real_escape_string($_POST['branch']);

            $deleteTemp = "DROP Table if exists auditMgmt";
             mysql_query($deleteTemp) or die(mysql_error());
            $createTemp = "CREATE TABLE auditMgmt SELECT loan.loanKey,
              loan.loanNumber,
              borrower.lastName,
              borrower.firstName,
              loan.addr1,
              loan.addr2,
              loan.city,
              loan.stateKey,
              loan.zip,
              loan.programKey,
              branch.branchKey,
              loan.propertyTypeKey,
              loan.ausKey,
              loan.rate,
              audit.auditID,
              audit.auditTypeKey,
              loan.lienPositionKey,
              loan.originationTypeKey,
              loan.loLastName,
              loan.loFirstName,
              loan.ltvRatio,
              loan.cltvRatio,
              loan.debtRatio,
              loan.housingRatio,
              loan.uwLastName,
              loan.uwFirstName,
              loan.fundDate,
              loan.investorName,
              loan.processorLastName,
              loan.processorFirstName,
              loan.loanTypeKey,
              loan.amount,
              loan.occupancyKey,
              loan.termKey,
              audit.selectionDate,
              audit.trackingDate,
              audit.auditorId,
              audit.dateAssigned,
              audit.auditBeginDt,
              audit.auditCompletedDt,
              audit.mgrReviewDt,
              audit.reprocessorAssigned,
              audit.reprocessorID,
              audit.auditDueDate
              FROM loan
              JOIN audit USING (loanKey)
              JOIN auditType USING (auditTypeKey)
              JOIN originationType USING (originationTypeKey)
              JOIN borrower USING (loanKey)
              JOIN branch USING (branchKey)
              WHERE branchKey='$branchKey'
              AND auditTypeKey='$auditTypeKey'
              AND borrower.type='1'
              AND borrower.active='1'
              
            ORDER BY audit.auditID";
            echo $createTemp;
            mysql_query($createTemp) or die(mysql_error());
                                             ?>

Open in new window

0
rcowen00
Asked:
rcowen00
  • 4
  • 3
2 Solutions
 
LAMASECommented:
No errors?
Can you ouput something at the end of the file?
Do you perform a connection to mysql before you use mysql_real_escape_string?
0
 
wdfdo1986Commented:
first u have to connect to the database using mysqlconnect()
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
rcowen00Author Commented:
wdfdo1986,

The code snippets I listed above were included in the attached code that does include the database connection
<?PHP
setlocale(LC_ALL, 'English_United States.65001');
if (!isset($_SESSION)) {
        session_start();
}
include "login-system/include/loginGlobals.php";
include "login-system/include/database.php";

if ((!isset($_SESSION["login"])) || ($_SESSION["login"]==False)) {
        header("Location: http://" . lg_domain . lg_loginPage ."?p=". $_SERVER["SCRIPT_NAME"]);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>ERM QC &#150; Audit Management</title>
<link rel="stylesheet" type="text/css" href="css/ermQCStyle.css" media="all" />
<link rel="stylesheet" type="text/css" href="css/tableStyle.css" media="all" />
<link rel="stylesheet" type="text/css" href="css/formStyle.css" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en-US" />
<meta name="author" content="Roderick Divilbiss" />
<meta name="copyright" content="&copy; 2010 EE Collaborative Login Project http://www.webloginproject.com" />
</head>

<body>
   
	<div id="wrapper">
		<div id="header">
			<div id="headerContent">
				<?php
				require('header.php');
          			?>
			</div>
                             <div id="mainData"><center><br/><br/><br/><br/>
                                        <?php
                                       if(isset($_POST['getAudit']))
                                            {
                                           include('include/submit/auditMgmtLoanCreate');
                                            }
                                            require('include/lists/loanConsistencyList.php');
                                            require('include/lists/loanConsistencyList2.php');
                                         
                                        ?>
                             </center><br/><br/>
                            
                             </div>
		<div id="footer">
			<div id="footerContent">
					<?php
                                        require('footer.php');
					
					?>
                              </div>
			</div>
		</div>

	</div>
</body>
</html>

Open in new window

0
 
wdfdo1986Commented:
I cant find mysql_connect() command there
0
 
rcowen00Author Commented:
Sorry, I misspoke it is in the 2nd code snippet (line 4)

include 'include/userConnect.php';
<?php

        $conn=mysql_connect("localhost", "xxxxx", "xxxxxx") or die(mysql_error());
	$dbc=mysql_select_db('xxxxxxx',$conn)or die(mysql_error());
        $ermqcUser=$_SESSION["userid"];
        

//get user id
        $userQuery = "SELECT id,userid,permissionKey FROM users WHERE userid='$ermqcUser'";
        $userList=mysql_query($userQuery,$conn) or die(mysql_error());
        $userListRow = mysql_fetch_assoc($userList);
        $userIDKey=$userListRow['id'];
        $userPermission=$userListRow['permissionKey'];

?>

Open in new window

0
 
wdfdo1986Commented:
what is the port that the mysql server is working on
0
 
rcowen00Author Commented:
Thanks for your help, but I found the problem.

include('include/submit/auditMgmtLoanCreate');

should have been

include('include/submit/auditMgmtLoanCreate.php');

I forgot the file extension.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now