php-general Digest 30 Apr 2008 06:53:57 -0000 Issue 5432
Topics (messages 273706 through 273721):
Re: web based chat app
273706 by: Børge Holen
Help with preg_match_all regex for alt tags
273707 by: Joe Harman
273709 by: James Dempster
273711 by: Shawn McKenzie
Re: mysql_connect slowness
273708 by: Joe Harman
Fun with SOAP.
273710 by: Eric Butera
273713 by: Nathan Nobbe
273721 by: Warren Vail
Question regarding fopen
273712 by: Joep Roebroek
273714 by: James
Xampp question, pretty much 0T
273715 by: Ryan S
273716 by: Chris
273718 by: Ryan S
273719 by: Chris
fourat wants to keep up with you on Twitter
273717 by: fourat
Best practices for using MySQL index
273720 by: Shelley
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Tuesday 29 April 2008 06:48:38 paragasu wrote:
> i am planning to integrate chat application on my website.
> the idea is to make online user on my website to chat to each other.
> it is using PHP5+jQuery, i want it to be as light as possible. I am not
> sure about the database to use, but i have 3 options.. file based, sqlite3
> or mysql5.
>
> i am thinking to use sqlite3 because it is fast but afraid it cannot handle
> many user
> request (i remember reading it is not so good for multiple user). It is
> also possible to use
> memory based storage /dev/shm (in debian based, i read somewhere - never
> tried yet)
>
> another issue is how to make it light.The chat script should refresh
> every 200ms to get the best result or even 1 second still bring quite a
> load to the web server.
> anyone ever run a web based application?
>
> or any chat based api i can use out there to save server resource?
You want light outta it? use the jabber2 server as a backend. It'll be done
serving while you try to access the database. No need to do a square wheel,
when a round one is invented
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
Hey y'all ... i am having alittle trouble with this regex for finding
ALT tags for images...
Here is my statement
--------------------------------------------------------------------------------------------------------------------------------
preg_match_all("'alt[^>]*?>.*?[^>]'si", $output, $alt_tags);
Evaluating
--------------------------------------------------------------------------------------------------------------------------------
[other html code]... <img src="images/race-parts_wheels-tires.jpg"
vspace="2" border="0" alt="Wheel & Tire Acc" /> ...[other html code]
I am currently getting
--------------------------------------------------------------------------------------------------------------------------------
alt="Wheel & Tire Acc" /><
I want this result
--------------------------------------------------------------------------------------------------------------------------------
alt="Shopping Cart"
Thanks for your help
--
Joe Harman
--- End Message ---
--- Begin Message ---
try preg_match_all('/<img[^>]*alt="([^"]*)"/i', $subject, $result);
--
/James
On Tue, Apr 29, 2008 at 8:18 PM, Joe Harman <[EMAIL PROTECTED]> wrote:
> Hey y'all ... i am having alittle trouble with this regex for finding
> ALT tags for images...
>
>
> Here is my statement
>
> --------------------------------------------------------------------------------------------------------------------------------
> preg_match_all("'alt[^>]*?>.*?[^>]'si", $output, $alt_tags);
>
> Evaluating
>
> --------------------------------------------------------------------------------------------------------------------------------
> [other html code]... <img src="images/race-parts_wheels-tires.jpg"
> vspace="2" border="0" alt="Wheel & Tire Acc" /> ...[other html code]
>
> I am currently getting
>
> --------------------------------------------------------------------------------------------------------------------------------
> alt="Wheel & Tire Acc" /><
>
> I want this result
>
> --------------------------------------------------------------------------------------------------------------------------------
> alt="Shopping Cart"
>
>
> Thanks for your help
> --
> Joe Harman
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Joe Harman wrote:
Hey y'all ... i am having alittle trouble with this regex for finding
ALT tags for images...
Here is my statement
--------------------------------------------------------------------------------------------------------------------------------
preg_match_all("'alt[^>]*?>.*?[^>]'si", $output, $alt_tags);
Evaluating
--------------------------------------------------------------------------------------------------------------------------------
[other html code]... <img src="images/race-parts_wheels-tires.jpg"
vspace="2" border="0" alt="Wheel & Tire Acc" /> ...[other html code]
I am currently getting
--------------------------------------------------------------------------------------------------------------------------------
alt="Wheel & Tire Acc" /><
I want this result
--------------------------------------------------------------------------------------------------------------------------------
alt="Shopping Cart"
Thanks for your help
preg_match_all('/alt="[^"]*["]/i', $output, $alt_tags);
--- End Message ---
--- Begin Message ---
Hi Waynn!
have you ever tried using
1. sql_cache
SELECT SQL_CACHE * FROM table ......
I use this alot... although you have to have mysql cache enable in the
sql config file... your webhost can tell you if it is on or not
2. make indexes for your tables
here is a good article
http://www.databasejournal.com/features/mysql/article.php/1382791
a great admin program to use is Navicat... it's very easy to make your
indexes there...
Hopefully those 2 suggestions speed up things a little! :o) let us
know if it works
Joe
On Mon, Apr 28, 2008 at 12:14 AM, Waynn Lue <[EMAIL PROTECTED]> wrote:
> Our site has been slowing down dramatically in the last few days, so
> I've been trying to figure out why. I ran some profiling scripts on
> our site and saw that we're spending between 3-9 seconds on
> mysql_connect. Then I connected to our db and saw that there were
> over 100 connections at the time, most of them sleeping. Is this
> because we don't close mysql connections until the end of script
> execution?
>
> How do people generally structure their code to minimize the time they
> keep mysql connections open? Currently all db connections go through
> one file, which gets included at the top of the file. One other
> question, is it better to open one connection, then re-use it later,
> or just continually open and close per db call?
>
> Thanks,
> Waynn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
A fellow co-worker of mine is working on a project integrating with
Amazon using SOAP. I've never used SOAP before but it seemed like
things were straight forward at first. Some parts work while others
done. Right now we are stuck trying to fetch a document from the
remote server.
We are able to connect and get a list of documents as expected. The
PHP 5 SOAP extension handles this like a champ. When a single
document is requested an exception is thrown with the error message
"looks like we got no XML document." The document listing request
returns a simple single text/xml SOAP XML response. The request for a
single document returns a multi-part (multipart/related) response.
Can the PHP 5 soap client even parse such things? I looked at the
manual pages and did Google searching, but I'm not even sure what to
word my queries as. It seems like somehow this should just work as
the script just defines a client and then does the call. So any help
or links to something that explains how this multipart response can be
handled will be greatly appreciated. See below for the script &
responses.
Here is the sample script:
($params and $merchant are defined)
$client = new
SoapClient('https://merchant-api.amazon.com/gateway/merchant-interface-mime',$params);
try {
$doc = $client->getDocument($merchant, 575326853);
} catch(SoapFault $fault) {
var_dump($fault);
}
Here are the raw headers:
HTTP/1.1 200
Date: Tue, 29 Apr 2008 19:33:18 GMT
Server: Server
EmbeddedSOAPServer: WASP-C++ Vespa/4.6, build 2162 (Linux i686
2.6.18-8.el5a2xen #1 SMP Tue Apr 3 16:48:05 PDT 2007)
MIME-Version: 1.0
nnCoection: close
Transfer-Encoding: chunked
Content-Type: multipart/related;
boundary="xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx";
type="text/xml"
Here is the raw XML response from the Amazon server:
--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx
Content-Type: text/xml; charset="UTF-8"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SE="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns0:string_Response
xsi:type="xsd:string"
xmlns:ns0="http://systinet.com/xsd/SchemaTypes/">575326853</ns0:string_Response><ns1:doc
href="cid:0xaff0940-0xb1ebe40-0xb06d3f0-0xb22d500-0xb1ec630"
xmlns:ns1="http://systinet.com/xsd/SchemaTypes/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx
Content-ID: <0xaff0940-0xb1ebe40-0xb06d3f0-0xb22d500-0xb1ec630>
Content-Type: application/binary
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>...</MerchantIdentifier>
</Header>
<MessageType>OrderReport</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderReport>
<AmazonOrderID>...</AmazonOrderID>
<AmazonSessionID>...</AmazonSessionID>
<OrderDate>...</OrderDate>
<OrderPostedDate>...</OrderPostedDate>
<BillingData>
<BuyerEmailAddress>...</BuyerEmailAddress>
<BuyerName>...</BuyerName>
<BuyerPhoneNumber>...</BuyerPhoneNumber>
</BillingData>
<FulfillmentData>
<FulfillmentMethod>...</FulfillmentMethod>
<FulfillmentServiceLevel>...</FulfillmentServiceLevel>
<Address>
<Name>...</Name>
<AddressFieldOne>...</AddressFieldOne>
<City>...</City>
<StateOrRegion>...</StateOrRegion>
<PostalCode>...</PostalCode>
<CountryCode>...</CountryCode>
<PhoneNumber>...</PhoneNumber>
</Address>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>...</AmazonOrderItemCode>
<SKU>...</SKU>
<Title>...</Title>
<Quantity>...</Quantity>
<ProductTaxCode>...</ProductTaxCode>
<ItemPrice>
<Component>
<Type>...</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>Shipping</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>Tax</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>ShippingTax</Type>
<Amount currency="USD">...</Amount>
</Component>
</ItemPrice>
<ItemFees>
<Fee>
<Type>Commission</Type>
<Amount currency="USD">...</Amount>
</Fee>
</ItemFees>
</Item>
</OrderReport>
</Message>
</AmazonEnvelope>
--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx--
--- End Message ---
--- Begin Message ---
On Tue, Apr 29, 2008 at 2:15 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> A fellow co-worker of mine is working on a project integrating with
> Amazon using SOAP. I've never used SOAP before but it seemed like
> things were straight forward at first. Some parts work while others
> done. Right now we are stuck trying to fetch a document from the
> remote server.
>
> We are able to connect and get a list of documents as expected. The
> PHP 5 SOAP extension handles this like a champ. When a single
> document is requested an exception is thrown with the error message
> "looks like we got no XML document." The document listing request
> returns a simple single text/xml SOAP XML response. The request for a
> single document returns a multi-part (multipart/related) response.
>
> Can the PHP 5 soap client even parse such things? I looked at the
> manual pages and did Google searching, but I'm not even sure what to
> word my queries as. It seems like somehow this should just work as
> the script just defines a client and then does the call. So any help
> or links to something that explains how this multipart response can be
> handled will be greatly appreciated. See below for the script &
> responses.
i know this has nothing to do w/ getting it to work w/ php, eric, but have
you tried hitting the service w/ soap ui?
http://www.soapui.org/
although its written in java, its an indispensable testing tool, imho, and i
always give it a shot when im having soap troubles. i might try to see if
you can get a successful response from the service w/ it.
-nathan
--- End Message ---
--- Begin Message ---
You should be able to parse it manually in PHP, but probably not with a XML
parser or reader. Simply var_dump() the responses you are getting and write
the code to break it up into values you can use. In some respects I've
found this easier than XML, which tends at times to be somebody else's idea
of a standard XML response ;-).
Warren
> -----Original Message-----
> From: Nathan Nobbe [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 29, 2008 2:07 PM
> To: Eric Butera
> Cc: php php
> Subject: Re: [PHP] Fun with SOAP.
>
> On Tue, Apr 29, 2008 at 2:15 PM, Eric Butera
> <[EMAIL PROTECTED]> wrote:
>
> > A fellow co-worker of mine is working on a project integrating with
> > Amazon using SOAP. I've never used SOAP before but it seemed like
> > things were straight forward at first. Some parts work
> while others
> > done. Right now we are stuck trying to fetch a document from the
> > remote server.
> >
> > We are able to connect and get a list of documents as
> expected. The
> > PHP 5 SOAP extension handles this like a champ. When a single
> > document is requested an exception is thrown with the error message
> > "looks like we got no XML document." The document listing request
> > returns a simple single text/xml SOAP XML response. The
> request for a
> > single document returns a multi-part (multipart/related) response.
> >
> > Can the PHP 5 soap client even parse such things? I looked at the
> > manual pages and did Google searching, but I'm not even
> sure what to
> > word my queries as. It seems like somehow this should just work as
> > the script just defines a client and then does the call.
> So any help
> > or links to something that explains how this multipart
> response can be
> > handled will be greatly appreciated. See below for the script &
> > responses.
>
>
> i know this has nothing to do w/ getting it to work w/ php,
> eric, but have you tried hitting the service w/ soap ui?
> http://www.soapui.org/
>
> although its written in java, its an indispensable testing
> tool, imho, and i always give it a shot when im having soap
> troubles. i might try to see if you can get a successful
> response from the service w/ it.
>
> -nathan
>
--- End Message ---
--- Begin Message ---
Hi, I'm having a strange problem with fopen
For clearence, here is the phpinfo page:
http://www.grondengoed.nl/phpinfo.php
I will shortly explain the problem I'm having:
$imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' .
$i . '.jpg';
echo $imagenamesmall; // For debugging purposses --> returns
exactly what I want.
//attempt to create folder
@mkdir($foldersystem);
@chmod($foldersystem, 0777);
//save picture
if(!($handle = fopen($imagenamesmall, 'w'))){
echo "Cannot open file (31)";
exit;
}
//$imagesmall, contains the image resource
if(fwrite($handle, $imagesmall) === FALSE) {
echo "Cannot write to file (32)";
exit;
}
fclose($handle);
Erverything works perfectly fine.But one thing, it doesn't give the
file the name that it should get. A name for instance has to be:
54961tdtdtdtd-s0.jpg
The number is the id of the database row, the 8 characters are random.
-s stands for small and 0 is the picture index.
When I echo the value, I get what I want. But when I save it, the
random 8 character string had become a totally different 8 character
string :S.
I have googled and checked things over and over again, cost me hours
and I still haven't found the reason. What is noticeable is that when
I leave one character away from the name, the value IS what it schould
be:S.
I really hope you can help me, if you need further info yust ask.
Thanks in advance.
regards,
Joep Roebroek
--- End Message ---
--- Begin Message ---
> Hi, I'm having a strange problem with fopen
>
> For clearence, here is the phpinfo page:
> http://www.grondengoed.nl/phpinfo.php
>
> I will shortly explain the problem I'm having:
> $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' .
> $i . '.jpg';
> echo $imagenamesmall; // For debugging purposses --> returns
> exactly what I want.
>
> //attempt to create folder
> @mkdir($foldersystem);
> @chmod($foldersystem, 0777);
>
>
> //save picture
> if(!($handle = fopen($imagenamesmall, 'w'))){
> echo "Cannot open file (31)";
> exit;
> }
>
> //$imagesmall, contains the image resource
>
> if(fwrite($handle, $imagesmall) === FALSE) {
> echo "Cannot write to file (32)";
> exit;
> }
>
> fclose($handle);
>
> Erverything works perfectly fine.But one thing, it doesn't give the
> file the name that it should get. A name for instance has to be:
> 54961tdtdtdtd-s0.jpg
> The number is the id of the database row, the 8 characters are random.
> -s stands for small and 0 is the picture index.
> When I echo the value, I get what I want. But when I save it, the
> random 8 character string had become a totally different 8 character
> string :S.
>
> I have googled and checked things over and over again, cost me hours
> and I still haven't found the reason. What is noticeable is that when
> I leave one character away from the name, the value IS what it schould
> be:S.
>
> I really hope you can help me, if you need further info yust ask.
>
> Thanks in advance.
>
> regards,
>
> Joep Roebroek
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What version of PHP?
My guess is that the mkdir is failing and the file is going to some weird
place.
You can do the chmod as part of the mkdir: bool mkdir ( string $pathname
[, int $mode [, bool $recursive [, resource $context ]]] )
Print/test the result of your mkdir.
If is doing what you think then it sounds like a memory overwriting bug.
--- End Message ---
--- Begin Message ---
Hello!
I have been using XAMPP for quite some time now (thanks to the recommendations
from this list) without any real complaints...
and the only reason I am writing here is because i am sure a lot of you guys
run the same thing considering the amount of people who recommended it to me
when I asked for an easy install of AMP.
It was easy to install and has given me months of hassle free use... but today
i have started facing some strange problems of everytime I start Apache... it
crashes my laptop, anybody else run into this?
I use this only for PHP, no perl.
My config:
Win Vista home premium with all updates and patches (genuine, not pirate copy)
core2 duo 2ghz
2 gigs ram
Nothing installed today for it to be acting up so.
Do you suggest I reinstall? or can I just reinstall Apache in some way? If i
have to reinstall is there an easy way of backing up my stuff and then
reinstalling then putting my stuff back? (I know i can just copy the files that
were in the htdocs... but am talking about an easy way to copy the files and
the DBs and put them back... or is that just wishful thinking?
TIA,
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--- End Message ---
--- Begin Message ---
Ryan S wrote:
Hello!
I have been using XAMPP for quite some time now (thanks to the recommendations from this list) without any real complaints...
and the only reason I am writing here is because i am sure a lot of you guys run the same thing considering the amount of people who recommended it to me when I asked for an easy install of AMP.
It was easy to install and has given me months of hassle free use... but today
i have started facing some strange problems of everytime I start Apache... it
crashes my laptop, anybody else run into this?
You could try their forums:
http://www.apachefriends.org/f/?language=english
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
> You could try their forums:
> http://www.apachefriends.org/f/?language=english
Thanks!
Just after I posted i started searching on google and found them, have joined
and posted... no reply as yet... just the waiting game now i guess.
Main prob is I cant even get phpmyadmin running to copy the DBs to do a
reinstall because PHPmyAdmin wont work... without apache of course.
After reading a bit I see that if I just copy the "data" directory in the mySql
directory, I can restore it from there? any idea if I have that wrong?
Cheers!
R
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--- End Message ---
--- Begin Message ---
After reading a bit I see that if I just copy the "data" directory in the mySql
directory, I can restore it from there? any idea if I have that wrong?
Hmm I guess, but I'd take the safer road and open a console and run:
mysqldump.exe -u <username> -p --all-databases --add-drop-database --opt
> mysql.database.dump
so you have an sql file you can restore if necessary.
Adjust paths/files/usernames/passwords as necessary.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
To find out more about Twitter, visit the link below:
http://twitter.com/i/bebf1448774167a5b91756e2b9829c5164624a20
Thanks,
-The Twitter Team
About Twitter
Twitter is a unique approach to communication and networking based on the
simple concept of status. What are you doing? What are your friends doing—right
now? With Twitter, you may answer this question over SMS, IM, or the Web and
the responses are shared between contacts.
--- End Message ---
--- Begin Message ---
Hi all,
I am currently responsible for a subscription module and need to design the
DB tables and write code.
I have described my table design and queries in the post:
http://phparch.cn/index.php/mysql/38-MySQL-configuration/152-best-practices-for-using-mysql-index
The problem is, in a short time the table will hold millions of records.
So the query and index optimization is very important.
Any suggestion will be greatly appreciated.
--
Regards,
Shelley
--- End Message ---