Jump to content

synking

Members
  • Posts

    108
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

synking's Achievements

Member

Member (2/5)

0

Reputation

  1. My for loop must have been clearing results while it was running.. i had to modify it so that the ldap_get_entries happens outside of the for loop. if($search) { $entries = (ldap_get_entries($ADconn,$search)); for($i=0;$i<$entries["count"];$i++){ print("<pre>"); print("User: " .$entries[$i]["cn"][0]." <br />"); print("Email: ".$entries[$i]["mail"][0]." <br />"); print("Telephone: ".$entries[$i]["telephone"][0]." <br />"); #print_r($entries); print "\n"; print("</pre>"); Now it all works fine.
  2. Hey guys, i am having trouble searching our ldap server and getting results from it. 1 <?php 2 3 $serv = 'ransohoff.com'; 4 5 $user = 'jking@ransohoff.com'; 6 7 $pass = 'V@lolon1'; 8 9 $tree = "OU=Ransohoff Users,DC=ransohoff,DC=com"; 10 11 $filter = '(&(objectClass=user)(objectCategory=person))'; 12 13 //$attrib = array("samaccountname","telephonenumber","othertelephone"); 14 15 16 $ADconn = ldap_connect($serv); 17 18 ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version'); 19 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search. 20 21 if($ADconn) { 22 23 $ADbind = ldap_bind($ADconn, $user, $pass); 24 if(!$ADbind) die("Unable to bind to connection " .ldap_error($ADconn)." ".ldap_errno($ADconn)." <br>"); 25 26 } else { 27 28 echo ("Unable to connect to AD server"); 29 } 30 31 print('Ldap = '.$ADconn.', Ldap_dn = '.$tree.', Query = '.$filter); 32 33 $search = ldap_search($ADconn, $tree, $filter) or die ("Error in search query: ".ldap_error($ADconn)); 34 35 if($search) { 36 37 for($i=0;$i<count($search);$i++){ 38 print_r(ldap_get_entries($ADconn,$search[$i])); 39 print "\n"; 40 } 41 } else { 42 43 print(ldap_error($ADconn). " ".ldap_errno($ADconn)); 44 45 } 46 ldap_close($ADconn); 47 ?> I have searched both here and google to try and solve the issue, but to me everything looks right and should be listing the user information. Im not exactly sure where my problem is but i keep getting this warning and im not sure how to solve it Im not exactly sure what im doing wrong.
  3. Ah ok that makes sense yeah there are 5 steps that it can be in... Technically 4 since they all start in the pending status that then move to 4 steps. I will just add the column to the already exsisting table thanks.
  4. Hey everyone. Thought i would ask on here cuz i don't seem to be understanding it. I am trying to setup a system where people input ideas to improve a project. Each idea is supposed to go through certain stages of approval or denial. I have one table that store all the ideas. which looks like DESCRIBE ideas; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | Id | int(5) | NO | PRI | NULL | auto_increment | | Date | date | NO | | NULL | | | Email | varchar(255) | NO | | NULL | | | Name | text | YES | | NULL | | | Headline | text | YES | | NULL | | | Problem | text | YES | | NULL | | | Promise | text | YES | | NULL | | | Proof | text | YES | | NULL | | | Threats | text | YES | | NULL | | | Passion | text | YES | | NULL | | | Cost | text | YES | | NULL | | | Value | text | YES | | NULL | | | Purpose | text | YES | | NULL | | +----------+--------------+------+-----+---------+----------------+ 13 rows in set (0.01 sec) Which i am trying to assign a foreign key too so that the status of them can be related to a seperate table. But my issue is im not sure if that is the best way to do it... Should i just add another column to this table for the status and not worry about creating a second table. If i do create a second table what is the best way to handle the foreign key relationship. Just trying to get ideas thanks guys
  5. Ahh i thought that it would step through thanks guess i just was not thinking.
  6. Hey guys, So i recently was trying to get mysql generated csv file.... found that to hard to get right through pdo. So what i did instead is had php parse the data and use fputcsv but it's not working for me quite right thought i would see what im doing wrong. <?php include('inc/dbconnect.php'); $filename = 'Innovation_data.csv'; try { $dbh = new pdo("mysql:host=$serv;dbname=$data", $name, $pass); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM Customer_Card"; $sth = $dbh->prepare($sql); $sth->execute(); $filename = "/var/www/html/innovation/inc/crad".time().".csv"; $handle = fopen($filename, 'w+'); foreach($sth->fetch(PDO::FETCH_ASSOC) as $row => $value) { fputcsv($handle, array($row, $value)); } fclose($handle); $dbh=null; } catch(PDOException $e) { echo ("I'm sorry, Dave. I'm afraid I can't do that."); error_log($e->getMessage()); } header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Length: ". filesize("$filename").";"); header("Content-Disposition: attachment; filename=$filename"); header("Content-Type: application/octet-stream; "); header("Content-Transfer-Encoding: binary"); readfile($filename); ?> I get the file created and downloaded but when i open it it's only the first line of the mysql table. And the name of the file is the whole sting /var/ww.... which i could correct by just fixing the string but i am just confused as why it's not writing the enitre table to the database.
  7. Thank you yeah im just using this to dispaly in an excel file not trying to import it or anything. So i will just use that.
  8. Hey guys, Just have a question as i looked on google but didn't find too much. I want to export a table to CSV so that it can be opened in excel and edited if needed. But the question is using PDO, would it be better for mysql to create this csv with a intofile query or should i have php use the fputcsv functions. I have not seen much on using that with pdo so i thought i would see what everyone thought.
  9. Actually just found out what was wrong... When i logged in as the user that is allowed to access just that database nothing happens... when i looged in as root it was reporting the database is curropt... does pdo not see that... either way it works now that i repeaired the database. Sorry for all the issues.
  10. Yes it is i just loged into mysql and checked everything with the credintials and everything. Unless PDO does not like localhost as a server name. Thats the only thing i can think of.. Does PDO prefer a type of server over another. I even changed the connection to try{ $dbh = new PDO("mysql:host=localhost;dbname=innovation", 'inno', 'inno'); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); But still no rows returned I am confused by this.
  11. Hmmm.... Im getting 0 rows... but that does not make sense... if i use the same exact query with mysqli i get what i want... Hmmm
  12. echo ('<pre>'. print_r($sth->errorInfo(), true) .'</pre>'); gives me the exact same array at the very top of the page.
  13. Alright now im getting this Array ( [0] => 00000 [1] => [2] => ) but i don't know what that means and a quick google didn't turn anything up.
  14. I did not until you mentioned it... Now i am getting an error that says And doing some searching means my query is wrong... but i don't see how it is.
  15. Hey guys hope you can help. I'm learning to use pdo and just started but for some reason what i am trying does not work. here is the code try{ $dbh = new PDO("mysql:host=$serv;dbname=$data", $name, $pass); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = 'Select * from Customer_Card'; $sth = $dbh->prepare($sql); $sth->execute(); $tables = ''; foreach ($sth->fetch(PDO::FETCH_ASSOC) as $row) { echo "<pre>"; print($row); echo "</pre>"; $tables .= " <tr>"; $tables .= " <td>{$row['Name']} </td>\n"; $tables .= " <td>{$row['Headline']} </td>\n"; $tables .= " <td>{$row['Problem']} </td>\n"; $tables .= " <td>{$row['Promise']} </td>\n"; $tables .= " <td>{$row['Proof']} </td>\n"; $tables .= " <td>{$row['Threats']} </td>\n"; $tables .= " <td>{$row['Passion']} </td>\n"; $tables .= " <td>{$row['Cost']} </td>\n"; $tables .= " <td>{$row['Value']} </td>\n"; $tables .= " <td>{$row['Purpose']} </td>\n"; } } catch(PDOException $e) { echo ("I'm sorry, Dave. I'm aftraid I can't do that."); error_log($e-getMessage()); } Im not sure what im doing wrong but i get no errors and no data from mysql.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.