Jump to content

zenlord

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Everything posted by zenlord

  1. Hi, For one of my functions, I need to remove a value from a table, so I thought about setting it to NULL: function removeDosLoc($file){ // Remove the old location, if any $res = pg_query(CNX_DOS, "SELECT id,file,category FROM dossiers_location WHERE file = '$file'"); $num = pg_num_rows($res); if ($num !== 0) { $fields = array('file' => NULL); $condition = array('file' => $file); pg_update(CNX_DOS,"dossiers_location", $fields, $condition) or die("removeDosLoc: failed"); } } But I always get the die()-error. I use the same function to set the value to $file, so the function should be working - all I can think of is the 'NULL' that is incorrect? Or not? thanks! /EDIT: oh, and BTW: I checked that $num equals 1, so it is not a problem of $num being > 1 (the column is set to UNIQUE, so it couldn't be that problem...)
  2. OK, I found the problem myself. Seems like I was mislead by phpldapadmin. Phpldapadmin showed the values of the attribute 'telephoneNumber' under (probably an alias) 'Phone'. Of course PHP doesn't know the attribute 'Phone'. So: if an LDAP-filter doesn't return the expected values, check the relevant RFC's. The one for inetOrgPerson can be found here: http://www.rfc-archive.org/getrfc.php?rfc=2798
  3. I'm not sure about this, but I have been experimenting with PHP/LDAP the last two weeks and in the beginning I had some weird error messages because the connection and/or bind did not succeed. You might want to try to add 'or die()'-statements to your connection / bind-cmd's. Also: I had to set my ldap-options even before the connection was made (you set it between the connection and the bind)... HTH
  4. Hi, First post on the forums. I am a self-thought PHP-coder and after some relatively simple websites I'm currently building a intranet-website to interconnect several of the services we're using in our 3-people-office. This time I'm stuck connecting the asterisk-call-data-records to our ldap-addressbook. I would like to show the name of the person that has called our office. This is my code: function TBS_tel($BlockName,&$CurrRec,$RecNum){ // 1. Extraheer ID van het toestel waarmee getelefoneerd werd $CurrRec['src_dev_id'] = substr($CurrRec['channel'],4,3); $CurrRec['dst_dev_id'] = substr($CurrRec['dstchannel'],4,3); // 2. Haal de persoonsgegevens uit de LDAP-dir // Persoonsgegevens zoeken $notNumbers = array(".", "/", ":", " ", "-"); if ($CurrRec['dcontext'] == "internal") { // Zoeken op dst: $tel = str_replace($notNumbers, "", $CurrRec['dst']); } else { // Zoeken op src: $tel = str_replace($notNumbers, "", $CurrRec['src']); } [b]$filter = "(|(mobile=$tel)(Phone=$tel)(homePhone=$tel))";[/b] $attributes = array("sn", "givenName", "dn", "title", "o"); $result = ldap_search(CNX_LDAP, LDAP_DIR_ADR, $filter, $attributes); $persID = ldap_get_entries(CNX_LDAP, $result); $CurrRec['pers_id'] = $persID[0]["title"][0]; $CurrRec['pers_id'] .= " "; $CurrRec['pers_id'] .= $persID[0]["givenname"][0]; $CurrRec['pers_id'] .= " <a href=\"link.php?dn="; $CurrRec['pers_id'] .= urlencode($persID[0]["dn"]); $CurrRec['pers_id'] .= "\">"; $CurrRec['pers_id'] .= $persID[0]["sn"][0]; $CurrRec['pers_id'] .= "</a>"; if ($persID[0][2]) { $CurrRec['pers_id'] .= "<br /><a href=\"link.php?org="; $CurrRec['pers_id'] .= urlencode($persID[0]["o"][0]); $CurrRec['pers_id'] .= "\">"; $CurrRec['pers_id'] .= $persID[0]["o"][0]."</a>"; } ldap_free_result($result); } This code is working, but not completely: everytime $tel is equal to a mobile number, then it outputs the requested data. But if we are called by someone with a number that is in 'Phone' or 'homePhone', than the result is blank. I have tried to ditch the capitals in 'Phone', I have tried to remove the (mobile=$tel)-filter, but to no effect. My guess is that the bug is situated on the bold line of my code. Am I overlooking something silly here? Thank you in advance...
×
×
  • 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.