php-general Digest 24 Jun 2006 14:28:54 -0000 Issue 4203

Topics (messages 238560 through 238578):

Re: GET, POST, REQUEST
        238560 by: Manuel Lemos

Re: comparing a string
        238561 by: Bill Guion

Re: GD problems
        238562 by: Beauford
        238564 by: Beauford
        238567 by: chris smith
        238574 by: Beauford
        238575 by: chris smith

Re: Problem displaying a mysql database field
        238563 by: Jochem Maas

Re: xmldoc
        238565 by: Michael Rasmussen
        238568 by: Ahmed Saad

Re: templating
        238566 by: Ryan A

Re: STRING TO ASCII CHARACTERS
        238569 by: Ahmed Saad

Cookie Question
        238570 by: Tom Ray [Lists]
        238578 by: tedd

Re: detect user click "stop" button in browser
        238571 by: Ahmed Saad

Extracting XMP tags from pictures
        238572 by: Dotan Cohen
        238573 by: chris smith

login problem
        238576 by: suresh kumar
        238577 by: kartikay malhotra

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 ---
Hello,

on 06/23/2006 09:46 AM John Nichel said the following:
>>> I come from languages
>>> where
>>> you not only have to initialize a variable but have to declare it as
>>> well so
>>> initializing comes natural, I feel wrong if I don't do it, even if the
>>> interpreter does not care.
>>
>> Just to be pedantic...
>>
>> The interpreter actually DOES care, but you have to be wise enough to
>> enable E_NOTICE messages for the interpreter to tell you that it does
>> care.
>>
>> You may want to get in the habit of using .htaccess to do that, as you
>> will be more comfy with PHP helping you catch any typos in failing to
>> initialize vars.
>>
>> :-)
> 
> I do that here....our development and staging servers have all errors
> turned on whereas on our production server, pretty much everything is
> turned off.  In a /perfect/ world, you would never see an error in my
> code, as I _try_ to write clean code, and trap all the errors before
> they get to the screen (no, not by the use of '@').  Since this is not a
> perfect world, and I don't always write clean code, it's nice to see
> those notices/errors pop up on the screen before the code gets live.  ;)

You should also leave all error flags on (except maybe for E_STRICT),
precisely because the world is not perfect. In the real world some bugs
may still escape when you ship the code to production. So you will want
to know of any notices caused by missed bugs, so you can fixed them
sooner rather than later.

What you should not do in production is to show error messages on the
page. I recommend the following php.ini settings:

http://www.phpclasses.org/browse/file/5051.html

What I do is to make PHP generate an error log and then can keep
monitoring it. If there are any log lines get added, the monitoring
script that is run regularly from cron, sends the added lines by urgent
mail to me so I can act promptly and fix any bugs before it is to late
to avoid major damage.

I use this class to watch PHP error log.

http://www.phpclasses.org/logwatcher

For sending really urgent mail, I use this class. It comes with a
wrapper function named urgent_mail(). It emulates the mail() function
but it attempts to inject the message directly in recipient SMTP server,
thus bypassing the local mail server, which is a good thing as the local
mail server may be too busy or not working at all (think of a disk full
or exhausted RAM).

http://www.phpclasses.org/mimemessage


I lost count of how many hours these small scripts save me of major
headaches and greater damages that could have been caused by often
subtil bugs.

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
At 9:28 PM -0500 6/21/06, Rafael wrote:

snip
        The only possible values of strcmp() are: 1, 0 & -1.

Hmmm. My manual says: "Compares two strings; returns a number less than 0 if the first string is less than the second, 0 if the two strings are equal, and a number greater than 0 if the first string is greater than the second." Sounds like values other than -1, 0, and +1 are possible.

     -----===== Bill =====-----
--

You never know who's right, but you always know who's in charge.

--- End Message ---
--- Begin Message ---
 
Here's something else I just noticed. When I run the script below in Windows
it works fine, in Linux I get this error:

Fatal error: Call to undefined function bcmod() in
/usr/local/apache/htdocs/home/cap.php on line 62

This is line 62: $pos_x = bcmod($code,$size_x-60) +3;

Linux is running PHP 5.0, Windows 4.4.

Thanks

-------

<?

//Select size of image
$size_x = "75";
$size_y = "25";

//generate random string
$code = mt_rand("100000","999999");

//store captcha code in session vars
session_start(  );
$_SESSION['captcha_code'] = $code;

//create image to play with
$image = imageCreate($size_x,$size_y);


//add content to image
//------------------------------------------------------


//make background white - first colour allocated is background
$background = imageColorAllocate($image,255,255,255);



//select grey content number
$text_number1 = mt_rand("0","150");
$text_number2 = mt_rand("0","150");
$text_number3 = mt_rand("0","150");

//allocate colours
$white = imageColorAllocate($image,255,255,255);
$black = imageColorAllocate($image,0,0,0);
$text  =
imageColorAllocate($image,$text_number1,$text_number2,$text_number3);



//get number of dots to draw
$total_dots = ($size_x * $size_y)/15;

//draw many many dots that are the same colour as the text
for($counter = 0; $counter < $total_dots; $counter++) {
  //get positions for dot
  $pos_x = mt_rand("0",$size_x);
  $pos_y = mt_rand("0",$size_y);

  //draw dot
  imageSetPixel($image,$pos_x,$pos_y,$text);
};



//draw border
imageRectangle($image,0,0,$size_x-1,$size_y-1,$black);



//get coordinates of position for string
//on the font 5 size, each char is 15 pixels high by 9 pixels wide
//with 6 digits at a width of 9, the code is 54 pixels wide
$pos_x = bcmod($code,$size_x-60) +3;
$pos_y = bcmod($code,$size_y-15);

//draw random number
imageString($image,  5,  $pos_x,  $pos_y,  $code,  $text);


//------------------------------------------------------
//end add content to image


//send browser headers
header("Content-Type: image/png");


//send image to browser
echo imagePNG($image);


//destroy image
imageDestroy($image);



?>

--- End Message ---
--- Begin Message ---
OK, so that works. So is gd (or one of the required programs) wonky then - I
mean 4 out of 5 scripts I downloaded didn't work. I can't see all of these
people being bad programmers.., but the funny thing is they all work on
Windows. So that can't be it - is there still something I'm missing in Linux
that is required by these scripts? This is what I've been fighting with the
last two weeks.

Thanks for all the help.

-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: June 23, 2006 2:20 AM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] GD problems

Beauford wrote:
> Since I know nothing of how this works, does this actually create a 
> physical image, and if it does I'm assuming it would be in the 
> originating directory from where the script was run  - if this is the
case, I got nothing.
> 
> This is a moot point now as I have done what I need without using gd, 
> but it would be nice to find out what the problem is.
> 
> Thanks.
> 
>> Anyone know of a way I can test this further. A small script perhaps.
> 
> <?php
>   $image = imagecreatetruecolor(50, 50);
>   imagefilledrectangle($image, 0, 0, 50, 50, 0xffffff);
>   imagejpeg($image);
> ?>

It creates it in memory and it's a 50 x 50 white square.

Change the 0xffffff to 0xFF6600 and it should be a red square.

--
Postgresql & php tutorials
http://www.designmagick.com/

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

--- End Message ---
--- Begin Message ---
On 6/24/06, Beauford <[EMAIL PROTECTED]> wrote:

Here's something else I just noticed. When I run the script below in Windows
it works fine, in Linux I get this error:

Fatal error: Call to undefined function bcmod() in
/usr/local/apache/htdocs/home/cap.php on line 62

David told you about this 3-4 replies ago.

http://marc.theaimsgroup.com/?l=php-general&m=115095875203362&w=2

bcmod is a bcmath function, if you don't have bcmath installed you
can't use that function.

http://www.php.net/manual/en/ref.bc.php

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Honestly, I've never seen anything so ridiculous. How is one to know that in
order to get one program to work you have to install 28 others. I'm not
trying to be a smart ass here, but seriously - No where in any documentation
I've read does it say I need to install all these other packages. Would it
just not be simpler to add them to the original package, and then check
whether or not it's installed - if not, install it. Or at the very least
include all the packages needed and the user can install them if need be. By
the way, I never saw Marks post - it might have saved me some time if I had
though.

Thanks to everyone.

B

-----Original Message-----
From: chris smith [mailto:[EMAIL PROTECTED]
Sent: June 23, 2006 6:11 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] GD problems

On 6/24/06, Beauford <[EMAIL PROTECTED]> wrote:
>
> Here's something else I just noticed. When I run the script below in 
> Windows it works fine, in Linux I get this error:
>
> Fatal error: Call to undefined function bcmod() in 
> /usr/local/apache/htdocs/home/cap.php on line 62

David told you about this 3-4 replies ago.

http://marc.theaimsgroup.com/?l=php-general&m=115095875203362&w=2

bcmod is a bcmath function, if you don't have bcmath installed you can't use
that function.

http://www.php.net/manual/en/ref.bc.php

--
Postgresql & php tutorials
http://www.designmagick.com/

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

--- End Message ---
--- Begin Message ---
On 6/24/06, Beauford <[EMAIL PROTECTED]> wrote:
Honestly, I've never seen anything so ridiculous. How is one to know that in
order to get one program to work you have to install 28 others. I'm not
trying to be a smart ass here, but seriously - No where in any documentation
I've read does it say I need to install all these other packages. Would it
just not be simpler to add them to the original package, and then check
whether or not it's installed - if not, install it. Or at the very least
include all the packages needed and the user can install them if need be. By
the way, I never saw Marks post - it might have saved me some time if I had
though.

Complain to the author(s) of the scripts. GD doesn't need bcmath, that
script does.
--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Don wrote:
> Hi,
>  
> I have a varchar field in a MySQL database that contains a line of text like
> so:
>  
> "This is a line if text"
>  
> The double quotes are included in the database field.
>  
> I cannot seem to display it on my HTML page, it always shows as blank.  I
> have tried using both the stripslashes() and the html_entity_decode() but it
> still shows as blank.
>  
> How can I display this please???

post some code and maybe someone can help.

also use var_dump() et al to dump the contents of the vars/vals you
retrieve from the DB - that might give you a clue.

and lastly have you tried do 'view source' in order to try and understand
what might be going on?

>  
> Tks,
> Don
> 

--- End Message ---
--- Begin Message ---
On Fri, 23 Jun 2006 16:12:56 -0300, Mariano Guadagnini wrote:

xmldoc, which is found in the extension DOM XML is no longer part of
PHP as of PHP >= 5.0. It has been replaced by DOM. See
http://dk2.php.net/manual/en/ref.dom.php
http://dk2.php.net/manual/en/ref.domxml.php

> Maybe when parsing the xml, the function throws an exception. That
> happened to me with PHP 5 xml builtin support, which uses libxml to
> process xml's, it can be that your document is malformed, you could try
> with a php debugger (like zend debugger).

There is really no need for debugger. Simple use the build-in exception
handler. The most sane advise would be this:

<?php
    $xmlfile = '/test/test.xml';
    echo "starting parsing xml";
    try {
        $doc = DOMDocument::load($xmlfile);
    }
    catch (Exception $ex)
    {
        echo $ex->getMessage();
    }
    echo "done parsing xml";
?>

-- 
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917

--- End Message ---
--- Begin Message ---
On 23/06/06, weetat <[EMAIL PROTECTED]> wrote:
  Anybody have any ideas what happening here ?

Try this as the first line

<?php  ini_set('display_errors', 1); ?>

You can remove it later, of course, but it would enable displaying php
errors as it's commonly disabled in production systems, AFAIK..


/ahmed

--- End Message ---
--- Begin Message ---
Hey Tedd,


> >
> >> > He just needs maybe 5 template
> >> > pages, same pages, different color.
> >>
> >> For something THIS simple, I truly believe you
> are
> >> Better Off (tm)
> >> with a simple head() and foot() function in a
> >> globals.inc file:
> >
> >Sorry, dont know where my brain was that day, what
> I
> >meant was he needs like 5 template pages, with 5
> >"dynamic" spots on them (meaning that php will
> >generate the content for these 5 spots and they are
> >the parts that will be constantly changing
> depending
> >on the page), and identical pages will be used to
> >serve people with other languages except with a
> color
> >difference (meaning different colored graphics, not
> >just css)




> Then within each of the "dynamic" spots run your
> php.
> 
> <?php include('spot1.php');?>
> 


That would work of course, but the guys he is working
with know pretty much zero about programming and are
mostly designers, by having a "template tag"
eg:
{{left_menu}} {{right_menu}} {{content_here}}
{{head_img}}

in a plain html page, they will get the idea much
better and they can move the menu around or whatever
if for whatever reason my pal is no longer with the
company.

Thats why was thinking of a simple
str_replace(array,array)

Cheers!
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
On 23/06/06, cajbecu <[EMAIL PROTECTED]> wrote:

  $data .= "&#".ord(substr($string,$i,1)).";";

and I think there's no need for substr.. just

$data .= "&#".$string[$i].";";


/ahmed

--- End Message ---
--- Begin Message --- I've run into something rather odd with cookies today. I'm working with this admin section on a site and I'm setting a cookie that is supposed to be good for one hour. So in the cookie I have time()+3600 and all was well or that was until someone fired up IE. It seems that IE refused to set the cookie. After much swearing at IE, I found that if I set it to time()+7200 the cookie would be set.

Not if that wasn't odd enough, in Firefox if I logged in at 6PM the cookie said it would expire at 8PM which is correct. However, when I logged in via IE at 6PM it said the cookie would expire at 23:00 hours (11PM for those who don't know)...so my question is...why is this happening and why does IE do this? I checked in Opera, Mozilla and Netscape and they all work the same as Firefox.....
--- End Message ---
--- Begin Message ---
At 6:26 PM -0400 6/23/06, Tom Ray [Lists] wrote:
>I've run into something rather odd with cookies today. I'm working with this 
>admin section on a site and I'm setting a cookie that is supposed to be good 
>for one hour. So in the cookie I have time()+3600 and all was well or that was 
>until someone fired up IE. It seems that IE refused to set the cookie. After 
>much swearing at IE, I found that if I set it to time()+7200 the cookie would 
>be set.
>
>Not if that wasn't odd enough, in Firefox if I logged in at 6PM the cookie 
>said it would expire at 8PM which is correct. However, when I logged in via IE 
>at 6PM it said the cookie would expire at 23:00 hours (11PM for those who 
>don't know)...so my question is...why is this happening and why does IE do 
>this? I checked in Opera, Mozilla and Netscape and they all work the same as 
>Firefox.....

You answered the question yourself, you're testing IE. It sounds like M$ is 
trying to make time to adapt to their standard.

But, you're not alone -- try Google with "IE cookies expiration"

tedd
-- 
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 23/06/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Thu, June 22, 2006 4:16 am, weetat wrote:

An javascript thingie for "onStop" if it exists might help.


window.onunload


/ahmed

--- End Message ---
--- Begin Message ---
I have successfully extracted IPTC tags from jpegs, but now that I've
switched to F-spot I need to extract XMP data. I have found this:
http://www.ozhiker.com/electronics/pjmt/library/documentation/

But I have been so far unable to extract the tags. I have an example image here:
http://dotancohen.com/xmp_test.jpg
This image has the comment "This is a comment" and two tags:
"People->Yehuda" and "Place->Sarid".

Has anybody invented a wheel to extract these tags and comment as
strings? I'd love to see it if so.

Thanks in advance.

Dotan Cohen
http://what-is-what.com

--- End Message ---
--- Begin Message ---
On 6/24/06, Dotan Cohen <[EMAIL PROTECTED]> wrote:
I have successfully extracted IPTC tags from jpegs, but now that I've
switched to F-spot I need to extract XMP data. I have found this:
http://www.ozhiker.com/electronics/pjmt/library/documentation/

But I have been so far unable to extract the tags. I have an example image here:
http://dotancohen.com/xmp_test.jpg
This image has the comment "This is a comment" and two tags:
"People->Yehuda" and "Place->Sarid".

Has anybody invented a wheel to extract these tags and comment as
strings? I'd love to see it if so.

This link:
http://www.photography-on-the.net/ee/beta/cs_xmp_to_exif.php

was on this page:
http://www.php.net/manual/en/function.exif-read-data.php

The manual usually has something useful.
--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hi,
     I am facing one problem.i previously mailed ,but there is no response,its 
running out of time.i want to implement that logic as soon as possible.This is 
my problem
   
                 We are developing an online software for  displaying ads in 
big mall.I want to restrict only one user can login to his own account at that 
particular time.suppose "users1" created a new user "users2" for another 
user.If "user1" login to the  "users2" account  and at that same time i want to 
restrict "user2 " for log in to his account.i want at a time only one user can 
access his account.I am waiting reponse from u
   
                                                                   A.suresh

                                
---------------------------------
 Yahoo! India Answers: Share what you know. Learn something new Click here
Catch all the FIFA World Cup 2006 action on Yahoo! India Click here

--- End Message ---
--- Begin Message ---
strange problem, but very similar to links in linux.

you must be maintaining a database or a record file. u can maintain all
links ('users' as u put it) for a given user. if a user logs in through any
of his accounts, check if he/she is logged in another A/C and stop this one.
else, allow log-in and set a flag.

alternately, close previously opened A/C and allow current one. this is
similar to wat yahoo messenger does and is a good safety measure.

Q. why do you want to assign more than one A/C anyway? and if its an
invitation to someone else, then you MUST not stop that new person. he would
be a valid subscriber, won't he?

No PHP here :(, guys would frown...


KM


On 6/24/06, suresh kumar <[EMAIL PROTECTED]> wrote:

Hi,
     I am facing one problem.i previously mailed ,but there is no
response,its running out of time.i want to implement that logic as soon as
possible.This is my problem

                 We are developing an online software for  displaying ads
in big mall.I want to restrict only one user can login to his own account
at that particular time.suppose "users1" created a new user "users2" for
another user.If "user1" login to the  "users2" account  and at that same
time i want to restrict "user2 " for log in to his account.i want at a
time only one user can access his account.I am waiting reponse from u


A.suresh


---------------------------------
Yahoo! India Answers: Share what you know. Learn something new Click here
Catch all the FIFA World Cup 2006 action on Yahoo! India Click here


--- End Message ---

Reply via email to