Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
php page won't display the first record
I have the following code, but it always skip the first row of the records pull from an Oracle table:
include "utility_functions.php";
// Form the query and execute it
$sql = "select * from dept where cid=".$_GET['q'];
$result_array = execute_sql_in_oracle ($sql);
$result = $result_array["flag"];
$cursor = $result_array["cursor"];
if ($result == false){
display_oracle_error_message($cursor);
die("Client Query Failed.");
}
// Display the query results
echo "<ul class=\"nav\">";
$values = oci_fetch_array ($cursor);
//echo $values[0];
// Fetch the result from the cursor one by one
while ($values = oci_fetch_array($cursor)){
$did = $values[0];
$dname = $values[1];
echo("<li><a href=\"showdetail.php?did=$did\">$dname</a></li> ");
}
oci_free_statement($cursor);
echo "</ul>";
for example, I have the following in dept table:
did dname
1 Business
2 Education
3 Math
4 English
It will only list: education, math, and english. Any clues?
Answers
-
What does execute_sql_in_oracle() do?
Try following example code, such as from:
http://www.php.net/manual/en/oci8.examples.php
http://www.php.net/manual/en/function.oci-fetch-array.php
http://www.php.net/manual/en/function.oci-bind-by-name.php
It's extremely insecure (and slow) to do a query made up with string concatenation like:
$sql = "select * from dept where cid=".$_GET['q'];
You probably need to first sanitize $_GET to remove anything malicious. Then you must use a bind variable on the sanitized result.