user3481084
user3481084

Reputation: 51

include in php not working

 <?php
    include("/Crypt/RSA.php");
    $rsa = new Crypt_RSA();
     $token=base64_decode("iKmHdK3ChRBPAU/I/wTKld4up91TMrcWjkE+VGggVryRzvhKC6l+sZ3F+j+qyW8rxg01/uu2E3z6aVirwmQ0ig==");
     $private=base64_decode("MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAyUFH4OJOUOKh38raMxiQhmtuNSMxcznSdt9fWiJZOYpnv1rbu3h/heNCIOxOHSrlMz8FAKAW6rd9ddXNcm4myQIDAQABAkEApGbPcMVtdGWuFkJ/PH40kZnwzTeSja4OX0zZd6fXe0hBZZjA1nREuLGh2x7OXkpArytgQ35W2NHCxeldniTmgQIhAO7SB0Mhb/HLst4ty6HT2kZoAC/N2UdsBtQFdC8sNNxXAiEA17t4cVsx5EYYFifDSUwawz5pJSfrQYk1C0H1atL9Id8CIQDOtJL8k7BkxD5o95JM2yUN02518eGiY+n1EVNikQyfuQIgdph88fQsTU2rWCKr3NOVstfQfbigP/rpyjKMdBlhRwkCIE/x13OF2JUHlA5DqxCVh3LHMDDowr7SkQ2QVkqfBcAb");
    $rsa->loadKey($privateKey);
    echo $rsa->decrypt($cipher);
?>

i kept my include_path as .:/usr/local/lib/php

i am getting errors like this:

Warning: include(/Crypt/RSA.php) [function.include]: failed to open stream: No such file or directory in /home/futureti/public_html/reg2.php on line 2

Warning: include() [function.include]: Failed opening '/Crypt/RSA.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/futureti/public_html/reg2.php on line 2

Fatal error: Class 'Crypt_RSA' not found in /home/futureti/public_html/reg2.php on line 3

Upvotes: 0

Views: 3233

Answers (2)

The Blue Dog
The Blue Dog

Reputation: 2475

Try using the document root variable:

$doc_root = $_SERVER['DOCUMENT_ROOT'];
include($doc_root . "/Crypt/RSA.php");

Upvotes: 0

Albzi
Albzi

Reputation: 15609

Try this:

include('../Crypt/RSA.php');

Your current leading / is creating an absolute link, so going right back to your root directory.

../ means one folder up.

Upvotes: 1

Related Questions