Php Script Solution
I have a little problem with my script. When I try to run it I receive "Parse error: syntax error, u开发者_如何学编程nexpected 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";
}
}
}
?>
Try
putenv("TNS_ADMIN='C:\Programy\OracleDeveloper10g\NETWORK\ADMIN\'");
If you look at the docs for putenv() it shows everything in quotes.
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\\
make sure you escape your \
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\\');
精彩评论