php-general Digest 26 Jan 2003 08:39:29 -0000 Issue 1845
Topics (messages 133123 through 133161):
Re: Minor email problem
133123 by: George E. Papadakis
Re: Word Count
133124 by: George E. Papadakis
Re: $object->function($parameter)->function();
133125 by: Alex
Re: a regular expression problem - split text
133126 by: George E. Papadakis
Re: Script under Windows OK, under Linux, not...
133127 by: Danny Shepherd
Re: GD jpg thumbnail - ugly discollored
133128 by: Mark Charette
133135 by: Victor
Apachequestion
133129 by: Øystein Håland
+ in filenames
133130 by: Victor
133133 by: Richard Whitney
133136 by: Victor
133138 by: Richard Whitney
133139 by: Victor
CRON?
133131 by: Nicole
133132 by: Leif K-Brooks
133134 by: Alex
133140 by: Nicole
133141 by: Nicole
133152 by: Tom Rogers
converting a Recorset into an XML string
133137 by: Octavio Herrera
133142 by: Sean Malloy
Re: Select value for driopdown box
133143 by: Ben C.
133149 by: Greg Beaver
SELECT with WHILE NOT
133144 by: Andre Dubuc
133146 by: Sean Malloy
133147 by: Andre Dubuc
Re: OO2relation mapping
133145 by: Manuel Lemos
133156 by: Dominik Wittenbeck
XORing a string with some hash???
133148 by: Peter Litov
133153 by: Tom Rogers
Check if directory has changed
133150 by: Carlos Fernando Scheidecker Antunes
133151 by: Peter Litov
133158 by: Jason Sheets
Masive mail Advice
133154 by: Maciek Ruckgaber Bielecki
133157 by: Mark Charette
133160 by: Jason Wong
Java problem...need advice.
133155 by: John Wells
A Date and Time Library for all seasons
133159 by: John Lim
__LINE__,__FILE__ + custom error handlers
133161 by: electroteque
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:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Take a look at the standard php mail function .
You can set most of the available mail headers inluding from/to ones.
That would do it.
--georgep
----- Original Message -----
From: "Denis L. Menezes" <[EMAIL PROTECTED]>
To: "PHP general list" <[EMAIL PROTECTED]>
Sent: Friday, January 24, 2003 1:48 AM
Subject: [PHP] Minor email problem
hello friends,
I am hosted with an ISP called Apexon. I have written php scripts to send
mail from a webpage. When I send this mail, the from address becomes
[EMAIL PROTECTED] . Their website says that the variable sendmail_from
is [EMAIL PROTECTED] . I want to force my own from address in this. I also want
to change the sender's name to my name rather than my website name.
I have tried many ways, but not successful. Can someone help me?
Please help.
Thanks
denis
--- End Message ---
--- Begin Message ---
$wordsCount = str_word_count($string);
-- georgep
----- Original Message -----
From: "Maxim Maletsky" <[EMAIL PROTECTED]>
To: "Craig" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, January 23, 2003 11:26 PM
Subject: Re: [PHP] Word Count
> words, for a programming language, are nothing more than just the spaces.
> So, as previousely was shown - could the mount of spaces in the string
> to get the amount of `words' in between them.
>
>
> --
> Maxim Maletsky
> [EMAIL PROTECTED]
>
>
>
> "Craig" <[EMAIL PROTECTED]> wrote... :
>
> > Is there a way to count the number of words in a string?
> >
> >
> >
> > --
> > 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
>
--- End Message ---
--- Begin Message ---
If I am not mistaken, this feature is coming in php5, but is not yet in php4
"Chris McCluskey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]..
.
Hi there, I've been using PHP for about 2 years now and absolutely love
it! Our company uses it as our main development language, so far
though, there is one thing that has been annoying me for a while now..
the following line of code will not work:
$object->function1($parameter)->function2();
I receive a parse error when i try to call another function off of the
object that function1 returns. I know this is possible in java:
object.function1(parameter).function2();
VB:
object.function1(paremeter).function2
and i'm sure C++, although i'm not too familiar with that language.
My question is, will or is there any support for this kind of call in
PHP? or is there another way that i should be doing it? as for now,
here is my work around:
$tmp =& $object->function1($parameter);
$tmp->function2();
Thank you in advance!
-Chris
-----------------------------------
_ _ _ _
|'|(_)|_)(_)|_(_)`-,
* * *
------------------------------------
Chris McCluskey Web Applications Engineer
Modulus, LLC
1720 Willow Creek Circle, Suite 520
Eugene, OR 97402
Email: [EMAIL PROTECTED]
Voice: +1 (541) 434-1024
Web..: http://www.modulusgroup.com <http://www.modulusgroup.com/>
============================================
The contents of this transmission may be
confidential in nature and should be
directed only to the person to whom it is
addressed. Do not read, copy, or disseminate
this material unless you are the intended
recipient. If this transmission reached you
in error, please forward the e-mail to the
sender to advise, then destroy the
transmission you received. Thank you.
--- End Message ---
--- Begin Message ---
If I got this right :
preg_match_all ("#\!.*?>(.*?)<#si",$string,$match);
You will have an array ($match[1]) with all your subs in there.
-- georgep
----- Original Message -----
From: "Juan Pablo Aqueveque" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 20, 2003 9:11 PM
Subject: [PHP] a regular expression problem - split text
> Hi all
> I am sorry for the very simple question but I can't doing this.
>
> I have a text like this:
>
> $text=" <!-- 1 --> this is January <!-- 2 --> this is February <!-- 3 -->
> this is March <!-- 4 --> this is April ";
>
> OK.. i want to show e.g. "this is January" in my var $sub_text.
>
> How can i doing this using a regular expressions?
>
> <?php
>
> ereg("(help-me-with-a-regulars-expressions-sentence)",text,$sub_text);
> echo $sub_text[0];
>
> ?>
>
> thanks a lot
>
> ________________________________________________________
> Juan Pablo Aqueveque <[EMAIL PROTECTED]>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Why are you opening the file in append mode?
As the manual says: " a+' - Open for reading and writing; place the file
pointer at the end of the file."
Try using 'r+' instead or rewind the file pointer before reading.
Danny.
----- Original Message -----
From: "Daniel Page" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 25, 2003 11:39 AM
Subject: [PHP] Script under Windows OK, under Linux, not...
> Hi,
>
> I have the following code :
>
> $_fp = fopen("/home/dh2240/mgt/index.php", "a+") or die();
> $_contents = fread($_fp,filesize("/home/dh2240/mgt/index.php"));
> fclose ($_fp);
> //Menu elements
> $_sme = strpos("$_contents","sub_menu_elements");
> echo "sme = $_sme<p>";
> ...
>
> It should display somthing like "sme = 850", after finding the string in
the
> specified file.
>
> Under windows, this script works fine (except replacing the
> "/home/dh2240/mgt/index.php" by "c:/apache/htdocs/mgt/index.php")... it
> seems that the file index.php cannot be opened under linux...
> The file is chmod 777, along with the directory /mgt, and the files
> identical, but still no luck... The fopen does not die(), but it does not
> seem to read any data from the file... I'm confused, and not sure how to
> check what is happening... Anyone got any ideas ?
>
> Cheers,
> Daniel
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
make sure you use:
ImageCreateTrueColor()
to create the thumbnail image and
ImageCopyResampled()
when you copy the image.
Mark C.
> -----Original Message-----
> From: Victor [mailto:[EMAIL PROTECTED]]
> I have a script that takes uploaded images (jpeg only) and makes
> proportionate thumbnails etc, and saves them in jpeg (.jpg) format again
> (default compression of %75 I think) anyway, the thumbnails are UGLY.
--- End Message ---
--- Begin Message ---
Thanks it worked.
- Vic
-----Original Message-----
From: Mark Charette [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 25, 2003 4:42 PM
To: Victor; [EMAIL PROTECTED]
Subject: RE: [PHP] GD jpg thumbnail - ugly discollored
make sure you use:
ImageCreateTrueColor()
to create the thumbnail image and
ImageCopyResampled()
when you copy the image.
Mark C.
> -----Original Message-----
> From: Victor [mailto:[EMAIL PROTECTED]]
> I have a script that takes uploaded images (jpeg only) and makes
> proportionate thumbnails etc, and saves them in jpeg (.jpg) format
again
> (default compression of %75 I think) anyway, the thumbnails are UGLY.
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
After reinstalling w2k on my laptop and installing Apache 2.0, php 4.3.0 I
cannot get cgi-scripts running.
In httpd.conf I have the following line:
ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/" since I have my scripts there.
When calling a script I get
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
So, what do I have to do?
--- End Message ---
--- Begin Message ---
I have a file upload field, and some filename checking code, but it
breaks the code whenever a + is inside the filename it verifies space
and other tags but breaks on + in the name. Anyone know a fix for this
please?
- Vic
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Some sample code would help, but maybe try urldecode('$filename');
RW
Quoting Victor <[EMAIL PROTECTED]>:
### I have a file upload field, and some filename checking code, but it
### breaks the code whenever a + is inside the filename it verifies space
### and other tags but breaks on + in the name. Anyone know a fix for this
### please?
###
### - Vic
###
### ______________________________________________________________________
### Post your free ad now! http://personals.yahoo.ca
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]
http://xend.net
602-971-2791
--- End Message ---
--- Begin Message ---
Here is some sample code:
________________________________________________
$file_name = explode(".", $_FILES['picture']['name']);
$name = str_replace('', '_', $file_name[0]);
# check if file uploaded is good
if
(
!in_array($_FILES['picture']['type'],
$file_type)
|| trim($_FILES['picture']['tmp_name']) == ""
|| trim($_FILES['picture']['tmp_name']) ==
"none"
)
{
echo ('You can upload a JPG or JPEG filetype
only.');
exit;
}
# Add slashes to prevent certain errors
$picture_name = strip_tags($_FILES['picture']['name']);
$picture_name = addslashes($picture_name);
$picture_name = str_replace("\r\n", "", $picture_name);
$picture_name = str_replace(" ", "", $picture_name);
____________________________________________________
-----Original Message-----
From: Richard Whitney [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 25, 2003 5:12 PM
To: Victor
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] + in filenames
Some sample code would help, but maybe try urldecode('$filename');
RW
Quoting Victor <[EMAIL PROTECTED]>:
### I have a file upload field, and some filename checking code, but it
### breaks the code whenever a + is inside the filename it verifies
space
### and other tags but breaks on + in the name. Anyone know a fix for
this
### please?
###
### - Vic
###
###
______________________________________________________________________
### Post your free ad now! http://personals.yahoo.ca
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]
http://xend.net
602-971-2791
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Victor!
What are you trying to accomplish?
Do you want to preserve the original filename?
Why not give uploaded files uniformly unique names?
In other words, where are the +'s coming from?
So, a little more detail, please!
RW
Quoting Victor <[EMAIL PROTECTED]>:
### Here is some sample code:
###
### ________________________________________________
###
### $file_name = explode(".", $_FILES['picture']['name']);
### $name = str_replace('', '_', $file_name[0]);
###
### # check if file uploaded is good
### if
### (
### !in_array($_FILES['picture']['type'],
### $file_type)
### || trim($_FILES['picture']['tmp_name']) == ""
### || trim($_FILES['picture']['tmp_name']) ==
### "none"
### )
### {
### echo ('You can upload a JPG or JPEG filetype
### only.');
###
### exit;
### }
###
### # Add slashes to prevent certain errors
### $picture_name = strip_tags($_FILES['picture']['name']);
### $picture_name = addslashes($picture_name);
### $picture_name = str_replace("\r\n", "", $picture_name);
### $picture_name = str_replace(" ", "", $picture_name);
###
### ____________________________________________________
###
### -----Original Message-----
### From: Richard Whitney [mailto:[EMAIL PROTECTED]]
### Sent: Saturday, January 25, 2003 5:12 PM
### To: Victor
### Cc: [EMAIL PROTECTED]
### Subject: Re: [PHP] + in filenames
###
### Some sample code would help, but maybe try urldecode('$filename');
###
### RW
###
### Quoting Victor <[EMAIL PROTECTED]>:
###
### ### I have a file upload field, and some filename checking code, but it
### ### breaks the code whenever a + is inside the filename it verifies
### space
### ### and other tags but breaks on + in the name. Anyone know a fix for
### this
### ### please?
### ###
### ### - Vic
### ###
### ###
### ______________________________________________________________________
### ### Post your free ad now! http://personals.yahoo.ca
### ###
### ### --
### ### PHP General Mailing List (http://www.php.net/)
### ### To unsubscribe, visit: http://www.php.net/unsub.php
### ###
### ###
###
###
### --
### Richard Whitney
### Transcend Development
### Producing the next phase of your internet presence.
### [EMAIL PROTECTED]
### http://xend.net
### 602-971-2791
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
### ______________________________________________________________________
### Post your free ad now! http://personals.yahoo.ca
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]
http://xend.net
602-971-2791
--- End Message ---
--- Begin Message ---
I DO want preserve the filenames, and the pluses come from the user
(beta testers that deliberately try to hack the script) . all I want to
do is make sure the the script doeasnt breack when a user uploads a file
that has the + character in it's name.
- Vic
-----Original Message-----
From: Richard Whitney [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 25, 2003 5:32 PM
To: Victor
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] + in filenames
Victor!
What are you trying to accomplish?
Do you want to preserve the original filename?
Why not give uploaded files uniformly unique names?
In other words, where are the +'s coming from?
So, a little more detail, please!
RW
Quoting Victor <[EMAIL PROTECTED]>:
### Here is some sample code:
###
### ________________________________________________
###
### $file_name = explode(".", $_FILES['picture']['name']);
### $name = str_replace('', '_', $file_name[0]);
###
### # check if file uploaded is good
### if
### (
### !in_array($_FILES['picture']['type'],
### $file_type)
### || trim($_FILES['picture']['tmp_name']) == ""
### || trim($_FILES['picture']['tmp_name']) ==
### "none"
### )
### {
### echo ('You can upload a JPG or JPEG filetype
### only.');
###
### exit;
### }
###
### # Add slashes to prevent certain errors
### $picture_name = strip_tags($_FILES['picture']['name']);
### $picture_name = addslashes($picture_name);
### $picture_name = str_replace("\r\n", "", $picture_name);
### $picture_name = str_replace(" ", "", $picture_name);
###
### ____________________________________________________
###
### -----Original Message-----
### From: Richard Whitney [mailto:[EMAIL PROTECTED]]
### Sent: Saturday, January 25, 2003 5:12 PM
### To: Victor
### Cc: [EMAIL PROTECTED]
### Subject: Re: [PHP] + in filenames
###
### Some sample code would help, but maybe try urldecode('$filename');
###
### RW
###
### Quoting Victor <[EMAIL PROTECTED]>:
###
### ### I have a file upload field, and some filename checking code, but
it
### ### breaks the code whenever a + is inside the filename it verifies
### space
### ### and other tags but breaks on + in the name. Anyone know a fix
for
### this
### ### please?
### ###
### ### - Vic
### ###
### ###
###
______________________________________________________________________
### ### Post your free ad now! http://personals.yahoo.ca
### ###
### ### --
### ### PHP General Mailing List (http://www.php.net/)
### ### To unsubscribe, visit: http://www.php.net/unsub.php
### ###
### ###
###
###
### --
### Richard Whitney
### Transcend Development
### Producing the next phase of your internet presence.
### [EMAIL PROTECTED]
### http://xend.net
### 602-971-2791
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
______________________________________________________________________
### Post your free ad now! http://personals.yahoo.ca
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]
http://xend.net
602-971-2791
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Does anyone have a PHP script to enter cron jobs? I have a limited control
panel (ensim) that doesn't have anyway to do cron, and I don't know how to
do it at the command line yet. Anyone have a good tutorial or a PHP script
to do this?
Thanks!
--- End Message ---
--- Begin Message ---
The problem is, PHP would have to be running as root. This creates a
huge security risk... if I was you, I'd just learn to edit cron jobs at
the command line.
Nicole wrote:
Does anyone have a PHP script to enter cron jobs? I have a limited control
panel (ensim) that doesn't have anyway to do cron, and I don't know how to
do it at the command line yet. Anyone have a good tutorial or a PHP script
to do this?
Thanks!
--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.
--- End Message ---
--- Begin Message ---
Well, if you really wanted to, you could create a php script, and then have
a meta refresh tag set to refresh the page whenever you want, and then just
leave the page open in your browser :p
"Nicole" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Does anyone have a PHP script to enter cron jobs? I have a limited control
> panel (ensim) that doesn't have anyway to do cron, and I don't know how to
> do it at the command line yet. Anyone have a good tutorial or a PHP script
> to do this?
>
> Thanks!
>
>
>
--- End Message ---
--- Begin Message ---
Thanks. But I would think if you can run cron jobs as certain users, you
could create cron jobs for those users only. I mean, if you can do it with
CPanel or these other Control Panels, then why not? It wouldn't have to run
as root? I have a good bit to learn about linux. I am new to getting around
in ssh.
I am learning from the command line now. It doesn't seem too bad yet. Not
sure.
Thanks!
"Leif K-Brooks" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The problem is, PHP would have to be running as root. This creates a
> huge security risk... if I was you, I'd just learn to edit cron jobs at
> the command line.
>
> Nicole wrote:
>
> >Does anyone have a PHP script to enter cron jobs? I have a limited
control
> >panel (ensim) that doesn't have anyway to do cron, and I don't know how
to
> >do it at the command line yet. Anyone have a good tutorial or a PHP
script
> >to do this?
> >
> >Thanks!
> >
> >
> >
> >
> >
> >
>
> --
> The above message is encrypted with double rot13 encoding. Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.
>
>
>
--- End Message ---
--- Begin Message ---
LOL. Thanks; that's ok. ;) That wouldn't cut it, I'm afraid. ;)
"Alex" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Well, if you really wanted to, you could create a php script, and then
have
> a meta refresh tag set to refresh the page whenever you want, and then
just
> leave the page open in your browser :p
>
> "Nicole" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Does anyone have a PHP script to enter cron jobs? I have a limited
control
> > panel (ensim) that doesn't have anyway to do cron, and I don't know how
to
> > do it at the command line yet. Anyone have a good tutorial or a PHP
script
> > to do this?
> >
> > Thanks!
> >
> >
> >
>
>
--- End Message ---
--- Begin Message ---
Hi,
Sunday, January 26, 2003, 7:58:18 AM, you wrote:
N> Does anyone have a PHP script to enter cron jobs? I have a limited control
N> panel (ensim) that doesn't have anyway to do cron, and I don't know how to
N> do it at the command line yet. Anyone have a good tutorial or a PHP script
N> to do this?
N> Thanks!
If you want to change cron jobs for the web server that is easy just
exec('crontab '.$newcronlist)
That should replace the current cron jobs with the new ones.
If you want to manipulate other users that is a whole new can o worms that is
probably full of security issues. Then you would need a root cron job to parse
an external file owned by the web server that it queries for any updates that
are needed and does them for you.
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Hello everybody, I make a function that lets you convert a recordset
obtained via mysql_query() into an XML string:
maybe could be helpfull to yours
this is the function
it have 3 parameters: $rs is the recordset you want to convert
$padre is the name for the parent node
that will contain every record on the recordset
$hijo is the name for the child node
that will contain a single record in the recordset
function rs2xml($rs,$padre,$hijo){
$num_campos=mysql_num_fields($rs);
$num_filas=mysql_num_rows($rs);
if($padre!="-1")
$xml="<$padre>\n";
else
$xml="";
$cont1=0;
while($cont1<$num_filas){
$fila=mysql_fetch_array($rs);
$xml.="<$hijo>\n";
$cont=0;
while($cont<$num_campos){
$nombre_campo=mysql_field_name($rs,$cont);
$valor_campo=$fila[$cont];
$xml.="<".$nombre_campo.">".$valor_campo."</".$nombre_campo.">\n";
$cont++;
}
$xml.="</$hijo>\n";
$cont1++;
}
if($padre!="-1")
$xml.="</$padre>\n";
return $xml;
}
I hope this will be helpful for you
OCTAVIO HERRERA
--- End Message ---
--- Begin Message ---
Personally, I would do it differently, but thats just me... However one
modification I would suggest you make:
The Line:
$xml.="<".$nombre_campo.">".$valor_campo."</".$nombre_campo.">\n";
would probably be better as this:
$xml.="<".$nombre_campo.">".htmlspecialchars($valor_campo)."</".$nombre_camp
o.">\n";
just incase there is an & or a " in the data, and some XML parsers will
throw an error saying that the XML file is not well formed.
-----Original Message-----
From: Octavio Herrera [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 26 January 2003 9:36 AM
To: [EMAIL PROTECTED]
Subject: [PHP] converting a Recorset into an XML string
Hello everybody, I make a function that lets you convert a recordset
obtained via mysql_query() into an XML string:
maybe could be helpfull to yours
this is the function
it have 3 parameters: $rs is the recordset you want to convert
$padre is the name for the parent node
that will contain every record on the recordset
$hijo is the name for the child node
that will contain a single record in the recordset
function rs2xml($rs,$padre,$hijo){
$num_campos=mysql_num_fields($rs);
$num_filas=mysql_num_rows($rs);
if($padre!="-1")
$xml="<$padre>\n";
else
$xml="";
$cont1=0;
while($cont1<$num_filas){
$fila=mysql_fetch_array($rs);
$xml.="<$hijo>\n";
$cont=0;
while($cont<$num_campos){
$nombre_campo=mysql_field_name($rs,$cont);
$valor_campo=$fila[$cont];
$xml.="<".$nombre_campo.">".$valor_campo."</".$nombre_campo.">\n";
$cont++;
}
$xml.="</$hijo>\n";
$cont1++;
}
if($padre!="-1")
$xml.="</$padre>\n";
return $xml;
}
I hope this will be helpful for you
OCTAVIO HERRERA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I tried to use the below but it does not work. Please help!
-----Original Message-----
From: Michael Sweeney [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 22, 2003 10:29 AM
To: Ben C.
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Select value for driopdown box
Assuming that you know which state is selected before you build the
select list:
$sel_state = $_REQUEST['state'];
...
while($row = mysql_fetch_array($result)) {
$buyerid = $row['buyerid'];
$state = $row['state'];
$selected = $state == $sel_state ? "selected=\"selected\"" : "";
$option_block .= "<option value=\"$state\" $selected>".
"$state</option>\n";
}
That will put the string "selected=\"selected\"" (xhtml compliant) into
the option statement for the state that was selected.
..michael..
On Wed, 2003-01-22 at 10:14, Ben C. wrote:
> I am using the query below to edit a record. I want to edit the field
which has a list of states in a dropdown box. I want to have the state
that is in the selected field shown as the selected state. How would I do
this?
>
>
> Query
> -------------------------
> <?
> $sql = "SELECT *
> FROM $table_name
> WHERE buyerid = \"$buyerid\"
> ";
>
> $result = @mysql_query($sql,$connection) or die(mysql_error());
>
>
> while ($row = mysql_fetch_array($result)) {
> $buyerid = $row['buyerid'];
> $state = $row['state'];
>
> $option_block .= "<option value=\"$state\">$state</option>";
> }
>
> $display_block = "
>
> <select name=\"state\" class=Pgtext>
> $option_block
> </select>
> ?>
>
> <tr>
> <td width="258" class="Pgtext" height="21">State</td>
> <td width="259" height="21"><? echo $display_block; ?></td>
> </tr>
>
> --------------------------------
--
Michael Sweeney <[EMAIL PROTECTED]>
Verisity Design, Inc
--- End Message ---
--- Begin Message ---
This line:
$selected = $state == $sel_state ? "selected=\"selected\"" : "";
should probably be:
$selected = (($state == $sel_state) ? "selected=\"selected\"" : "");
I haven't tested this correction, but have had to use the parentheses in my
code many times to fix problems with using ? :
Greg
--
phpDocumentor
http://www.phpdoc.org
"Ben C." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I tried to use the below but it does not work. Please help!
>
> -----Original Message-----
> From: Michael Sweeney [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 22, 2003 10:29 AM
> To: Ben C.
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Select value for driopdown box
>
>
> Assuming that you know which state is selected before you build the
> select list:
>
> $sel_state = $_REQUEST['state'];
>
> ...
>
> while($row = mysql_fetch_array($result)) {
> $buyerid = $row['buyerid'];
> $state = $row['state'];
> $selected = $state == $sel_state ? "selected=\"selected\"" : "";
>
> $option_block .= "<option value=\"$state\" $selected>".
> "$state</option>\n";
> }
>
> That will put the string "selected=\"selected\"" (xhtml compliant) into
> the option statement for the state that was selected.
>
> ..michael..
>
> On Wed, 2003-01-22 at 10:14, Ben C. wrote:
> > I am using the query below to edit a record. I want to edit the field
> which has a list of states in a dropdown box. I want to have the state
> that is in the selected field shown as the selected state. How would I do
> this?
> >
> >
> > Query
> > -------------------------
> > <?
> > $sql = "SELECT *
> > FROM $table_name
> > WHERE buyerid = \"$buyerid\"
> > ";
> >
> > $result = @mysql_query($sql,$connection) or die(mysql_error());
> >
> >
> > while ($row = mysql_fetch_array($result)) {
> > $buyerid = $row['buyerid'];
> > $state = $row['state'];
> >
> > $option_block .= "<option value=\"$state\">$state</option>";
> > }
> >
> > $display_block = "
> >
> > <select name=\"state\" class=Pgtext>
> > $option_block
> > </select>
> > ?>
> >
> > <tr>
> > <td width="258" class="Pgtext" height="21">State</td>
> > <td width="259" height="21"><? echo $display_block; ?></td>
> > </tr>
> >
> > --------------------------------
> --
> Michael Sweeney <[EMAIL PROTECTED]>
> Verisity Design, Inc
>
--- End Message ---
--- Begin Message ---
Hi,
Using PostgreSql 7.2 + PHP I am trying to do a SELECT that will
choose all records except ones that have a certain id number. I can't seem to
get the syntax to work.
Here's the code:
"SELECT * FROM rap WHERE NOT rsponsor = '{$_SESSION['sid']}' ORDER by
rsname,rfname,rcountry,rcity DESC LIMIT 20";
What I get is all the records including those with '{$_SESSION['sid']}' .
How can I accomplish an exclusion in a table-wide search?
Any help or advice will be greatly appreciated.
Tia,
Andre
--- End Message ---
--- Begin Message ---
SELECT * FROM rap WHERE rsponsor != '{$_SESSION['sid']}' ORDER by
rsname,rfname,rcountry,rcity DESC LIMIT 20
SELECT * FROM rap WHERE rsponsor NOT IN ('{$_SESSION['sid']}') ORDER by
rsname,rfname,rcountry,rcity DESC LIMIT 20
-----Original Message-----
From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 26 January 2003 11:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] SELECT with WHILE NOT
Hi,
Using PostgreSql 7.2 + PHP I am trying to do a SELECT that will
choose all records except ones that have a certain id number. I can't seem
to
get the syntax to work.
Here's the code:
"SELECT * FROM rap WHERE NOT rsponsor = '{$_SESSION['sid']}' ORDER by
rsname,rfname,rcountry,rcity DESC LIMIT 20";
What I get is all the records including those with '{$_SESSION['sid']}' .
How can I accomplish an exclusion in a table-wide search?
Any help or advice will be greatly appreciated.
Tia,
Andre
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi Sean,
Before sending to the list, I had already tried your first suggestion and
ended up with only the records that I wanted excluded.
Your second suggestion with "NOT IN" works like a charm. (There wasn't much
about 'NOT' in the docs, and I must have missed the 'IN' part.)
Thanks for your help!
Regards,
Andre
On Saturday 25 January 2003 07:48 pm, Sean Malloy wrote:
> SELECT * FROM rap WHERE rsponsor != '{$_SESSION['sid']}' ORDER by
> rsname,rfname,rcountry,rcity DESC LIMIT 20
>
> SELECT * FROM rap WHERE rsponsor NOT IN ('{$_SESSION['sid']}') ORDER by
> rsname,rfname,rcountry,rcity DESC LIMIT 20
>
> -----Original Message-----
> From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 26 January 2003 11:28 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] SELECT with WHILE NOT
>
>
> Hi,
>
> Using PostgreSql 7.2 + PHP I am trying to do a SELECT that will
> choose all records except ones that have a certain id number. I can't seem
> to
> get the syntax to work.
>
> Here's the code:
>
> "SELECT * FROM rap WHERE NOT rsponsor = '{$_SESSION['sid']}' ORDER by
> rsname,rfname,rcountry,rcity DESC LIMIT 20";
>
> What I get is all the records including those with '{$_SESSION['sid']}' .
>
> How can I accomplish an exclusion in a table-wide search?
>
> Any help or advice will be greatly appreciated.
>
> Tia,
> Andre
--- End Message ---
--- Begin Message ---
Hello,
On 01/25/2003 01:40 PM, Dominik Wittenbeck wrote:
I am currently developing a object to relational mapping layer for PHP. It's
NOT a simple treat all databases like one kind of layer (although it does
involve it to preserve extensibility) but an XML based intermediate layer
that creates both, table structures, following a conventional scheme and PHP
classes that allow, OO access to these tables.
I have enclosed the XML file that represents the intermediate layer. Its
pretty readable even without the XML schema.
I am currently under development, so don't expect anything useful in less
than a few weeks
Question:
Does anyone of you know anyone who has tried something similar, because my
research on the subject grows thin? Is something like this of public
interest at all, or would you prefer accessing your datastructure the old
fashion way?
You have pretty much describe Metastorage. It is basically a generator
application that lets you model classes of objects that are mapped and
stored in relational database database.
You just need to to describe your classes also in a XML file with the
class variables, validation rules, relationships between classes and the
types of functions that your application needs to manipulate the classes
objects.
Metastorage generates all the code for the classes ready to use in your
applications. That includes also a separate class with code to install
the database schema. The resulting classes API is database independent.
This means that you do not need to change your application to use the
same classes with different types databases. Many types of databases are
supported. Still, you do not need to write absolutely any SQL in
anywhere. Metastorage generates adequate code for you where needed.
I do not mean to discourage from continuing your work, but since there
is a great deal of overlap between Metastorage and what you have in
mind, you are most welcomed at least to eveluate Metastorage if not also
contribute in anyway to its development.
Metastorage is Open Source and is avaliable here:
http://www.meta-language.net/news-2002-12-09-metastorage.html
http://www.meta-language.net/metastorage.html
--
Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---
Sounds most interesting (and far more ambicious, than what I had in mind).
I'll probably do you wrong by not grasping the full extend of the project,
but in short, did I get it right:
XML2UML2ProgrammingLanguage
I know this probably doesn't grasp the whole scope ;-) But it's a VERY
interesting project, and I will have a look into it, that's for sure.
CU!
Dominik
"Manuel Lemos" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> On 01/25/2003 01:40 PM, Dominik Wittenbeck wrote:
> > I am currently developing a object to relational mapping layer for PHP.
It's
> > NOT a simple treat all databases like one kind of layer (although it
does
> > involve it to preserve extensibility) but an XML based intermediate
layer
> > that creates both, table structures, following a conventional scheme and
PHP
> > classes that allow, OO access to these tables.
> > I have enclosed the XML file that represents the intermediate layer. Its
> > pretty readable even without the XML schema.
> > I am currently under development, so don't expect anything useful in
less
> > than a few weeks
> >
> > Question:
> > Does anyone of you know anyone who has tried something similar, because
my
> > research on the subject grows thin? Is something like this of public
> > interest at all, or would you prefer accessing your datastructure the
old
> > fashion way?
>
> You have pretty much describe Metastorage. It is basically a generator
> application that lets you model classes of objects that are mapped and
> stored in relational database database.
>
> You just need to to describe your classes also in a XML file with the
> class variables, validation rules, relationships between classes and the
> types of functions that your application needs to manipulate the classes
> objects.
>
> Metastorage generates all the code for the classes ready to use in your
> applications. That includes also a separate class with code to install
> the database schema. The resulting classes API is database independent.
> This means that you do not need to change your application to use the
> same classes with different types databases. Many types of databases are
> supported. Still, you do not need to write absolutely any SQL in
> anywhere. Metastorage generates adequate code for you where needed.
>
> I do not mean to discourage from continuing your work, but since there
> is a great deal of overlap between Metastorage and what you have in
> mind, you are most welcomed at least to eveluate Metastorage if not also
> contribute in anyway to its development.
>
> Metastorage is Open Source and is avaliable here:
>
> http://www.meta-language.net/news-2002-12-09-metastorage.html
>
> http://www.meta-language.net/metastorage.html
>
>
> --
>
> Regards,
> Manuel Lemos
>
--- End Message ---
--- Begin Message ---
Hello everybody,
I was wondering if someone can tell me how do I XOR a given string with
some hash .. like MD5 hash or something. I know how to do this in C - it's
more than easy but with PHP I can't find a way at all.
Thank you all in advance.
Regards,
Peter
--- End Message ---
--- Begin Message ---
Hi,
Sunday, January 26, 2003, 10:02:40 AM, you wrote:
PL> Hello everybody,
PL> I was wondering if someone can tell me how do I XOR a given string with
PL> some hash .. like MD5 hash or something. I know how to do this in C - it's
PL> more than easy but with PHP I can't find a way at all.
PL> Thank you all in advance.
PL> Regards,
PL> Peter
$out = $string1 ^ $string2;
--
regards,
Tom
--- End Message ---
--- Begin Message ---
I would like to write a function to check if the contents of a directory, its files,
have been changed.
The idea is to check the directory every 2 minutes and take some actions if some files
were updated
or new files added.
Does anyone has any ideas?
I was considering listing the files (name, date modified, size) on a variable array,
then list again and compare both arrays. In case there are different, take some action.
Thank you,
C.F.
--- End Message ---
--- Begin Message ---
Hi Carlos,
Directories are just normal files thus they have "Last Modified" and "Last
Changed" time stamps. So the quickest and easiest way is to check these
times periodically and if any of them has changed then there was some
activity other than reading in the directory. You can get the timestamps
using stat() function.
Regards,
Peter
"Carlos Fernando Scheidecker Antunes" <[EMAIL PROTECTED]> wrote in
message 003301c2c4df$d3fa42e0$9d505ad1@Nando0">news:003301c2c4df$d3fa42e0$9d505ad1@Nando0...
I would like to write a function to check if the contents of a directory,
its files, have been changed.
The idea is to check the directory every 2 minutes and take some actions if
some files were updated
or new files added.
Does anyone has any ideas?
I was considering listing the files (name, date modified, size) on a
variable array, then list again and compare both arrays. In case there are
different, take some action.
Thank you,
C.F.
--- End Message ---
--- Begin Message ---
Hi Carlos,
I've written a similar script in the past, except mine was to backup
files and then automatically restore them if they were accidentally
deleted (I had 75 people that had to modify 1 excel document at least
once a day).
What I have done is write a script that gets a list of files from the
directory using opendir, it then does a md5_file or sha1_file hash on
the file and puts it into an array, something like $files[filename] =
hash_value, then at the end of the script it serializes the array and
writes it to a text file, then it copies the file to a backup location.
The next time the script is run it opens the text file with the hashes,
opens the directory and checks makes sure each file still exists, if it
doesn't it copies it out from the backup location. If the file does
exist it updates the hash, copies the file over again because it has
changed and ends.
You could store the file hashes in a temporary file, then compare the
hashes each time the script is run, if the hashes do not match your file
has changed and you should take whatever action you need to take.
Note that sha1_file is only available in PHP 4.3.0 and newer, md5_file
will be available in older versions of PHP as well.
Jason
On Sat, 2003-01-25 at 19:08, Carlos Fernando Scheidecker Antunes wrote:
> I would like to write a function to check if the contents of a directory, its files,
>have been changed.
> The idea is to check the directory every 2 minutes and take some actions if some
>files were updated
> or new files added.
>
> Does anyone has any ideas?
>
> I was considering listing the files (name, date modified, size) on a variable array,
>then list again and compare both arrays. In case there are different, take some
>action.
>
> Thank you,
>
> C.F.
--- End Message ---
--- Begin Message ---
Hi there Guys!
I'll start to write an application which will be used to send large
amounts of mail to users in a DB. All these mails to be sent shoul be
personalized. Since i understand, and please correct me if im wrong, the
mail() function is not a good option for this purpose. (the amount of mail
to be sent may vary from 50 to 800 messages). I have considered using some
masive mail application such majordomo or EZMLM. EZMLM is not easily
configurable for sending personalized mail, and majordomo requires
sendmail, (i would prefer to use qmail), i know about patches to be done
so it works with qmail, but i dont consider them really clean.
What would you guys suggest ?? should i jump into majordomo - sendmail,
or do you know something else that might be a better solution.
Thanks a lot in Advance, regards
------------------------------------------------------------------
"Few are those who see with their own eyes and feel with their own
hearts."
Albert Einstein
-----------------------------------------------------------------
Maciek Ruckaber Bielecki
--- End Message ---
--- Begin Message ---
It is incredibly easy to write a short little php script that edits a
template and submits it directly to qmail-inject; if you're using qmail
already php mail()/sendmail is just a wrapper to qmail-inject. I use
qmail-inject directly because it allows me to write my own VERP and process
bounces against the database.
A little Pentium 200 running Linux, MySQL, php4, and qmail with 100 queues
can more than saturate a T1 line when used for mailing that way! 800
messages isn't close to being "massive" - that many can be sent in way less
than a minute (depending on size, of course - a T1 isn't that big anymore
...).
> -----Original Message-----
> From: Maciek Ruckgaber Bielecki [mailto:[EMAIL PROTECTED]]
> I'll start to write an application which will be used to send large
> amounts of mail to users in a DB. All these mails to be sent shoul be
> personalized. Since i understand, and please correct me if im wrong, the
> mail() function is not a good option for this purpose. (the amount of mail
> to be sent may vary from 50 to 800 messages).
--- End Message ---
--- Begin Message ---
On Sunday 26 January 2003 12:17, Maciek Ruckgaber Bielecki wrote:
> Hi there Guys!
>
> I'll start to write an application which will be used to send large
> amounts of mail to users in a DB. All these mails to be sent shoul be
> personalized. Since i understand, and please correct me if im wrong, the
> mail() function is not a good option for this purpose. (the amount of mail
> to be sent may vary from 50 to 800 messages). I have considered using some
> masive mail application such majordomo or EZMLM. EZMLM is not easily
> configurable for sending personalized mail, and majordomo requires
> sendmail, (i would prefer to use qmail), i know about patches to be done
> so it works with qmail, but i dont consider them really clean.
>
> What would you guys suggest ??
If you haven't already done so, look in the archives -- lots of useful info
have been repeated again and again (and again).
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
QOTD:
"Everything I am today I owe to people, whom it is now
to late to punish."
*/
--- End Message ---
--- Begin Message ---
Trying to get java working so I can make native calls.
I've got php.ini setup and it seems to work (i.e., I can use the online
(php.net) example and create a java.lang.System object, and access
properties from it).
However, created my own class in a directory I specified in my
java.class.path directive and it doesn't seem to work. I get "Document
contains no data". I can comment out the method call on $obj and it
prints my message, so I can only assume it's creating the object.
However, if I call a method on the object, I get the message. By watching
the task bar, I see the "Connecting to localhost..."/"Sending request to
localhost" sequence being repeated every 5 secs or so.
Can anyone help me out? I'd really appreciate it. See code below:
<?
$obj = new Java('com.x.reports.Serv');
print $obj->getMsg();
?>
--- java code stored off of class path in com/x/reports ---
package com.x.reports;
class Serv
{
public String msg = "THIS IS A TEST MESSAGE";
Serv()
{
}
public String getMsg()
{
return this.msg;
}
}
--- End Message ---
--- Begin Message ---
Download: http://php.weblogs.com/adodb_date_time_library
PHP native date functions use integer timestamps for computations.
Because of this, dates are restricted to the years 1901-2038 on Unix
and 1970-2038 on Windows due to integer overflow for dates
beyond those years.
This has been frustrating for me, so i developed this library to overcome
these limitation by replacing the native function's signed integers
(normally
32-bits) with PHP floating point numbers (normally 64-bits) when
necessary. This library supports dates from 100 A.D. to billions of years in
the future.
It also fixes the problem of negative timestamps (pre-1970) not supported
on Windows.
To use, simply replace
getdate() with adodb_getdate()
date() with adodb_date()
gmdate() with adodb_gmdate()
mktime() with adodb_mktime()
gmmktime() with adodb_gmmktime()
This library is available as a standalone PHP file, and you do not have
to use the ADOdb database abstraction classes if you do not want to.
Performance
For high speed, this library uses the native date functions where possible,
and only switches to PHP code when the dates fall outside the 32-bit signed
integer range.
Quality Assurance
For QA, several thousand dates were randomly generated and the results
of the adodb_* date functions were compared with the native PHP versions.
Years between 100 A.D. and 3000 A.D were also tested. The code is
Y2K compliant
--- End Message ---
--- Begin Message ---
hi guys i am trying to create callback error functions handlers , i was
wondering if there was a way to get the file and line caught in a error
function say with a database abstraction query without having to explicitly
put the line and number in the query function , at the moment if i put line
and file inside the error handler it will only display where the error was
caught inside the handler itself :|
--- End Message ---