Jump to content

ShadowMage

Members
  • Posts

    3,476
  • Joined

  • Last visited

About ShadowMage

  • Birthday August 27

Previous Fields

  • Languages
    (X)HTML, CSS, JavaScript, PHP

Recent Profile Visitors

58,467 profile views

ShadowMage's Achievements

Devoted Member

Devoted Member (5/7)

94

Reputation

  1. I have two tables: OrderHed and OrderRel. There are multiple records in OrderRel for each OrderHed. I'm trying to pull out the first record from OrderRel for each OrderHed. I have the following query, but it gives me a "Function sequence error" SELECT OrderHed.OrderNum, OrderRel.Plant FROM OrderHed INNER JOIN (SELECT Plant FROM OrderRel WHERE OrderRel.OrderNum = OrderHed.OrderNum LIMIT 1) OrdRel WHERE ((OrderHed.OpenOrder <> 0) AND (OrderHed.VoidOrder = 0)) ORDER BY OrderHed.OrderNum DESC Can anyone help me, please?
  2. That's unfortunate. And also probably true... I much prefer forums for this type of thing and I actually kind of despise the social media type stuff. I have a strange urge to make a comment about whipper-snappers and ... lawns ... and? 🤔
  3. Shoot. Forgot I posted here. It ended up being an issue with Epicor (the DB I'm connecting to). Turns out that UserComp.PlantList is a varchar(1000) field and any time we try to pull out a 1000 character field from Epicor in PHP, we have to use CAST(fieldname AS varchar(1000)) or we get funky, completely unrelated, inaccurate error messages. Like this one. Anyway, thanks for looking, Ingolme. Much appreciated. On a completely unrelated sidenote: What happened to this place? This used to be a fairly active community, but now it's almost like a ghost town...😕
  4. I have the following query: $sql = "SELECT UserFile.DcdUserID, UserComp.PlantList FROM UserFile INNER JOIN UserComp ON UserFile.DcdUserID = UserComp.DcdUserID"; but it's giving me the following error: PHP Warning: odbc_fetch_array(): SQL error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Ambiguous column name 'DcdUserID'., SQL state 37000 in SQLGetData If I adjust the query with an alias on 'DcdUserID' as follows: $sql = "SELECT UserFile.DcdUserID AS 'UserID', UserComp.PlantList FROM UserFile INNER JOIN UserComp ON UserFile.DcdUserID = UserComp.DcdUserID"; then it tells me that 'UserID' is an invalid column name. Any ideas what's going on here? I can't see any issues with the SQL and in fact both queries run in a standalone querying tool we use (ODBC Test Utility) without issue.
  5. That seems to have done the trick on getting the PHPSpreadsheet stuff to load. But it looks like I've got some prerequisite stuff to take care of now as it's giving me an error saying it can't load psr/simple-cache which is not part of the PHPSpreadsheet library. Thanks for all the help, Ingolme!! I'll be back if I run into more snags. 😄
  6. So I've got this code: require('PhpSpreadsheet\autoload.php'); use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'Hello World !'); $writer = new Xlsx($spreadsheet); $writer->save('hello world.xlsx'); Which was copied directly from their documentation as a test. However, I get this error: PHP Warning: include(PhpSpreadsheet/src/PhpOffice\PhpSpreadsheet\Spreadsheet.php): failed to open stream: No such file or directory The autoload.php file looks like this: spl_autoload_register(function ($class_name) { // include 'PhpSpreadsheet/src/PHPSpreadsheet/'.$class_name.'.php'; include 'PhpSpreadsheet/src/'.$class_name.'.php'; }); I copied the files from their original folder (PHPSpreadsheet) up a level into the src folder just to eliminate the extra file path length. However, I did try it with the original file structure when it failed. Both ways produce the same error. It looks to me like maybe the use lines aren't functioning correctly? Maybe? It looks like the autoload function is pulling in the full namespace of the class instead of just the class name. Any ideas what's going on?
  7. So do I need to change the $class_name variable? Or just make sure the "src/PHPSpreadsheet" part is pointing to the right place? EDIT: Nvmind, answered my own question with a bit of research. 😁 Found a StackOverflow article that explains autoloading. Just need to change the "src/PHPSpreadsheet" part. Let's see if I can get this thing working now... I might be back... Thanks, Ingolme!!
  8. ShadowMage

    Write to Excel

    My company has started asking for more and more Excel-based data. We used to just print the data to a table and then copy/paste from the browser to Excel, but they're wanting auto emailers and stuff like that now. I did a little research and it seems like PHPSpreadsheet is the way to go. It seems to be the most up to date, and still actively supported. Problem is, I'm not sure how to set it up and use it. Their documentation (https://phpspreadsheet.readthedocs.io/en/latest/) is a little vague on that part. It reads like this is supposed to be installed into a project (similar to Visual Studio's projects) but I didn't even know that was a thing with PHP. I've only ever used PHP in a webserver environment (maybe that's the project?). I've never used Composer so I have no clue where to even start. So, I guess my question is, can somebody offer some assistance in setting this up and/or using it in a webserver environment? Or, offer some alternatives to PHPSpreadsheet that are easier to use? Thanks in advance.
  9. Bumping this again because it is really a pain to try and work around this issue. Does anyone have any ideas as to how I can get all the output back? It's incredibly helpful in trying to track down undefined indexes and such within loops.
  10. ah, ok. I'll give it a shot with iframes then. Thanks guys.
  11. Totally forgot I posted this until I was asked about it again this morning... I thought iframes were deprecated or not recommended?
  12. This is strange but recently my page stopped displaying PDFs using the object tag. Nothing has changed on the page (in fact, I haven't worked with it in a very long time and there's no one else besides my supervisor who can edit it; I'm 99.99999% sure he hasn't touched it either). I guess what I want to ask is if there's anything that looks out of place with my code: $x = 0; foreach ($arrPDF as $pdf) { echo "<object id='bulletin".$x."' data='../path/".$pdf."' type='application/pdf'>\n"; echo "<span class='error'>Error: Could not load PDF. Your browser does not support embedded objects.</span>\n"; echo "</object>\n"; $x++; } This code used to work, then just seemingly at random one day, it decided not to. Used to display the PDFs, now I just get the error message. Any suggestions? I've already tried updating the browser. I've tried it in FireFox, Chrome, and Edge. None of them display the PDFs. Everything I've seen online about the <object> tag suggests this code should be just fine. Is there a different/better way to embed a PDF that I'm not finding?
  13. The problem is not data coming from an HTML form. As mentioned, memos that are entered from the intranet (the HTML forms) are functioning correctly. The problem appears when users copy/paste directly into the ERP system. To try to further clarify, memos can be entered in one of two ways. Through a form on the intranet or directly into the ERP system. Those memos that come from the intranet form are functioning fine and do not have any character encoding issues. Entering memos directly doesn't cause issues UNLESS the user copy/pastes data (from an Outlook email, for example) into the memo. The intranet and the ERP system are two separate entities, not really connected in any way except for sharing data back and forth through an ODBC connection. The intranet is of our own design and we have full control over it. As mentioned, it connects to the ERP system's database through ODBC to retrieve data and occasionally very limited writing of data to Memos and certain other similar things. The ERP system (Epicor, in case you're wondering) is not our own and we have very, very limited control of the database it uses and none over how it interacts with said database.
  14. So, first a little background on the setup/system we're running. We have an ERP system where users enter memos and notes on quotes/orders. We also have an intranet that pulls this information back out to run reports and such. The problem I'm facing, is that users are copy/pasting data into the memo text which is creating a character encoding issue. The memo text is displaying in the web browser as the black diamond with a question mark for certain specific characters (like apostrophe's). Manually typed text doesn't seem to have this issue, nor does text that comes from the intranet and is inserted into the ERP system. It is only data that's copy/pasted directly into the ERP system. How do I detect these wrongly encoded strings and display them properly? I did try to just use utf8_encode() on the text, but that changes the black diamond to a white box. I also see there is a iconv() function to convert strings to specific encodings, but it requires an input encoding, and I have no idea what the starting charset is. I found the mb_detect_encoding() function, but that gives me a fatal error. I tried to enable the mbstring extension in php.ini but that didn't seem to make any difference.
  15. Ok, so this is stemming from the fact that I can't get any output from PHP except errors when they occur (as described here) but since that doesn't seem to be an issue that's going to be resolved any time soon, I need to figure out how to work around it. So, I split this issue (which I also posted in the linked thread) off into it's own separate thread to see if I can resolve this particular issue. Anyway, I'm getting this error: PHP Warning: A non-numeric value encountered in ...filepath... on line 166 Line 166 looks like this: $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; The error doesn't even tell me which of the three variables is throwing the error. Normally, this wouldn't be an issue, because I'd just print out all the variables in the equation to see what they're being set to. However, due to the previously mentioned issue, that's not possible. So, I've tried to catch this error in the following ways: try { $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; } catch (Throwable $e) { echo "<pre>".print_r($Dim, true)."</pre>"; } and: $blnDump = false; $which = ''; if (!is_numeric($Dim['bays'])) { $blnDump = true; $which = 'bays'; } elseif (!is_numeric($Dim['purlins'])) { $blnDump = true; $which = 'purlins'; } elseif (!is_numeric($Dim['qty'])) { $blnDump = true; $which = 'qty'; } if ($blnDump) echo "$which was non-numeric:<br /><pre>".print_r($Dim, true)."</pre>"; but neither one catches the error and I just get the error printed on the page. The error prints twice, because the code above is in a function that gets called multiple times within a loop, and the issue apparently is occurring on two different iterations of the loop. And, because the code is in a loop, I can't use exit; or die(); to kill the script and print my debugging messages, because it kills the script on the first iteration of the loop. As luck would have it, the first iteration is error free and is therefore unhelpful to say the least. Please help?
×
×
  • Create New...