In earlier versions of PHP, you could use the $HOSTNAME global
variable to get the server/machine name that is running Apache/PHP.
However, that variable is no longer working and I can't seem to find a
replacement in any of the super global variables. Is there one? How
can you get
How does this function really work? I've been
beating my head against the wall for the last
8 hours trying to figure it out. This is what
I'm trying and it isn't working:
{this is a very simplified version}
class MyClass {
function myFunc( $stringVar, $arrayVar ) {
echo $stringVarbr\n;
On my system, the function works as expected (at least as I
understand it): myFunc receives the parameters Hello! and
array(this=that), which is what you pass to it in the
first place.
See, that's not what I'm getting... :|
Were you expecting it to expand $myArrayVar into individual
Try encoding like this:
$retval = base64_encode(serialize( domxml_open_mem( $xml )));
and on the next page:
$xml = unserialize(base64_decode($xml));
It works via html but don't know enough about soap
Well, you don't have to use soap - you can use sessions and get the
same result.
As for your
Using PHP with cURL, I am currently able to dynamically
create XML documents and HTTP POST to a remote server,
receive an XML response, and parse XML as needed.
What I am having trouble finding information on is doing
the reverse. Basically, I am trying to create a PHP script
that acts
Consider the following:
page1.php
?php
// initializing soap server object, blah, blah, whatever here.
// the important function, dumbed down to the barest essentials.
//
function test() {
$retval = ;
$xml = rootrowelementtest/element/row/root\n;
$retval = serialize(
I'm switching from a MySQL environment to PGSQL and I'm
going through and trying to learn the differences between the
two. I've come across some issues that I can't seem to find the
answers to in the docs or on the web. I'm hoping someone can
help me out.
* MySQL has a function to reset the
pg_result_seek() should perform a similar function. In most cases
you wouldn't need to use that because if you're going to be using
the results more than once you could store them in an array.
Sometimes yes, sometimes no. But a valid point nonetheless.
* For PGSQL, you can get the
Sorry, you've lost me. In your OP you say you wanted the
table name, but now you're talking about the dbname?
For dbname, you can use (oddly enough) pg_dbname().
Eeep, I'm ever so sorry. That's what I get for responding
at 4:30a when trying to battle insomnia.
Yes, I am looking for the
Does anyone know of a mailing list for PHP and XML or can I
just pose them here??
PHP-XML. The list address is:
[EMAIL PROTECTED]
Chris
Wait until after the for loop has completed.
for ($i=0; $i $num_results; $i++) {
$variable[$i];
}
global $variable;
That's not going to work. The only thing that is doing is
making an already global instance of $variable global
within the function.
What you want is this instead:
$today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
echo ($today - $last_week);
The result is a number like 8876 (20020107-20011231 = 8876)
But in date thinking it should be 7!
No, that's the difference in time
Consider the following:
$number = 102.52;
echo $number % 50;
echo bcmod( $number, 50 );
in both cases, it's spitting out 2. Why is it not spitting
out 2.52? Is there a way I can get that information?
w/o having to parse the string, breaking it up, getting
the modulus and then adding it back
I think it is $HTTP_SERVER_VARS['HTTP_REFERER']
Except that the value for this variable isn't always set and can
be spoofed. This value should not be relied upon.
Oftentimes (though, you'd have to be creative to make this
work in a seperate window), what I use to send the user back
to where
if ($efa != nm || $HTTP_REFERER !=
http://www.globalhealth.org/news/article.php3?id=1526;){
do this);
}
Not sure what the exact problem is as you haven't been all that
descriptive as to what the values are or what is happening, but
you should know that $HTTP_REFERER can't be trusted. You
I've got the following possible (example) strings:
[hi] there, this is me [HI] there, this is me
[ho] there, that is you [HO] there, that is you
[hey] there, where are you [HEY] there, where are you
and so on. I'm trying to come up with a regex that will
find the capitalized text (only)
This is untested, but something like...
$str = [hi] there, this is me [HI] there, this is me;
$newstring = ereg_replace((\[[A-Z]*]), br\\1, $str);
should do it.
using the Perl regexe's might make it easier, but that should work.
That worked perfectly. Is there any way I can make it so that
H - killer - how about an Orca? We'll pretend that they
get along well with the MySQL dolphin, but PHP is definitely a
killer app.
Yeah, but don't Orcas eat penguins?
Chris
The pop outs are done using JavaScript. Its something to do
with setting the STYLE=visibility: hidden property of the HTML
element. I'm not sure exactly how its done though.
Yeah, and it only works on IE (and maybe NN6+). It won't work
(the same way) on NN 6.
Chris
I would like to know if there is a way to store objects
globally from a php-page, so that the object can be used
from another page.
Yes, using sessions or cookies.
Chris
$filename = 'kunden/'.$name.'.png';
I see this all the time and I'm curious: what takes more
computing power (granted, either would be incredibly little
I'm sure, just curious which requires more work by PHP)?
this:
$filename = this . $varname . that;
or this:
$filename = this $varname
thanks for a quick response but I have a major problem with that:
no shell access = can't use cron
Your Windows task manager? Just set it up to go to that page
every night at your (not the server's) midnight...
Chris
How can I send the values inside the array into a function
for calculation?
function addValues( $arrayVar ) {
$reteval = 0;
foreach( $arrayVar as $element ) {
$retval += $element;
}
return $retval;
}
$myArray = array( 1, 2, 3, 4, 4 );
echo addValues( $myArray );
Chris
A large page is generated with data from a MySQL database. The various
paragraphs inside this page have variable, internal links,
also extracted from the database.
Example: a name=\$value\/a
Let's assume that $value represents FOO.
Ok
Now i want to take the value of this variable to post
When is $value assigned a value? Before or after the
script prints out the form action= line?
This $value is somewhere within the form page ($PHP_SELF).
So it is a value that the user sets? After the script runs and the
HTML output generated?
$PHP_SELF?#FOO in the script, it all
It depends on where value is coming from. If it's coming from the
script server side, then you just need to make sure that $value is
set before the line form action= gets printed. If it's coming from
the client side, there may be other problems...
$value is defined in the server-side
In setting up a form to allow a user to upload a file,
upon submission of that form, you can get the actual
file name that is being uploaded by accessing the
variable:
$userfile_name
(assuming the form element's name where the user
specifies the file is $userfile).
Is there a way to get the
i have txt file have this words
--
bla bla bla
[phpcode]
?
echo 'hello word';
?
[/phpcode]
bla bla bla
---
now I want to convert the code that are between [phpcode] and
[/phpcode] to colorized code ..
How I can do that
Copy the file to .phps and access that page
How can I search for a certain word in a string?
strpos() ereg() preg() and similar functions.
Chris
Is there any function in PHP that is similar to alert() or
confirm() of javascript ? I tried die() but that's not what I need.
What do you want it to do? Remember, though, that
PHP = server side while Javascript = client side. If you
want alert() or confirm() functionality on the client
Yes that's what I do but it freeze on netscape 6 ?
FAFAIK the client's browser can't influence the header() call in
your script. Are you sure there aren't any errors somewhere else. Eg
before the header() call or at the start of the page where you
redirect the user to?
Indeed. A good way
How do I turn off the error messages that appear at the top
of the page? I have this function below that if an image is
not there for $url, it give a warning.
$size = GetImageSize($url);
Example error message below...
Warning: getimagesize: Unable to open 'http://www.yahoo.com'
for
I want PHP parser to warn/fail when I try to use a variable
not declared before. Like Option Explicit on ASP/VBA.
Look here:
http://www.php.net/manual/en/function.error-reporting.php
Chris
I'm looking for a function which enables me to allow user
only to enter those dates which are still to come. In my head
I have three select things... one for day, one for month and
one for year. In order to prevent the user from submitting the
form with the date which is in past, I need
What if I want to pad a number with zeros in the other
direction? I.E:
524 becomes 00524
printf() / sprintf() is your friend.
Chris
Yeah, but what if they don't JUST want to print it...
Umm, have you read the documentation on either of
the functions? They both return a string; they don't
send anything to standard out (like echo or print does).
$myString = printf();
$myString = sprintf();
echo $myString;
Chris
I want to use the value of a variable in a variable name. For
instance:
$id = 1;
$sql_$id = hey; //set variable $sql_1 to hey
print $sql_1; //should print hey
I *believe* (could be wrong) what you want is this:
print ${$sql_1};
Check out variable variables in the dox.
Chris
I've got to different files of words. One on each line.
What would be the best way to combine both into one file
alphabetically?
after you merge the arrays, use asort();
Chris
i want to send emails with attachements... can I modify the
mail()-function or how can I perform this?
You can get classes that do this very thing at the following site:
http://phpclasses.upperdesign.com/
Chris
I would even go for $Something and just $SomethingMore
with $Something really being $Something-$SomethingElse.
I don't know if that makes sense.
Any help would be greatly appreciated.
Take a look at file(); and just loop through the resulting array
and removing all the blank elements.
what are you trying to do?
why do you want to diffirentiate between 99 as a string or
as a number?
Because if it is a string, more than likely it means that the key
was user defined and is not PHP defined as an element number.
Again, consider the differences between these two arrays:
Sample code:
script language=php
$array = array( one, two, three );
while( list( $key, $val ) = each( $array )) {
if( is_string( $key )) {
echo Key is a string\n;
}
echo Key: $key = $val :Val\n;
}
echo \n\n;
$array = array( SS = one, 15 = two, 19 = three
Then you can use:
if (mysql_num_rows($result) == 0) {
stuff here
}
This will check the number of rows returned from your query. If zero,
then do somethingmodify as you need.
What I generally do is this:
if(( !$result ) || ( mysql_errno() 0 )) {
// error code here
}
OR
if((
the require(morefunctions.php); will ofcource not work but
bassicly this is what I want. en all the functions added should
be able to use VAR1 VAR2 VAR3 (and the other functions that
are allready in the class)
is there a why to do this ??
Yes, there is.
Go here:
So sprach »Arcadius A.« am 2001-08-31 um 05:27:04 -0700 :
$u = $SCRIPT_FILENAME;
Because you did not define $SCRIPT_FILENAME anywhere. If you want to
access the global variable, you've got to say so:
global $SCRIPT_FILENAME;
Or, so you don't have to specify all the variables you are
Or, so you don't have to specify all the variables you are using
as globals (especially if you are using *alot* of them), you can
use:
$GLOBALS[SCRIPT_FILENAME];
What's the gain? 'global ' has 7 characters, whereas '$GLOBALS[]' has
10 characters. So, you don't type less. And with
One of the downside of PHP IMHO is, that you do not have to define
variables. This leads to a lot of errors. At least there should be a
option, which forces you to define variables, like maybe so:
dim $some_var;
I definitely agree there. I've been bitten by this bug more times
than
Cool ...
Now that we're talking about PHP
I'd like to ask a question
You know the overloading function in C++ Is that
possible in PHP ?
No, I do not believe so.
Basically , I'd like to define more than one function having
the same name but different number of
I am trying to get a double data type to display the .00 in a
hole dollar amount (i.e. 432.00 not 432 or $432.00 not $432).
Can anyone tell me how to do this?
printf(); or sprintf(); is your friend
Chris
How can I use PHP to detect if the visitor wanted MainDomain.com (and
display MainDomain/index.php) or WidgetWorld.com (and then display
MainDomain/Widgets/index.php).
I *believe* what you are looking for is $HTTP_HOST.
Chris
Is there a prewritten function for capitalizing the first
letter of each word in a string except for the common
words you wouldn't want to capitalize in a title? Like
Come Learn the Facts From an Industry Leader
None that I've seen.
But it wouldn't be hard to write a function that takes a
Is it possible to send an array of numbers into a php file
through a url? Like if I have a file that adds numbers together, could
I send it
www.domain.com/add.php?num=2,3,4,5
$num would be an array.
Thanks,
Pat
I am trying to receive file names but can't quite figure out
the proper substr to do it:
jeff.dat
jeffrey.dat
chris.dat
tom.dat
I want to receive the name to the left of the .dat
$fileName = eregi_replace( \.dat, , $fullFileName );
Chris
I couldn't find anything in the docs about this...
What do you need to have installed to be able to
use the mail() function (and have mail get sent
out) in PHP for Windows?
If you could point me to the proper place in the
documentation so I can read up on it, I'd be ever
so grateful!
Chris
Driving me mad. Works if I put a string in quote marks instead of the
variable $location.
$result = mysql_query(SELECT shootID FROM shoots WHERE
(location=$location));
This should work shouldn't it? If it's a problem with the variable being
embedded in the query what's the easiest way to
this doesn't work,how should it be done?
insert into test (uid, companyUid)
values(1, select uid from companysTable where company = Micrsoft);
If you are using MySQL, it doesn't support sub selects...
Chris
get the difference in months between two dates
using a unix time stamp?
I know I can do something like this:
$startMonth = date( m, $startTimestamp );
$startYear = date( Y, $startTimestamp );
$endMonth = date( m, $endTimestamp );
$endYear = date( Y, $endTimestamp );
$numMonths = $endMonth -
$numMonths += ( 12 + ( $endMonth - $startMonth ));
This last line should have read:
$numMonths += ( 12 + ( $endYear - $startYear ));
Too much cutting and pasting... :p
Chris
Seems that $PHP_SELF is not defined when it's run from the
command line.
Try:
__FILE__
Chris
I had that before.
OK, seems that my problem is not that simple. The thing is ,
I have something
like this in my file test.php:
require('my_api.inc');
echo This is test.php3;
Now, in my_api.inc, I want to know that I run test.php3, when I do
bash$ php test.php3
and the filename is
8:$result = mysql_db_query(users, $query);
9:$r=mysql_fetch_array($result);
10: $count=$r[count];
And the error message is
Warning: Supplied argument is not a valid MySQL result
resource in
c:\inetpub\wwwroot\PhpAndMysqlTest\test2\reg1.php3 on line 9
You need to validate that the
Here's my code:
?
function expDate($date) {
$month = substr($date, 0, 2);
$len = strlen($date);
$year = substr($date, $len-2, $len);
return $month;
return $year;
}
expDate(11/2002);
print $month $year;
?
I know this isn't the correct usage of
Here's something I found on the PHP Code Exchange:
Generate Excel files from PHP by Christian Novak on
2000-11-25 11:47:24 (v for 4.0) is 1974 bytes.
Small function library to generate Excel files/stream
directly from PHP.
http://px.sklar.com/code.html?code_id=488
I haven't tried it
if (!$C_Last_Name$y) {
The form submitting information to this code has field name like
C_Last_Name1 C_Last_Name2 depending on how many Children
are signing up for something. So I need $y to represent the number.
You want this:
if (!{$C_Last_Name}{$y}) {
The {} surrounding the
Is there a way in PHP to get the referring url when a link is click
to get to that page?
$HTTP_REFERER
getenv('HTTP_REFERER')
Note that this isn't supported on all browsers and can be turned
off or faked/munged.
Chris
Basically I mean this: I load the page, it has two comboboxes
(select with option).
The first one contains names of countries, the second names
of cities within those countries.
When I select Belgium in the first one, I only want to see
all Belgian cities.
Now with JavaScript this
I've done this very thing for a leasing company. I used
PHP and MySQL to create a series of arrays in Javascript.
When the user clicked on a value in the first combobox I
used onClick to call a function which loaded information
into the second box.
A definite possibility. The
I have some field error checking going on ... and when a user
(say) doesn't fill in a field correctly, my error page comes up telling
them. They then must click on their browsers back button
and make the changes.
Now -- I have a password field, and when they click back,
they are forced
I'm using sessions and if the user hits the back button an
expiration page appears! how can i disable the back button ?
i tried window.history.forward(1) but it fails !
Even more interesting is that when a user presses the back
button all the way back to the page that initially started the
Below is the (very) simple form that I'm using to allow users
to upload files to my site:
---
html
head
titleUpload Attachment/title
/head
body
br
center
h3Upload File/h3
You are uploading from an unsecure server.br
FORM ENCTYPE=multipart/form-data
Have you asked what browsers they are using?
This happens primarily on IE but it also happens
using NS
Also, what are you using to serve this page?
?
PHP 4.0.4 and Apache.
Chris
Anyway, it's not a big thing if you're _really_ stringent about how you
check every single variable which is used in a database query,
system/passthru/exec, or eval command, and your checking methods are
flawless, but otherwise it's just best to go to the trouble of hacking
around the input
Is there any sleep function in PHP like in Perl?
For example, you will define the time in seconds and system
will wait for that time to continue running the script?
You read the documentation at all?!?
http://www.php.net/manual/en/function.sleep.php
Chris
header(Content-type: application/download);
I think you'd need to change this to:
header(Content-type: text/plain);
but I could be wrong...
and where can I find reference on these header stuff?
Not sure. I find bits and pieces in this list...
Chris
Hi,
How can I calculate days between two dates ?
This should work:
$firstDate = mktime( 0, 0, 0, 1, 12, 2001 );
$secondDate = date( U );
$daysInBetween = ( $secondDate - $firstDate ) / 86400;
Chris
Sorry,
it doesn't work !!
Why do you say that? I just tested it and it worked.
It returned:
115.31296296296
115 being the number of days
.31296296296 is the fraction of the day that is the
difference of hours between the two times.
mktime() and date( U ) return a unix timestamp
which is
Below is the (very) simple form that I'm using to allow users
to upload files to my site:
---
html
head
titleUpload Attachment/title
/head
body
br
center
h3Upload File/h3
You are uploading from an unsecure server.br
FORM ENCTYPE=multipart/form-data
The problem that I'm experiencing using the above form is that when
some users (and the problem is consistent for those users) submit the
above form, *none* of the POST variables are getting passed to the
receiving page. None of the hidden variables, not the input
type = file variable,
is there a PHP class/library available anywhere, that supports
dynamic creation of different graphs? I need 2D bar graph and
pie graph support.
i found the VH Graph (http://www.vhconsultants.com/graph/graph.htm),
but they want $100 for their 2.x version. i'd prefer a free one
(i'm sure
Again, any help would be greatly appreciated!
could be a browser specific issue. have you checked into the
possibility that people having problems are all using the same
browser?
I don't know what all of them are using, but most are using
IE. I don't know how feasable it would be to get
From the manual:
Handling file uploads Uploading multiple files
Common Pitfalls
Not validating which file you operate on may mean that users
can access sensitive information in other directories.
What is meant by the above? How would you validate that
you weren't operating on the
Its my understanding that PHP appends the SID on the
end of the URL regardless of weather its a form or not. If thats
not happening for you, check your php.ini and make sure you
have session.use_trans_sid enabled.
It is enabled. And it's being appended to most URLs (though, not
Here is what I see in my FORM with --enable-trans-sid:
FORM METHOD=POST ACTION=./test_formRun.php
INPUT TYPE=HIDDEN NAME=PHPSESSID
VALUE=cbf75d263416e77d773b1772f6e1be89
PHP is adding the HIDDEN field with the session id. For some
reason, it also appends it to the SRC attribute of the
have you checked your PHP.INI file?
it sais there what links to rewrite.
This is what is in my .ini.
url_rewriter.tags = a=href,area=href,frame=src,input=src,form=fakeentry ;
added 3/2/01
Am I missing something here that I should have?
I don't see anything in the docs about the above
*sigh* I'm thinking so too ;(
Doh!
However, I have at least a usable hack around.
In the constructor of your class, add:
function Class ($object_name) {
global $pge;
$pge = $object_name;
}
Then when you use create a new object of that type you must use:
$objectname = new
My problem is that not displaying anything in case of an error is a
completely unacceptable solution. I *MUST* return a valid
XML message in a predefined format. If not, I am violating the
standard we are
if (@foo_bar (42, 4711) == ERROR_CODE) {
PrintXMLErrorMessage ();
I do not
Is there a good write up out there or can anyone offer
some insight to the rest of us as to how error handling
should be properly implemented?
Yes, PEAR has some error handling routines, but it
doesn't have any kind of information as to how it should
be properly implemented. I've just finished
standard we are
if (@foo_bar (42, 4711) == ERROR_CODE) {
PrintXMLErrorMessage ();
I do not believe the above will work. When using the @ symbol
in front of an expression, it makes it so that the error
code that is returned is 0. While writing my error handler class,
in the
if (@foo_bar (42, 4711) == ERROR_CODE) {
PrintXMLErrorMessage ();
Well, we both are right. The snippet I suggested (top of this mail)
*will* work, because the @ operator doesn't mess with the return
value of the function.
That is correct. However, the == ERROR_CODE
I want to query an oracle database and push the output to an MS
Excel spreadsheet . Currently I am dumping it to a csv text file and
reading into Excel.
Is there a better way to do this?? Is there a php function for this ??
What I am doing is using PHP to generate an HTML table in
Two words:
URL Encode.
Actually, one word: urlencode();
heheheh
Chris
If you use the file() function to open up the file, it will
put each line of the file into an array. At that point you
can say:
But how can i put into a var $total the total lines that i
have into the file?
After you've used the file() function as suggestion above,
the total number
We have an array:
$myArray = array( joe=bob, this=that );
I know that technically, you shouldn't do the following
to print it out:
echo Here is a $string, $myArray[joe] with $alot of PHP $variables;
If you have the highest error level on, PHP will display
an error though if you don't, it
I wasn't able to find this in the docs, so could someone
tell me exactly how --enable-trans-sid is supposed to work
behind the scenes?
while it won't for this url:
a href=/interactive/direct_apply/resident.php
target=_tophere/a
I've also tried...
a
So is there ANY way to get the name of the object in PHP code without
knowing the name of the object ahead of time?
I went through this exact thing not too long ago with an error class
I wrote. Unfortunately, there is no way to know. What you can do,
however, is do a check to see if that
INPUT TYPE ="text" blab blab VALUE = "Here's the text "in quotes""
Well, obviously there's a problem with that. The form field will show
"Here's the text " and then thinks it ends. Is there any way to get
around this, other than stripping out her quotes? Thanks,
I wasn't able to find this in the docs, so could someone
tell me exactly how --enable-trans-sid is supposed to work
behind the scenes?
Why would this option work and transmit the SID for
this url:
a href="/interactive/secure_frame.php?sourcePage=? echo urlencode(
I wasn't able to find this in the docs, so could someone
tell me exactly how --enable-trans-sid is supposed to work
behind the scenes?
Why would this option work and transmit the SID for
this url:
while it won't for this url:
It makes no sense to me...
Any help would be greatly
Ok, I found out what the problem was. I'm still curious
why the problem is occuring.
if( $tmpArray[errorNumber] $typesToDisplay ) {
you're using the bitwise when you want the logical
No, I actually wanted to use the bitwise . I wanted to see
if the "errorNumber" was in
""Boget, Chris"" [EMAIL PROTECTED] wrote:
Can you use the above function to set the error
handler to a custom class? If so, how? I've been
having no luck no matter what I do...
I tried doing something like:
set_error_handler("Error::handleError");
mys
1 - 100 of 223 matches
Mail list logo