tags:

views:

73

answers:

4

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 '. How can I solve it?

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";
        }
      }
   }
?>
+2  A: 

make sure you escape your \

Marek Karbarz
+2  A: 

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\\
Pekka
so simple, thanks to all :)
szaman
+2  A: 

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\\');
Eric Petroelje
+4  A: 

Try

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

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

Chris Kloberdanz