Jump to content

mstap42

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mstap42's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. In case anyone wondered... Recall the problem: I modified the code from the PHPFreaks tutorial "Exporting MySQL To Excel" to send my Oracle data to Excel, but was unable to substitute "\t" for null values, thus: [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]while($row = oci_fetch_row($stmt)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; // if $value is blank, write a tab... } else { ... }[!--fontc--][/span][!--/fontc--] Tests with ($value == ""), is_null(), and empty() returned *nothing*. Not TRUE, not FALSE, but exactly nothing. So tabs weren't substituted for NULL values, and therefore data got slammed to the left in the Excel file. Evidently, (and assuming the tutorial's code works as advertised for NULL values), there's not a one-to-one correspondence between mysql_fetch_row and oci_fetch_row. But, *this* works against Oracle 9i: [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]while($row = oci_fetch_array($stmt, OCI_NUM + OCI_RETURN_NULLS)) { ... }[!--fontc--][/span][!--/fontc--] If you think you want to try the tutorial's approach, remember that oci_num_fields follows oci_execute. Sounds pretty basic, but it tripped me up the first time. Thanks to everyone who took a look at the original post!
  2. I've seen your error in my setup (IIS6/PHP5) whenever I've had the following problems in tnsnames.ora. verify tnsnames.ora -- path set in System Environment variables? -- sytax (unmatched brackets?) -- valid net service name I found answers [a href=\"http://ora-12154.ora-code.com/\" target=\"_blank\"]here[/a].
  3. I've run into a bit of a snag with querying Oracle in PHP and wondered if you had any ideas. The problem is null values. With my scripts, when data is sent to HTML tables or Excel, the nulls aren't recognized, and the value to the right is moved into that blank position. Otherwise, where all fields have some content, the data is displayed correctly. Example: SELECT last_name, first_name, middle_initial, profile FROM mydb.operators If middle_initial contains nothing, the profile value is written in the middle_initial column: last_name first_name middle_initial profile Simpson Homer admin I would like to be able to substitute a blank value with something like a tab (\t). But tests with PHP's is_null() and empty() functions seem to show that these functions do not recognize the Oracle null at all. With error_reporting set to 2047 (E_ALL), they return nothing--neither Null nor Not Null, neither Empty nor Not Empty. Whether a field is populated or not, isset() shows the value to be Set. So conditional statements like this fail: [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--] if ((!isset($value)) || ($value == "")) { $value = "\t"; }[!--fontc--][/span][!--/fontc--] The conditions [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]is_null($value)[!--fontc--][/span][!--/fontc--] and [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]empty($value)[!--fontc--][/span][!--/fontc--] also fail. Is there something about Oracle null values that PHP can't see? Is there some other function I could use to identify Oracle nulls for character substitution? Many thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.