Solved

Drop/Create Table

Posted on 2011-02-19
8
282 Views
Last Modified: 2012-05-11
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
Comment
Question by:rcowen00
  • 4
  • 3
8 Comments
 
LVL 4

Accepted Solution

by:
LAMASE earned 400 total points
ID: 34935173
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
 
LVL 7

Expert Comment

by:wdfdo1986
ID: 34935222
first u have to connect to the database using mysqlconnect()
0
 
LVL 7

Expert Comment

by:wdfdo1986
ID: 34935227
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:rcowen00
ID: 34935902
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
 
LVL 7

Expert Comment

by:wdfdo1986
ID: 34935961
I cant find mysql_connect() command there
0
 

Author Comment

by:rcowen00
ID: 34936035
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
 
LVL 7

Assisted Solution

by:wdfdo1986
wdfdo1986 earned 100 total points
ID: 34936050
what is the port that the mysql server is working on
0
 

Author Comment

by:rcowen00
ID: 34936060
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question