The PHP script functions as expected in both my local environment and the demo cPanel server, but it does not perform correctly on the client's server

I developed a patient record management site two years ago. Every three months, the client encounters some errors. For example, yesterday they searched for a patient named “Kumar” but could not find the record. However, today the same search for “Kumar” successfully displayed the patient record. This issue does not occur on my local or demo servers. What could be causing this?

Additionally, I am using the same PHP version across all environments: local, demo, and client server.

Any insights on resolving this issue would be greatly appreciated. Thank you in advance!

1 Like

First thing is, I would have requested them for a screenshot or a video recording of them going in and searching for the term. This way, it gives you an idea on what they’re inputting on their side to help you reproduce the issue. Next, I would check your access and error logs to see what you get. If the access logs correspond with what the user is inputting then I would check the error logs. If the error logs show nothing then I would check the database to see if those records are in there from server to server.

1 Like

Fatal error : Uncaught mysqli_sql_exception: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘dbname.sechdule_date.auto_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in /home/domainname/public_html/dashboard/doctor-clerking-pag.php:47 Stack trace: #0 /home/domainname/public_html/dashboard/doctor-clerking-pag.php(47): mysqli->query(‘SELECT * from s…’) #1 {main} thrown in /home/domainname/public_html/dashboard/doctor-clerking-pag.php on line 47

this is the error which my client face when he search the patient name kumar

1 Like

so you have disabled the mySQL8 default value to not allow group by statements without aggregating all select values (or you are still using mySQL5).
In fact your code is not correct in that a case but it will work (but might have some unwanted results on the query).
You have two choices:

  1. Correct your SQL queries to group all select values
  2. Ask the client to edit the mysql.ini and disable ONLY_FULL_GROUP_BY

Given that this query works most of the time and only occasionally doesn’t work, is this query being dynamically/conditionally built? What is the actual query? Are you trimming submitted data to remove any accidental space, tab, new-line characters?

Given that the ->query() method is being used and this query involves searching for user submitted data, you should be using a prepared query in order to prevent any sql special characters in a value from being able to break the sql query syntax. This in fact may have something to do with the sql error, if the submitted name has some extra character(s) (space, tab, new-line, quote) typed/copy-pasted as part of it.