php-general Digest 26 Feb 2001 05:00:42 -0000 Issue 534

Topics (messages 41593 through 41649):

Re: Temporarily turning off magic quotes?
        41593 by: Philip Olson
        41596 by: Chris Adams

Re: incrementing  a date!
        41594 by: Philip Olson

Simple String Replace Question
        41595 by: Jeff Oien
        41601 by: Chris Adams
        41606 by: Jeff Oien
        41607 by: Simon Garner
        41612 by: Chris Adams
        41613 by: Jeff Oien
        41615 by: Simon Garner
        41644 by: Jeff Oien
        41645 by: Simon Garner

Re: Unwanted Characters
        41597 by: Chris Adams

Re: isset()
        41598 by: Chris Adams
        41600 by: Joe Stump

Re: Plugin Detection with PHP?
        41599 by: Chris Adams

PhpLib Template Not Parsing
        41602 by: Kyndig

PHP CGI-Binary
        41603 by: Julia A . Case
        41604 by: Frank M. Kromann

sockets...
        41605 by: Julia A . Case

Removing HTML codes using regexp
        41608 by: Toke Herkild
        41609 by: Simon Garner

Re: so what program?
        41610 by: CC Zona

Maximum queries from a database?
        41611 by: James, Yz

Script not updating
        41614 by: Peter Houchin
        41616 by: Simon Garner
        41618 by: Peter Houchin
        41620 by: Miles Thompson
        41621 by: Miles Thompson

Re: Can't connect php to mysql on linux
        41617 by: David Robley
        41619 by: eschmid+sic.s.netic.de
        41624 by: Miles Thompson

Using one invocation of PHP executable to generate multiple pages?
        41622 by: Jim Lum
        41625 by: Miles Thompson

Dynamic Corners GD Image library
        41623 by: sam1600.iname.com

Re: php.ini
        41626 by: David Robley
        41627 by: John Monfort
        41629 by: eschmid+sic.s.netic.de

Printing long strings
        41628 by: Clayton Dukes
        41630 by: Miles Thompson

switch statement
        41631 by: Peter Houchin
        41632 by: Jon Rosenberg
        41633 by: David Robley
        41634 by: Peter Houchin
        41636 by: David Robley

include file
        41635 by: JW
        41637 by: David Robley

mysql_info()
        41638 by: Gustavo Vieira Goncalves Coelho Rios

Logging out a user
        41639 by: Chris Aitken

Regular expression problems
        41640 by: Dan Watt
        41641 by: Simon Garner
        41642 by: Dan Watt
        41643 by: Simon Garner

JavaScript
        41646 by: Deependra B. Tandukar
        41647 by: Robert Gormley
        41648 by: Simon Garner

PHP4 directives in httpd.conf not working
        41649 by: Brian White

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]


----------------------------------------------------------------------



> you can use:
> 
> if($REQUEST_METHOD=='GET' or $REQUEST_METHOD=='POST')
>       ini_set ('magic_quotes_gpc',  'off'); 

This will not work, ini_set cannot mess with magic_quotes setting,
.htaccess is the prime option for temporarily changing this setting, as
per the example provided by Zeev.


Regards,


Philip Olson
http://www.cornado.com/






On 25 Feb 2001 09:15:08 -0800, Philip Olson <[EMAIL PROTECTED]> wrote:
>>      ini_set ('magic_quotes_gpc',  'off'); 
>
>This will not work, ini_set cannot mess with magic_quotes setting,

More precisely, it can change the setting but your PHP code will be executed
after the magic quotes work has already completed.





> ex: 2001-03-28 'll become 2001-04-01

Here's an example (a hack) which may help you get going :


 print getFutureDate('2001-03-28',4); // 2001-04-01

 function getFutureDate($date,$days,$format='Y-m-d')
 {
     list($year,$month,$day) = explode('-', $date);

     $timestamp = mktime(0,0,0, $month, $day, $year); 

     $secs = ($days * 86400);

     return date($format,$timestamp+$secs);
 }


Regards,


Philip Olson
http://www.cornado.com/

On Sun, 25 Feb 2001, kaab kaoutar wrote:

> Hi all!
> s there a way with which we can increment a date (by day) without extracting 
> the month the day and the year then increment some of them depending on the 
> day the month and the year ?
> ex: 2001-03-28 'll become 2001-04-01
> 
> Thanks
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 





I would like to get rid of \n characters unless there
are two or more in a row. So for example if there
is a long email formatted like we do here with
line break I want to remove the line breaks so 
text can be wrapped by a browser, but also show
paragraph breaks where necessary. This is what
I have:
$string_new = str_replace("\n", "", $string);
How can I augment this to not replace:
\n
\n
Thanks.
Jeff Oien




On 25 Feb 2001 10:34:27 -0800, Jeff Oien <[EMAIL PROTECTED]> wrote:
>I would like to get rid of \n characters unless there
>are two or more in a row. So for example if there

The Perl-compatible regular expressions support lookahead and look behind:

$str = 'abcdefabcaadd';
echo "$str\n";
$str = preg_replace("/(?<!a)a(?!a)/", "-", $str);
echo "$str\n";

will display this:
abcdefabcaadd
-bcdef-bcaadd




> On 25 Feb 2001 10:34:27 -0800, Jeff Oien <[EMAIL PROTECTED]> wrote:
> >I would like to get rid of \n characters unless there
> >are two or more in a row. So for example if there
> 
> The Perl-compatible regular expressions support lookahead and look behind:
> 
> $str = 'abcdefabcaadd';
> echo "$str\n";
> $str = preg_replace("/(?<!a)a(?!a)/", "-", $str);
> echo "$str\n";
> 
> will display this:
> abcdefabcaadd
> -bcdef-bcaadd

Man, that went right over my head. Is there a description of
how this works anywhere? Thanks for help in any case.
Jeff Oien




From: "Jeff Oien" <[EMAIL PROTECTED]>

> > On 25 Feb 2001 10:34:27 -0800, Jeff Oien <[EMAIL PROTECTED]> wrote:
> > >I would like to get rid of \n characters unless there
> > >are two or more in a row. So for example if there
> >
> > The Perl-compatible regular expressions support lookahead and look
behind:
> >
> > $str = 'abcdefabcaadd';
> > echo "$str\n";
> > $str = preg_replace("/(?<!a)a(?!a)/", "-", $str);
> > echo "$str\n";
> >
> > will display this:
> > abcdefabcaadd
> > -bcdef-bcaadd
>
> Man, that went right over my head. Is there a description of
> how this works anywhere? Thanks for help in any case.
> Jeff Oien
>


Or you could just do this:

<?php
    $str = "abc\ndefg\n\nxyzpqr\njklmno";
    $str = ereg_replace("([^\n])\n([^\n])", "\\1 \\2", $str);
    echo $str;
?>

That should give you:

abc defg\n\nxyzpqr jklmno

Works by replacing any \n with a space, as long as that \n is not next to
another \n.


Cheers

Simon Garner






On 25 Feb 2001 14:37:02 -0800, Jeff Oien <[EMAIL PROTECTED]> wrote:
>> On 25 Feb 2001 10:34:27 -0800, Jeff Oien <[EMAIL PROTECTED]> wrote:
>> >I would like to get rid of \n characters unless there
>> >are two or more in a row. So for example if there
>> 
>> The Perl-compatible regular expressions support lookahead and look behind:
>> 
>> $str = preg_replace("/(?<!a)a(?!a)/", "-", $str);
>
>Man, that went right over my head. Is there a description of
>how this works anywhere? Thanks for help in any case.

The Regular Expression part of the online PHP manual has a lot of information
(http://www.php.net/manual/en/ref.pcre.php) but it does tend to assume you
already know what you need to do.

Basically, the regular expression in there matches any "a" where the character
before isn't an "a" (?<!a) and the character after isn't an a (?!a). Any
matched characters are replaced with hyphens. 

For your needs, '/(?<!\n)\n(?!\n)/m' should work (the /m turns on multi-line
support, which is necessary since we're working with line breaking characters).
Note that you'll need to escape those backslashes in PHP if you use
doublequotes.




That almost works. The two \n in a row are on new lines.
So it's
\n
\n
intead of \n\n. If that makes any sense.
Jeff Oien

> Or you could just do this:
> 
> <?php
>     $str = "abc\ndefg\n\nxyzpqr\njklmno";
>     $str = ereg_replace("([^\n])\n([^\n])", "\\1 \\2", $str);
>     echo $str;
> ?>
> 
> That should give you:
> 
> abc defg\n\nxyzpqr jklmno
> 
> Works by replacing any \n with a space, as long as that \n is not next to
> another \n.
> 
> 
> Cheers
> 
> Simon Garner
> 
> 




From: "Jeff Oien" <[EMAIL PROTECTED]>

> That almost works. The two \n in a row are on new lines.
> So it's
> \n
> \n
> intead of \n\n. If that makes any sense.
> Jeff Oien


No, that doesn't make any sense whatsoever :)

A \n *is* a new line. I can only guess you're getting confused because
there's \r's as well as \n's in the string. Try this:


<?php
    $str = "abc\r\ndefg\r\n\r\nxyzpqr\r\njklmno";
    $str = ereg_replace("([^\r\n])\r\n([^\r\n])", "\\1 \\2", $str);
    echo $str;
?>

Or alternatively:

<?php
    $str = "abc\r\ndefg\r\n\r\nxyzpqr\r\njklmno";
    $str = ereg_replace("\r", "", $str);
    $str = ereg_replace("([^\n])\n([^\n])", "\\1 \\2", $str);
    echo $str;
?>


A CR is a carriage return, a LF is a line feed or newline. \r = CR, \n = LF.
Unix files use only LF (\n) for new lines, whereas MS DOS/Windows uses CRLF
(\r\n) and Mac uses just CR (\r).


Cheers

Simon Garner






> No, that doesn't make any sense whatsoever :)
>
> A \n *is* a new line. I can only guess you're getting confused because
> there's \r's as well as \n's in the string. Try this:
>
>
> <?php
>     $str = "abc\r\ndefg\r\n\r\nxyzpqr\r\njklmno";
>     $str = ereg_replace("([^\r\n])\r\n([^\r\n])", "\\1 \\2", $str);
>     echo $str;
> ?>

Ok now I'm really being a pest. Your code works on your
example but not on mine. I can't figure out why. But I really
appreciate the help so far from Chris and Simon so thanks.

Here is my example and what happens when I use your
code. I tried it by pasting text into a textarea part of a
form and also just having it in a plain text file (Windows system).
(I just tried creating a file on Unix also, same result.)
Removes the line breaks but also the multiples for paragraphs.
This isn't very important, more of a curiosity.
-----------
original text:

This is a story
of how the West was won.
Not about the Brady bunch
but how those guys with guns
somehow won.

I don't know who won, but
I do know the West was won.
So the West is number one.

Yay.
-----------
returned from your code:

This is a story of how the West was won. Not about the Brady bunch but how those guys
with guns somehow won. I don't know who won, but I do know the West was won. So the
West is number one. Yay.
-----------
what I want is:

This is a story of how the West was won. Not about the Brady bunch but how those guys
with guns somehow won.

I don't know who won, but I do know the West was won. So the West is number one.

Yay.

^that may wrap in your e-mail program





From: "Jeff Oien" <[EMAIL PROTECTED]>

> Ok now I'm really being a pest. Your code works on your
> example but not on mine. I can't figure out why. But I really
> appreciate the help so far from Chris and Simon so thanks.
>
> Here is my example and what happens when I use your
> code. I tried it by pasting text into a textarea part of a
> form and also just having it in a plain text file (Windows system).
> (I just tried creating a file on Unix also, same result.)
> Removes the line breaks but also the multiples for paragraphs.
> This isn't very important, more of a curiosity.


I just tried with your text and it reformats it correctly for me...

Here's what I have got:


<html>
<body>

<form method=post>
<textarea name="str" cols=50 rows=10></textarea><br>
<input type=submit>
</form>

<hr><pre>
<?php
    $str = ereg_replace("([^\r\n])\r\n([^\r\n])", "\\1 \\2", $str);
    echo $str;
?>
</pre>

</body>
</html>


I pasted your text into the textarea and submitted it:


This is a story
of how the West was won.
Not about the Brady bunch
but how those guys with guns
somehow won.

I don't know who won, but
I do know the West was won.
So the West is number one.

Yay.


And it outputted:


This is a story of how the West was won. Not about the Brady bunch but how
those guys with guns somehow won.

I don\'t know who won, but I do know the West was won. So the West is number
one.

Yay.


(Just need to run it through stripslashes() to fix the don\'t.)

Does this not work for you? Some troubleshooting ideas:

<?php
    $str = ereg_replace("\r", "CR", $str); // replace CRs with "CR"
    $str = ereg_replace("\n", "LF", $str); // replace LFs with "LF"
?>

<?php
    echo urlencode($str);  // may help to highlight any special characters
in the string
?>


Hope this helps

Simon Garner





On 24 Feb 2001 21:31:33 -0800, Clayton Dukes <[EMAIL PROTECTED]> wrote:
>How do I remove unwanted/unprintable characters from a variable?
>
>$sometext =3D "Th=C0e c=D8ar r=F6=F8an over m=D6y dog"
>needs to be filtered and reprinted as:
>"The car ran over my dog"

Strip everything which isn't in the list of allowed characters:
eregi_replace("[^[:alpha:]]", "", $sometext)




On 25 Feb 2001 00:01:30 -0800, Mark Maggelet <[EMAIL PROTECTED]> wrote:
>On Sat, 24 Feb 2001 17:51:07 +0100, Christian Reiniger 
>([EMAIL PROTECTED]) wrote:
>>On Saturday 24 February 2001 17:18, PHPBeginner.com wrote:
>>> in my preceding email I've written:
>>>
>>> if($var!='')
>>>
>>> will fix your all your worries without an intervention of a 
>strings
>>> function.
>>
>>Except that it will throw a warning in PHP4 if $var is not set.
>>=> isset () should be used.
>
>man, this is like the thread that will not die. isset() will return 
>true for an empty string, which is not what he wants. the right thing 
>to do is use
>
>if((isset($var))&&($var!=""))

Isn't this a bit more legible:

if (!empty($var))




empty() fails when $var == 0

--Joe

On Sun, Feb 25, 2001 at 10:50:15AM -0800, Chris Adams wrote:
> On 25 Feb 2001 00:01:30 -0800, Mark Maggelet <[EMAIL PROTECTED]> wrote:
> >On Sat, 24 Feb 2001 17:51:07 +0100, Christian Reiniger 
> >([EMAIL PROTECTED]) wrote:
> >>On Saturday 24 February 2001 17:18, PHPBeginner.com wrote:
> >>> in my preceding email I've written:
> >>>
> >>> if($var!='')
> >>>
> >>> will fix your all your worries without an intervention of a 
> >strings
> >>> function.
> >>
> >>Except that it will throw a warning in PHP4 if $var is not set.
> >>=> isset () should be used.
> >
> >man, this is like the thread that will not die. isset() will return 
> >true for an empty string, which is not what he wants. the right thing 
> >to do is use
> >
> >if((isset($var))&&($var!=""))
> 
> Isn't this a bit more legible:
> 
> if (!empty($var))
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 

-------------------------------------------------------------------------------
Joe Stump, PHP Hacker, [EMAIL PROTECTED]                                 -o)
http://www.miester.org http://www.care2.com                                 /\\
"It's not enough to succeed. Everyone else must fail" -- Larry Ellison     _\_V
-------------------------------------------------------------------------------





On 25 Feb 2001 04:37:21 -0800, Andy Clarke <[EMAIL PROTECTED]> wrote:
>Is there a way to use PHP to tell whether a user's browser has a particular
>plugin?
...
>I know that this can be done using Javascript, but as this can be turned
>off by the user etc, it seemed as though it would be more reliable to do it
>server side (if it is possible).

No, it's not possible. The safest approach is to assume the user doesn't have a
plugin and then use JavaScript to enable a plugin. In certain cases, there are
plugin specific tricks you could play in a detection script (e.g. QuickTime
allows a QTSRC attribute which overrides the SRC value - SRC="somefile"
QTSRC="plugin_check.php?HasQT=1&filename=somefile"). For the rest, you'll need
to use JavaScript.

This is complicated by the way Microsoft broke Netscape's plugins object - on
netscape, you can iterate over that list very easily. IE has the object, but
it's always empty. (You can use VBScript to attempt to create an object of that
class and then trap the error if it fails, but that's not particularly elegant)




Afternoon All,

  Been running through archives and posts throughout the net.
Hopin ta find an answer. Looks like the questions been asked,
but no public answer has been made.

  I'm using PhpLib's Template code. ( just pulled the file and
modified it a minor bit ) The problem I'm having is when I create
a dynamic page with the Template class, any php within that
page is not being parsed by the webserver. If you visit:
http://www.kyndig.com/listings  and look at the page source,
you'll see the php code to call the banner code in. Any pointers
in how to go about fixing this is much appreciated.

-- 
Kind Regards,
---
Kyndig
Online Text Game Resource Site:  http://www.kyndig.com
ICQ#    10451240





Ok, I give up...  how do I build PHP as a CGI-Binary?  I've spent two days 
searching the configure file for this.

Julia

-- 
[  Julia Anne Case  ] [        Ships are safe inside the harbor,       ]
[Programmer at large] [      but is that what ships are really for.    ]  
[   Admining Linux  ] [           To thine own self be true.           ]
[ Windows/WindowsNT ] [ Fair is where you take your cows to be judged. ]
          




IF you dont specify --with-apache or --with-apxs configure options you will build the 
CGI !

- Frank

>Ok, I give up...  how do I build PHP as a CGI-Binary?  I've spent two days 
>searching the configure file for this.
>
>Julia
>
>-- 
>[  Julia Anne Case  ] [        Ships are safe inside the harbor,       ]
>[Programmer at large] [      but is that what ships are really for.    ]  
>[   Admining Linux  ] [           To thine own self be true.           ]
>[ Windows/WindowsNT ] [ Fair is where you take your cows to be judged. ]
>          
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>







Ok, I'm trying to open a socket connection to port 23 (telnet)...  the 
script just seems to hang on connect...  though I can connect and talk 
with ports 25 (smtp), port 80 (http), port 110 (pop3) and port 443 (https) 
so the code isn't too bad...  Is there something special about the telnet 
port?

Julia

-- 
[  Julia Anne Case  ] [        Ships are safe inside the harbor,       ]
[Programmer at large] [      but is that what ships are really for.    ]  
[   Admining Linux  ] [           To thine own self be true.           ]
[ Windows/WindowsNT ] [ Fair is where you take your cows to be judged. ]
          




What if I want to replace all html codes from a string ?
I've tried using :

$myString = preg_replace('/<*>/, '', $myString);
but that deletes all string... ( or everything from first '<' ) ...

Toke Herkild...









From: "Toke Herkild" <[EMAIL PROTECTED]>

> What if I want to replace all html codes from a string ?
> I've tried using :
> 
> $myString = preg_replace('/<*>/, '', $myString);
> but that deletes all string... ( or everything from first '<' ) ...
> 
> Toke Herkild...
> 
> 



Try striptags()

http://php.net/striptags


Cheers

Simon Garner





In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Knasen) wrote:

> What I found out in my first mail to the list was..quit working with
> filmaker =). Sure, I can do that. But the question remains..what program
> WILL a macuser use to forfill the needs in MySQL/PHP?

Don't quit working with filemaker entirely.  It has many advantages, such 
being great for quick prototyping.  Just don't waste time trying to use FM 
as a web backend, 'cuz that gets ugly quick.  A Mac user can fulfill that 
need with MySQL/PHP  (or PostgresSQL/PHP) just fine.  I know of at least 
two options for doing this:

1) OS X
2) using one of the Linux distros for Mac (ex. LinuxPPC, YellowDogLinux, 
SuSe)

Both options are very cheap to try, and offer slightly different 
advantages, so no harm in trying out both.  Plan on setting aside 1GB or so 
for a Linux partition, for which you get a dual-boot Mac--giving you all 
the advantages of Mac PLUS all the advantages of Linux in one box.  Not 
bad, eh?

-- 
CC




Hi all,

I'm a little concerned as to how many times some of the scripts I've been
working on are querying a database:  Some are making up to 4 or 5 queries
each.  Should this give me any cause for concern?

I've only ever been unable to connect to the database once (other than
through script error), and that's when I was using a persistent connection.
So, I guess my question is, is there a recommended maximum number of queries
I should be working around? (MySQL).

Thanks,
James.






Could some one please have a look thru my code and tell me why it creates a new record 
instead of updating the record?

What this script is suposed to do is show a HTML form .. then once the user fills it 
out it then shows another form which echo's the values inputted in the first so the 
user can update if they made a mistake .. it does everything right .. up until the 
user clicks on update ... where instead of updating the record it creates a new one ..

Any sussestions/Help would be greatful


Peter Houchin
Sun Rentals
[EMAIL PROTECTED]

<?
$db = mysql_connect("localhost","root","password");
 mysql_select_db("rentdb",$db);

if ($submit){
 
 $result = mysql_query("INSERT INTO app 
(name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email,secret) 
VALUES 
('$name','$company','$address','$suburb','$state','$post','$areacode','$phone','$faxareacode','$fax','$email','$secret')");

 
 if($name){
 $result="SELECT * FROM app WHERE name=$name";
 if ($submit){

 $result ="UPDATE app SET 
name='$name',company='$company',address='$address',suburb='$suburb',state='$state',post='$post',areacode='$areacode',phone='$phone',faxareacode='$faxareacode',fax='$fax',email='$email',secret='$secret'
 WHERE name=$name";
echo mysql_error();

}


echo "<p><p>";
echo "<TABLE BORDER=0 WIDTH=800 >";
echo "<tr><td>";
 
?> <table border="0" width="650" align="center"> <tr> <td> <font face="Helvetica, 
sans-serif" size="3" color="#00499C"> 
Please Check your information, and change any details that are not correct, then 
click update.<br> if this information is correct <? echo "<a 
href=thankyou.php?session=$session>click here</a>";?>.</font><p> 
</td></tr> </table><form name=check method="POST" action=""></font> <TABLE BORDER=0 
CELLPADDING=3 CELLSPACING=1 WIDTH=500 BGCOLOR=#990033 ALIGN=CENTER> 
<tr BGCOLOR=#CCCCCC> <td colspan=2 bgcolor=#006699><div align=center> <font 
face=Helvetica, sans-serif size=3 color=#FFFFFF><b>The 
information you entered is:</b></font> </div></td></tr> <tr BGCOLOR=#CCCCCC> <td 
bgcolor=#006699 width=122> 
<input type=hidden name=id value="<? echo $id ?>"> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF><b>Your 
Name:</b></font></td><td><div align=center><font face=Helvetica, sans-serif size=3 
color=#000000><input type=text name=name value="<?echo 
$name?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFF width=180><b><FONT 
COLOR="#FFFFFF">Company:</FONT></b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><input type=text name=company 
value="<?echo $company?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Address:</b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><input type=text name=address 
value="<?echo $address?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Suburb:</b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><input type=text name=suburb 
value="<?echo $suburb?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>State:</b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><input type=text name=state 
value="<?echo $state?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Post 
Code:</b></font></td><td><div align=center><font face=Helvetica, sans-serif size=3 
color=#000000><input type=text name=post value="<?echo 
$post?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Phone:*</b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><SELECT NAME="areacode"><OPTION 
VALUE="02" <? if ($areacode == '02') { echo 'SELECTED '; }?>>02</OPTION><OPTION 
VALUE="03" <? if ($areacode == '03') { echo 'SELECTED '; }?>>03</OPTION><OPTION 
VALUE="07" <? if ($areacode == '07') { echo 'SELECTED '; }?>>07</OPTION><OPTION 
VALUE="08" <? if ($areacode == '08') { echo 'SELECTED '; 
}?>>08</OPTION></SELECT><input type=text name=phone value="<?echo 
$phone?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Fax:*</b></font></td><td><div align=center><font 
face=Helvetica, sans-serif size=3 color=#000000><SELECT NAME="faxareacode"><OPTION 
VALUE="02" <? if ($faxareacode == '02') { echo 'SELECTED '; }?>>02</OPTION><OPTION 
VALUE="03" <? if ($faxareacode == '03') { echo 'SELECTED '; }?>>03</OPTION><OPTION 
VALUE="07" <? if ($faxareacode == '07') { echo 'SELECTED '; }?>>07</OPTION><OPTION 
VALUE="08" <? if ($faxareacode == '08') { echo 'SELECTED '; 
}?>>08</OPTION></SELECT><input type=text name=fax value="<?echo 
$fax?>"></font></div></td></tr> 
<tr BGCOLOR=#CCCCCC> <td bgcolor=#006699 width=122> <font face=Helvetica, sans-serif 
size=3 color=#FFFFFF width=180><b>Email 
Address:</b></font></td><td><div align=center><font face=Helvetica, sans-serif size=3 
color=#000000><input type=text name=email value="<?echo 
$email?>"></font></div></td></tr> 
<tr><td bgcolor=#006699><div align=center><FONT FACE="Helvetica" SIZE="3" 
COLOR="#FFFFFF"><B>Secret 
Word:**</B></FONT></div></td><td bgcolor=#CCCCCC><DIV ALIGN="CENTER"><INPUT 
TYPE="text" NAME="secret" VALUE="<? echo $secret?>" MAXLENGTH="15"></DIV></td></tr>
<tr>
<td colspan=2 bgcolor=#CCCCCC>
<DIV ALIGN="CENTER">
<INPUT TYPE="submit" NAME="submit" VALUE="update">
</DIV>
</td>
</tr>
</table>
</form>
<?
echo "</td></tr></table>\n";
}
} 
else {
 
 
 
?> </P><table width="800" border="0" align="center"> <tr> <td height="485"> <form 
method="post" action="" name="app"> 
<div align="center"> <table width="700" border="0" align="center"> <tr> <td 
width="112" height="2"><font face="Helvetica, sans-serif" size="3" 
color="#00499C">Name:</font></td><td width="578" height="2"> 
<input type="text" name="name"> </td></tr> <tr> <td width="112" height="2"><font 
face="Helvetica, sans-serif" size="3" color="#00499C">Company:</font></td><td 
width="578" height="2"> 
<input type="text" name="company"> </td></tr> <tr> <td width="112" height="2"><font 
face="Helvetica, sans-serif" size="3" color="#00499C">Address:</font></td><td 
width="578" height="2"> 
<input type="text" name="address" size="35"></td></tr> <tr><td WIDTH="112"><font 
face="Helvetica, sans-serif" size="3" color="#00499C"> 
Suburb: </font></td><td WIDTH="578"><input type="text" name="suburb"> </td></tr> 
<tr><td WIDTH="112"><font face="Helvetica, sans-serif" size="3" color="#00499C"> 
State: </font></td><td WIDTH="578"> <select name="state" size="1"> <option 
value="Canberra">ACT</option> 
<option value="New South Wales">NSW</option> <option value="Northern 
Territory">NT</option> 
<option value="Queensland">QLD</option> <option value="South Australia">SA</option> 
<option value="Tasmania">TAS</option> <option value="Victoria">VIC</option> <option 
value="Western Australia">WA</option> 
</select> <font face="Helvetica, sans-serif" size="3" color="#00499C"> Post 
Code:</font> 
<input type="text" name="post" size="4"> </td></tr> <tr><td width="112" 
height="2"><font face="Helvetica, sans-serif" size="3" 
color="#00499C">Phone:*</font></td><td width="578" height="2"> 
<SELECT NAME="areacode"> <OPTION VALUE="02">02</OPTION> <OPTION VALUE="03">03</OPTION> 

<OPTION VALUE="07">07</OPTION> <OPTION VALUE="08">08</OPTION> </SELECT> <input 
type="text" name="phone" size="10" maxlength="9"> 
</td></tr> <tr> <td width="112" height="2"><font face="Helvetica, sans-serif" size="3" 
color="#00499C">Fax:*</font></td><td width="578" height="2"> 
<SELECT NAME="faxareacode"> <OPTION VALUE="02">02</OPTION> <OPTION 
VALUE="03">03</OPTION> 
<OPTION VALUE="07">07</OPTION> <OPTION VALUE="08">08</OPTION> </SELECT> <input 
type="text" name="fax"> 
</td></tr><tr><td width="112" height="2"><FONT FACE="Helvetica, sans-serif" SIZE="3" 
COLOR="#00499C">Email:</FONT></td><td width="578" height="2"><INPUT TYPE="text" 
NAME="email"></td></tr> 
<tr> <td width="112" height="2"><FONT FACE="Helvetica, sans-serif" SIZE="3" 
COLOR="#003399">Secret 
word:**</FONT></td><td width="578" height="2"><INPUT TYPE="text" NAME="secret" 
MAXLENGTH="15"> 
</td></tr> <tr> <td width="112" height="2">&nbsp;</td><td width="578" height="2"> 
<input type="submit" name="submit" value="Submit"> 
<input type="reset" name="submit2" value="Clear"> <p> <font face="Helvetica, 
sans-serif" size="3" color="#00499C"><b>* 
Please Include your area code with your phone &amp; fax number.</b></font> <BR><FONT 
FACE="Helvetica, sans-serif" SIZE="3" COLOR="#00499C"><B>**Please 
include a secret word (maximum of 15 characters) for verification should you lose 
your password.</B></FONT></td></tr> </table></div></form><?
}
echo mysql_error();
?>




From: "Peter Houchin" <[EMAIL PROTECTED]>


> Could some one please have a look thru my code and tell me why it creates
a new record instead of updating the record?
>

[snip]

>
> if ($submit){
>
>  $result = mysql_query("INSERT INTO app
(name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email
,secret) VALUES
('$name','$company','$address','$suburb','$state','$post','$areacode','$phon
e','$faxareacode','$fax','$email','$secret')");
>


^^ Here's your culprit. Check your logic. Whenever they push submit it
INSERTs a new record (I think...).


Regards

Simon Garner






but that's why i've got the
if($name){ ....
if($submit) ...


clause in it .. thinking that if there was a name then update the record..
otherwise create a new one
-----Original Message-----
From: Simon Garner [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 26, 2001 10:36 AM
To: Peter Houchin; PHP MAIL GROUP
Subject: Re: [PHP] Script not updating


From: "Peter Houchin" <[EMAIL PROTECTED]>


> Could some one please have a look thru my code and tell me why it creates
a new record instead of updating the record?
>

[snip]

>
> if ($submit){
>
>  $result = mysql_query("INSERT INTO app
(name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email
,secret) VALUES
('$name','$company','$address','$suburb','$state','$post','$areacode','$phon
e','$faxareacode','$fax','$email','$secret')");
>


^^ Here's your culprit. Check your logic. Whenever they push submit it
INSERTs a new record (I think...).


Regards

Simon Garner






Peter,

In case "AAA" When $submit is set, you will always get an an insert; you 
have a mysql_query executing.

In case "BBB" you are only assigning the SQL statement to $result, I didn't 
look further to see where it executes. It really doesn't matter because 
case "AAA" will always fire first.

Can you structure your flow so that, depending on your conditions you 
assign the SQL statement to a variable, such as $sql_string, and then at 
the end of your conditions execute $result = mysql_query( $sql_string ); ?

This also looks like a scenario where having a good hard look at using 
switch ... case .. break. I've really liked it for control structures 
involving buttons.

You may also want to consider redisplaying your input page with a flag 
identifying the missing or incorrect values. Julie Meloni has a very nice 
example of this at http://www.thickbook.com

Hope you are having lovely weather. Our forecast tonight is snow, followed 
by ice pellets, freezing rain, rain and then back to snow. All that's 
missing is the sunshine!

Regards - Miles Thompson

At 10:30 AM 2/26/01 +1100, Peter Houchin wrote:
>Could some one please have a look thru my code and tell me why it creates 
>a new record instead of updating the record?
>
>What this script is suposed to do is show a HTML form .. then once the 
>user fills it out it then shows another form which echo's the values 
>inputted in the first so the user can update if they made a mistake .. it 
>does everything right .. up until the user clicks on update ... where 
>instead of updating the record it creates a new one ..
>
>Any sussestions/Help would be greatful
>
>
>Peter Houchin
>Sun Rentals
>[EMAIL PROTECTED]
>
><?
>$db = mysql_connect("localhost","root","password");
>  mysql_select_db("rentdb",$db);
>
>if ($submit){

"AAA"

>
>  $result = mysql_query("INSERT INTO app 
> (name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email,secret) 
> VALUES 
> 
>('$name','$company','$address','$suburb','$state','$post','$areacode','$phone','$faxareacode','$fax','$email','$secret')");
>
>  if($name){
>  $result="SELECT * FROM app WHERE name=$name";
>  if ($submit){
>
>  $result ="UPDATE app SET 
> 
>name='$name',company='$company',address='$address',suburb='$suburb',state='$state',post='$post',areacode='$areacode',phone='$phone',faxareacode='$faxareacode',fax='$fax',email='$email',secret='$secret'
> 
> WHERE name=$name";
>echo mysql_error();
>
>}
<snip>







The query flagged by if ($submit) will always fire first, and it appears 
you will always have a $name value as well. I believe it's actually firing 
twice in some scenarios - runs the insert and then immediately updates.

Will $submit contain different values? Then

switch ( $submit )
{
    case "update":
         $sql = "update blah blah ....";
       break;
    case "new":
          $sql = "insert into blah blah ...";
       break;
     default:
          echo "No value to process for submit";
           unset( $sql );
}

if isset( $submit )
{
    $result = mysql_query( $sql );
    .... and so forth ..
}

With this structure you can use an array to hold the value of your buttons, 
such as $action[ ], in which case the switch statement is "switch( 
$action[0] )"

Cheers - Miles


Miles

At 10:43 AM 2/26/01 +1100, Peter Houchin wrote:

>but that's why i've got the
>if($name){ ....
>if($submit) ...
>
>
>clause in it .. thinking that if there was a name then update the record..
>otherwise create a new one
>-----Original Message-----
>From: Simon Garner [mailto:[EMAIL PROTECTED]]
>Sent: Monday, February 26, 2001 10:36 AM
>To: Peter Houchin; PHP MAIL GROUP
>Subject: Re: [PHP] Script not updating
>
>
>From: "Peter Houchin" <[EMAIL PROTECTED]>
>
>
> > Could some one please have a look thru my code and tell me why it creates
>a new record instead of updating the record?
> >
>
>[snip]
>
> >
> > if ($submit){
> >
> >  $result = mysql_query("INSERT INTO app
>(name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email
>,secret) VALUES
>('$name','$company','$address','$suburb','$state','$post','$areacode','$phon
>e','$faxareacode','$fax','$email','$secret')");
> >
>
>
>^^ Here's your culprit. Check your logic. Whenever they push submit it
>INSERTs a new record (I think...).
>
>
>Regards
>
>Simon Garner
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





On Sat, 24 Feb 2001 16:10, George  Alexander wrote:
> Hi,
>
> I working on Redhat Linux 6.1 and I've installed
> MySQL-3.23.33-1.i386.rpm and MySQL-client-3.23.33-1.i386.rpm. MySql is
> working fine. I've even created a database also using MySqlAdmin.
> Regarding Php I've installed php-3.0.18-1.6.x.i386.rpm and as for
> Apache : apache-1.3.14-2.6.2.i386.rpm. I've even installed
> php-mysql-3.0.16-1.i386.rpm and mod-php3-3.0.12-2.i386.rpm.
>
> My problem is I can't connect PHP to Mysql Db using the
> mysyql_connect("localhost","root","mypassword") command.
>
> Please help me asap.
> Regards,
> George

Use mysql_error() after your unsuccessful call to mysql_connect to return 
a mysql error string

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA




On Mon, Feb 26, 2001 at 10:11:02AM +1030, David Robley wrote:
> On Sat, 24 Feb 2001 16:10, George  Alexander wrote:
> > Hi,
> >
> > I working on Redhat Linux 6.1 and I've installed
> > MySQL-3.23.33-1.i386.rpm and MySQL-client-3.23.33-1.i386.rpm. MySql is
> > working fine. I've even created a database also using MySqlAdmin.
> > Regarding Php I've installed php-3.0.18-1.6.x.i386.rpm and as for
> > Apache : apache-1.3.14-2.6.2.i386.rpm. I've even installed
> > php-mysql-3.0.16-1.i386.rpm and mod-php3-3.0.12-2.i386.rpm.
> >
> > My problem is I can't connect PHP to Mysql Db using the
> > mysyql_connect("localhost","root","mypassword") command.
> >
> > Please help me asap.
> > Regards,
> > George
> 
> Use mysql_error() after your unsuccessful call to mysql_connect to return 
> a mysql error string

Hehe, this wouldn't work if the connect was unsuccessful. You can always
get an mysql error string after a successful call to mysql_connect. Look
into Paul DuBois book and it should be very clear.

-Egon

-- 
http://www.linuxtag.de/
http://php.net/books.php 
http://www.concert-band.de/
http://www.php-buch.de/




George,

1. Is this a brand new project, or were you connecting before, on your web 
pages? If the latter, what changed?
2. **IMPORTANT**  Have you also run phpinfo() and confirmed that you have 
mysql support installed? **IMPORTANT**
3. Did you stop and restart Apache?
4. Have you tried a minimal page - just connecting and echoing the result? 
or with a built-in die message?
5. Is  this a self-hosted server, or someone elses? What name combinations 
of localhost, username and password have you played with? What name is 
mysql running under?

I'll also confess I've given up on .rpms for all of mysql, apache and php. 
It's fairly quick to build them from source, and you have full control over 
where things are placed. Search for something like "LAMP Apache" and that 
will turn up the necessary tutorials.

This probably hasn't been much direct help, but maybe it'll get you going. 
It's not fun, but I've slowly learned to check basics first! (Like the 
wire, when there's a network connectivity problem - sheepish grin.)

Regards - Miles Thompson


At 10:11 AM 2/26/01 +1030, David Robley wrote:
>On Sat, 24 Feb 2001 16:10, George  Alexander wrote:
> > Hi,
> >
> > I working on Redhat Linux 6.1 and I've installed
> > MySQL-3.23.33-1.i386.rpm and MySQL-client-3.23.33-1.i386.rpm. MySql is
> > working fine. I've even created a database also using MySqlAdmin.
> > Regarding Php I've installed php-3.0.18-1.6.x.i386.rpm and as for
> > Apache : apache-1.3.14-2.6.2.i386.rpm. I've even installed
> > php-mysql-3.0.16-1.i386.rpm and mod-php3-3.0.12-2.i386.rpm.
> >
> > My problem is I can't connect PHP to Mysql Db using the
> > mysyql_connect("localhost","root","mypassword") command.
> >
> > Please help me asap.
> > Regards,
> > George
>
>Use mysql_error() after your unsuccessful call to mysql_connect to return
>a mysql error string
>
>--
>David Robley                        | WEBMASTER & Mail List Admin
>RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
>AusEinet                            | http://auseinet.flinders.edu.au/
>             Flinders University, ADELAIDE, SOUTH AUSTRALIA
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





Hi,

I have PHP installed on a Win95 machine.  What I'd like to do is to use
a PHP page that will create multiple HTML pages.

I guess that I can execute PHP.EXE multiple times, but was thinking that
this means that it's going thru the overhead of starting up PHP.EXE each
time.  Is there any way to tell PHP.EXE to build multiple HTML pages,
i.e., kind of like a loop?

Jim




Jim,
PHP works with your server to generate the HTML output, so PHP is "running" 
all the time, it's not like a CGI script. PHP code is embedded in your HTML 
pages, so you can use it to control the generated HTML. You can turn it on 
and off within the page. Carefully look at Chapter 1 Page 1 of the manual 
"What is PHP?"

Then look at a couple of the tutorials at www.thickbook.com, WeberDev, 
Devshed, and so on. The concept will become clearer. From there on, take it 
away; it's powerful, flexible and occasionally frustrating and embarrassing 
(like all languages).

So you can have little pages full of buttons or links which open up other 
pages, or sometimes a lot of PHP script generating relatively few lines of 
code, all depending on various conditions.

Miles Thompson


At 07:21 PM 2/25/01 -0500, Jim Lum wrote:
>Hi,
>
>I have PHP installed on a Win95 machine.  What I'd like to do is to use
>a PHP page that will create multiple HTML pages.
>
>I guess that I can execute PHP.EXE multiple times, but was thinking that
>this means that it's going thru the overhead of starting up PHP.EXE each
>time.  Is there any way to tell PHP.EXE to build multiple HTML pages,
>i.e., kind of like a loop?
>
>Jim
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]






Hi,

This is probably a no brainer for the math wizards out there.
Can anyone see how the folowing code ( originally posted on
phpbuilder titled "RE: dynamic corners" as a responce to Rasmus's
article on image creation with php & GD :
http://www.phpbuilder.com/annotate/message.php3?id=1003041 )
can be modified to change the "curve" of the arc.

I would like to be able to modify the code so it can display
and arc with a curve inbetween the arc the code produces now:

#################
#              ##
#           #####
#        ########
#      ##########
#    ############
#  ##############
# ###############
#################
#################

and a triange like below:

#################
#              ##
#             ###
#            ####
#           #####
#          ######
#         #######
#        ########
#       #########
#      ##########
#     ###########
#    ############
#   #############
#  ##############
# ###############
#################
( pretend this image is the same
 height as the one above ;)

In otherwords I would like to be able to modify
the "height" of the arc ( not to be confused with
the height of the image ) as one is able to modify
the  height of the arc produced using the GD ImageArc()
function.

You may be wondering why I am not using the 
ImageArc() function in the first place.  Well 
check it out and see... this code produces 
a beautifully antialiassed curve, and the 
ImageArc() does not.


Looking forward to your ideas.

Thanks,
Sam


<?

# test arguments 
$cnr='tl'; 
$inc='ff0000'; 
$outc='00ff00'; 
$side='40'; 
######## 


$corner=ImageCreate($side,$side); 

### set palette 
$bg['r']=hexdec(substr($outc,0,2)); 
$bg['g']=hexdec(substr($outc,2,2)); 
$bg['b']=hexdec(substr($outc,4,2)); 

$fg['r']=hexdec(substr($inc,0,2)); 
$fg['g']=hexdec(substr($inc,2,2)); 
$fg['b']=hexdec(substr($inc,4,2)); 

$dcolor['r']=$fg['r']-$bg['r']; 
$dcolor['g']=$fg['g']-$bg['g']; 
$dcolor['b']=$fg['b']-$bg['b']; 

for ($i=0;$i<256;$i++) { 
$ind[$i]=ImageColorAllocate($corner,
round($bg['r']+($dcolor['r']*$i/255)),
round($bg['g']+($dcolor['g']*$i/255)),
round($bg['b']+($dcolor['b']*$i/255))); 
} 

### colorise function 

function colorise($x,$y,$area)
   { 
   global $dcolor,$bg,$corner; 
   $col= ImageColorClosest($corner,
   round($bg['r']+($dcolor['r']*$area)),
   round($bg['g']+($dcolor['g']*$area)),
   round($bg['b']+($dcolor['b']*$area))); 
   imagesetpixel ($corner, $x, $y, $col); 
   } 

### getarea function 

function getarea($x,$y)
   { 
   global $r; 

   #distances 
   $d1=pow( ( pow($x,2) + pow($y,2) ), 0.5 ); 
   if ($d1>=$r)
      return 0; 

   $d3=pow( ( pow(($x+1),2) + pow(($y+1),2) ), 0.5 ); 
   if ($d3<=$r)
      return 1; 

   $d2=pow( ( pow(($x+1),2) + pow(($y),2) ), 0.5 ); 
   $d4=pow( ( pow(($x),2) + pow(($y+1),2) ), 0.5 ); 

   # p or t 
   if ($d2==$r)
      $p=1; 
   elseif ($d2>$r)
      $p = ( pow( ( pow($r,2) - pow($y,2) ), 0.5 ) - $x ); 
   else  
      $t = ( pow( ( pow($r,2) - pow(($x+1),2) ), 0.5 ) - $y ); 

   # q or s 
   if ($d4==$r)
      $q=1; 
   else if ($d4>$r)
      $q = ( pow( ( pow($r,2) - pow($x,2) ), 0.5 ) - $y ); 
   else
      $s = ( pow( ( pow($r,2) - pow(($y+1),2) ), 0.5 ) - $x ); 

   # area 
   if ($p&&$q) 
      return (0.5*$p*$q); 
   else if ($q&&$t) 
      return (0.5*($q+$t)); 
   else if ($s&&$p) 
      return (0.5*($p+$s)); 
   else if ($t&&$s)
      return ( 0.5*(2+($s-1)*(1-$t)) ); 
   } 


### scan gif 
$r=$side; 

for($x=0;$x<$r;$x++)
   { 
   for($y=0;$y<$r;$y++)
      { 
      $area=getarea($x,$y); 
      ### flip image 
      (strchr($cnr,'b')) ? ($ty=$y) : ($ty=$side-$y-1); 
      (strchr($cnr,'r')) ? ($tx=$x) : ($tx=$side-$x-1); 
      colorise($tx,$ty,$area); 
      } 
 } 

Header("Content-type: image/gif"); 
ImageGif($corner); 

?>



----------------------------------------------------------------
Get your free email from AltaVista at http://altavista.iname.com




On Sun, 25 Feb 2001 18:21, Brandon Feldhahn wrote:
> what do i put in the "Sendmail_from" section of php.ini?

Did you check the documentation, or the sample ini file? According to the 
docs,

sendmail_from string

Which "From:" mail address should be used in mail sent from PHP under 
Windows.

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA






__________John Monfort_________________
_+-----------------------------------+_
     P E P I E  D E S I G N S
       www.pepiedesigns.com
"The world is waiting, are you ready?"
-+___________________________________+-

On Mon, 26 Feb 2001, David Robley wrote:

> On Sun, 25 Feb 2001 18:21, Brandon Feldhahn wrote:
> > what do i put in the "Sendmail_from" section of php.ini?
>
> Did you check the documentation, or the sample ini file? According to the
> docs,
>
> sendmail_from string
>
> Which "From:" mail address should be used in mail sent from PHP under
> Windows.
>
> --
> David Robley                        | WEBMASTER & Mail List Admin
> RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
> AusEinet                            | http://auseinet.flinders.edu.au/
>             Flinders University, ADELAIDE, SOUTH AUSTRALIA
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>





On Mon, Feb 26, 2001 at 11:22:20AM +1030, David Robley wrote:
> On Sun, 25 Feb 2001 18:21, Brandon Feldhahn wrote:
> > what do i put in the "Sendmail_from" section of php.ini?
> 
> Did you check the documentation, or the sample ini file? According to the 
> docs,
> 
> sendmail_from string
> 
> Which "From:" mail address should be used in mail sent from PHP under 
> Windows.

It works also under GNU/Linux. I haven't tested it under Unix. The
comments in php.ini may be wrong.

-Egon

-- 
http://www.linuxtag.de/
http://php.net/books.php 
http://www.concert-band.de/
http://www.php-buch.de/




How can I get php to print a long string and ignore any of the characters in the string?
 
ie:
$string = "so<me'strin^g";
print $string;
 
isn't there some kind of command to use that keeps the string exactly as it is?
 
 
 
Clayton Dukes
CCNA, CCDA, CCDP, CCNP
Internetwork Solutions Engineer
Internetwork Management Engineer
Thrupoint, Inc.
Tampa, FL
(c) 904.477.7825
(h) 904.292.1881




Clayton,

Have a look at http://www.php.net/manual/en/function.addslashes.php

I've not used them, there are also references to stripslashes, you may need 
to experiment a bit.

Miles

At 07:56 PM 2/25/01 -0500, Clayton Dukes wrote:
>How can I get php to print a long string and ignore any of the characters 
>in the string?
>
>ie:
>$string = "so<me'strin^g";
>print $string;
>
>isn't there some kind of command to use that keeps the string exactly as 
>it is?
>
>
>
>Clayton Dukes
>CCNA, CCDA, CCDP, CCNP
>Internetwork Solutions Engineer
>Internetwork Management Engineer
>Thrupoint, Inc.
>Tampa, FL
>(c) 904.477.7825
>(h) 904.292.1881
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





Does any one know where there are some tutorials for the switch statement?

Peter Houchin
Sun Rentals
[EMAIL PROTECTED]





Here is a basic example.

switch ($option)
{

case "optiona":
statements;
statements;
break;

case "optionb":
statements;
break;

}




----- Original Message -----
From: "Peter Houchin" <[EMAIL PROTECTED]>
To: "PHP MAIL GROUP" <[EMAIL PROTECTED]>
Sent: Sunday, February 25, 2001 9:03 PM
Subject: [PHP] switch statement


> Does any one know where there are some tutorials for the switch statement?
>
> Peter Houchin
> Sun Rentals
> [EMAIL PROTECTED]
>
>





On Mon, 26 Feb 2001 12:33, Peter Houchin wrote:

> > Does any one know where there are some tutorials for the switch
> statement?
 
> Peter Houchin
> Sun Rentals
> [EMAIL PROTECTED]
>
 
Have a quick look at 
http://www.php.net/manual/en/control-structures.switch.php
which has some user notes which are possibly useful over and above the 
actual documentation.

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA





I'm playing aruond with the switch statement trying to get one to work for
$submit
I have 2 forms on the one page (only one displays at a time) 1 is for
creating a new record in my data base the other is for updating/changing
values from the first form should there be any. So i want it to switch
between the 2 cases
-----Original Message-----
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 26, 2001 1:34 PM
To: Peter Houchin; PHP MAIL GROUP
Subject: Re: [PHP] switch statement


On Mon, 26 Feb 2001 12:33, Peter Houchin wrote:

> > Does any one know where there are some tutorials for the switch
> statement?

> Peter Houchin
> Sun Rentals
> [EMAIL PROTECTED]
>

Have a quick look at
http://www.php.net/manual/en/control-structures.switch.php
which has some user notes which are possibly useful over and above the
actual documentation.

--
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]






On Mon, 26 Feb 2001 13:20, Peter Houchin wrote:
> I'm playing aruond with the switch statement trying to get one to work
> for $submit
> I have 2 forms on the one page (only one displays at a time) 1 is for
> creating a new record in my data base the other is for
> updating/changing values from the first form should there be any. So i
> want it to switch between the 2 cases

OK. Suppose the possible values for $submit are 'insert' and 'update'. [I 
assume those are values _you_ can assign to a submit button]

Then

switch($submit) {

case 'insert':
  // Your insert stuff here
  break; //So it doesn't fall through to the next case

case 'update:
  // Your update stuff here
  break;

case default:
  // The page has somehow been called without a value (or an
  // inappropriate value) for submit
  // Error handling or whatever here

}

Does that make it clearer? or muddier :-)

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA




I have created a config.php3 to store the connection of the database and
some constant variable. Then, I created the other file functions.php3 and
inculde config.php3 into this file for function.phps3 should use some
variables inside the file config.php3. However, I don't know why all the
variable cannot display in the function.php3.

would anyone please to tell me what is the reason and how I can solve it?






On Mon, 26 Feb 2001 13:29, JW wrote:
> I have created a config.php3 to store the connection of the database
> and some constant variable. Then, I created the other file
> functions.php3 and inculde config.php3 into this file for
> function.phps3 should use some variables inside the file config.php3.
> However, I don't know why all the variable cannot display in the
> function.php3.
>
> would anyone please to tell me what is the reason and how I can solve
> it?

You may need to declare the variables global within the function, or pass 
them as arguments to the function.

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA




Am i wrong or php does not support mysql_info() function ?

Is there plans to support it?

thanks in advance!




Okay, I got a bit of a curley one that I havent been able to solve by 
looking at the archives and in the manual. Its kind of a PHP/Apache question.

I have a system where a user logs in through .htaccess, it queries my mysql 
database, sets a cookie which logs their username and access level number.

What I want to be able to do it this.......... Give the option to "Log Out" 
which will clear the cookie, and also make htaccess re-request a login. 
Once it logs in again, the current scripts do their thang and log the new 
user in.


Is there any direction anyone can point me to start looking cause I have a 
feeling im off the track on what im searching for in TFM and in TFA.



Chris


--
       Chris Aitken - Webmaster/Database Designer - IDEAL Internet
email: [EMAIL PROTECTED]  phone: +61 2 4628 8888  fax: +61 2 4628 8890
             --------------------------------------------

       Unix -- because a computer's a terrible thing to waste!





Im trying to build a user login system, and when there is a new user, I need
to validate that they are usign using word characters ([0-9A-Za-z_] or
\w)... I have TRIED MANY different regular expressions to test this, but
none work. This seems so simple but I am missing something. I need a
expression that returs true ONLY if ALL the characters match \w .... Any
help would be appreciated.






From: "Dan Watt" <[EMAIL PROTECTED]>

> Im trying to build a user login system, and when there is a new user, I
need
> to validate that they are usign using word characters ([0-9A-Za-z_] or
> \w)... I have TRIED MANY different regular expressions to test this, but
> none work. This seems so simple but I am missing something. I need a
> expression that returs true ONLY if ALL the characters match \w .... Any
> help would be appreciated.
>
>


<?php
    $username = "johnny";

    if (!eregi("[^A-Z0-9_-]", $username))
    {
        echo "username OK";
    }
    else
    {
        echo "bad username!";
    }
?>

Assuming you only want letters, numbers, underscores or hyphens. If you
really want \w you would need to use preg instead of ereg, and then you need
PCRE support in PHP. Or you could use ereg's character classes, I think the
pattern would look like: "[^[:alphanum:]]". However you are probably better
off using an explicit set of characters as I have shown, so that it is
obvious what is and is not allowed.


Cheers

Simon Garner






ok, that was my problem.... Was using ereg... All the places I read about
how to do regular expressions (book, online...) did NOT clarify that \w and
such would need preg.. Thanks!

""Simon Garner"" <[EMAIL PROTECTED]> wrote in message
022d01c09fa6$a2bbd460$[EMAIL PROTECTED]">news:022d01c09fa6$a2bbd460$[EMAIL PROTECTED]...
> From: "Dan Watt" <[EMAIL PROTECTED]>
>
> > Im trying to build a user login system, and when there is a new user, I
> need
> > to validate that they are usign using word characters ([0-9A-Za-z_] or
> > \w)... I have TRIED MANY different regular expressions to test this, but
> > none work. This seems so simple but I am missing something. I need a
> > expression that returs true ONLY if ALL the characters match \w .... Any
> > help would be appreciated.
> >
> >
>
>
> <?php
>     $username = "johnny";
>
>     if (!eregi("[^A-Z0-9_-]", $username))
>     {
>         echo "username OK";
>     }
>     else
>     {
>         echo "bad username!";
>     }
> ?>
>
> Assuming you only want letters, numbers, underscores or hyphens. If you
> really want \w you would need to use preg instead of ereg, and then you
need
> PCRE support in PHP. Or you could use ereg's character classes, I think
the
> pattern would look like: "[^[:alphanum:]]". However you are probably
better
> off using an explicit set of characters as I have shown, so that it is
> obvious what is and is not allowed.
>
>
> Cheers
>
> Simon Garner
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>






From: "Dan Watt" <[EMAIL PROTECTED]>

> ok, that was my problem.... Was using ereg... All the places I read about
> how to do regular expressions (book, online...) did NOT clarify that \w
and
> such would need preg.. Thanks!
>


No prob - yeah, \w is a Perl feature :)

(preg = PCRE = Perl Compatible Regular Expressions)



Cheers

Simon Garner





Greetings!

Is there any equivalent code for (JavaScript) <a
href=JavaScript:history-back(1)>Back Button</a> in php?

This works as back button on the menu bar.

Looking forward to hearing from you.

regards,
DT





The problem with this (the javascript history) is it bites on frames.

One thing you could do is

print("<a href=\"" . $HTTP_REFERER . "\">Go back</a>");

or some such. At least then you could do referer sanity checking to make 
sure you didn't dump the user somewhere nonsensical (if they've bookmarked 
something in the middle of your site.

Robert

At 10:37 AM 26/02/2001 +0545, Deependra B. Tandukar wrote:
>Greetings!
>
>Is there any equivalent code for (JavaScript) <a
>href=JavaScript:history-back(1)>Back Button</a> in php?
>
>This works as back button on the menu bar.
>
>Looking forward to hearing from you.
>
>regards,
>DT
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

Robert Gormley
[EMAIL PROTECTED]
http://distortedreality.net





From: "Deependra B. Tandukar" <[EMAIL PROTECTED]>

> Greetings!
>
> Is there any equivalent code for (JavaScript) <a
> href=JavaScript:history-back(1)>Back Button</a> in php?
>
> This works as back button on the menu bar.
>
> Looking forward to hearing from you.
>
> regards,
> DT
>
>


Yes, but it works differently. If the user typed in the URL of your page
(instead of clicking a link) then you can't go back from PHP, so you need to
be careful. Here's some sample code:


<?php
    $referer = getenv("HTTP_REFERER");

    if ($referer)
    {
        $url = $referer;
    }
    else
    {
        // can't go back... try JS instead
        $url = "javascript:history.back()";
    }

    echo "<a href=\"$url\">Back Button</a>";
?>



Cheers

Simon Garner





I have php4 running under Apache. Under that apache I have several
<VirtualHost>s. I want to set to some of the PHP.INI values under
one of those hosts. So far I have tried the following values in
my httpd.conf file:

    1) include_path       "/my/phpinc/path"
    2) php_include_path   "/my/phpinc/path"
    3) php3_include_path  "/my/phpinc/path"
    4) php4_include_path  "/my/phpinc/path"

None of them have worked - I can't even restart Apache with them in place.
"/my/phpinc/path" definitely exists.

What am I doing wrong?

Regs

Brian White
-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]



Reply via email to