php-general Digest 11 Mar 2005 17:32:13 -0000 Issue 3332

Topics (messages 210495 through 210522):

Re: Using javascript function from php
        210495 by: b.rbz.biz

HELP TO GET OUT OF PHP MAILING LIST
        210496 by: Abiodun Akala

Re: free php live chat with visitor/customer script
        210497 by: Kim Madsen

Re: Increase execution time
        210498 by: Kim Madsen

Re: incrementing a number from a text file
        210499 by: Kim Madsen
        210501 by: Ross Hulford
        210506 by: Steve Buehler
        210510 by: Ariceaga, Luis TQM
        210515 by: Jason Barnett
        210521 by: Richard Lynch

showing an image with php
        210500 by: Ross Hulford
        210514 by: Jason Barnett
        210520 by: Richard Lynch

Re: Imap and attachments
        210502 by: Evert | Rooftop Solutions

Re: PHP 5.0.3 and base64 encoded cookie value issue?
        210503 by: Pink Floyd

Newbie Question: breaking a substr() string on a space
        210504 by: Jackson Linux
        210505 by: Jay Blanchard
        210509 by: Jackson Linux
        210513 by: John Nichel

Re: PHP help Quotations, Quotations, Quotations
        210507 by: stg
        210516 by: Jason Barnett

Re: PHP causes Apache segmentation fault?
        210508 by: Burhan Khalid
        210517 by: John Swartzentruber
        210518 by: John Swartzentruber

Searching Multiple Columns, Multiple Tables in MySQL...
        210511 by: Nick Zukin

Re: Temporary storage of data
        210512 by: Jason Barnett
        210519 by: Dan Trainor

How to ge the ones which are not
        210522 by: Mário Gamito

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 ---
It's OK I worked it out.

On Fri, 11 Mar 2005 15:44:55 +1100, <[EMAIL PROTECTED]> wrote:

Hi,

I am just learning php, and am currently converting some jsp pages to php. I used the follwing code in jsp to toggle between two images

<SCRIPT type="text/javascript" language=javascript>
function toggle(imagename,src1,src2){
if(document.images && document.images[imagename])
{
image1=new Image;
image1.src=src1;
if(document.images[imagename].src != image1.src){document.images[imagename].src = image1.src}
else{document.images[imagename].src=src2}
}
}
</SCRIPT>

start code snippet.............
out.println("<A");
out.println("onclick=\"toggle('" + child + "image','images/" + type + ".jpg','images/" + childimg "');return(false);\"");
out.println("><img src='images/" + type + ".jpg' alt='' name=" + child + "image></a>");
out.println("<input type=hidden name=" + child + " value='" + childimg + "'>");
end code snippet...............

I have tried many different ways to achieve this in php, but nothing works. This is my latest attempt

start code snippet.............
print("<A href=\"javascript:;\" onclick=");
echo "\"if(document.images && document.images[" . $child . "image])\n";
echo " {\n";
echo " image1=new Image;\n";
echo " image1.src=images/$type.jpg;\n";
echo " if(document.images[" . $child . "image].src != image1.src){document.images[" . $child . "image].src = image1.src}\n";
echo " else{document.images[" . $child . "image].src=images/$childimg}\n";
echo " }\n";
echo "};\n";
echo "return(false);\">\n";
print("<img src='images/$type.jpg' alt='' name=" . $child . "image>\n</a>\n");
print("<input type=hidden name=$child value='$childimg'>\n");
end code snippet.............

Could someone please let me know how to do this

Cheers
Barb




-- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

--- End Message ---
--- Begin Message ---
Hello everyone,
 
I just need your assistance on how to unsubscribe from PHP mail list. I have 
tried all the automated approach but no luck. The system keeps rejecting my 
"unsubscribe" request. I get more than 200 unsolicited mailS on PHP daily that 
do not mean anything to me because I did not subscribe to it in the first place 
- not a computer guru.
 
Any help to lead me to effectively unsubscribe will be well appreciated. My 
mail box has been overtaken completely by this service which is of no value to 
me.
 
Regards,
Biodun


stg <[EMAIL PROTECTED]> wrote:

Hello,



I am having a small issue with posting from forms;



It goes like such:



I have a form in which a user can type in a message and in a hidden text
field a link is sent, then in the page the form goes to it sends and email
to a mailing list with the message and a link underneath bottom.



However when I submit a hyperlink in a form like 

 [input] href="http://localhost/knewsl/"; >



It is received in the next page with a "\" before every " " " for example: 

Click here to view
newsletter - Which obviously doesn't work.



I would be most grateful if anyone could help.



Cheers,

Simon


                
---------------------------------
Do you Yahoo!?
 Make Yahoo! your home page   

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: p80 [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 11, 2005 1:17 AM
To: php-general@lists.php.net
Subject: [PHP] free php live chat with visitor/customer script

> I was recently visiting a commercial site and suddunly a window chat 
> popped up and some assistant asked me if I needed some help. I thought 
> this was pretty cool and I was wondering if such a thing existed in php, i > 
> know there are lots of php live chat script out there but I'm not sure if > 
> they allow to monitor visitors on your webpage and launch a window chat to 
> the visitor of your choice. does anyone know of such a thing in PHP? I 
> think the application on that site I visited was a java applet.

One way to approach this could be that You set a start visiting time in a 
session, when the user enters the site. If he/she is still online after letīs 
say 5 minutes, then a Javascript window is popped up. Notice that popup 
blockers kill more than 50% of all popups (a stat I implemented a couple of 
months ago on 2 heavily visited sites in Denmark).

The popup window access a script, that for instance could be made with fopen(), 
fwrite(), fclose(), which opens, reads and write to a txtfile, that has the 
name of the session_id

On the admin site, where the employee is suppose to see users, You can read all 
txt files in the dir with opendir() and readdir(). Of course You will need to 
have a clean up script to get rid of or move ended chat sessions.

I hope this will give You enough ideas to start Your project :-)

Sincerely 
Kim Madsen

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Jeremy Schreckhise [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 10, 2005 11:25 PM
To: php-general@lists.php.net
Subject: [PHP] Increase execution time

> How do you increase the execution time in php?

Like You have done

> I have set max_execution_time to 360 and setting set_time_limit(0);
> nothing works.

> I still get Fatal Error: maximum execution time of 60 seconds.

Did You restart the webserver?

Sincerely
Kim Madsen

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 10, 2005 10:14 PM
To: Ross Hulford
Cc: php-general@lists.php.net
Subject: Re: [PHP] incrementing a number from a text file

>> I want to read a number from an external (txt) file and increment it.then
>> save the number back on the text file.
>> I know this is possible but want a simple amd economical way to do this.

> That's what you *THINK* you want to do :-)

> But what happens when *TWO* users hit that same script at exactly the same
> time.

<snip>

> This is why so many early "hit counter" scripts back in the day were
> always getting messed up and reset to 0.

Donīt increase if counter is not read?

> What you really want, almost for sure, is an SQL database with "sequences"

I try NOT to use databases if not nessecary

> You *can* use http://php.net/flock, but even that is a Bad Idea, because
> flock under Un*x is self-imposed -- If some *other* program/script/user
> decides not change that file and doesn't use flock, well, they're not
> STOPPED from doing that.

Poor programming?

> flock is therefore all too subject to human fallibility when you re-work,
> re-write, or add more code to your system.

Every code is... if You donīt use Your head, the outcome will be...? 

If U no nothing about SQL, I use a database to a counter, I get a piece of code 
from a friend "alter table counter auto_increment = 1"; and Iīm curious to see, 
what it does? 

Or better: I put my query in a link like <a 
href="db.php?q=select+*+from+customers">show customers</a> and Iīve got NO clue 
about the settings in the mysql db, so this gets "funny"
<a href="db.php?q=delete+from+customers">show customers</a>
<a href="db.php?q=drop+table+customers">show customers</a>

*whistle*

This _was_ an issue in a company I worked for, along with queries like:

Select blablabla FROM t1,t2,t3
WHERE customers LIKE '%$s%'
OR name LIKE '%$s%'
OR domain LIKE '%$s%'
OR email LIKE '%$s%'
OR log LIKE '%$s%'
AND t1.id = t2.t1_id
AND t1.id = t3.t1_id

Horror!

Kind regards
Kim Madsen

--- End Message ---
--- Begin Message ---
I am just going to adda auto incrementing DB filed and get the numbers that 
way. Seems the best way.


"Kim Madsen" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 10, 2005 10:14 PM
To: Ross Hulford
Cc: php-general@lists.php.net
Subject: Re: [PHP] incrementing a number from a text file

>> I want to read a number from an external (txt) file and increment it.then
>> save the number back on the text file.
>> I know this is possible but want a simple amd economical way to do this.

> That's what you *THINK* you want to do :-)

> But what happens when *TWO* users hit that same script at exactly the same
> time.

<snip>

> This is why so many early "hit counter" scripts back in the day were
> always getting messed up and reset to 0.

Donīt increase if counter is not read?

> What you really want, almost for sure, is an SQL database with "sequences"

I try NOT to use databases if not nessecary

> You *can* use http://php.net/flock, but even that is a Bad Idea, because
> flock under Un*x is self-imposed -- If some *other* program/script/user
> decides not change that file and doesn't use flock, well, they're not
> STOPPED from doing that.

Poor programming?

> flock is therefore all too subject to human fallibility when you re-work,
> re-write, or add more code to your system.

Every code is... if You donīt use Your head, the outcome will be...?

If U no nothing about SQL, I use a database to a counter, I get a piece of 
code from a friend "alter table counter auto_increment = 1"; and Iīm curious 
to see, what it does?

Or better: I put my query in a link like <a 
href="db.php?q=select+*+from+customers">show customers</a> and Iīve got NO 
clue about the settings in the mysql db, so this gets "funny"
<a href="db.php?q=delete+from+customers">show customers</a>
<a href="db.php?q=drop+table+customers">show customers</a>

*whistle*

This _was_ an issue in a company I worked for, along with queries like:

Select blablabla FROM t1,t2,t3
WHERE customers LIKE '%$s%'
OR name LIKE '%$s%'
OR domain LIKE '%$s%'
OR email LIKE '%$s%'
OR log LIKE '%$s%'
AND t1.id = t2.t1_id
AND t1.id = t3.t1_id

Horror!

Kind regards
Kim Madsen 

--- End Message ---
--- Begin Message ---
At 03:14 PM 3/10/2005, Richard Lynch wrote:

> I want to read a number from an external (txt) file and increment it.then
> save the number back on the text file.
> I know this is possible but want a simple amd economical way to do this.

That's what you *THINK* you want to do :-)

But what happens when *TWO* users hit that same script at exactly the same
time.

Richard has a good idea about using mysql to do this. Some things I have not tried, but might also do for you is php's flock http://www.php.net/flock . Or go to http://www.php.net/fopen and search the page for "lock" (no quotes). The example you might want was the 4th instance of that word that I found.
<?php
#going to update last users counter script since
#aborting a write because a file is locked is not correct.

$counter_file = '/tmp/counter.txt';
clearstatcache();
ignore_user_abort(true); ## prevent refresh from aborting file operations and hosing file
if (file_exists($counter_file)) {
$fh = fopen($counter_file, 'r+');
while(1) {
if (flock($fh, LOCK_EX)) {
#$buffer = chop(fgets($fh, 2));
$buffer = chop(fread($fh, filesize($counter_file)));
$buffer++;
rewind($fh);
fwrite($fh, $buffer);
fflush($fh);
ftruncate($fh, ftell($fh));
flock($fh, LOCK_UN);
break;
}
}
}
else {
$fh = fopen($counter_file, 'w+');
fwrite($fh, "1");
$buffer="1";
}
fclose($fh);

print "Count is $buffer";

?>
--- End Message ---
--- Begin Message ---
Is it possible to let the OS handle the collisions?

For example:

$last_value = system('cat counter.txt', $retval);
$last_value++;
$result = system('echo $last_value > counter.txt', $retval);

...just a suggestion!

Regards
/Luis



-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 10, 2005 3:14 PM
To: Ross Hulford
Cc: php-general@lists.php.net
Subject: Re: [PHP] incrementing a number from a text file

> I want to read a number from an external (txt) file and increment 
> it.then save the number back on the text file.
> I know this is possible but want a simple amd economical way to do
this.

That's what you *THINK* you want to do :-)

But what happens when *TWO* users hit that same script at exactly the
same time.

At best, you get:

User1             User2
Reads 9          Reads 9
Writes 10         Writes 10

and when you should have 11, you've only got 10.

[aside] "My amp goes to 11!" [/aside]

But it's worse than that:  It's entirely poassible that your script,
instead of having two users write "10" one after the other, will have
two users both trying to write "10" at EXACTLY the same time.

The result is comparable to a head-on collision between two trains.
Your file is TOAST.

This is why so many early "hit counter" scripts back in the day were
always getting messed up and reset to 0.

What you really want, almost for sure, is an SQL database with
"sequences"

You have to forge those in MySQL by making a table with auto_increment.

You *can* use http://php.net/flock, but even that is a Bad Idea, because
flock under Un*x is self-imposed -- If some *other* program/script/user
decides not change that file and doesn't use flock, well, they're not
STOPPED from doing that.

flock is therefore all too subject to human fallibility when you
re-work, re-write, or add more code to your system.

The SQL guys have worked out this problem, in all respects.

This is one of those things that SEEMS so simple that turns out to be a
hell of a lot more involved than you thought at first.  So it goes.

--
Like Music?
http://l-i-e.com/artists.htm

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

--- End Message ---
--- Begin Message ---
Luis TQM Ariceaga wrote:
> Is it possible to let the OS handle the collisions?
>
> For example:
>
> $last_value = system('cat counter.txt', $retval);
> $last_value++;
> $result = system('echo $last_value > counter.txt', $retval);
>
> ....just a suggestion!
>

Luis: if the OS handled the read/write collisions then you could just
file_*_contents() and be done with it.  Unfortunately it's not that
simple in any situation where you might have more than one person trying
to access the same PHP page at *exactly* the same time.

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
> Is it possible to let the OS handle the collisions?
>
> For example:
>
> $last_value = system('cat counter.txt', $retval);
> $last_value++;
> $result = system('echo $last_value > counter.txt', $retval);
>
> ...just a suggestion!

Even if your OS guarantees locks on > re-direct, you'd still have the
*WRONG* number in there any time two people did this at the same time.

>
> Regards
> /Luis
>
>
>
> -----Original Message-----
> From: Richard Lynch [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 10, 2005 3:14 PM
> To: Ross Hulford
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] incrementing a number from a text file
>
>> I want to read a number from an external (txt) file and increment
>> it.then save the number back on the text file.
>> I know this is possible but want a simple amd economical way to do
> this.
>
> That's what you *THINK* you want to do :-)
>
> But what happens when *TWO* users hit that same script at exactly the
> same time.
>
> At best, you get:
>
> User1             User2
> Reads 9          Reads 9
> Writes 10         Writes 10
>
> and when you should have 11, you've only got 10.
>
> [aside] "My amp goes to 11!" [/aside]
>
> But it's worse than that:  It's entirely poassible that your script,
> instead of having two users write "10" one after the other, will have
> two users both trying to write "10" at EXACTLY the same time.
>
> The result is comparable to a head-on collision between two trains.
> Your file is TOAST.
>
> This is why so many early "hit counter" scripts back in the day were
> always getting messed up and reset to 0.
>
> What you really want, almost for sure, is an SQL database with
> "sequences"
>
> You have to forge those in MySQL by making a table with auto_increment.
>
> You *can* use http://php.net/flock, but even that is a Bad Idea, because
> flock under Un*x is self-imposed -- If some *other* program/script/user
> decides not change that file and doesn't use flock, well, they're not
> STOPPED from doing that.
>
> flock is therefore all too subject to human fallibility when you
> re-work, re-write, or add more code to your system.
>
> The SQL guys have worked out this problem, in all respects.
>
> This is one of those things that SEEMS so simple that turns out to be a
> hell of a lot more involved than you thought at first.  So it goes.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> 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
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
I want to asssign an image to a variable and show it if certain conditions 
are met. E.g


If condition is met

{
$myimage= retrieve image (images/myimage.jpg)
 echo $myimage
}

Have not used image creation before with php just dipping my toe in the 
water.

Thanks


R. 

--- End Message ---
--- Begin Message ---
Ross Hulford wrote:
> I want to asssign an image to a variable and show it if certain conditions
> are met. E.g
>

Make it a little more clear what you want.  Is this an already existing
image, or one you are trying to create?  If it already exists then you
want to use an img tag.

<?php echo '<img src="/path/to/image.jpg" />'; ?>

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
> I want to asssign an image to a variable and show it if certain conditions
> are met. E.g
>
>
> If condition is met
>
> {
> $myimage= retrieve image (images/myimage.jpg)
>  echo $myimage
> }
>
> Have not used image creation before with php just dipping my toe in the
> water.

Not sure you need to use image creation now.

All you seem to really want to do is display an <IMG tag, or not, based on
the if.

if (...){
  echo "<img src=images/myimage.jpg>";
}

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Jim Plush wrote:

here is a script I use to get jpg attachments with IMAP.. good luck

<?php
[snip]


Thanx Jim,

Unfortunaly some e-mail clients send the headers in ways the imap-functions can't read. So I figured something out using regular expressions. If anyone needs this, mail me (in total it's a big script, so I won't post it here)

grt,
Evert

--- End Message ---
--- Begin Message ---
Greetings again,
 Thanks to richard for pointing out a good way to
devle
into the source. It appears after browsing through the
source that the ' ' (space) is encoded to '+'. Also
the
characters '_', '-', '.' do get special treatment.

Obviously, this works great in the scenario where the
cookie is set by the PHP/Server and retrieved by a
PHP/Server.

Since the encoding is not mandated by the spec, I
guess I cannot fault PHP for doing what it does. But I
am curious as to what led to the design decision to
encode ' ' to '+'.

Thanks to richard and others for all the help.
MK

[snipped the previous threads]
 


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

--- End Message ---
--- Begin Message --- Hi, everyone, I apologise if this posts twice; I'm having issues with my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some articles. This works great:

    $content = strip_tags($article['content']);
    $striptease = substr($content, 0, 275);

but cuts off words right in the midd ...

I'd like to find a way to take $content, look at the first 250 characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?

Thanks in advance,
Jack

--- End Message ---
--- Begin Message ---
[snip]
Hi, everyone, I apologise if this posts twice; I'm having issues with 
my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some 
articles. This works great:

     $content = strip_tags($article['content']);
     $striptease = substr($content, 0, 275);

but cuts off words right in the midd ...
[/snip]

http://www.php.net/explode you can use to get individual words.....

--- End Message ---
--- Begin Message ---
Hi, everyone,

I'm 'teasers' of the first, say 200 to 250 characters of some articles. This works great:

    $content = strip_tags($article['content']);
    $striptease = substr($content, 0, 275);

but cuts off words right in the midd ...

I'd like to find a way to take $content, look at the first 250 characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?

Thanks in advance,
Jack

--- End Message ---
--- Begin Message --- Jackson Linux wrote:
Hi, everyone, I apologise if this posts twice; I'm having issues with my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some articles. This works great:

    $content = strip_tags($article['content']);
    $striptease = substr($content, 0, 275);

but cuts off words right in the midd ...

I'd like to find a way to take $content, look at the first 250 characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?

Thanks in advance,
Jack


You can do something like this...

function subEndWord ( $string, $start, $max ) {
        $string = substr ( $string, $start, $max );
        $string = preg_replace ( "/\s\w+$/", "", $string );
        return $string;
}

Untested, but should work.  Tinker with the RegEx to perfect it.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Thanks a lot for that, I am really grateful, now it sends along the link
properly, which is great, however it is now having trouble converting spaces
to %20 and it does it for some and not others, eg

It does this:
http://localhost/knewsl/NewsletterName.pdf

When it should be:
http://localhost/knewsl/Newsletter%20Name.pdf

Cheers,
Simon


-----Original Message-----
From: Stephen Johnson [mailto:[EMAIL PROTECTED] 
Sent: Friday, 11 March 2005 1:32 PM
To: stg
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP help Quotations, Quotations, Quotations

http://www.php.net/stripslashes


On Mar 10, 2005, at 9:17 PM, stg wrote:

> Hello,
>
>
>
> I am having a small issue with posting from forms;
>
>
>
> It goes like such:
>
>
>
> I have a form in which a user can type in a message and in a hidden 
> text
> field a link is sent, then in the page the form goes to it sends and 
> email
> to a mailing list with the message and a link underneath bottom.
>
>
>
> However when I submit a hyperlink in a form like
>
> <input type="hidden" name="link" value=<a
> href="http://localhost/knewsl/<?php echo $row_Recordset1['path']; ?>" >
>
>
>
> It is received in the next page with a "\" before every " " " for 
> example:
>
> <a href=\"http://localhost/knewsl/file.pdf\";>Click here to view
> newsletter</a> -  Which obviously doesn't work.
>
>
>
> I would be most grateful if anyone could help.
>
>
>
> Cheers,
>
> Simon
>
>
*********
Stephen Johnson
[EMAIL PROTECTED]
http://www.thelonecoder.com

--continuing the struggle against bad code--
*********

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

--- End Message ---
--- Begin Message ---
Stg wrote:
> Thanks a lot for that, I am really grateful, now it sends along the link
> properly, which is great, however it is now having trouble converting spaces
> to %20 and it does it for some and not others, eg
>
> It does this:
> http://localhost/knewsl/NewsletterName.pdf
>
> When it should be:
> http://localhost/knewsl/Newsletter%20Name.pdf
>
...

urlencode()

http://php.net/manual/en/function.urlencode.php

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message --- John Swartzentruber wrote:
I am running Fedora core3 with Apache 2.0.52 (from default RPMs), MySQL 4.1.10 (from RPMs from MySQL site), and PHP 5.0.3 built from source.

I'm going through the PHP manual and trying some of the mysqli examples. The last one I tried didn't work. The problem appears to be this line:

$row = $result->fetch_array(MYSQLI_ASSOC);

Using MYSQLI_BOTH also fails, and MYSQLI_NUM works.

This is what is in my httpd error log:

[Thu Mar 10 17:07:06 2005] [error] jk2_init() Can't find child 29980 in scoreboard
[Thu Mar 10 17:07:06 2005] [notice] workerEnv.init() ok /etc/httpd/conf/workers2.properties
[Thu Mar 10 17:07:06 2005] [error] mod_jk child init 1 -2
[Thu Mar 10 17:07:06 2005] [notice] child pid 29903 exit signal Segmentation fault (11)

I'm not sure these lines are the ones that are triggered from PHP. These seem to be Tomcat/JSP related (mod_jk)
--- End Message ---
--- Begin Message --- On 3/11/2005 10:33 AM Burhan Khalid wrote:
John Swartzentruber wrote:

I am running Fedora core3 with Apache 2.0.52 (from default RPMs), MySQL 4.1.10 (from RPMs from MySQL site), and PHP 5.0.3 built from source.

I'm going through the PHP manual and trying some of the mysqli examples. The last one I tried didn't work. The problem appears to be this line:

$row = $result->fetch_array(MYSQLI_ASSOC);

Using MYSQLI_BOTH also fails, and MYSQLI_NUM works.

This is what is in my httpd error log:

[Thu Mar 10 17:07:06 2005] [error] jk2_init() Can't find child 29980 in scoreboard
[Thu Mar 10 17:07:06 2005] [notice] workerEnv.init() ok /etc/httpd/conf/workers2.properties
[Thu Mar 10 17:07:06 2005] [error] mod_jk child init 1 -2
[Thu Mar 10 17:07:06 2005] [notice] child pid 29903 exit signal Segmentation fault (11)


I'm not sure these lines are the ones that are triggered from PHP. These seem to be Tomcat/JSP related (mod_jk)

I just tried it again, and it looks like I included too much information. This is all I got this time:

[Fri Mar 11 11:55:04 2005] [notice] child pid 31108 exit signal Segmentation fault (11)

So even though the other messages came through at the same time, it might only be the last one that is significant.
--- End Message ---
--- Begin Message --- On 3/11/2005 10:33 AM Burhan Khalid wrote:
John Swartzentruber wrote:

I am running Fedora core3 with Apache 2.0.52 (from default RPMs), MySQL 4.1.10 (from RPMs from MySQL site), and PHP 5.0.3 built from source.

I'm going through the PHP manual and trying some of the mysqli examples. The last one I tried didn't work. The problem appears to be this line:

$row = $result->fetch_array(MYSQLI_ASSOC);

Using MYSQLI_BOTH also fails, and MYSQLI_NUM works.

This is what is in my httpd error log:

[Thu Mar 10 17:07:06 2005] [error] jk2_init() Can't find child 29980 in scoreboard
[Thu Mar 10 17:07:06 2005] [notice] workerEnv.init() ok /etc/httpd/conf/workers2.properties
[Thu Mar 10 17:07:06 2005] [error] mod_jk child init 1 -2
[Thu Mar 10 17:07:06 2005] [notice] child pid 29903 exit signal Segmentation fault (11)


I'm not sure these lines are the ones that are triggered from PHP. These seem to be Tomcat/JSP related (mod_jk)

I just tried it again, and it looks like I included too much information. This is all I got this time:

[Fri Mar 11 11:55:04 2005] [notice] child pid 31108 exit signal Segmentation fault (11)

So even though the other messages came through at the same time, it might only be the last one that is significant.
--- End Message ---
--- Begin Message ---
Sorry if this is too DB oriented.

PHP 4.3, MySQL 3.23

I've got a somewhat complex search of a MySQL database I'm trying to make.
(At least it's complex to me.)  And I'm wondering if it's better to try to
handle it in MySQL or to split it up into multiple processes using PHP.

Essentially, I have three tables: vendors, products, and a join table for
vendors and products:

VENDORS
-------
vendorid INT
vendorname VARCHAR
vendorcategory VARCHAR

PRODUCTS
--------
productid INT
productname VARCHAR
productcategory VARCHAR

JOINS
-----
xid INT
xproductid INT
xvendorid INT

I want to be able to do a keyword search of sorts with a list of vendors as
the result.  However, I want one value from a form to be used to search
three columns in two different tables: vendorcategory, productname, and
productcategory.  Of course, the join table would have to be used to make
sure that the product names and categories that match give corresponding
vendors.

There's probably some method of using MySQL to do this with one query, but
it's beyond me.  And experience tells me that sometimes it's easier or
better to use PHP (or even necessary to use PHP) to get the results how I
want them, often splitting complex queries into two parts.

Any suggestions?

Thanks.

--- End Message ---
--- Begin Message ---
Dan wrote:
> dan wrote:
>
...

Before we go through all of this, why isn't SQLite an option?  It is in
by default as of PHP5.0.0 so if the server is / will be PHP5 soon then I
would go that route.

http://php.net/manual/en/ref.sqlite.php

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message --- Jason Barnett wrote:
Dan wrote:

dan wrote:


...

Before we go through all of this, why isn't SQLite an option?  It is in
by default as of PHP5.0.0 so if the server is / will be PHP5 soon then I
would go that route.

http://php.net/manual/en/ref.sqlite.php


Jason -

Yea, I saw that, but for this I have to assume that they're running 4.x, else I most definately would go the route of SQLite :/

Thanks
-dant

--- End Message ---
--- Begin Message ---
Hi,

I've built this little regular expression to test wether an e-mail address is valid or not:

if(eregi ("[EMAIL PROTECTED]", $email))
print ('valid email)
else
print ('Invalid email');

--

ok, now i want to use this in a filling form web page scenario.
I have this forms with its fields to be filled and when it gets to the e-mail address textbox, i want to check if the address is not well formed.

So i did (notice the "!" before the eregi):

if (!eregi ("[EMAIL PROTECTED]", $email))
{ send a warn to the user telling the e-mail address is not correct}

--

Well, if the first block of code works pretty good saying if an address is valid or invalid, the second one, when the data from the filled form is checked, always says the adress is invalid.

I thought the "!" would adapt the confition to its new scenario, but, well... as i've told you, it isn't.

Any ideas of how to solve this, i.e., being the regular expression (and it is), what do i have to do to get only the invalid adresses ?
In short, i only want to trap the invalid ones.

Any help would be apreciated.

Warm Regards,
Mário Gamito

--- End Message ---

Reply via email to