Jump to content

sonnieboy

Members
  • Posts

    154
  • Joined

  • Last visited

Everything posted by sonnieboy

  1. Sorry sir. I think you mis understood my intentions. When I post a question, I don't sit around waiting for someone to solve it for me. I keep researching. So, what i was doing with those posts was to come and update you that i have resolved it so you don't waste your time on it any longer. Your help is truly appreciated. I was able to resolve thos string conversion error. The reason I had those errors was I was treating some form fields as arrays when infact they are not. All I have left now is to figure out a way to display those array results to the user. echo is not getting it done.
  2. OK, the Invalid argument supplied error is gone. It is probably due to empty string being passed. I was able to do this: if (is_array($rowIDs) || is_object($rowIDs)) { for each(...) ... ... ) Now, I got to figure our thw Array to string conversion error and the other error.
  3. Ok, I resolved that already. All I needed to do was refresh and start all over. But I am getting way too many errors: Notice: Array to string conversion in C:\xampp\htdocs\disclosures\forms\preview.php on line 3 Array Notice: Array to string conversion in C:\xampp\htdocs\disclosures\forms\preview.php on line 4 Array Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\disclosures\forms\preview.php on line 6
  4. The error seems to be pointing to this line: [income1{{rowNumber}}] => $98,000.00 But I can see the difference between that line in the markup and the rest of the lines. Maybe, you can spot it?
  5. That makes perfect sense. Thanks a lot sir. Now, the errors are gone. I don't know yet what the output will look like but at least the errors there are gone. Now, I getting it on line 10 which is starts from here: These are hidden fields that will be passed to submit.php to submit to the database: echo "<input type='hidden' name='employeename[]' value='".$sourcename1."' />"; echo "<input type='hidden' name='ttitle[]' value='".$sourceaddress1."' />"; echo "<input type='hidden' name='sourcename1[]' value='".$income1."' />"; Parse error: in C:\xampp\htdocs\disclosures\forms\preview.php on line 10 Do I add the DEBUG... at top (of preview) page? Yes, I added it to the top and it seems to be showing me what I am doing wrong on the markup. Let me review that and post back. Many thanks for your help.
  6. Thank you sir for your prompt response. I did - > Parse error: in C:\forms\preview.php on line 2 ​However, I have made some changes since I posted the issue here and that error seemed to have been resolved but not completely. Now, I am getting the following error: Invalid argument supplied for foreach() in C:\forms\preview.php on line 5 ​Here is the latest code after some changes: <?php if(isset($_POST['employeename'])) echo $_POST['employeename']; if(isset($_POST['ttitle'])) echo $_POST['ttitle']; $rowIDs = $_POST['rowIDs']; foreach ($rowIDs as $id) { echo $sourcename1 = $_POST['sourcename1' . $id]; echo $sourceaddress1 = $_POST['sourceaddress1' . $id]; echo $income1 = $_POST['income1' . $id]; } echo "<input type='hidden' name='employeename[]' value='"$sourcename1"' />"; echo "<input type='hidden' name='ttitle[]' value='".$sourceaddress1."' />"; echo "<input type='hidden' name='sourcename1[]' value='".$income1."' />"; ?> The ROWIDs declaration is based on the assumption that some users may click a button to add additional textbox rows and we need to make sure all their data is captured. Again, thanks a lot.
  7. Greetings experts, I am trying to give our users the ability opportunity to preview their data before submitting to the database. So, we have contacts.php with the following: <div class="bs-example"> <form class="form-inline" action="<?php echo get_option('siteurl'); ?>/form/preview.php" id="contactForm" role="form" method="post"> <div class="form-group"> <label for="employeename">Employee Name</label><br> <input type="text" name="employeename" id="employeename" style="width:375px;" placeholder="your name..." class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <div class="form-group"> <label for="ttitle">Title</label><br> <input type="text" name="ttitle" id="ttitle" style="width:375px;" placeholder="Your title..." class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div><br><br> <script id="row-template" type="text/x-handlebars-template"> <div> <!--reseed attribute IDs in case of gap resulting from deletions --> <input type="hidden" name="rowIDs" value="{{rowNumber}}" /> <div class="form-group"> <input type="text" name="sourcename1{{rowNumber}}" id="sourcename1{{rowNumber}}" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <div class="form-group"> <input type="text" name="sourceaddress1" id="sourceaddress1{{rowNumber}}" style="width:250px;" class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <div class="form-group"> <input type="text" name="income1{{rowNumber}}" id="income1{{rowNumber}}" style="width:250px;" class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <input id="Button{{rowNumber}}" type="button" rel="remove-row" value="Remove" /> </div> </script> <div id="addrow"> <div> <!--reseed attribute IDs in case of gap resulting from deletions --> <input type="hidden" name="rowIDs" value="{{rowNumber}}" /> <div class="form-group"> <label for="sourcename1">Name</label><br> <input type="text" name="sourcename1" id="sourcename1" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <div class="form-group"> <label for="sourceaddress1">Address</label><br> <input type="text" name="sourceaddress1" id="sourceaddress1" style="width:250px;" class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> </div> <div class="form-group"> <label for="income1">Income</label><br> <input type="text" name="income1{{rowNumber}}" id="income1" style="width:250px;" class="form-control" value="" class="required requiredField" /> <?php if($nameError != '') { ?> <span class="error"><?=$nameError;?></span> <?php } ?> <input type="button" value="Add More" rel="add-row" /> </div> </div> </div><br><br> There is a whole lot more code than this. I am just trying to simplify. When the user clicks submit, s/he is taken to the preview.php code with following: <?php echo "<p>Employee Name: <b>" .$_POST["employeename"]. "</b></p>"; echo "<p>Title: <b>" .$_POST["ttitle"]. "</b></p>"; $rowIDs = $_POST['rowIDs']; foreach ($rowIDs as $id) { echo "Source Name: <b>" $sourcename1 = $_POST['sourcename1' . $id] "</b></p>"; echo "Source Address: <b> <b>" $sourceaddress1 = $_POST['sourceaddress1' . $id] "</b></p>"; echo "Income Source:" $income1 = $_POST['income1' . $id] "</b></p>"; } echo "<input type='hidden' name='employeename[]' value='".$sourcename1."' />"; echo "<input type='hidden' name='ttitle[]' value='".$sourceaddress1."' />"; echo "<input type='hidden' name='sourcename1[]' value='".$income1."' />"; Right now, I am getting an error on the preview.php that says: Parse error: in C:\forms\preview.php on line 2 ​which is this line: echo "<p>Employee Name: <b>" .$_POST["employeename"]. "</b></p>"; ​It might be obvious but I can't see it. Can you please help? Thanks in advance
  8. Actually, I withdraw that last statement because if it were possible for people to do so, they would delete or infect all the files. Sorry about that last post. It is a bit silly.
  9. http://domain/AppFolder/AppFiles/uploadsFolder/ I also wanted to add that if I just enter the url where the uploadsFolders resides on the server, I get same error that I posted. I don't know if it is irrelevant or not.
  10. I have checked the error log and it is not showing me anything. This issue has exactly the same attributes as the Directory Not Found error I alluded to. So, because when I click the Submit button and it is not reaching the processing.php page, it is not possible to find anything on the server. I have tried a file as small as 25kb and the error occurs. I would add that as at 1:15PM tomorrow, they have been able to upload files. Also, I have set the file limit to up to 2GB and in the past, they have been to upload to 200MB. I cannot empty the folder because of the traffic on the site. I can probably do that tonight around 11PM when the traffic is very limited of any and see what happens. My gut tells me there is some additional IIS configuration I have to do to resolve this. I just don't know what to look for.
  11. First, thanks for your response. As stated, the only reason I even posted that code is because I am convinced code is not the issue. I say this because when I add debugger to processing.php and click submit, it is not being reached. I have had similar situation about 2 years ago when I started receiving directory not found error. It turned out that I need to increase the size of file uploads in IIS and it solved the problem. I am confident it is something similar except I don't know where to look. I can dump all the thousands of code I have here but I don't think it is the code. About switching away from IIS, I can begin to look into that but this is so urgent that my head is hurting the many calls and emails I have received so far from management which prompted me to ask for help.
  12. //Markup //*initialize file path to be used later. $path_to_file = '../uploadsFolder/'; <table border="0"> <tr> <td class="td_input_form"> <?php // if the SignInSheet is empty, if(file_exists($path_to_file . $result["SignInSheet"])) { // Bid file already upload, show checkbox to delete it. echo '<input type="file" name="SignInSheet[]" size="50"> <br />'; echo '<input type="checkbox" name="delete[]" value="'.$result["SignInSheet"].'"> (delete) <a href="http://domain/AppFolder/AppFiles/uploadsFolder/'.$result["SignInSheet"].'" target="_blank" onclick="window.open (this.href, \'child\', \'height=800,width=850,scrollbars\'); return false" type="application/octet-stream">'.$result["SignInSheet"].'</a>'; } else { //then show file upload field for SignInSheet echo '<input type="file" name="SignInSheet[]" size="50">'; } ?> </td> <td class="td_hint_form"></td> </tr> </table> We have an app that has been stable and working for the past two and half years till yesterday when we started receiving the following error: The specified URL cannot be found This is an app that allows users to enter comments and upload a file that accompanies the comments. When you enter comments and click the submit button without uploading a file. Then no problem; everything works. If however, you upload a file along with the comments, you get the above error message. What is most interesting is that when you select a file to upload and click the upload button, it is not reaching the processing.php page. We set up and configured php with IIS. I am sure that whatever the problem is has to do with browser or IIS. I have spent all yesterday afternoon and the all day today but could not figure out what the problem could be. Your urgent assistance is greatly appreciated. I am posting this code snippet although I don't think code is causing the problem.
  13. Greetings again experts. When users log in, they are directed to a particular page based on whether or not they have already registered before. If the user is registered, s/he is redirected to a particular page indicating s/he is already registered with some information about the benefits of being a member. If that user has not yet registered, s/he is redirected to registration form. This is not working particularly well. Example: here is the code that does the redirecting. By the way, I am using custom code for ms_escape_string() $strSQL = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname, e.Department, e.UnitName, e.empnum FROM users u inner join EmployeeData e on u.Employee_Id = e.EmpNum inner join tblTBA t on u.Employee_Id = t.Employee_Id WHERE USERNAME = '".ms_escape_string($_POST['user'])."' and PASSWORD = '".ms_escape_string($pass)."' "; // echo $strSQL; $sqll = sqlsrv_query($con, $strSQL); if ($objResult = sqlsrv_fetch_array($sqll, SQLSRV_FETCH_ASSOC)) { $firstname = $objResult["empl_first"]; $_SESSION["firstname"] = $objResult["empl_first"]; header('location:registered.php?user=' . urlencode($firstname)); } else header("location:register.php?user='".ms_escape_string($_POST['user'])."'&pass='".ms_escape_string($_POST['pass'])."' "); The problem I am having is with grabbing the values passed to register.php. $strSQL = "SELECT u.empl_first, u.empl_first +' '+ empl_last as fullname, e.Department, e.UnitName, e.empnum FROM users u inner join EmployeeData e on u.Employee_Id = e.EmpNum WHERE USERNAME = ? and PASSWORD = ? "; //echo $strSQL; $params = array($_GET["user"], $_GET["pass"] $sqll = sqlsrv_query($con, $strSQL, $params); When I use this code: It works because my form gets populated with the records queried from the database but I know that code has sql injection attack written all over it. However, when I use the following code, my form is not getting populated. What could I be doing wrong? Thanks a lot in advance for yoru help
  14. That's it!!! Thank you so very much Jacques.
  15. inner join status s on b.BidStatus=s.StatusId " . ( count($where) > 0 ? " WHERE " . implode(' AND ', $where) : " " ); First of all, the issue here really has nothing to do with knowing my application. Second, the one field I would like to modify is call bidStatus Third, I am pretty good with sql and writing queries but this is a problem for me because of the php component. The code as you can see is written to dynamically pass parameter based on what parameter is selected by the user. So modifying the code to add WHERE when there is already dynamic where is where I am having problem.
  16. $fields = array( 'projectTitle' => array('field' => 'b.BidTitle', 'searchType' => 'like'), 'bidType' => array('field' => 'b.BidType', 'searchType' => 'equal'), 'bidStatus' => array('field' => 'b.BidStatus', 'searchType' => 'equal'), 'department' => array('field' => 'b.AliasID', 'searchType' => 'equal'), 'bidId' => array('field' => 'b.BidID', 'searchType' => 'like'), 'txtFromDate' => array('field' => 'b.BidDate', 'searchType' => 'gte'), 'txtToDate' => array('field' => 'b.BidDate', 'searchType' => 'lte'), 'txtFromDueDate' => array('field' => 'b.DueDate', 'searchType' => 'gte'), 'txtToDueDate' => array('field' => 'b.DueDate', 'searchType' => 'lte'), 'bidDate' => array('field' => 'b.BidDate', 'searchType' => 'equal'), 'dueDate' => array('field' => 'b.DueDate', 'searchType' => 'equal'), 'ddlCategory' => array('field' => 'b.CategoryID', 'searchType' => 'equal') ); $where = array(); $searchType = ""; foreach($fields as $fieldPost => $field) { if(isset($_GET[$fieldPost]) && strlen($_GET[$fieldPost]) > 0) { if($field['searchType'] == 'like') { $where[] = "".$field['field']." LIKE '%" . ms_escape_string($_GET[$fieldPost]) . "%'"; } elseif ($field['searchType'] == 'gte') { $where[] = "".$field['field']." >= '" . ms_escape_string($_GET[$fieldPost]) . "'"; } elseif ($field['searchType'] == 'lte') { $where[] = "".$field['field']." <= '" . ms_escape_string($_GET[$fieldPost]) . "'"; } else { $where[] = "".$field['field']." = '" . ms_escape_string($_GET[$fieldPost]) . "'"; } $searchType .= (empty($searchType) ? "" : "&") . $fieldPost . "=" . $_GET[$fieldPost]; // echo $searchType; } } Well, that's why I came here because I am not sure how to make the change. The original intent of the code is to display everything but now they want everything displayed except where b.bstatusid is not equal to 7. Here is the code I didn't post the first time where the Where is generated:
  17. Greetings mates I have this code below: $tsql = "Select COUNT(*) As totalRecords FROM bids b inner join DeptALIAS da on b.AliasID = da.AliasID inner join Dept d on da.DeptCode =d.DeptCode inner join status s on b.BidStatus=s.StatusId " . ( count($where) > 0 ? " WHERE " . implode(' AND ', $where) : " " ); //echo $tsql; I would like to add a WHERE clause where b.aliasID <> 22 Does anyone know how I can modify code above to add this please? Thanks a lot in advance
  18. Greetings honorable experts, We have a server that hosts php applications. Our director recently told us he wants us to build a blog site so users from across spectrums can post comments and respond to comments. Is it possible to set up a wordpress blog on the same server? Even better, is there a strictly php blog app that I can be referred to instead of wordpress? Your assistance is greatly appreciated.
  19. Please, please JG, enough of the negativity. If you really wish to assist, please, please concentrate on the problem that I have and I have provided any useful information for any php guru wishing to assist would need to assist. It is one thing to keep nit picking but to do so without any attempt to help with the real problem I am having is a bit frustrating. My question to anyone wishing to assist: These files have different input names. How do I code it in such that our users are able to upload any or all of the files on a single button click? <form id="form1" name="form1" method="POST" action="Process.php" enctype="multipart/form-data"> <input type="file" id="BidFile" name="BidFile[]" value="" size="50"> <input type="file" name="Adden1[]" size="50"> <input type="file" name="Adden2[]" size="50"> <input type="file" name="TagSheet[]" size="50"> </form>
  20. I am trying to approach this from a different angle. Here is actual markup is below. Only difference is that I removed several form fields to avoid clutter. <form id="form1" name="form1" method="POST" action="Process.php" enctype="multipart/form-data"> <table> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form"><span style="color:#ff0000;">*</span>Bid Date </td> </tr> </table></td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"></td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"> <div class="input text"> <input type="text" name="txtBidDate" Id="txtBidDate" value="" style="width:150px;"></div></td> <td class="td_hint_form"></td> </tr> </table> </td> </tr> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form">Description </td> </tr> </table> </td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"> </td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"> <div class="input textarea"> <textarea cols="50" style="width:430px;" name="Description"></textarea></div></td> <td class="td_hint_form"></td> </tr> </table> </td> </tr> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form"><span style="color:#ff0000;">*</span>Bid File </td> </tr> </table> </td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"> </td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"><input type="file" id="BidFile" name="BidFile[]" value="" size="50"></td> <td class="td_hint_form"> </td> </tr> </table> </td> </tr> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form">Addendum 1 </td> </tr> </table> </td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"> </td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"><input type="file" name="Adden1[]" size="50"></td> <td class="td_hint_form"></td> </tr> </table> </td> </tr> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form">Addendum 2 </td> </tr> </table> </td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"> </td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"><input type="file" name="Adden2[]" size="50"></td> <td class="td_hint_form"></td> </tr> </table> </td> </tr> <tr> <td align="right" valign="top"> <table> <tr> <td class="td_label_form">Tag Sheet </td> </tr> </table> </td> <td align="right" valign="top"> <table> <tr> <td class="td_null_checkbox_form"> </td> </tr> </table> </td> <td> <table border="0"> <tr> <td class="td_input_form"><input type="file" name="TagSheet[]" size="50"></td> <td class="td_hint_form"></td> </tr> </table> </td> </tr> </table> If someone would be kind enough to assist with sample code on how to upload three different files with different input names, I would greatly appreciate it. Right now, I have BidFile, Adden1, Adden2, Tagsheet. Thanks a lot in advance.
  21. I apologize Jacques. I have it at 200M. I was including the "B" in this thread for emphasis. Another point I would like to make is that if I add an echo to see what ID is being passed from edit.php to the processing page: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if(isset($_POST["Id"])) { $strId = $_POST["Id"]; echo $strId; } ?> If it is a relatively small file, it displays the ID. If not, I get "This Page Cannot be Displayed" if I run it in IE. If I run it in FF, I get, 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. Yes, my code likely has something to do with it but huge file size is the big issue.
  22. Sigh! This is one of your questions: Is that a valid syntax?> And I said yes with examples that there is a function called AddFiles(...) and that's how I was calling the function. This has been working for over 6 months until they decided to upload a file of over 97MB of size. Your second paragraph pretty much derided the code with some scolding to boot and I am not complaining because you can't complain when you need help. Your next instruction was to add echos which I did and nothing was coming out except the same "page cannot be displayed". This a point I have made to you previously. The one question I mistakenly did not address was whether I looked into error log. I did and got same thing I told Jacques that I was getting which is: [17-Feb-2016 12:00:02 America/New_York] PHP Warning: POST Content-Length of 458679 bytes exceeds the limit of 1800 bytes in Unknown on line 0 In his response, he suggested that post max size was too small at 1800 bytes although I had it at 1800MB. Per his advise, I reduced it to 200MB but still getting same "Page Cannot Be Displayed" error message. The issue from what I could tell is that is not even getting to the processing page. I have these lines at the very top of the page: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> From what I can tell so far, based on the "Page Cannot Be Displayed" error I keep getting, it is doesn't appear to be reaching that page. That's why I asked yesterday if I should put that error on the markup page - edit.php page. Thanks again for help JG.
  23. Yes, that's a valid syntax. It works. The AddFiles(...) call is from this function: public function AddFiles($name = 'item') All I was trying to do with the code is have the ability to do three things: Add multiple files at same time. For instance, I have Addend1 through Addend1 An item solution would have been to have it like this: ->SaveFolder('../uploads/') ->AddFiles('BidIDFile') ->AddFiles('item') and the rest But it doesn't work. The second thing we are trying to accomplish with the code is the ability to delete (unlink) a file during update. Due to my newbiness and its complications to me, I had to do the way I did it. Sorry and thanks again
  24. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <html> <head> <style> .error_reporting { display: none; text-align: center; } .error_reporting .error_button h2 { font-size: 22px; margin: 0; padding: 0; } .error_reporting .error_button p { font-size: 18px; margin: 0; padding: 0; } .error_button { margin: 120px auto; margin-left: 300px; background-color: green; padding: 10px 20px; font-family: Arial; color: #FFF; text-shadow: 1px 1px 3px #000; font-size: 16px; display: inline-block; border-radius: 4px; box-shadow: 1px 1px 15px rgba(0,0,0,0.5); border: 5px solid #FFF; cursor: pointer; } table.infotext tr td { cursor: default; } table.infotext tr:hover td { background-color: #EBEBEB; } </style> </head> <body> <?php class ProcessBid { public $data; public $statement; public $where_vals; protected $keyname; protected $conn; public function __construct($conn = false) { $this->conn = $conn; } public function SaveData($request = array(),$skip = false,$keyname = 'post') { $this->keyname = $keyname; $this->data[$this->keyname] = $this->FilterRequest($request,$skip); return $this; } public function FilterRequest($request = array(), $skip = false) { // See how many post variables are being sent if(count($request) > 0) { // Loop through post foreach($request as $key => $value) { // Use the skip if($skip == false || (is_array($skip) && !in_array($key,$skip))) { // Create insert values $vals['vals'][] = "'".ms_escape_string($value)."'"; // Create insert columns $vals['cols'][] = "".str_replace("txt","",$key).""; // For good measure, create an update string $vals['update'][] = "".str_replace("txt","",$key)."".' = '."'".ms_escape_string($value)."'"; // For modern day binding, we can use this array $vals['bind']['cols'][] = "".$key.""; $vals['bind']['cols_bind'][] = ":".$key; $vals['bind']['vals'][":".$key] = $value; $vals['bind']['update'][] = "".$key.' = :'.$key; } } } return (isset($vals))? $vals:false; } public function AddFiles($name = 'item') { // If the files array has been set if(isset($_FILES[$name]['name']) && !empty($_FILES[$name]['name'])) { // Remove empties $_FILES[$name]['name'] = array_filter($_FILES[$name]['name']); $_FILES[$name]['type'] = array_filter($_FILES[$name]['type']); $_FILES[$name]['size'] = array_filter($_FILES[$name]['size']); $_FILES[$name]['tmp_name'] = array_filter($_FILES[$name]['tmp_name']); // we need to differentiate our type array names $use_name = ($name == 'item')? 'Addend':$name; // To start at Addendum1, create an $a value of 1 $a = 1; if(!empty($_FILES[$name]['tmp_name'])) { foreach($_FILES[$name]['name'] as $i => $value ) { $file_name = ms_escape_string($_FILES[$name]['name'][$i]); $file_size = $_FILES[$name]['size'][$i]; $file_tmp = $_FILES[$name]['tmp_name'][$i]; $file_type = $_FILES[$name]['type'][$i]; if(move_uploaded_file($_FILES[$name]['tmp_name'][$i], $this->target.$file_name)) { // Format the key values for addendum if($name == 'item') $arr[$use_name.$a] = $file_name; // Format the key values for others else $arr[$use_name] = $file_name; $sql = $this->FilterRequest($arr); // Auto increment the $a value $a++; } } } } if(isset($sql) && (isset($i) && $i == (count($_FILES[$name]['tmp_name'])-1))) $this->data[$name] = $sql; return $this; } public function SaveFolder($target = '../uploads/') { $this->target = $target; // Makes the folder if not already made. if(!is_dir($this->target)) mkdir($this->target,0755,true); return $this; } public function where($array = array()) { $this->where_vals = NULL; if(is_array($array) && !empty($array)) { foreach($array as $key => $value) { $this->where_vals[] = $key." = '".ms_escape_string($value)."'"; } } return $this; } public function UpdateQuery() { $this->data = array_filter($this->data); if(empty($this->data)) { $this->statement = false; return $this; } if(isset($this->data) && !empty($this->data)) { foreach($this->data as $name => $arr) { $update[] = implode(",",$arr['update']); } } $vars = (isset($update) && is_array($update))? implode(",",$update):""; // Check that both columns and values are set $this->statement = (isset($update) && !empty($update))? "update bids set ".implode(",",$update):false; if(isset($this->where_vals) && !empty($this->where_vals)) { $this->statement .= " where ".implode(" and ",$this->where_vals); } return $this; } public function SelectQuery($select = "*",$table = 'bids') { $stmt = (is_array($select) && !empty($select))? implode(",",$select):$select; $this->statement = "select ".$stmt." from ".$table; return $this; } public function InsertQuery($table = 'bids') { $this->data = array_filter($this->data); if(empty($this->data)) { $this->statement = false; return $this; } $this->statement = "insert into ".$table; if(isset($this->data) && !empty($this->data)) { foreach($this->data as $name => $arr) { $insert['cols'][] = implode(",",$arr['cols']); $insert['vals'][] = implode(",",$arr['vals']); } } $this->statement .= '('; $this->statement .= (isset($insert['cols']) && is_array($insert['cols']))? implode(",",$insert['cols']):""; $this->statement .= ") VALUES ("; $this->statement .= (isset($insert['vals']) && is_array($insert['vals']))? implode(",",$insert['vals']):""; $this->statement .= ")"; return $this; } } include("../Connections/Connect.php"); function render_error($settings = array("title"=>"Failed","body"=>"Sorry, your submission failed. Please go back and fill out all required information.")) { ?> <h2><?php echo (isset($settings['title']))? $settings['title']:"Error"; ?></h2> <p><?php echo (isset($settings['body']))? $settings['body']:"An unknown error occurred."; ?></p> <?php } // this function is used to sanitize code against sql injection attack. function ms_escape_string($data) { if(!isset($data) || empty($data)) return ""; if(is_numeric($data)) return $data; $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 $non_displayables[] = '/[\x00-\x08]/'; // 00-08 $non_displayables[] = '/\x0b/'; // 11 $non_displayables[] = '/\x0c/'; // 12 $non_displayables[] = '/[\x0e-\x1f]/'; // 14-31 foreach($non_displayables as $regex) $data = preg_replace($regex,'',$data); $data = str_replace("'","''",$data); return $data; } // New bid save engine is required for both sql statement generations $BidSet = new ProcessBid($conn); $strId = null; if(isset($_POST["Id"])) { $strId = $_POST["Id"]; //echo $strId; } If ($strId == "") { //echo "This is an insert statement"; // This will generate an insert query $insert = $BidSet->SaveData($_POST) ->SaveFolder('../uploads/') ->AddFiles('BidIDFile') ->AddFiles('item') ->AddFiles('SignInSheet') ->AddFiles('TabSheet') ->AddFiles('Xcontract') ->InsertQuery() ->statement; // Check that statement is not empty if($insert != false) { sqlsrv_query($conn,$insert); ?> <br><br><br><br><br> <div class="error_button"> <div style="float: right; font-size: 18px; font-weight: bold; color: #FFF;" onClick="DisplayErrorTag('close')">x</div> <?php render_error(array("title"=>"Record Successfully Saved!","body"=>'Go back to <a href="currentrecs.php">Solicitation screen</a>')); ?> </div> <?php $err = false; } //echo '<pre>'; //print_r($insert); // echo '</pre>'; } else { // Check to see if any images need deleting if(isset($_POST['delete']) && !empty($_POST['delete'])) { // whilelisted table columns $fileColumnsInTable[] = 'BidIDFile'; $fileColumnsInTable[] = 'Addend1'; $fileColumnsInTable[] = 'Addend2'; $fileColumnsInTable[] = 'Addend3'; $fileColumnsInTable[] = 'Addend4'; $fileColumnsInTable[] = 'Addend5'; $fileColumnsInTable[] = 'Addend6'; $fileColumnsInTable[] = 'TabSheet'; $fileColumnsInTable[] = 'SignInSheet'; $fileColumnsInTable[] = 'Xcontract'; // Loop through the post to assign delete fields foreach($_POST['delete'] as $fileCol => $fileColumn) { // If set and allowed to be delete if(in_array($fileCol, $fileColumnsInTable)) { // Save the columns to temp $fileColumns[] = $fileCol; // Save the file spots as blanks in the main post $_POST[$fileCol] = ''; } } // Check that there are files requiring attention if(isset($fileColumns)) { $sql_statement = "select ".implode(", ",$fileColumns)." from bids where ID = ?"; $query = sqlsrv_query($conn,$sql_statement,array($strId)); // No files, just return if($query === false) return $errors = 'file_fail_link'; $files = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC); //print_r($files); // loop over the files returned by the query // foreach ($files as $file) { foreach($_POST['delete'] as $file) { $thisfile = __DIR__.'/../uploads/'.$file; //delete file unlink($thisfile); //delete from filename from the database $sql = "delete ".implode(", ",$fileColumns)." from bids where ID = ?"; $query = sqlsrv_query($conn,$sql,array($strId)); } } } if(isset($_POST['delete'])) unset($_POST['delete']); { //echo "This is an update statement"; // This will generate an update query $update = $BidSet->SaveData($_POST,array("Id")) ->SaveFolder('../uploads/') ->AddFiles('BidIDFile') ->AddFiles('Addend1') ->AddFiles('Addend2') ->AddFiles('Addend3') ->AddFiles('Addend4') ->AddFiles('Addend5') ->AddFiles('Addend6') ->AddFiles('SignInSheet') ->AddFiles('TabSheet') ->AddFiles('Xcontract') ->where(array("Id"=>$_POST["Id"])) ->UpdateQuery() ->statement; //echo '<pre>'; //print_r($update); //echo '</pre>'; // Check that statement is not empty if($update != false) { sqlsrv_query($conn,$update); ?> <br><br><br><br><br> <div class="error_button"> <div style="float: right; font-size: 18px; font-weight: bold; color: #FFF;" onClick="DisplayErrorTag('close')">x</div> <?php render_error(array("title"=>"Record Successfully Saved!","body"=>'Go back to <a href="currentrecs.php">Solicitation screen</a>')); ?> </div> <?php $err = false; } } } // This will post an error if the query fails if((isset($err) && $err == true) || !isset($err)) { ?> <div class="error_button"> <div style="float: right; font-size: 18px; font-weight: bold; color: #FFF;" onClick="DisplayErrorTag('close')">x</div> <?php render_error(); ?> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script> <script> $(".error").fadeIn('slow'); </script> <script type="text/javascript"> function DisplayErrorTag(SetAction) { if(SetAction == null) { $(".error_reporting").fadeIn('slow'); // $(".error_reporting").delay(3000).slideUp('fast'); } else if(SetAction == 'close') { $(".error_button").fadeOut('fast'); } } </script> <?php } ?> </body> </html> Sorry, I didn't mean to ignore that. The message is not of my own creation. It is the dreaded IE page cannot be displayed error. Here is the code but please be warned, it is very, very long. Thanks again for your help.
  25. I copied it, replaced the one liner with yours and same result, same "This page cannot be displayed" error. Please allow me to ask a silly question. I have 2 pages, the edit.php file, more like the markup and the processing page called insertEdit.php. If the mode is insert, then insert records. If mode is edit, then edit records. My question is this, I put the two lines of your code in insertEdit.php code. That's the appropriate page to put them. Am I right? And I put them at the very, very top and yet once I click the submit button, within 5 seconds, I get that message. Thanks for your help.
×
×
  • 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.