Solved

Drop/Create Table

Posted on 2011-02-19
8
277 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now