Jump to content

ncurran217

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by ncurran217

  1. This worked amazing! Thank you very much!
  2. Thanks for the replies and help. I will try your guys suggestions and see what works best.
  3. I am working on trying to get php code to take a record set from mysql table and rotate the records, so when you refresh the page, the first record would show at the top of the list, then record 2 and so on down the line. If you were a new person to come to the page, record 2 would show at the top of the list, then record 3 and down the line, and record 1 would now be at the bottom. I have a position column in the table and when the page loads it will update the position field of each record to be one less then it was before, so when the next person to come to the page, it will be up one spot in the table. My issue is that when the page gets refreshed to quickly or I have had it not finish updating the records and then there is multiple records with the same position number. I am looking to only have 9 records only for the example, so if Position is set to 1 it will be set to 9, if not it will take Position - 1. if(isset($_GET["page"])){ } else{ $sql = "SELECT ID,Name,Position FROM tableA ORDER BY Position DESC"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { if($row["Position"] == 1){ $p = 9; } else{ $p = $row["Position"]-1; } $conn->query("UPDATE tableA SET Position = $p WHERE ID = $row[ID]"); } mysqli_free_result($result); } Am I going down the right path? It just seems like it will not work 100% of the time. Hopefully I explained what is going wrong fully and clearly. Thank in advance.
  4. I am trying to remove some information off urls that are placed into my database. I have this query that I am using: Select substring_index(refurl,'?gclid',1) as refurl, Count(*) from leads group by substring_index(refurl,'?gclid',1) But for the delimiter I want it to clear off ?gclid or &gclid, is this possible by doing an OR statement within the substring or is it something completely different to get this done?
  5. Well I figured it out. It had to do with how the first IF then ELSE statement were setup.
  6. Well I have this login script, and there are if statements if something doesn't match up and it will set $error with a sentence of what is wrong. Then at the bottom of the code has the login form, with an if statement that says if $error is set, then echo $error. But when actually put in wrong credentials, it goes to a blank page and doesn't echo $error. If I put in the correct credentials it goes to the next page properly. Here is my code, what am I doing wrong? Thanks for the help in advance! <?php include 'includes/db_connect.php'; $self = $_SERVER['PHP_SELF']; //-----------------------------------Anti-Injection Function----------------------------------------------- function anti_injection($sql) { $sql = preg_replace("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/","",$sql); $sql = trim($sql); $sql = strip_tags($sql); $sql = addslashes($sql); return $sql; } //---------------------------------------------------------------------------------------------------------- if(isset($_POST['user']) && $_POST['pass']){ $user = anti_injection($_POST['user']); $pass = anti_injection($_POST['pass']); $crypt_pass = md5($pass); $query1 = "SELECT username FROM Logins WHERE Username = '".$user."'"; $params1 = array(); $options1 = array( "Scrollable" => SQLSRV_CURSOR_KEYSET ); $result1 = sqlsrv_query( $connection, $query1 , $params1, $options1 ); $count1 = sqlsrv_num_rows($result1); $query2 = "SELECT password FROM Logins WHERE Username = '".$user."'"; $result2 = sqlsrv_query( $connection, $query2); while ($row2=sqlsrv_fetch_array( $result2, SQLSRV_FETCH_ASSOC)) { $sysadmin_password = $row2['password']; } if($count1 == '0') { $error = 'This account is not found in the database.'; } elseif($sysadmin_password != $crypt_pass) { $error = 'Wrong password. Try again.'; } elseif($_GET['login'] != 'login' && $count1 == '0') { $error = 'Login Error, Please login again.'; } else { session_start(); $_SESSION['valid_sysadmin'] = $user; echo "<script type='text/javascript' language='javascript'> window.location.href = 'index.php';</script>"; exit; // Dont forget to and your session // session_destroy(); // End secure content } } else { // build form echo "<title>Mail Report</title>"; echo "<form name='auth' action='$self' method='post'>\n"; echo "<table align=center width=210 border=0 cellpadding=7 cellspacing=1>\n"; echo " <tr class=right_main_text><td colspan=2 height=35 align=center valign=top><h2>Mail Report Login</h2></td></tr>\n"; echo " <tr class=right_main_text><td align=left>Username:</td><td align=right><input type='text' name='user' maxlength='30'></td></tr>\n"; echo " <tr class=right_main_text><td align=left>Password:</td><td align=right><input type='password' name='pass' maxlength='16'></td></tr>\n"; echo " <tr class=right_main_text><td align=center colspan=2><input type='submit' value='Login'> </td></tr>\n"; if (isset($error)) { echo "<tr class=right_main_text><td align=center colspan=2><font color='red'>'".$error."'</font></td></tr>\n"; } echo "</table>\n"; echo "</form>\n"; } ?>
  7. I have this import code and it works if I take the header out of the csv file, but I would like to keep the header in the file so I can keep a template for my co-workers to use so there is no issues with what columns are which. Here is my code: <?php /* Format the errors and die */ function get_last_error() { $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); $errorMessage = 'No errors found'; if ($retErrors != null) { $errorMessage = ''; foreach ($retErrors as $arrError) { $errorMessage .= "SQLState: ".$arrError['SQLSTATE']."<br>\n"; $errorMessage .= "Error Code: ".$arrError['code']."<br>\n"; $errorMessage .= "Message: ".$arrError['message']."<br>\n"; } } die ($errorMessage); } /* connect */ function connect() { if (!function_exists('sqlsrv_num_rows')) { // Insure sqlsrv_1.1 is loaded. die ('sqlsrv_1.1 is not available'); } /* Log all Errors */ sqlsrv_configure("WarningsReturnAsErrors", TRUE); // BE SURE TO NOT ERROR ON A WARNING sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_ALL); sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ALL); include '/includes/db_connect.php'; if ($connection === FALSE) { get_last_error(); } return $connection; } function query($connection, $query) { $result = sqlsrv_query($connection, $query); if ($result === FALSE) { get_last_error(); } return $result; } /* Prepare a reusable query (prepare/execute) */ function prepare ( $connection, $query, $params ) { $result = sqlsrv_prepare($connection, $query, $params); if ($result === FALSE) { get_last_error(); } return $result; } /* do the deed. once prepared, execute can be called multiple times getting different values from the variable references. */ function execute ( $stmt ) { $result = sqlsrv_execute($stmt); if ($result === FALSE) { get_last_error(); } return $result; } function fetch_array($query) { $result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC); if ($result === FALSE) { get_last_error(); } return $result; } $connection = connect(); /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( &$param1, &$param2, &$param3 ); $prep = prepare ( $connection, $query, $params ); // $result = execute ( $prep ); //get the csv file $file = $_FILES["importrecords"]["tmp_name"]; /* Here is where you read in and parse your CSV file into an array. That may get too large, so you would have to read smaller chunks of rows. */ $csv_array = file($file); $_SESSION['records_row_count'] = 0; foreach ($csv_array as $row_num => $row) { $_SESSION['records_row_count']++; $row = trim ($row); $column = explode ( ',' , $row ); $param1 = $column[0]; $param2 = $column[1]; $param3 = $column[2]; // insert the row $result = execute ( $prep ); } /* Free statement and connection resources. */ sqlsrv_close($connection); header( "Location: import.php?successrecords=1" ); ?> How would I accomplish leaving the header in the csv file but skipping on the import? I tried adding a count, but that didn't work. Thanks for the help in advance!
  8. That worked perfectly. Thank you so much. I was looking at it for so long, just needed a second set of eyes I guess. Thanks again. Kicken, when I did what you said, it still added the row of NULL values. Also, adding the & to $params in the function came back as deprecated. Thank you for the input as well!
  9. I have found some code that I am trying to work with to import some data from a CSV file into a table of my database. It works and imports the data, but always inserts a NULL row for each column. Here is the code: <?php $self = $_SERVER['PHP_SELF']; $request = $_SERVER['REQUEST_METHOD']; if (!isset($_GET['success'])) { $get_success = ""; } else { $get_success = $_GET['success']; } if (!empty($_FILES)) { /* Format the errors and die */ function get_last_error() { $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); $errorMessage = 'No errors found'; if ($retErrors != null) { $errorMessage = ''; foreach ($retErrors as $arrError) { $errorMessage .= "SQLState: ".$arrError['SQLSTATE']."<br>\n"; $errorMessage .= "Error Code: ".$arrError['code']."<br>\n"; $errorMessage .= "Message: ".$arrError['message']."<br>\n"; } } die ($errorMessage); } /* connect */ function connect() { if (!function_exists('sqlsrv_num_rows')) { // Insure sqlsrv_1.1 is loaded. die ('sqlsrv_1.1 is not available'); } /* Log all Errors */ sqlsrv_configure("WarningsReturnAsErrors", TRUE); // BE SURE TO NOT ERROR ON A WARNING sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_ALL); sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ALL); $conn = sqlsrv_connect('cslogs', array ( 'UID' => 'mailreport', 'PWD' => '123456', 'Database' => 'Mail', 'CharacterSet' => 'UTF-8', 'MultipleActiveResultSets' => true, 'ConnectionPooling' => true, 'ReturnDatesAsStrings' => true, )); if ($conn === FALSE) { get_last_error(); } return $conn; } function query($conn, $query) { $result = sqlsrv_query($conn, $query); if ($result === FALSE) { get_last_error(); } return $result; } /* Prepare a reusable query (prepare/execute) */ function prepare ( $conn, $query, $params ) { $result = sqlsrv_prepare($conn, $query, $params); if ($result === FALSE) { get_last_error(); } return $result; } /* do the deed. once prepared, execute can be called multiple times getting different values from the variable references. */ function execute ( $stmt ) { $result = sqlsrv_execute($stmt); if ($result === FALSE) { get_last_error(); } return $result; } function fetch_array($query) { $result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC); if ($result === FALSE) { get_last_error(); } return $result; } $conn = connect(); /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); //get the csv file $file = $_FILES["csv"]["tmp_name"]; /* Here is where you read in and parse your CSV file into an array. That may get too large, so you would have to read smaller chunks of rows. */ $csv_array = file($file); foreach ($csv_array as $row_num => $row) { $row = trim ($row); $column = explode ( ',' , $row ); $param1 = $column[0]; $param2 = $column[1]; $param3 = $column[2]; // insert the row $result = execute ( $prep ); } /* Free statement and connection resources. */ sqlsrv_close($conn); header( "Location: test.php?success=1" ); } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Import a CSV File with PHP & MS SQL Server</title> </head> <body> <?php if (!empty($get_success)) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> Now I know it is at this part wiht the $param1, $param2 and $param 3 that it is inserting the NULL values for each column: /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); But if I take that out them three out, the php errors out then doesn't import the data. Is there a way with what I have to ignore the first row to import? Or am I going about this all wrong?
  10. I am moving my site and database to a new server. The configuration is nearly the same except the new server is 64bit. I can connect to the database remotely with the username and password that I have in my php code to connect. Here is my database connect code: <?php $serverName = 'Nick_C_Desktop\SQLEXPRESS'; $connectionInfo = array('Database'=>'CSLogs', 'UID'=>'cslogslogin', 'PWD'=>'123456'); $connection = sqlsrv_connect($serverName, $connectionInfo); ?> This code worked perfectly fine on my old server, but gives me this error: Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\cslogs\includes\db_connect.php on line 4 I have these two items in my php.ini file enabled: extension=php_pdo_sqlsrv_53_ts.dll extension=php_sqlsrv_53_ts.dll Which is what I had before. Using Wamp Server. PHP 5.3.13 all the same as before. What else am I missing that is not allowing this to connect to the SQL server. Thanks in advance!
  11. Ok I finally found something that worked. Sorry for the premature post, but if there are possibly better ways to do this that would be nice to know. Here is what I got and I will mark as solved: // each array key is the database column name, the corresponding value is the legend/heading to display in the HTML table // the order of the items in this array are the order they will be output in the HTML table $fields = array('RefNumber'=>'Reference Number','Status'=>'Status','Rep'=>'Rep','Disposition'=>'Disposition','appNumber'=>'appNumber', 'Con_Number'=>'Contract Number','Finance_Num'=>'Finance Number','Phone_Num'=>'Phone Number','Disc_Amount'=>'Discount Amount', 'Total_Cost'=>'Total Cost','Total_MP'=>'Total Monthly Payments','New_MP_Amt'=>'New MP Amount','New_DP_Amt'=>'New DP Amount','Notes'=>'Notes'); // start table and produce table heading $color1 = "white"; $color2 = "#A4A4A4"; $i = 1; echo "<table>\n<tr>"; foreach($fields as $legend){ echo "<th>$legend</th>"; } echo "</tr>\n"; // output table data while($row = sqlsrv_fetch_array( $result,SQLSRV_FETCH_ASSOC)) { if ($i % 2 != 0) //An Odd Row {$rowcolor = $color1;} else //An Even Row {$rowcolor = $color2;} echo "<tr bgcolor='$rowcolor'>"; foreach($fields as $key=>$not_used) { echo "<td>$row[$key]</td>"; } $i++; //Increment Row Counter echo "</tr>\n"; } echo "</table>\n";
  12. I am looking to alternate the row color on this loop I have. I have looked up a couple things through google, but none of them seem to fit into what I have. Let me know if this is simple or any suggestions on how to do this. Here is my code: $fields = array('RefNumber'=>'Reference Number','Status'=>'Status','Rep'=>'Rep','Disposition'=>'Disposition','appNumber'=>'appNumber', 'Con_Number'=>'Contract Number','Finance_Num'=>'Finance Number','Phone_Num'=>'Phone Number','Disc_Amount'=>'Discount Amount', 'Total_Cost'=>'Total Cost','Total_MP'=>'Total Monthly Payments','New_MP_Amt'=>'New MP Amount','New_DP_Amt'=>'New DP Amount','Notes'=>'Notes'); // start table and produce table heading echo "<table>\n<tr>"; $color1 = "#EFEFEF"; $color2 = "#FBFBFB"; foreach($fields as $legend){ echo "<th>$legend</th>"; } echo "</tr>\n"; // output table data while($row = sqlsrv_fetch_array( $result,SQLSRV_FETCH_ASSOC)) { echo "<tr>"; foreach($fields as $key=>$not_used) { echo "<td>$row[$key]</td>"; } echo "</tr>\n"; } echo "</table>\n"; $color1 & $color2 are the background colors I want to alternate on each row.
  13. Ok, so now this one pops up: (!preg_match ("#^([[:alnum:]]|~|\!|@|#|\$|%|\^|&|\*|\(|\)|-|\+|`|_|\=|\{|\}|\[|\]|\||\:|\<|\>|\.|,|\?)+$#", $password)) with error: Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier '|'
  14. Ok, I have never used this function. Is there something you suggest, as I have no clue what this function does.
  15. I have acquired a time clock script that I wanted to try and use, instead of the employees manually punching in and out, but going through it now, found that this function eregi() is old and I have tried to change it to preg_match. Here is the code: elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; } else { if ($calendar_style == "amer") { if (isset($date_regs)) {$from_month = $date_regs[1]; $from_day = $date_regs[2]; $from_year = $date_regs[3];} if ($from_month > 12 || $from_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; }} elseif ($calendar_style == "euro") { if (isset($date_regs)) {$from_month = $date_regs[2]; $from_day = $date_regs[1]; $from_year = $date_regs[3];} if ($from_month > 12 || $from_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; }}}} if (!isset($evil_post)) { if (empty($to_date)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; } elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $to_date, $date_regs)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; } else { if ($calendar_style == "amer") { if (isset($date_regs)) {$to_month = $date_regs[1]; $to_day = $date_regs[2]; $to_year = $date_regs[3];} if ($to_month > 12 || $to_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; }} elseif ($calendar_style == "euro") { if (isset($date_regs)) {$to_month = $date_regs[2]; $to_day = $date_regs[1]; $to_year = $date_regs[3];} if ($to_month > 12 || $to_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; }}}} if (isset($evil_post)) { echo " <br />\n"; echo " <form name='form' action='$self' method='post' onsubmit=\"return isFromOrToDate();\">\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=3 cellspacing=0>\n"; echo " <tr>\n"; echo " <th class=rightside_heading nowrap halign=left colspan=3><img src='../images/icons/report.png' /> Daily Time Report</th></tr>\n"; echo " <tr><td height=15></td></tr>\n"; echo " <input type='hidden' name='date_format' value='$js_datefmt'>\n"; When I change the two lines: !eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs) to this: !preg_match("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs) I get an error saying this: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '^' I also get an error within it saying: A valid From Date is required. The calendar style is "amer", so you can ignore the "euro" part of the code, as I did not want to delete anything. Hopefully this is enough information.
  16. Well no one helped me, so thanks!
  17. Well I found a tutorial on how to get what I was looking for.
  18. To start off with I am really sorry if the title doesn't necessarily describe what I am trying to accomplish here and really didn't know how to title it. What I have is a form that user inputs information and then when they hit submit it takes them to the page with the code to insert the information into the sql server database. This page also, will send an email out with the some of the information based on one of the fields the user input information into. When the information is inserted into the database, I have a column named RefNumber, that the column settings for it are as follows: [RefNumber] [int] IDENTITY(1,1) NOT NULL I want to have this RefNumber displayed out to the user as well as have it in the emails that are sent out as a confirmation for that the email is associated with. Here is my code that I currently and if any let me know if I need to explain anything more clearly: <?php session_start(); if (!(isset($_SESSION['forteid']) && $_SESSION['forteid'] != '')) { header ("Location: login.php"); exit(); } ?> <?php error_reporting(E_ALL ^ E_NOTICE); include 'includes/db_connect.php'; $CallDispo = $_POST['disposition']; $NewNotes = str_replace("'", "", "$_POST[notes]"); if (trim($CallDispo) == "Revision" or trim($CallDispo) == "Revision/Save" or trim($CallDispo) == "Revision/Collection" or trim($CallDispo) == "Reinstatement") { $to = "dawn.okeefe@srb1.com"; $subject = "Revision - $_POST[appnumber]"; $message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'> <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr> <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Discount Amount:</td><td>$_POST[Disc_Amount]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>New Total Cost:</td><td>$_POST[Total_Cost]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Total Monthly Payments:</td><td>$_POST[Total_MP]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>New MP Amount:</td><td>$_POST[New_MP_Amt]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>New DP Amount:</td><td>$_POST[New_DP_Amt]</td></tr> <TR style='border:0 solid black; text-align: Left;'><td></td><td></td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>"; } elseif (trim($CallDispo) == "Escalation"){ $to = "jeremy.nemens@srb1.com"; $subject = "Escalation - $_POST[appnumber]"; $message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'> <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr> <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>"; } elseif (trim($CallDispo) == "Email Contract"){ $to = "jeff.starke@srb1.com"; $subject = "Email Contract - $_POST[appnumber]"; $message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'> <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr> <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>"; } elseif (trim($CallDispo) == "Send Contract/Invoice"){ $to = "nicole.lehew@srb1.com"; $subject = "Send Contract/Invoice - $_POST[appnumber]"; $message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'> <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr> <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr> <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>"; } $headers = 'From: nick.curran@srb1.com' . "\r\n" . 'Reply-To: nick.curran@srb1.com' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //Insert to form data into database $tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, num_payments, ach_cc, date, notes, Phone_Num, Cancel_Disposition, Con_Number, Post_Date, Total_Cost, Total_MP, New_MP_Amt, New_DP_Amt, Disc_Amount, Callback) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $parameters = array( $_POST[ForteID], $_POST[disposition], $_POST[appnumber], $_POST[Finance_Num], $_POST[num_payments], $_POST[ach_cc], $_POST[date], $NewNotes, $_POST[Phone_Num], $_POST[Cancel_Disposition], $_POST[Con_Number], $_POST[Post_Date], $_POST[Total_Cost], $_POST[Total_MP], $_POST[New_MP_Amt], $_POST[New_DP_Amt], $_POST[Disc_Amount], $_POST[Callback]); $stmt = sqlsrv_query($connection, $tsql, $parameters); // Send Email if(mail($to, $subject, $message, $headers)) echo "Email sent!<br>"; else echo "No email to be sent!<br>"; /* Free statement and connection resources. */ sqlsrv_free_stmt( $stmt); sqlsrv_close( $connection); header( "refresh:2;url=index.php" ); echo 'Your entry has been saved!'; exit(); ?> Thanks in advance!
  19. I think you need to use an update statement for you query not an insert. But I could be wrong not to sure about it, just a thought.
  20. Thanks for the help so much!!!
  21. Well, I was getting there, haha. Also, one thing I changed was: GROUP BY listcode, year To: GROUP BY c.listcode, c.year
  22. From what I see Cross Join is in SQL Server. Just trying to understand what all is going on with the Query you wrote up. I think I have part of it, but so not getting what really is happening within it. Sorry for the lack of understanding on this.
  23. Ok, well right now it seems the query is what is throwing everything else off. When I put it into SSMS it doesn't like it. I have to move some of the code around.
  24. Now what if every LISTCODE do not have data for all the years?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.