How to use require in a php script in file?


#1

I have a authentication.php script that requires connect.php, but when I use require it doesn’t work.

<?php

    require("/cc_scripts/connect.php");
    // $con = mysqli_connect(""); This line is the only line in connect.php and I am 100% sure it works.

    $ID= $_REQUEST["id"];
    $password = $_REQUEST["password"];

    $statement = mysqli_prepare($con, ...);
    mysqli_stmt_bind_param(...);
    mysqli_stmt_execute(...);
    mysqli_stmt_store_result(...);
    mysqli_stmt_bind_result(...);

    $response = array();
    $response["success"] = false;  

    while(mysqli_stmt_fetch($statement)){...  }

    echo json_encode($response);
?>

Is there a specific way to require from a different folder?


#2

Hi!

To use a path relative to your current folder, use cc_scripts/connect.php

To use a path relative to the root directory, use /cc_scripts/connect.php

Hope this helps :slight_smile:


#3

Thanks It is working now… much Love!!!


#4

You’re welcome :slight_smile:


#5