php-general Digest 19 Jul 2005 15:30:47 -0000 Issue 3576
Topics (messages 218932 through 218960):
Re: Is there a way to get a variable name as a string?
218932 by: Daevid Vincent
218933 by: Rob Agar
218934 by: Rasmus Lerdorf
218935 by: Ryan A
218936 by: Edward Vermillion
218937 by: Edward Vermillion
218938 by: Tyler Kiley
218942 by: Burhan Khalid
Re: Session has new id on 'some' pages.
218939 by: Burhan Khalid
Re: PHP from CLI with SAPI
218940 by: Burhan Khalid
Re: Tracking a mobile phone
218941 by: Burhan Khalid
218943 by: Tom Rogers
Re: Date function and MySQL
218944 by: Arno Coetzee
Re: sytax errors
218945 by: Mark Rees
218946 by: babu
218947 by: Raz
Re: show a field in php file
218948 by: Jay Blanchard
218949 by: Raz
218957 by: John Nichel
218958 by: Jochem Maas
218959 by: John Nichel
PHP CERT. Question
218950 by: Joseph
Re: Question about apache-php concurrent process control
218951 by: Liang ZHONG
218952 by: Shaw, Chris - Accenture
218953 by: Liang ZHONG
218955 by: Liang ZHONG
mysql problem- I know it isn't strictly php
218954 by: Ross
218956 by: Jay Blanchard
"Only variable references should be returned by reference"
218960 by: Marc G. Fournier
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
That won't work. Then I will get what the VALUE of $bar is set to. I want
the actual text "bar". Basically everything after the "$" -- ie. The NAME of
the VARIABLE, not it's contents.
The closest I've come so far is to do this.
Function myname($foo)
{
echo "variable named $foo has the contents $$foo";
}
Myname('bar');
Which is pretty lame.
> -----Original Message-----
> From: Ryan A [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 18, 2005 6:57 PM
> To: [EMAIL PROTECTED]
> Cc: php
> Subject: Re: [PHP] Is there a way to get a variable name as a string?
>
> Maybe something like:
>
>
> Function myname ($foo)
> {
> $return_value="the variable name passed in is ".$foo;
> return $return_value;
> }
>
> echo myname($bar);
>
>
> Just a guess.....
>
>
> On 7/19/2005 3:27:57 AM, Daevid Vincent ([EMAIL PROTECTED]) wrote:
> > Is there a way to get the name of a variable as a string?
> For example...
> >
> > Function myname ($foo)
> > {
> > echo "the variable name passed in is ".realname($foo);
> > }
> >
> > myname($bar);
> > ^^^^
> >
> > I want to see printed out:
> >
> > "the variable name passed in is bar"
> > ^^^
> >
> > Dig what
> > I'm trying to do?
> >
> > And 'why?' you may ask am I trying to do this... Well, I am
> sick of always
> > putting an "echo 'printing
> > out
> > bar:'; print_r($bar);" all the time. I want
> > to make a wrapper function.
> >
> > I also have written one for XML that would be nice to make
> a NAME='bar'
> > attribute...
> >
> > /**
> > * Print out an array in XML form (useful for debugging)
> > * @access public
> > * @author Daevid Vincent [EMAIL PROTECTED]
> > * @since 4.0b4
> > * @version 1.0
> > * @date 07/18/05
> > */
> > function print_r_xml($myArray)
> > {
> > print xmltag('ARRAY', array('NAME'=>'myArray'), 1);
> > foreach($myArray as $k => $v)
> > {
> > if (is_array($v))
> > print_r_xml($v);
> > else
> > print xmltag($k,htmlspecialchars($v));
> > }
> > print xmltag('ARRAY', null, 2);
> > }
> >
> > --
> > P
>
>
--- End Message ---
--- Begin Message ---
hi Daevid
FWIW, I was trying to do the exact same thing a while back, and came to
the conclusion that it wasn't possible.
Rob
> -----Original Message-----
> From: Daevid Vincent [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 19 July 2005 11:28 AM
> To: php-general@lists.php.net
> Subject: [PHP] Is there a way to get a variable name as a string?
>
>
> Is there a way to get the name of a variable as a string? For
> example...
>
> Function myname ($foo)
> {
> echo "the variable name passed in is ".realname($foo);
> }
>
> myname($bar);
> ^^^^
>
> I want to see printed out:
>
> "the variable name passed in is bar"
> ^^^
>
> Dig what I'm trying to do?
>
> And 'why?' you may ask am I trying to do this... Well, I am
> sick of always
> putting an "echo 'printing out bar:'; print_r($bar);" all the
> time. I want
> to make a wrapper function.
>
> I also have written one for XML that would be nice to make a
> NAME='bar'
> attribute...
>
> /**
> * Print out an array in XML form (useful for debugging)
> * @access public
> * @author Daevid Vincent [EMAIL PROTECTED]
> * @since 4.0b4
> * @version 1.0
> * @date 07/18/05
> */
> function print_r_xml($myArray)
> {
> print xmltag('ARRAY', array('NAME'=>'myArray'), 1);
> foreach($myArray as $k => $v)
> {
> if (is_array($v))
> print_r_xml($v);
> else
> print xmltag($k,htmlspecialchars($v));
> }
> print xmltag('ARRAY', null, 2);
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Daevid Vincent wrote:
> Is there a way to get the name of a variable as a string? For example...
Nope, not possible.
-Rasmus
--- End Message ---
--- Begin Message ---
I didnt totally understand you q in the beginning (and still dont fully),
but....
> > Is there a way to get the name of a variable as a string? For example...
> Nope, not possible.
> -Rasmus
the man has spoken :-D
-Ryan
--- End Message ---
--- Begin Message ---
Rasmus Lerdorf wrote:
Daevid Vincent wrote:
Is there a way to get the name of a variable as a string? For example...
Nope, not possible.
-Rasmus
Wouldn't the name of the variable show up in a var_dump()? It would be
messy, but if it's there...
--- End Message ---
--- Begin Message ---
Edward Vermillion wrote:
Rasmus Lerdorf wrote:
Daevid Vincent wrote:
Is there a way to get the name of a variable as a string? For example...
Nope, not possible.
-Rasmus
Wouldn't the name of the variable show up in a var_dump()? It would be
messy, but if it's there...
Actually I meant debug_backtrace()... Damn fingers... but it is still a
question. :)
--- End Message ---
--- Begin Message ---
function named_print($var_name) {
return "echo 'the variable named $var_name is set to ' . \$var_name;"
}
eval(named_print($foo));
;-)
Tyler
--- End Message ---
--- Begin Message ---
Rasmus Lerdorf wrote:
Daevid Vincent wrote:
Is there a way to get the name of a variable as a string? For example...
Nope, not possible.
Well....
ob_start();
echo '$var';
$contents = ob_get_contents();
ob_end_clean();
echo 'Variable Name is : '.substr($contents,strpos($contents,'$')+1);
--- End Message ---
--- Begin Message ---
Marek Kilimajer wrote:
Andy Pieters wrote:
Ok found the solution, seems like one page is on http://server.org.uk
and the other on www.server.org.uk even though its the same server it
generates a different session id!
set the domain of the cookie to 'server.org.uk', it's the fifth
parameter of setcookie()
Actually, you should set it to '.server.org.uk' which will make the
cookie valid for all *.server.org.uk hosts.
--- End Message ---
--- Begin Message ---
Fredrik Tolf wrote:
Hi!
I've begun to be more and more displeased with Apache lately, so I've
been thinking of writing my own HTTP server instead. I still want PHP
support, but writing a new SAPI for PHP seems like overkill.
What's so bad about Apache?
Therefore, is it possible to use PHP from the command line, but still
enable some HTTP-server-only stuff, like GET and POST variables,
cookies, session management, file uploads, and so on? I haven't been
able to find any docs on doing that, but I'm thinking that it should be
possible.
No, not really. $_GET and $_POST are populated by PHP from information
from the HTTP request (which, obviously, isn't available in CLI mode).
In CLI, there is no concept of cookies, sessions (as there are in web
world), file uploads, etc. What you get is what you would recieve with
any CLI app, command line parameters, and access to the system calls
that you can execute using exec() and friends.
I'm not really sure why you want to write your own HTTP server, as this
has been done many times over the years. What exactly are your issues
with Apache?
So, can someone either point me to some docs in this, or, lacking such,
give me a short intro to it?
For a decent CLI script, you will need to access the command line
arguments, for which there is a great PHP class over at PEAR. There you
will also find classes for color output on the console and other classes
that you will find useful.
FWIW,
Burhan
--- End Message ---
--- Begin Message ---
Please add OT to the subject if the topic has nothing to do with PHP. OT
= Off Topic.
--- End Message ---
--- Begin Message ---
Hi,
Tuesday, July 19, 2005, 5:15:10 AM, you wrote:
T> Hi there,
T> I was wondering if anybody has attempted to track a mobile phone through a
T> country. I know that this is usually more a case for the FBI . a friend of
T> mine is going on a 4 month bike tour and I would like to 'track' him for
T> locations. I thought of an sms receiving system, but if could do any other
T> way would be great.
T> Any ideas?
T> Thomas
This may be of interest :)
http://www.aspicore.com/en/tuotteet_tracker.asp?tab=2&sub=4
Funny enough it looks a php solution.....
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
Hi all.
I have the week number (for example, this is the 29th week of the
year and it begins on 7/17/05). Does anyone know how to obtain the
first (and maybe the last) date of the week if you only know the week
number of the year? Would it be better for me to obtain this in PHP
or MySQL? or both?
I have researched the archives on a few lists and I know that others
have asked this same questions, but I have not found a good solution.
I have also looked on MySQL's "date and time functions" page, but had
little luck.
Any thoughts would be appreciated.
~Philip
Hi Philip
give this a go... i played around with the date functions of mysql
select date_sub(curdate() , interval (date_format(curdate() , '%w')-1)
day) as firstday , date_add(curdate() , interval (7 -
date_format(curdate() , '%w')) day) as lastday
it will give you the date of the monday and the sunday of the current week
hope this solves your problem.
Arno
--- End Message ---
--- Begin Message ---
"John Nichel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> babu wrote:
> > Hi,
> >
> > could someone please check where the sytax error is in these statements.
> >
> > $sqlstmt= "EXEC sp_addlogin ".$adduser." , ".$addpass;
> > $sqlstmt1= "EXEC sp_adduser @loginame= ".$adduser." , @name_in_db=
".$adduser;
> > $sqlstmt2= "GRANT CREATE TABLE TO ".$adduser;
> > $sql=mssql_query($sqlstmt);
> > $sql1=mssql_query($sqlstmt1);
> > $sql2=mssql_query($sqlstmt2);
>
> Didn't php give you a line number?
Is it a php or mysql syntax error? If the latter, please echo $sqlstmt etc
and show us the output
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hi,
Its giving the line number. But actually i want to know the correct syntax for
concatenation. I think all there is some mistake in all the three concatination
statements.
so could some one check and give some idea.
thanks
John Nichel <[EMAIL PROTECTED]> wrote:
babu wrote:
> Hi,
>
> could someone please check where the sytax error is in these statements.
>
> $sqlstmt= "EXEC sp_addlogin ".$adduser." , ".$addpass;
> $sqlstmt1= "EXEC sp_adduser @loginame= ".$adduser." , @name_in_db= ".$adduser;
> $sqlstmt2= "GRANT CREATE TABLE TO ".$adduser;
> $sql=mssql_query($sqlstmt);
> $sql1=mssql_query($sqlstmt1);
> $sql2=mssql_query($sqlstmt2);
Didn't php give you a line number?
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---------------------------------
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
--- End Message ---
--- Begin Message ---
> Its giving the line number. But actually i want to know the correct syntax
> for concatenation. I think all there is some mistake in all the three
> concatination statements.
>
No - there is no problem with any of the statements per se, but there
may be when executed with $adduser, $addpass etc. Why not take the
advice of Mark Rees and echo the $sqlstmt etc and show us the output?
Raz
--- End Message ---
--- Begin Message ---
[snip]
what is it wrong to ask questions on a php general mailing list where I
know there are a bunch of people that can help? I do have a php book
But it dosent show. Why can other people ask questions but I cant?
[/snip]
It is not that you cannot ask questions, it is that your questions show
a basic lack of research. The answers to the questions you have asked
are easily gotten from the manual, tutorials, and good books on PHP
development. Which book do you have?
--- End Message ---
--- Begin Message ---
Hey George...
On 19/07/05, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> It is not that you cannot ask questions, it is that your questions show
> a basic lack of research. The answers to the questions you have asked
> are easily gotten from the manual, tutorials, and good books on PHP
> development.
For instance, take a look at:
http://www.php.net/manual/en/ref.mysql.php - this is the first page in
the reference manual about mysql. 'bout a third down the page
is...'Example 1. MySQL extension overview example' copy, paste, amend
as required and run. Doesn't work? PHP manual -> google ->
book....and...
...if then you don't understand, come back and ask - least it shows an
ounce of initiative which is what most on this list would like to see
;)
Raz
--- End Message ---
--- Begin Message ---
George B wrote:
Jochem Maas wrote:
John Nichel wrote:
George B wrote:
<snip non-researched basic stuff>
http://us2.php.net/manual/en/index.php
:-) anyone care for a php mysql extension:
mysql_do_xml_http_request_bound_richdatagrid([string] query);
george if you want to keep asking questions on NRBS**
then you'll need to change email addrs + name :-)
** from Johns 'non-researched basic stuff' I like the way
the BS comes out ... :-P
what is it wrong to ask questions on a php general mailing list where I
know there are a bunch of people that can help? I do have a php book But
it dosent show. Why can other people ask questions but I cant?
It's not that you can't ask questions, it's that it's bad form to ask
numerous questions to which the answers are well documented. The people
on this list aren't here to hold someone's hand or write the code for
that person; we're here to help solve problems (or ask for help with
problems of our own). The questions you have been asking are really
basic, and if your book doesn't cover the answers, you need to look into
getting a new book. The online PHP manual is an excellent place to find
answers to the questions you've been asking, as is the mailing list
archives. This list shouldn't be your first stop when you encounter a
road block. Check the manual, the archives, and Google first. 9 times
out of 10, you'll find your answer there quicker.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
George B wrote:
Jochem Maas wrote:
John Nichel wrote:
George B wrote:
<snip non-researched basic stuff>
http://us2.php.net/manual/en/index.php
:-) anyone care for a php mysql extension:
mysql_do_xml_http_request_bound_richdatagrid([string] query);
george if you want to keep asking questions on NRBS**
then you'll need to change email addrs + name :-)
** from Johns 'non-researched basic stuff' I like the way
the BS comes out ... :-P
what is it wrong to ask questions on a php general mailing list where I
know there are a bunch of people that can help? I do have a php book But
it's just that what you ask and how (coupled with the frequency)
determines the response you get, if any.
your general attitude, the number of posts you answer, etc, etc all
play a part. e.g. as is regularly mentioned you don't argue with Rasmus,
why? because he wrote the original php, still actively develops it, runs
yahoo, and _still_ has time answer posts on this list... basically
he know more than you and has enough 'credits' in phpland to buy the
bank (so to speak) -
...you blew most of your startup 'credits' already, so now you are 'forced'
do a lot of increaseKnowledge() where:
function increaseKnowledge()
{
while (kowledgeSucks()) {
readTheManual();
SearchTheWeb();
writeSomeCode();
}
}
then come back to the list when you are _really_ stuck and you can
explain the problem and what you have tried so far in _detail_...
if you do that then you'll almost garantee yourself and answer
there are no hard and fast rules regarding this but the consensus
is 'try harder please George' ... basically NRBS** doesn't entice people
to spend time working on _your_ problem.
it dosent show. Why can other people ask questions but I cant?
which book? show what? be specific, do research - google is your friend
(that's beginning to sound like something bigbrother would say).
regarding "Why can other people ask questions but I cant?" ... er?
that is a question, you asked it, ergo the question moot is moot...
what you should be asking is why other people get better answers ...
hopefully you get that now, anyway good to see you reading other people
threads.
rgds,
Jochem
**Non-Researched Basic Stuff - from John Nichel, eventually I'll be able to
leave off the footnote :-P
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
<snip>
**Non-Researched Basic Stuff - from John Nichel, eventually I'll be able to
leave off the footnote :-P
Cool, I've left my mark on history. An Internet acronym to my credit;
my life is complete. ;)
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Is there a list which deals with basic certification questions and
anxieties? I got the 'official' Zend study guide and now believe I know
nothing. And the practice book has quests whose subjects are not
mentioned in the relevant chapters. If someone else has completed the
exam, which text did you use to prepare? I know O'reilly has Programming
PHP, but I fear trying to parse out what I need to know might be a
little difficult form that book...any ideas?
Thanks for any help or redirection,
jozef
--- End Message ---
--- Begin Message ---
Thank you Rouvas,
I never used the tools you mentioned. But I will definitely give them a try.
I wrote a perl script using LWP as an http user agent. and the timing
function you suggested. It works well.
I am new to this forum, and new to PHP. It seems Rasmus is famous, and I
should have shown my respect.
Thanks again all of you for your kindly help.
Hi Liang,
trying to get conclusive results with browsers is futile. Use a
command-line
tool (like curl) to invoke the web pages and get the results. Or you can
use
PHP's own function to query the web server and do your own timing with
microtime() function or another suitable for your purposes.
In order for flush() results to reach you (in a browser) they have to pass
from multiple caches like PHP's, Apache's, the occasional proxies and
finally
the browser's own cache. So you cannot get dependaple results measuring
times
or responses from your browser. Try the methods above.
And a final tip... When Rasmus speaks, you don't question him:-) Period.
Have a nice day,
-Stathis
--- End Message ---
--- Begin Message ---
<snip>It seems Rasmus is famous, and I should have shown my respect.</snip>
<history src = 'php_manual_en.chm'>
PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus
Lerdorf in 1995, initially as a simple set of Perl scripts for tracking
accesses to his online resume. He named this set of scripts 'Personal Home
Page Tools'. As more functionality was required, Rasmus wrote a much larger C
implementation, which was able to communicate with databases, and enabled
users to develop simple dynamic Web applications. Rasmus chose to release the
source code for PHP/FI for everybody to see, so that anybody can use it, as
well as fix bugs in it and improve the code. </history>
************************
This message has been delivered to the Internet by the Revenue Internet e-mail
service
*************************
--- End Message ---
--- Begin Message ---
Hi André,
It sounds interesting. But since I am pretty new to PHP, I have some
questions, naive maybe, about what you wrote.
"#!/bin/sh\n/path/to/script/Send.php 12 &\n"
What does the Send.php look like? I do not have idea how a shell interprets
an php script and what the parameter 12 means here. If you do not mind,
could you please also let me look at your Send.php?
Thank you very much.
I did something like that for a newsletter sending script. Basiclly, I
had two scripts:
a) AddEdit.php that would list the newsletter's items and allow it to send
b) Send.php that was a script I ran on the background
When pressed "Send" on AddEdit, it would do something like
$tempName = tempnam( '/tmp', 'newsletter' );
$fp = fopen( $tempName, 'w+' );
fputs( $fp, "#!/bin/sh\n/path/to/script/Send.php 12 &\n" );
fclose( $fp );
chmod( $tempName, 0755 );
system( $tempName . ' &' );
That way, it would launch the second script into the background,
checking if the script altered the newsletter's state for "Sent"
everytime a user saw the newsletter's details.
Hope it helped.
--- End Message ---
--- Begin Message ---
Can somebody here help me to delete my message?
People who read this must be laughing at me.
:)))))
<snip>It seems Rasmus is famous, and I should have shown my respect.</snip>
<history src = 'php_manual_en.chm'>
PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus
Lerdorf in 1995, initially as a simple set of Perl scripts for tracking
accesses to his online resume. He named this set of scripts 'Personal Home
Page Tools'. As more functionality was required, Rasmus wrote a much larger
C
implementation, which was able to communicate with databases, and enabled
users to develop simple dynamic Web applications. Rasmus chose to release
the
source code for PHP/FI for everybody to see, so that anybody can use it, as
well as fix bugs in it and improve the code. </history>
************************
This message has been delivered to the Internet by the Revenue Internet
e-mail service
*************************
--- End Message ---
--- Begin Message ---
Hi all,
I am trying to create a table on the remote server but it never seems to
work
CREATE TABLE `sheet1` (
`id` int(10) NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`fname` varchar(255) NOT NULL default '',
`sname` varchar(255) default NULL,
`job_title` varchar(255) default NULL,
`organisation` varchar(255) default NULL,
`email` varchar(255) default NULL,
`street` varchar(255) default NULL,
`city` varchar(255) default NULL,
`postcode` varchar(255) default NULL,
`office_tel` varchar(255) default NULL,
`mobile` varchar(255) default NULL,
`fax` varchar(255) default NULL,
`web` varchar(255) default NULL,
`add_info` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=303 ;
There seems to be a problem with the last line (this is exported from my
local server). I am just learning about mySql as I go so have no real clue
about CHARSET and ENGINE (which I believe may be the problem)
This is the error
1064 - You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use near
'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18
and this is what the manual says (not very helpful)
a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR)
Message: %s near '%s' at line %d
Any help will be appreciated.
R.
--- End Message ---
--- Begin Message ---
[snip]
1064 - You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near
'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18
and this is what the manual says (not very helpful)
a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR)
Message: %s near '%s' at line %d
Any help will be appreciated.
[/snip]
There is nothing PHP here, but you knew that when you pressed send.
Really there are a lot of MySQL gurus on this list. There are a lot more
on mysql@lists.mysql.com
You're problem is likely related to the version of MySQL that you are
running, perhaps it doesn't support CHARSET definitions.
--- End Message ---
--- Begin Message ---
Just upgraded to 4.4.0 ... several "legacy applications" that we have
installed now break with the above error message ... specifically, older
installs of Horde, but I've seen reports of other apps ...
Without reverting back to 4.3.11, is there a way I can temporarily fix
this while working on the application issues themselves? :(
Thanks ...
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664
--- End Message ---