szaman
szaman

Reputation: 6756

Php Script Solution

I have a little problem with my script. When I try to run it I receive "Parse error: syntax error, unexpected T_STRING" as long as I have ' sign in my code. When I change all ' into " then I have the same error. So I have to change all " into '.

Here is my code:

<?php
      PutEnv(TNS_ADMIN='C:\Programy\OracleDeveloper10g\NETWORK\ADMIN\');
      $conn = oci_connect("user", "pass", "dbstring");
      if (!$conn)
      {
        $e = oci_error();
        print $e;
        exit;
      }
      else
      {
        $stmt = OCIParse($conn, "SELECT password FROM USERS WHERE username=szymon");
        OCIExecute($stmt, OCI_DEFAULT);
      while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
      foreach ($row as $item) {
       $password = $item;
      }
        if ($password != $_POST[password]){
          $stmt = OCIParse($conn, "EXECUTE drop_tables");
          $message = "Tabele zostały usunięte";
        }
        else {
          $message = "Podane hasło jest niepoprawne";
        }
      }
   }
?>

Upvotes: 0

Views: 416

Answers (4)

Chris Kloberdanz
Chris Kloberdanz

Reputation: 4536

Try

putenv("TNS_ADMIN='C:\Programy\OracleDeveloper10g\NETWORK\ADMIN\'");

If you look at the docs for putenv() it shows everything in quotes.

Upvotes: 5

Eric Petroelje
Eric Petroelje

Reputation: 60498

On this line:

PutEnv(TNS_ADMIN='C:\Programy\OracleDeveloper10g\NETWORK\ADMIN\');

The slashes cause the ending quote to be escaped. Try it like this:

PutEnv(TNS_ADMIN='C:\\Programy\\OracleDeveloper10g\\NETWORK\\ADMIN\\');

Upvotes: 2

Pekka
Pekka

Reputation: 449385

The problem is the backslashes in the TNS_ADMIN path. The last backslash escapes the closing '.

Try doubling all backslashes:

C:\\Programy\\OracleDeveloper10g\\NETWORK\\ADMIN\\

Upvotes: 2

Marek Karbarz
Marek Karbarz

Reputation: 29294

make sure you escape your \

Upvotes: 2

Related Questions