Re: [PHP] recursive

2010-07-18 Thread Ashley Sheridan
On Sun, 2010-07-18 at 09:49 +0430, shahrzad khorrami wrote:

> hi all :)
> here is a xml file:
> 
> 
>
>   
>
>
>   
>
> 
> 
> 
>
>   
>
>
>   
>
> 
> .
> .
> .
> .
> I have a xml file with a name for example(test.xml)..
> and 3 tables of database, (group,directives,rules)
> group is for recording the name of the opened xml file,  directives is for
> storing the attributes of directive tag and rules is for 'rule' tag's
> attributes.
> 
> I know I must use of recursive function.. but how? first read name of the
> xml file and store it in group table, then the content of the file and fill
> the directive and rules table...
> 
> 
> 
>
>   
>
>
>   
>
> 
> 
> 
> how to implement it in php?
> 
> Thanks,
> Shahrzad


I don't think a recursive function is what you need here, that's
something which has to call itself over and over.

I assume there may be multiple xml files you need to parse?

What you need is a series of nested loops. The first one loops through
the list of xml filenames you need to parse (you can get this list from
a directory listing if you need), the second goes through each
 tag, the third through the  tags.

The attributes of each tag can be pulled out quite easily. Are these a
list of known attributes, or unknown? If you know what they are, you can
hard-code retrieving their values, but if not, another loop will be able
to fetch these out for you.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Getting only attribute and not its values when doing LDAP calls to 2003 AD server

2010-07-18 Thread Unix Nair
Hi
I followed the examples mentioned in ldap functions pages at
www.php.net.

But I am getting only the attribute names and not the values stored in
attributes array. Can some one give me some tips to fix my issue.
Here is my configuration.

Apache/2.0.59 HP-UX_Apache-based_Web_Server (Unix) DAV/2 PHP/5.2.13
on  HP-UX 11.11 and php is using OpenLDAP, vendor version 20122

Here is my php code.
==
\n";
  //$dn contain information asked by Windows server to browse the
correct AD tree.
  $dn ="OU=User Accounts,DC=gsm1900,DC=org";
  $filter="sAMAccountName=mkangar";
  $justthese =
array("surname","mail","memberof","name","givenname","sn");
  $sizelimit=15; // limit to maximum 15 return rows
  $result = ldap_search($resource,$dn,$filter,$justthese,$sizelimit);
  $result = ldap_search($resource,$dn,$filter,$justthese);
  $info = ldap_get_entries($resource, $result);
  var_dump($info);
  echo "\n";
  echo $info["count"]. " entries returned\n";
  echo "first surname entry " . $info[0]["surname"][0]. "\n";
  echo "first mail entry " . $info[0]["mail"][0]. "\n";
  echo "first memberof entry " . $info[0]["memberof"][0]. "\n";
  echo "first name entry " . $info[0]["name"][0]. "\n";
  echo "first givenname entry " . $info[0]["givenname"][0]. "\n";
  echo "first sn entry " . $info[0]["sn"][0]. "\n";
  echo "DN: " . $info[0]["dn"]. "\n";
  echo "Number of attributes in 0th entry " . $info[0]["count"]. " 
\n";
  for ($i=0; $i<$info["count"];$i++)
   {
   for ($j=0;$j<$info[$i]["count"];$j++)
{
echo $info[$i][$j].": ".$info[$i][$info[$i][$j]][0]."\n";
}
   }
  }
 else
  {
  echo "AD bind failed\n";
  }
 ldap_close($resource);
 } // end of if ($resource)
?>

Here is the output from webpage. You can see that it is not displaying the
values. What am I doing wrong. Do I need to perform any configuration
settings in ldap.conf file at my side?
===
AD bind successful
array(2) { ["count"]=> int(1) [0]=> array(2) { ["count"]=> int(0)
["dn"]=> string(93) "CN=MKangar,OU=Data Center Ops,OU=Systems
Operations,OU=COS,OU=User Accounts,DC=gsm1900,DC=org" } }
1 entries returned
first surname entry
first mail entry
first memberof entry
first name entry
first givenname entry
first sn entry
DN: CN=MKangar,OU=Data Center Ops,OU=Systems Operations,OU=COS,OU=User
Accounts,DC=gsm1900,DC=org
Number of attributes in 0th entry 0
===


Re: [PHP] Getting only attribute and not its values when doing LDAP calls to 2003 AD server

2010-07-18 Thread Nathan Nobbe
On Sun, Jul 18, 2010 at 1:01 PM, Unix Nair  wrote:

> Hi
> I followed the examples mentioned in ldap functions pages at
> www.php.net<
> http://www.google.com/url?sa=D&q=www.php.net&usg=AFQjCNHoc0Ba_1Imkk_33DysfxCk38dNag
> >.
>
> But I am getting only the attribute names and not the values stored in
> attributes array. Can some one give me some tips to fix my issue.
> Here is my configuration.


give the adLdap class a shot; if it works you can reverse engineer how they
accomplished it.

http://adldap.sourceforge.net/

-nathan


[PHP] handing over data between two PHP connections

2010-07-18 Thread tobias . mueller13
Hello everybody

For a science project I am working on a mechanism that hands over data from a 
smartphone to a web-browser (=Internet PC). Both connect to a PHP server. The 
PHP server has to receive the data (=some kind of an URL) on the smartphone end 
and deliver it to the browser end. 

Up to now there have been two (working) implementations. One using the 
filesystem the other one using a MySQL Database. The data coming up from the 
smartphone is stored in a file/table and some seconds later sent down to the 
browser. 


My question: is it possible to implement this mechanisms just with PHP methods? 
I can't think of such a method but need to be sure. 


Tank you in advance. 

Have a good evening,
Tobias
___
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] handing over data between two PHP connections

2010-07-18 Thread Ashley Sheridan
On Sun, 2010-07-18 at 21:27 +0200, tobias.muelle...@web.de wrote:

> Hello everybody
> 
> For a science project I am working on a mechanism that hands over data from a 
> smartphone to a web-browser (=Internet PC). Both connect to a PHP server. The 
> PHP server has to receive the data (=some kind of an URL) on the smartphone 
> end and deliver it to the browser end. 
> 
> Up to now there have been two (working) implementations. One using the 
> filesystem the other one using a MySQL Database. The data coming up from the 
> smartphone is stored in a file/table and some seconds later sent down to the 
> browser. 
> 
> 
> My question: is it possible to implement this mechanisms just with PHP 
> methods? I can't think of such a method but need to be sure. 
> 
> 
> Tank you in advance. 
> 
> Have a good evening,
> Tobias
> ___
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
> 


I suppose you could do it with some sort of socket connection, but it
would surely be more work than is worth the trouble. I've not worked
with sockets before, so don't know how you'd go about it. If I were to
do this, I'd just have all communications from the phone stored on the
server somehow (database, file, etc) and then the browser can use some
refresh mechanism (http refresh or ajax update) to query for new
messages. Messages can be tagged as read once they've been sent to the
browser as well. In this way, you can retain a history of communications
and only show the browser new information sent from the phone.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] handing over data between two PHP connections

2010-07-18 Thread Floyd Resler


On Jul 18, 2010, at 3:27 PM, tobias.muelle...@web.de wrote:


Hello everybody

For a science project I am working on a mechanism that hands over  
data from a smartphone to a web-browser (=Internet PC). Both connect  
to a PHP server. The PHP server has to receive the data (=some kind  
of an URL) on the smartphone end and deliver it to the browser end.


Up to now there have been two (working) implementations. One using  
the filesystem the other one using a MySQL Database. The data coming  
up from the smartphone is stored in a file/table and some seconds  
later sent down to the browser.



My question: is it possible to implement this mechanisms just with  
PHP methods? I can't think of such a method but need to be sure.



Tank you in advance.

Have a good evening,
Tobias
___
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


What I would do is have the smartphone send some unique identifier  
along with its data.  For the browser I would have the page refresh at  
certain time interval, calling a PHP script to see if any data is  
available for the smartphone's ID.  If you did want the page to keep  
reloading, you could use AJAX.


Take care,
Floyd


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] functions and global variables

2010-07-18 Thread David Mehler
Hello,
I've got a file with a variable declared in it. For purposes of this post:

$name = $_POST['name'];

Now a little later in the same file I have a custom function call that
outputs some information. In that information is an echo statement
outputting $name:

echo $name;

I'm wondering do I have to have $name declared as a global variable
within that function? For example:

function customFunction() {
global $name
}

I've tried it both ways and both ways it works, with and without the
global statement. I was under the impression that to be useful in a
function variables outside were not accessible.
Thanks.
Dave.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] functions and global variables

2010-07-18 Thread Paul M Foster
On Sun, Jul 18, 2010 at 06:37:30PM -0400, David Mehler wrote:

> Hello,
> I've got a file with a variable declared in it. For purposes of this post:
> 
> $name = $_POST['name'];
> 
> Now a little later in the same file I have a custom function call that
> outputs some information. In that information is an echo statement
> outputting $name:
> 
> echo $name;
> 
> I'm wondering do I have to have $name declared as a global variable
> within that function? For example:
> 
> function customFunction() {
> global $name
> }
> 
> I've tried it both ways and both ways it works, with and without the
> global statement. I was under the impression that to be useful in a
> function variables outside were not accessible.
> Thanks.
> Dave.

Variables declared outside a function are visible outside the function.
Variables declared inside a function are visible only within that
function. To use a "global" variable inside a function, you must declare
it global, as:

global $globalvar;

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] MySQL Query Puzzle

2010-07-18 Thread Peter

Hi All,

I have a  table which contain's some duplicate rows. I just want to 
delete the duplicate records alone

not original records.

Assume my table as look as below

column1 column2
1
a
1
a
2
b
3
c
3
c



i want the above table need  to be as below, After executing the mysql 
query.


column1
column2
1
a
2
b
3
c




Thanks in advance..

Regards
Peter


[PHP] help using phpadmin

2010-07-18 Thread Isaac Lee
this is the second time that i have made an account and set the
password. then when i try to reaccess phpadmin, it shows this message:

Error

MySQL said:

#1045 - Access denied for user 'root'@'localhost' (using password: NO)


What am supposed to do so that my regain access to phpadmin?  edit the
php.ini file?

isaac

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Query Puzzle

2010-07-18 Thread Paul M Foster
On Mon, Jul 19, 2010 at 10:14:30AM +0530, Peter wrote:

> Hi All,
>
> I have a  table which contain's some duplicate rows. I just want to
> delete the duplicate records alone
> not original records.
>
> Assume my table as look as below
>
> column1 column2
> 1
>   a
> 1
>   a
> 2
>   b
> 3
>   c
> 3
>   c
>
>
>
> i want the above table need  to be as below, After executing the mysql
> query.
>
> column1
>   column2
> 1
>   a
> 2
>   b
> 3
>   c
>
>

If you're looking for a MySQL solution to this, this is the wrong list
to ask the question on. In fact, I'd be surprised to find a MySQL query
which would do this.

For a PHP solution, you'll need to query MySQL for all the rows, in
order by the column you want to use to kill duplicates. Then loop
through the rows one at a time in PHP, checking the contents of that
column against the last iteration. If they are the same, issue a DELETE
command in MySQL. Continue the loop until all rows are exhausted.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Query Puzzle

2010-07-18 Thread Shafiq Rehman
On Mon, Jul 19, 2010 at 10:44 AM, Peter  wrote:
> Hi All,
>
> I have a  table which contain's some duplicate rows. I just want to delete
> the duplicate records alone
> not original records.
>
> Assume my table as look as below
>
> column1 column2
> 1
>        a
> 1
>        a
> 2
>        b
> 3
>        c
> 3
>        c
>
>
>
> i want the above table need  to be as below, After executing the mysql
> query.
>
> column1
>        column2
> 1
>        a
> 2
>        b
> 3
>        c
>
>
>
>
> Thanks in advance..
>
> Regards
> Peter
>

Create a table with similar structure and add UNIQUE INDEX on both
columns. Execute the following query:

INSERT IGNORE INTO NEW_TABLE (column1, column2) SELECT column1,
column2 FROM OLD_TABLE

This will give you distinct rows as required.

-- 
Keep Smiling :-)
Shafiq Rehman
Blog: http://shafiq.pk, Twitter: http://twitter.com/shafiq

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] help using phpadmin

2010-07-18 Thread Carlos Sura
Hello Isaac Lee.

Are you running on Linux or Windows?

You might try:
mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’);

Then restart your service -if needed-

If not... Try to edit config.inc.php file.

Regards,

Carlos Sura

-Original Message-
From: Isaac Lee [mailto:rhinecant...@gmail.com] 
Sent: domingo, 18 de julio de 2010 10:34 p.m.
Cc: php-general@lists.php.net
Subject: [PHP] help using phpadmin

this is the second time that i have made an account and set the
password. then when i try to reaccess phpadmin, it shows this message:

Error

MySQL said:

#1045 - Access denied for user 'root'@'localhost' (using password: NO)


What am supposed to do so that my regain access to phpadmin?  edit the
php.ini file?

isaac

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php