nander 15 Newbie Poster

Hello I am trying to query a database to show records only for the current user using variable I get the correct data but only 1 row with results any guidance?

// Query database to retrieve records associated with the user
$sql = "SELECT * FROM table_name WHERE variable_name = :variable_name";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':variable_name', $variable_name, PDO::PARAM_STR);
$stmt->execute();
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);

nander 15 Newbie Poster

Anyone seen or had this happen before, whenever I add, edit or delete in this datable. It only does this when I add the js pagination\search

TableDuplicate.JPG

AndreRet commented: You need to provide your code when making the call to the data edit etc. It seems that a call is made twice hence the duplicates. +15
nander 15 Newbie Poster

PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in

<?php
include("header.php");
$_SESSION['loc'] = "viewkeyowners.php";
if ($_SESSION['loggedin'] <> 1)
{
    header("Location: logintest.php");
    exit();
}

//this is done because if user closes a tab/page, and logs back in(still in session), it would redirect to the last opened tab/page
function onclose(){
    unset($_SESSION['loc']);
}

register_shutdown_function('onclose');

if(isset($_SESSION['illegalmove'])){
    if($_SESSION['illegalmove'] == 1){
        echo "<script>alert('Your account is not authorized to view this page.');</script>";
        $_SESSION['illegalmove'] = 0;
    }
}
if(isset($_POST['checking_viewbtn']))
{
    $id = $_POST['id'];
    // echo $return = $id;

    $query = "SELECT * FROM keyOwners WHERE id='$id' ";
    $query_run = mysqli_query($conn, $query);

    if(mysqli_num_rows($query_run) > 0)
    {
        foreach($query_run as $row)
        {
            echo $return = '                                
                                <h5> Key Type : '.$row['keyType'].'</h5>
                                <h5> Key Department : '.$row['area'].'</h5>
                                <h5> Key Description : '.$row['keyDesc'].'</h5>
                                <h5> Key Status : '.$row['keyStatus'].'</h5>
                <h5> First Name : '.$row['fname'].'</h5>
                <h5> Last Name : '.$row['lname'].'</h5>
                <h5> Employee Status : '.$row['emplStatus'].'</h5>
                <h5> Employee Number : '.$row['emplNum'].'</h5>
                                <h5> Date Assigned : '.$row['dateAssigned'].'</h5>
                                <h5> Updated By : '.$row['userid'].'</h5>


            ';
        }
    }
    else
    {
        echo $return = "<h5>No Record Found</h5>";
    }

}
?>
nander 15 Newbie Poster

So it should look like this?

 $res = ldap_search($ldap, $dn, $filter);
 $first = ldap_first_entry($ldap, $res);
 $data = ldap_get_dn($ldap, $first);

  var_dump($res);
  var_dump($first);
  var_dump($data);
nander 15 Newbie Poster

I'm sorry I am not sure where to place the code you mentioned above?

nander 15 Newbie Poster

Here is the value

$first = ldap_first_entry($ldap, $res);
$data = ldap_get_dn($ldap, $first);

nander 15 Newbie Poster
<?php
/*
error_reporting(E_ALL);
ini_set('display_errors', '1');
*/
/*xxxxx.xx.xxx.xxxxx*/
function _ldap_login($user, $password, $samuid)
{
    ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
    $ldap = ldap_connect("xx.xx.xx.xx") or die("Could not connect to ldap host");
    if ($ldap)
    {
        $username = $user;
        ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
        ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
        define('LDAP_OPT_DIAGNOSTIC_MESSAGE', 0x0032);
        if ($bind = @ldap_bind($ldap, $username, $password))
        {
            $login_status = 1;
            $login_err = "";

            $filter="(samaccountname=$samuid)";
            $dn="OU=xxxx,OU=United States Users & Workstations,DC=xx,DC=xxx,DC=xxxxx";
            $res = ldap_search($ldap, $dn, $filter);
            $first = ldap_first_entry($ldap, $res);
            $data = ldap_get_dn($ldap, $first);
            //echo "<br /><br />OU= $data<br /><br />";
            switch (true)
            {
                case strpos($data, 'OU=XXXX') > 0:
                    echo '<br /><br />Welcome XXXX DC user.<br /><br />';
                break;
                case strpos($data, 'OU=XXXX') > 0;
                echo '<br /><br />Welcome YYYY DC user<br /><br />';
                break;
                case strpos($data, 'OU=XXXX') > 0:
                    echo '<br /><br />Welcome ZZZZ DC user.<br /><br />';
                break;
                default:
                echo "<br /><br />I don't know where you're from.<br /><br />";
            }

        }
        else
        {
            // error message
            $login_status = 0;
            ldap_get_option($ldap, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error);
            $ldapcode = explode(",", $extended_error);
            $ldaperr = trim($ldapcode[2]);
            //*echo "ldaperr = $ldaperr<br />";
            switch ($ldaperr)
            {
                case "data 773":
                    $login_err = "Password Must Be Changed";
?>
                <SCRIPT LANGUAGE="JavaScript">
                <!-- Start Hiding the Script
                jlert = alert("Your domain password is set to require a change at the next logon.\nPlease log off and then back on to your computer to complete this.");
                // Stop Hiding script --->
                </SCRIPT>
<?php
                    break;
                case "data 775":
                    $login_err = "Domain Account Locked";
?>
                <SCRIPT LANGUAGE="JavaScript">
                <!-- Start Hiding the Script
                jlert = alert("Your domain account appears to be locked.\nPlease open a support ticket to have this …
nander 15 Newbie Poster

Hi has anyone seen an error like this before I believe it has to do with logging into a page using domain credentials but our logins have been converted to exchange online (PHP Fatal error: Uncaught TypeError: ldap_get_dn(): Argument #2 ($entry) must be of type LDAP\ResultEntry, bool given in /var/www/html/folder/external/ldap.php:26\nStack trace:\n#0 /var/www/html/folder/external/ldap.php(26): ldap_get_dn()\n#1 /var/www/html/folder/login.php(141): _ldap_login()\n#2 {main}\n thrown in /var/www/html/folder/external/ldap.php on line 26,)