Records do not return in PHP

Good Morning.

I have an incident portal in PHP and am with the following problem:

I have a select when run in ORACLE, the various records are listed, but the PHP page does not return all records.

The problem is probably the while, but I do not know why in PHP only a few records are listed.

Attached PHP code and the result in Oracle.

In this example, the PHP page is not bringing any records, but in the ORACLE has a record that should be showing.

Thank you.
grid_global_soc3.php
Capturar.PNG
Capturar2.PNG
Support_38Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I'm going to make a few recommendations - none are "directly" related to the question, but all will help you move forward on this task, and in your career.

First, please learn about coding standards, adopt one, and use it without fail all of the time.  The lack of consistent spacing and indentation makes the code very hard to read and understand.

Second, please take some time to learn the fundamentals of how to use HTML and PHP.  W3Schools is good for HTML learning.  We have an article here at E-E that can help you learn PHP.  One of the things that jumps out at me is that the script does not test for success or failure, nor does it elevate error messages.  How do you know that oci_execute() worked?  Your script must test the return values.  This is all documented in the online manuals.

Third, please learn about the SSCCE.  It teaches us the right way to ask a question here, and it's the right way to pursue problem resolution.  In this method we eliminate all of the extraneous stuff and isolate the minimum necessary code that demonstrates the problem.

Fourth, please learn about Test-Driven Development.  This appears to be a data-dependent problem, but there is no test data posted with the question.  In most professional development shops, programmers will write the test cases first, using predictable test data sets, before they start writing the code to solve the problems.  The test cases enable us to prove that the code is correct, and to avoid regressions when we must extend or refactor a code base.

To try to come to grips with the query, here is what I might do.  First, go into the code attachment at line 91 and test for success or failure of the query.  Visualize any error messages.  Next, at line 94 insert this statement, and eliminate the rest of the script.  This will let you see the query results without any conditional code or formatting that might interfere with an understanding.
var_dump($resultado); }

Open in new window

HTH, ~Ray
slightwv (䄆 Netminder) Commented:
First:  I don't know anything about PHP.

I do know Oracle.  I notice the row you are looking for has Unicode characters in it.

I wonder if it is a characterset encoding mismatch between the client and server.

Oracle typically needs to set NLS_LANG on the client side to properly handle conversion between the client and server correctly.

I'll let Ray deal with the PHP specifics since he is the PHP Expert.

Until he posts back a quick web search provided:
https://community.oracle.com/thread/476322?start=0&tstart=0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
I don't know anything about Oracle, but you're in good hands with SlightWV on that front.

For a better understanding of character encoding issues, you might find this article useful.  It talks about MySQL, but some of the same principles may apply to Oracle, too.
http://iconoun.com/articles/collisions/
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Support_38Author Commented:
Hello

I appreciate the recommendations.

I'm not a developer, I am of the database area but need to implement this portal.

This code was initially written for Windows using ODBC connection, I had to export it to linux, but I have not found a way to make the connection to the database by ODBC in linux, the only way I found worked and was utiliando OCI

What is harder to understand is that some records are shown in php, some not, but is not filter problem in select, because when I direct select the PL-SQL records are displayed correctly.

Thank you.
slightwv (䄆 Netminder) Commented:
>>What is harder to understand is that some records are shown in php, some not, but is not filter problem in select, because when I direct select the PL-SQL records are displayed correctly.


This is what makes me think it is a characterset encoding issue.  The tool you are using to directly query the database is encoding the characters properly and it is able to find them.

If PHP isn't encoding them properly, what is being passed to the database aren't the same characters you think they are which is why the row isn't found.
Ray PaseurCommented:
See the fourth connection parameter here:
http://php.net/manual/en/function.oci-connect.php
character_set

    Determines the character set used by the Oracle Client libraries. The character set does not need to match the character set used by the database. If it doesn't match, Oracle will do its best to convert data to and from the database character set. Depending on the character sets this may not give usable results. Conversion also adds some time overhead.

    If not specified, the Oracle Client libraries determine a character set from the NLS_LANG environment variable.

    Passing this parameter can reduce the time taken to connect.
My guess is that this parameter must be correct and consistent for writing as well as for reading.  Your PHP script needs these statements if you're using UTF-8.
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
mb_http_output('UTF-8');

Open in new window

Support_38Author Commented:
Hi

Actually the problem was in Unicode.

To solve the problem, it was added AL32UTF8 command in the connection string as shown below:

$ Conn = oci_connect (username, pass, $ tns2, 'AL32UTF8')

Thank you all
Support_38Author Commented:
Thank you for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.