Jump to content

synking

Members
  • Posts

    108
  • Joined

  • Last visited

Everything posted by synking

  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.
  16. I am honestly not sure the best route to take... still trying to figure it out. What i need to do is group them by month. So all of the entries for the month of august are together. Then I have a few fields that are not stored in the database that are based off of the total usage for that month. So all of august usage grouped and then used to create a total for K001, K002, and the totalvocemission are created as separate fields
  17. Hey guys. I asked this question in the php coding help as i was not sure where i needed to do it but got help I need to do some math to the results for the table. I need to have the all months entered group together and then have the columns K001, K002, and total multiplied by 22 to get a month total of used amount. I have a table structure that looks like this. Array ( [Manufacturer] => SUPERIOR [Description] => S-0170 B BLEND [VOCContent] => 100 [Disbursed] => 55 [Recovered] => 0 [Month] => October [K001] => 0.67 [K002] => 1.83 [usePerDay] => 2.5 [TotalVocEmissions] => 17.45 [TotalK001] => 4.68 [TotalK002] => 12.77 [Year] => 2001 ) so far i have tried this but i am not that fluent in sql statements beyond the very basic. "Select Manufacturer, Description, VOCContent, Disbursed, Recovered, Month, K001, K002, UsePerDay, TotalVocEmissions, TotalK001, TotalK002 FROM SolventUsage Where Month > '$month' and Year > '$year' Group BY month, year"; That is just one i have tried. But that gets an error about columns not being contained as aggregate or in the group by. anyone able to point me in a direction to solve this
  18. if i am not mistaken you would need to change a lot of that formula as 60% can not be easily represented in a number. you would need to use a formula of %/100 = is/of so 60%/100 = is a % / of some number
  19. Well i did not develop this database... IT is an MSSQL database that was designed for use as a VB6 application. That application no longer works and that is why i am trying to do this. They had everything imported to a crystal report that displayed the data and did all the formulas. So i am not sure why they have it like that and i am actually once i can migrating it to mysql and going to create a better structure.. So to clarify on what i am doing though... So should i do the sum and multiply when i specify the fields i want to grab or after in the group by. Thanks for the help so far.
  20. You can look into having it done in the while loop. while($row=mysql_fetch_array($result)){ $First_Name =$row['First_Name']; $Last_Name=$row['Last_Name']; $Resource_ID=$row['Resource_ID']; $table .= <tr><td>$First_Name</td><td>$Last_Name</td><td>$Resource_ID</td></tr> } Then start and end the table in html and echo $table in between the table tags. It all depends on what you have to use it for how long you need the variables. Or do what he did above his is a more elegant and reusable way.
  21. Ok so i have been messing around with the group by but can't seem to make it work The statement i am using is here. "Select Manufacturer, Description, VOCContent, Disbursed, Recovered, Month, K001, K002, UsePerDay, TotalVocEmissions, TotalK001, TotalK002 FROM SolventUsage Where Month > '$month' and Year > '$year' Group BY month, year"; When it executes i get errors about columns not being contained as aggregate or in the group by. all the columns only contain numbers except for description month and manufacturer. here is an output of the table if i take away the group by. Array ( [Manufacturer] => SUPERIOR [Description] => S-0170 B BLEND [VOCContent] => 100 [Disbursed] => 55 [Recovered] => 0 [Month] => October [K001] => 0.67 [K002] => 1.83 [usePerDay] => 2.5 [TotalVocEmissions] => 17.45 [TotalK001] => 4.68 [TotalK002] => 12.77 [Year] => 2001 ) I thouhgt that error only happens if it expects something to be done with the fields.. Not sure where to go.
  22. In the code here change the header to what page you want them to see. if($count==1){ // Register $username, $password and redirect to file "home.html" session_register("myusername"); session_register("mypassword"); header("location:home.php?myusername=" . $username); } That code though only checks if they are registered... You will need to create something that checks if they have admin rights from the user table in your database. YOu should have something there that denotes who is an admin and who is not. Then set a session variable to only those users that is unique and will never accidentaly be given to a non admin user. Once you have that session set. You can do a session check on any page. if(!(isset($_SESSION['isadmin']))) { header("location:error404.php"): //this can be any page you want a non admin to see if they attempt to access a page designed only for admin use. } else { here you can display whatever you want the admin to see. I can be tables that access databases or whatever you like. then close it at the bottom of you page } Sessions can get a little tricky though so have a look at this. http://php.net/manual/en/features.sessions.php Also please check it out as there is probably a better way to have this done. That is just a quick way.
  23. you need to look for a php log in system there really not that difficult but they deal with some pretty useful php features. What you would want to do is set a session variable when they log in and are an admin. Then forward them to the page you want with a header. You would still want to keep a check on that page for that session variable though as someone could just type in that page and be able to access admin features. This is the tutorial i followed a while back. http://www.phpeasystep.com/phptu/6.html
  24. Well the database was setup by someone about 10 years ago. This is used for keeping track of chemical emissions used in paint booths. The cleaning one is the one i am working on now. It is a table that has data input from a paint tech they keep track of just the amount of cleaner they use and when. Then once a month they will use this script to pull the data. They need to know how much is used per month.. Since the average month has 22 working days i use 22. They also need to have the result changed from gallons to lbs for complience with the chimical company they buy the supplies from. So i have to multiple the used gallon amount by 6.98 to get the pound equivalent. The structure is 25 columns of data that keeps track of the different chimicals But they are not always populated. It is calculated when information is input the total amount of the chimicals per gallon is used then when they pull the report i need to do the math for the per months and lbs converstions. Right now i am doing a table display with a while loop that writes the data into a variable and then prints it out later in the script. I am using a generic select all statement from that database. let me know if that makes sense.
  25. ok yeah sorry.... if this is a query issue whould i post it there.... but i will say here i have about 12 records i need to pull 4 of those records i have to multiply the data by 22 for how many working days there are in an average month, then i have to multiply those same fields by 6.98 to convert them from gallons to lbs. I have tried this in sql query but i don't know enough to get it right i never end up with the same data or results at all i get errors. I have searched but i can't find it.
×
×
  • 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.