Jump to content

ShadowMage

Members
  • Posts

    3,476
  • Joined

  • Last visited

Everything posted by ShadowMage

  1. If I use the backticks I get this: PHP Warning: odbc_exec(): SQL error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near '`'., SQL state 37000 in SQLExecDirect
  2. This is a really bizarre issue and I'm not sure if anyone will be able to help, but maybe someone's seen something like this before. So, I have a query: SELECT OrderHed.OrderNum, OrderHed_UD.ShortChar06 AS 'SalesLeader', OrderHed_UD.Character01 AS 'JobName' FROM OrderHed INNER JOIN OrderHed_UD ON OrderHed.SysRowID = OrderHed_UD.ForeignSysRowID WHERE (OrderHed.OpenOrder = 0) This gives me an error message: PHP Warning: odbc_fetch_array(): SQL error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'SalesLeader'., SQL state S0022 in SQLGetData (Yes, this is run in PHP) Now, if I just remove the alias from ShortChar06 OR if I entirely remove Character01, the query runs just fine. So both of these queries will run without issue: SELECT OrderHed.OrderNum, OrderHed_UD.ShortChar06, OrderHed_UD.Character01 AS 'JobName' FROM OrderHed INNER JOIN OrderHed_UD ON OrderHed.SysRowID = OrderHed_UD.ForeignSysRowID WHERE (OrderHed.OpenOrder = 0) OR SELECT OrderHed.OrderNum, OrderHed_UD.ShortChar06 AS 'SalesLeader' FROM OrderHed INNER JOIN OrderHed_UD ON OrderHed.SysRowID = OrderHed_UD.ForeignSysRowID WHERE (OrderHed.OpenOrder = 0) Any ideas what might be causing this strange behavior? I can't see anything in the syntax that would cause issues, but something is clearly not functioning. This is happening for a couple of different fields (all of which are from the _UD tables; but not all of the _UD table fields are doing it).
  3. That's what I ended up doing. If this is a standard coding practice, I'm not sure why it worked before (I didn't write any of this stuff, but it was working so I never gave any thought to good practice). Thanks for the help!
  4. I debated just editing my last post and changing it completely, but I decided to leave it in case it's more useful than it appears to me. Anyway, here's a more accurate illustration of what's going on. This is the code for ValidateSession.php: <?php session_start(); // must have a valid cookie if ( isset($_COOKIE['MajorEpicor10Login']) ) { // split the cookie data into an array parse_str($_COOKIE['MajorEpicor10Login'], $tmparr); if ( !(isset($_SESSION['User']) and ($_SESSION['User'] == $tmparr['User'])) ) { $_SESSION['User'] = $tmparr['User']; $_SESSION['FirstName'] = $tmparr['FirstName']; $_SESSION['LastName'] = $tmparr['LastName']; $_SESSION['Staff'] = $tmparr['Staff']; $_SESSION['OutsideSales'] = $tmparr['OutsideSales']; $_SESSION['GroupList'] = $tmparr['GroupList']; $_SESSION['DepartmentID'] = $tmparr['DepartmentID']; setrawcookie("MajorEpicor10Login", $_COOKIE['MajorEpicor10Login'], time()+60*60*24*30, '/'); } } else { header('Location: /Logon/Logon.php?From=Home'); } //die(); ?> Now, using my test code from my original post: require('ValidateSession.php'); echo "User: ".$_SESSION['User']; produces the error. If I un-comment the die() command in ValidateSession, it will redirect successfully to the logon.php page. Same behavior in my actual code which looks something like this (there is some pseudo-code): <?php require('ValidateSession.php'); $User = $_SESSION['User']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Major Web Portal</title> </head> <body> <form name="MajorWebPortal"> <?php /**SQL query to pull user data such as DepartmentID**/ if ($RecordExists) { switch ($DepartmentID) { /**Redirect to dept homepage using header()**/ } } else { header('Location: ./Logon/Logon.php?From=SetCookie'); } ?> </form> </body> </html> Now if I put this bit: $User = ''; if (isset($_SESSION['User'])) { $User = $_SESSION['User']; } into each file in place of direct access to the session variable, the test code will successfully redirect back to the logon page while my actual code proceeds on down through the rest of the code, pulling in a "random" user with a blank ID and redirecting to that user's homepage (where I then get a bunch more undefined index errors). I presume the header() call in ValidateSession is being overwritten by the header() calls in the index page, but why is the code even going that far instead of just executing the first header() call like it does on our current server?
  5. Ok, so I tried using isset to check the session variable, but that seems to have just bypassed the whole logon and redirected me to a random homepage (not quite) with even more session variable errors. Just to clarify, this is on a company intranet where users log in and are directed to a department-related homepage. I'm not sure if I can accurately explain everything, but I'll try, so here goes. This is what is supposed to happen (pseudo-code, obviously): ValidateSession { check for valid session if (!valid) redirect to logon } Get user dept based on user ID from session Redirect to appropriate homepage This code is all in the _index.php file (where the user lands after typing the intranet address), except for the ValidateSession which is in an includes file as seen before. This is the behavior that is happening on our current web server. Copying that code over, exactly, to our new server results in the error mentioned previously. It doesn't seem to allow any other output except the error message. When I try to access an undefined index on the current server, I get the undefined index notice, but it's in the middle of the rest of the page output. That said, I did try to use isset to check the session variable first and that resulted in the following behavior: require('ValidateSessin.php'); //This doesn't seem to actually execute but I included it to show that it is still in my actual code isset($_SESSION['User']) $User = $_SESSION['User'] else $User = '' //this is the block being executed because it seems to entirely skip the ValidateSession code above Execute query to pull user dept; finds random user in DB with blank ID (ID is not the PK of DB) Redirect to random user's "homepage" This results in a good many undefined index notices because the homepages use the session variable to determine specific users that can see specific tools and links so every time it tries to check a session variable it throws a notice. As I mentioned, it seems to just entirely skip the ValidateSession code whenever I try to actually access the session variables. If I just want to print out the session, it works just fine.
  6. The error setting is the same on both servers:
  7. I have the following code in a test document: require('ValidateSession.php'); // echo "<pre>".print_r($_SESSION, true)."</pre>"; echo "User: ".$_SESSION['User']; As written above (with the print_r line commented out and attempting to access the 'User' index) I get the following error: If I swap the two echo lines (so the print_r is no longer commented and the other line is) it redirects to the login page as expected. This is what the ValidateSession.php is supposed to do. It checks whether there is a current/valid session and if not, redirects to a login page. I can post this code if it will help. A little more context on some things. We're in the process of migrating to a new web server going from 32-bit PHP 5.5.15 to 64-bit PHP 7.4.3. I went through the INI files and got them as close as possible. Is there some setting or behavior that makes the above function differently in the new version? The above works as intended on our current server. Any help you can offer would be much appreciated. Thanks in advance.
  8. We're migrating to Windows Server 2019 (IIS 10) now and this issue has reappeared. I've changed the account in anonymous authentication to the domain admin account as before, but the error is still showing up. I tried creating a new account specifically to run PHP/IIS and gave the account access to the share/file. I tried specifying this account in anonymous authentication and in the application pool identity (and setting anon auth to use the app pool identity), but nothing seems to work. Any ideas on what else I can try?
  9. Unfortunately, i am required to use Progress... I am in touch with Epicor to try to get drivers, otherwise I will revert PHP to an older version. Luckily, Epicor 10 (which we are planning to upgrade to this fall) has moved away from Progress and adopted MySQL so I won't have to deal with this anymore after that. Thanks for your help!
  10. Yes, via ODBC. I set up the DSN in the 32-bit data source manager and a test connection succeeds there. Am I going to have to downgrade PHP and MySQL to 32-bit?
  11. The Progress DB? Yes, I believe so. I have no trouble connecting to it with the same driver on the current intranet (which is running 32-bit PHP 5.??)
  12. Got a new problem now. I'm trying to connect to a Progress DB using OpenEdge 10.2A and getting this error: The specified DSN contains an architecture mismatch between the Driver and Application Clearly its complaining about the fact that I'm running 64-bit PHP and trying to use a 32-bit driver (that's the only driver available). I've enabled 32-bit applications in the app pool on IIS but it's still giving this error. Any ideas?
  13. I did that, I think. That's what I meant by setting the character_set_server. I launched the MySQL command line and ran the following: set global character_set_server = 'UTF8MB4'; It gave me a warning if I set it to just 'UTF8'. Something about being ambiguous with UTF8MB3? Should I be setting this somewhere else?
  14. I'm trying to configure a new web server to migrate the company intranet, but I'm getting the following error: Server sent charset (255) unknown to the client. Please, report to the developers I did a little googling and it is supposedly a PHP bug that was fixed in version 7.0-ish. I am running MySQL 8.0.15 with PHP 7.3.3 (on Win Server 2019, if that matters) and still getting this error. I tried setting the character_set_server to 'UTF8MB4' but that didn't seem to do anything. Please help.
  15. Well, adjusting my join to use syntax like that I now get this error: I suspect that this is due to what I mentioned previously about there being multiple possibilities to join on and it doesn't know which to use. It looks like I might just have to find a different way to get the information I need (multiple queries and looping through them in PHP perhaps). Thanks, JSG!
  16. The best I've been able to come up with so far is something like this: SELECT OrderHed.OrderNum, OrderHed.SalesRepList, SalesRep.SalesRepCode, SalesRep.Name FROM OrderHed INNER JOIN SalesRep ON OrderHed.Company = SalesRep.Company AND LCASE(LEFT(LTRIM(OrderHed.SalesRepList, '~'), (INSTR(LTRIM(OrderHed.SalesRepList, '~'), '~')-1))) = LCASE(SalesRep.SalesRepCode) WHERE (SalesRep.SalesRepCode = 'ABC') which works, but only returns records if the rep is the first one in the list. Ie, it'll return an order where rep list is "ABC~DEF" but not one where rep list is "DEF~ABC".
  17. lol. They'll tell me to go to their Yahoo user group. Been there done that. Anyways, no the codes are not the same length and yes there could be codes that are subsets of others. They are user generated codes and typically some abbreviated form of a company name.
  18. ShadowMage

    Join Using LIKE

    Hey guys, I have the following SQL statement: SELECT OrderHed.OrderNum, OrderHed.SalesRepList, SalesRep.SalesRepCode, SalesRep.Name FROM OrderHed INNER JOIN SalesRep ON OrderHed.Company = SalesRep.Company AND LCASE(OrderHed.SalesRepList) LIKE CONCAT('%', LCASE(SalesRep.SalesRepCode), '%') WHERE (SalesRep.SalesRepCode = 'ABC') Where OrderHed.SalesRepList is a delimited list of codes in the format "ABC~DEF~GHI" and order is not always the same. I realize this is bad design, but I have no control over the database design (it's Epicor) so I just have to work with what I've got. I need to be able to join the OrderHed table and the SalesRep table on that list of codes. My Google searches suggest that the syntax above should work, but when I run that I get the following error: Is this a limitation on the Progress engine or am I doing something wrong? EDIT: Actually, now that I think about it, I wonder if it's failing because it's trying to create multiple joins in one. Ie, in the example rep list I gave, it would be trying to join the rep codes ABC, DEF, and GHI all at the same time. Are there any other ways around this to accomplish what I'm trying to do? Maybe a nested query of some kind (those really confuse the heck out of me...)?
  19. Seems like that was the problem. Apparently Everyone doesn't include the IUSR... I couldn't find a way to add the IUSR account to the share in AD, but I did figure out how to change the account used in anonymous authentication in IIS.
  20. Maybe a silly question, but how and where do I find the IIS account? I see a group called IIS_IUSRS but there's no members.
  21. I'm not sure if this should go here or in PHP, but I'm having problems getting PHP to connect to a Progress DB. I have IIS installed and configured on a Windows 2008 server and all seems to be fine on that front. I can access the site, and I can run PHP code. I can also access the MySQL databases we have. When I try to access the Progress database, however, I get the following error: Warning: odbc_connect(): SQL error: Specified driver could not be loaded due to system error 5: Access is denied. (Progress OpenEdge 10.2A driver, \\share\path\to\file.dll)., SQL state IM003 in SQLConnect in C:\inetpub\phplib\ODBC.php on line 349 I created a system DSN on the webserver and I am able to successfully test connect from there. I've also added full control for Everyone on the specified DLL (and the path to get to it) and still get the access denied error. Any ideas or suggestions? Thanks in advance for any help you can offer.
  22. I just echoed the xml string. Nothing else. No html tags of any kind. This script is intended to be accessed through AJAX so there is no other output (aside from any error messages if/when they occur).
  23. This is the code I'm using: $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadXML($xml); // $tmp = $doc->saveXML(); $doc->save($FileLocation); The saveXML() function returns the xml code as a string. The save() function saves it to a file. When I echo $tmp, I get all the goofy characters described above. However, I just tested printing out the xml string prior to loading it into DOMDocument and it prints out just fine... Must be something with DOMDocument messing up the character encoding.
  24. It seems to recognize as a valid entity at least. I know that it works in HTML. I did try using the other two you mentioned. ™ doesn't seem to work in either the browser or when I save it as a file. Shows a bunch of odd symbols in the browser and puts the entity code itself into the file where the symbol should be. Maybe that's how it's supposed to work, not sure. However, while ™ doesn't work in the browser, it does put the actual symbol (not the entity code) in the right place when saved to a file. I think I'll run with it this way for now and see if I encounter any problems.
×
×
  • Create New...