SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    May 2008
    Location
    Missouri, USA
    Posts
    273
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Oracle and PHP Error

    This is my first attempt at using oracle and i'm trying to do a simple query and am having a problem.

    This is my connect code:
    PHP Code:
     $dbconn oci_connect('username''password''dbase1');
                            
    $query =  "SELECT * FROM Employee WHERE LOWER(Username)='" $uname "' AND Password= '" sha1($pword) . "';";
                            print 
    $query;
                            
    $parsed =  oci_parse($dbconn$query);
                            
    oci_execute($parsed);

                            
    $nrows =  oci_fetch_all($parsed$results); 
    And i'm receiving this error message:
    Warning: oci_execute() [function.oci-execute]: ORA-00911: invalid character in Login.php on line 34

    Warning: oci_fetch_all() [function.oci-fetch-all]: ORA-24374: define not done before fetch or execute and fetch in Login.php on line 36
    I'm assuming the second error is a result of the first error. In the first error it says there is an invalid error... but i'm not sure what character its talking about because everything looks good to me.

    I appreciate any help.
    Follow Me On Twitter: BryceRay

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Try removing the semi-colon from the end of your SQL statement, pretty sure that's MySQL specific.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Addict
    Join Date
    May 2008
    Location
    Missouri, USA
    Posts
    273
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok that fixed the error but there is still a logic problem in my code. Here is another very simple segment of code that should be working as far as i can tell but is not

    PHP Code:
    $dbconn oci_connect('username''password''dbase1');
    $query =  "SELECT FirstName, LastName FROM Employee";
    $parsed =  oci_parse($dbconn$query);
    oci_execute($parsed);

    $nrows =  oci_fetch_all($parsed$results);
    print 
    $nrows
    Now when I print $nrows I get 0.

    However when i use the exact query above directly in the SQL command line it returns lots of results.
    Follow Me On Twitter: BryceRay

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I've never used the functions before, but after a brief read of the manual, it appears the following should work.
    PHP Code:
    <?php
    $conn 
    oci_connect('user''pass''database');
    $stmt oci_parse($conn'SELECT FirstName, LastName FROM Employe');
    oci_execute($stmtOCI_DEFAULT);
    $data = array();
    oci_fetch_all($stmt$data);
    printf(
        
    "<h2>%d rows of data recieved.</h2>
        <pre>%s</pre>
        "
    ,
        
    count($data),
        
    print_r($datatrue)
    );
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •