Re: [PHP] MySQL auto_increment fields Server version: 5.1.32-community-log

2009-08-09 Thread Jerry Wilborn
ALTER TABLE T1 AUTO_INCREMENT=1;
It's likely that you dropped every record and expected the auto_increment to
reset.

Jerry Wilborn
jerrywilb...@gmail.com


On Sun, Aug 9, 2009 at 1:17 PM, Ralph Deffke ralph_def...@yahoo.de wrote:

 Hi all,

 I'm facing the fact that it seems that auto_increment fields in a table not
 start at 1 like it was in earlier versions even if I install mySQL brand
 new
 creating all tables new. it seems to me that auto_increments handling has
 changed to older version. is somebody out there who can give me a quick
 background about auto_increment and how and if I can control the behavior
 of
 mySQL about them.

 ralph_def...@yahoo.de



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




Re: [PHP] Can php be cause a strain on a web server

2009-08-09 Thread Jerry Wilborn
You seem nice.
Jerry Wilborn
jerrywilb...@gmail.com


On Sun, Aug 9, 2009 at 12:54 PM, Daniel Brown danbr...@php.net wrote:

 On Sat, Aug 8, 2009 at 11:08, Jerry Wilbornjerrywilb...@gmail.com wrote:
  You're going to have to be more
  specific.  There are very few problems where this is absolutely no
 solution.

 And you're going to have to read what he said again and understand
 the context of the question and answer.  It requires no more specifics
 unless it's being explained to a pre-schooler.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Check out our great hosting and dedicated server deals at
 http://twitter.com/pilotpig



Re: [PHP] Server change affecting ability to send downloaded files???

2009-08-08 Thread Jerry Wilborn
http://us2.php.net/readfile

Returns the number of bytes read from the file. If an error occurs, FALSE is
 returned and unless the function was called as @readfile(), an error message
 is printed.


Ah. So readfile() was generating some error and outputting before the
Content-Type was sent to the browser.  It might not hurt to move to a
fread($fh, 8096) + print() to prevent the bug in the future.

Jerry Wilborn
jerrywilb...@gmail.com


On Sat, Aug 8, 2009 at 9:00 AM, Brian Dunning br...@briandunning.comwrote:

 A Rackspace guy determined that php.ini was set to use 16MB of memory, and
 he upped it to 32MB, and now everything works. Some of my downloads are as
 large as 41MB so I asked him to up it to 48MB.

 Maybe they upgraded the PHP version or something and wiped this setting.
 The 41MB files had always been downloading to customers before, without any
 problem -- is there some way that could have worked with php.ini set to
 16MB, or does this mean for sure that the setting was changed somehow?


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




Re: [PHP] curl_exec not hit server

2009-08-07 Thread Jerry Wilborn
You could also try checking the SSL log.  This may give hints about the
problem; none of the HTTP conversation happens until after SSL has been
negotiated.
Jerry Wilborn
jerrywilb...@gmail.com


On Fri, Aug 7, 2009 at 1:16 PM, Tom Worster f...@thefsb.org wrote:

 On 8/6/09 2:33 PM, Ted Yu ted...@yahoo.com wrote:

 
  Hi,
  I use the following code to call third party web service:
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
  curl_setopt($ch, CURLOPT_SSLVERSION, 3);
  curl_setopt($ch, CURLOPT_SSLCERT, $loc);
  curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $this-_httpHeaders);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $this-_xmlData);
  $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
  $xmlResponseData = curl_exec($ch);
 
  But for a specific API, curl_exec() returns true but there was no hit on
 their
  server (as verified by contact in that company from server log)
 
  Can someone provide hint ?

 not me.

 but, if you haven't already, maybe try debugging by: print out the values
 of
 all the variables in the above code and with them (or some subset) try
 making the same (or similar, or simpler) requests to the same $url using
 curl the command line with verbosity or tracing turned on.

 curl might give the hint you need.



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




Re: [PHP] Buffered Logging?

2009-08-07 Thread Jerry Wilborn
You don't mention what database you're using, but mySQL supports memory
based tables.  You can use this to insert your single page loads and then
have a job that periodically inserts in bulk.

Memory based tables:
http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html


Jerry Wilborn
jerrywilb...@gmail.com


On Fri, Aug 7, 2009 at 5:46 PM, Waynn Lue waynn...@gmail.com wrote:

 Hey PHPers,

 We've been doing sampled logging to the database in our application for
 awhile, and now I'm hoping eventually to blow that out to a larger scale.
 I'm worried about the performance implications of logging to our database
 on
 every single page load, though, so I was wondering if anyone's found a
 solution that does buffered logging.  Essentially it would log to memory
 (memcached/apc/etc), and then periodically dump to a database in a
 structured format, preferrably user-defined.  It's not essential that we
 get
 every signle hit, so I'd be fine if there was some data loss on a restart.
 I started writing my own solution, and then thought I'd ask the list to see
 if anyone has any experience with other tools that do this.

 My Google searches around buffered logging have mainly found error
 logging
 packages, like PEAR's Log package, or log4php.  Those all seem to write to
 only one particular stream at a time, with no real support for buffering it
 in memory and then moving it to database.

 Thanks for any help!

 Waynn



Re: [PHP] Server change affecting ability to send downloaded files???

2009-08-07 Thread Jerry Wilborn
The 500 is the result of the missing content-type in the real header. Once
you get a blank line in there, it thinks thats the content.  The error log
will likely say 'premature end of script headers'... Good mystery on why
it's got the blank line though.

Jerry Wilborn
jerrywilb...@gmail.com


On Fri, Aug 7, 2009 at 7:16 PM, Ben Dunlap bdun...@agentintellect.comwrote:

  Very interesting. Excellent debugging advice. It's giving me a 500
  error, probably why the Rackspace techs told me to check my code:
 
  HTTP/1.0 500 Internal Server Error

 Did you get that 500 while running curl from a machine outside of
 Rackspace's
 network?

 If so, I'd be interested to see what you get if you run it from the
 server's
 command line (using 'localhost' in the URL you pass to curl).

 Have you checked your Apache error log as well, and PHP's? There will
 usually
 be more detail in those locations when the server sends a 500.

 Ben

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




Re: [PHP] curl_exec not hit server

2009-08-06 Thread Jerry Wilborn
Can you tell us anything about the cert on the host? Is it self signed, is
it expired, etc?  A hip-shot: try turning off VERIFYPEER and VERIFYHOST.

Jerry Wilborn
jerrywilb...@gmail.com


On Thu, Aug 6, 2009 at 1:33 PM, Ted Yu ted...@yahoo.com wrote:


 Hi,
 I use the following code to call third party web service:
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_TIMEOUT, 120);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
 curl_setopt($ch, CURLOPT_SSLVERSION, 3);
 curl_setopt($ch, CURLOPT_SSLCERT, $loc);
 curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password);
 curl_setopt($ch, CURLOPT_HTTPHEADER, $this-_httpHeaders);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $this-_xmlData);
 $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 $xmlResponseData = curl_exec($ch);

 But for a specific API, curl_exec() returns true but there was no hit on
 their server (as verified by contact in that company from server log)

 Can someone provide hint ?

 Thanks




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




Re: [PHP] navigation include not functioning

2009-08-05 Thread Jerry Wilborn
I'm having trouble understanding your description of the problem.  Can you
tell us what you're seeing and what you expect to see?
Jerry Wilborn
jerrywilb...@gmail.com


On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe allenmcc...@gmail.com wrote:

 I am trying to generate pages by importing content in includes, and using
 my
 navigation include to tell PHP to replace a $thisPage variable which all
 the
 includes use ?php include('phpincludes/' . $thisPage . '.php') ?

 The idea behind it (I know tons of people do it, but I'm new to this
 concept), is to have a 'layout' page where only a variable changes using
 $_GET on an href (index.php?page=services or index.php?page=about) to load
 the new 'pages'.

 PROBLEM:
 All my links are displaying the current page state, and links are not
 building around the link text (hrefs are built conditionally with if
 $thisPage != services then build the link, otherwise leave it as normal
 text). Same thing with the background image behind the link text (to
 indicate a page's current position). If the condition is not true, all the
 links (except the true current 'page') are supposed reload index.php and
 pass a variable to itself to place into $thisPage using
 href=index.php?page= (after which I have a variable which stores about
 or services within the if statement near the link text.

 If this sounds like something you are familiar with (former issues and
 whatnot) please let me know what I'm doing wrong. I would be happy to give
 you any code you want to look at (index.php or navigation.php, whatever).

 Thanks again for your help PHP gurus!



Re: [PHP] Time keeping in DB

2009-08-05 Thread Jerry Wilborn
You don't mention what DB you're using, but mySQL can be quite a pain when
dealing with multiple time zones. Not impossible, but a hassle none the
less. Be sure to set aside a place to store this (and another spot for user
preferences to keep track of their TZ).
Jerry Wilborn
jerrywilb...@gmail.com


On Wed, Aug 5, 2009 at 2:20 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 On Wed, 2009-08-05 at 14:18 -0500, Shawn McKenzie wrote:
  So, obviously not PHP related, but I'm looking for thoughts on the best
  way to record time sheets in a DB.  A time sheet for hours worked per
  day, not like a time clock where you start and stop.
 
  The two possibilities that I have thought of are (these are simplistic,
  of course I'll be storing references to the user, the project code etc.):
 
  1. One record for each 7 day week (year, week_num, d1, d2, d3, d4, d5,
  d6, d7) where the dX field holds the hours worked
  2. One record for each day (date, hours)
 
  --
  Thanks!
  -Shawn
  http://www.spidean.com
 
 I'd go with a record per timesheet, so you might end up with more than
 one timesheet per day. That way, it's just simple SQL to find out how
 many hours you've worked on one day, or on one job, etc.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


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




Re: [PHP] dynamically naming PHP vars on the fly?

2009-08-05 Thread Jerry Wilborn
http://us2.php.net/manual/en/language.variables.variable.php
Jerry Wilborn
jerrywilb...@gmail.com


On Wed, Aug 5, 2009 at 5:17 PM, Govinda govinda.webdnat...@gmail.comwrote:

 HI all

 One thing I have been working around but now would love to just do it
 finally (and save workaround/longer code hassle) is when:

 I need to be able to create a variable (name it, and assign it a value)
 whose name is built up from a fixed string concatenated with another string
 which comes from the  value of another (already set) variable.

 Ie:

 I want to do this:
 (I am just assuming it won't work; I haven't even tried it yet)

 $var1='apple';
 $Fruit_$var1=organic;
 echo $Fruit_apple; // I want this to return organic

 Or how are you guys dynamically naming PHP vars on the fly?

 
 John Butler (Govinda)
 govinda.webdnat...@gmail.com




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




[PHP] socket_last_error() equiv

2009-08-04 Thread Jerry Wilborn
Is there an equivalent to socket_last_error() when using a socket opened
with stream_socket_client()?  If it's not written yet, is there a suitable
work around?

I am looking to get the last status of the system connect() call.  I see
there is a bug opened for it (http://bugs.php.net/bug.php?id=34380), but the
last movement on it is 2005.

Jerry Wilborn
jerrywilb...@gmail.com


Re: [PHP] Clean break.

2009-08-04 Thread Jerry Wilborn
Am I missing something? Can't this be done quickly/easily with preg_match()?

if (preg_match('/\[(.*):(.*)\s/U', '[21/Jul/2009:00:00:47 -0300]',
$matches)) {
print date: {$matches[1]}, time: {$matches[2]};
}

Jerry Wilborn
jerrywilb...@gmail.com


On Tue, Aug 4, 2009 at 5:36 AM, Wolf lonew...@nc.rr.com wrote:

 Paul Halliday wrote:
  Whats the cleanest (I have a really ugly) way to break this:
 
  [21/Jul/2009:00:00:47 -0300]
 
  into:
 
  date=21/jul/2009
  time=00:00:47
 
  Caveats:
 
  1) if the day is  10 the beginning of the string will look like
 [space1/...
  2) the -0300 will differ depending on DST or TZ. I don't need it
  though, it just happens to be there.
 
  This is what I have (it works unless day  10):
 
  $theParts = split([\], $theCLF);
 
  // IP and date/time
  $tmpParts = explode( , $theParts[0]);
  $theIP = $tmpParts[0];
  $x = explode(:, $tmpParts[3]);
  $theDate = str_replace([,, $x[0]);
  $theTime = $x[1]:$x[2]:$x[3];
 
  the full text for this part looks like:
 
  10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here
 
  Anyway, any help would be appreciated.
 
  thanks.
 

 unset ($STRING,$pos,$pos2,$pos3,$L,$D,$T,$pos4,$NString);
 $STRING=10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here
 $pos=strpos($STRING,[);
 $pos2=strpos($STRING,]);
 $L=$pos2-$pos;
 $NString=substr($STRING,$pos,$L);
 $pos3=strpos($NString,:);
 $D=substr($NString,0,$pos3);
 $pos4=$pos3++;
 $T=substr($NString,$pos4,8);
 echo date=$D;
 echo time=$T;

 untested, but that should be pretty much all you need.

 HTH,
 Wolf


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




Re: [PHP] Multiple MySQL Queries

2009-08-04 Thread Jerry Wilborn
Keep in mind that you can use name=var[] value=value1, name=var[]
value=value2 and php will create an array as $_REQUEST['var'] with each of
your values. The keys are numbered and don't count on what order they'll
come through.
Jerry Wilborn
jerrywilb...@gmail.com


On Tue, Aug 4, 2009 at 10:47 AM, Bastien Koert phps...@gmail.com wrote:

 On Tue, Aug 4, 2009 at 11:40 AM, sono...@fannullone.us wrote:
 Is what I'm looking to do not possible in PHP?  I've come close
 with
  a JavaScript version, but I'd rather not rely on everyone having JS
 turned
  on.  Or am I stuck having to use JS?
 
  Thanks again,
  Frank
 
 
 I'd like to revisit this one last time.  Below is the revised
 code
  I'm using, but I don't like having individual 'Add To Cart' buttons for
 each
  item.  I've tried to find a way to have only one that resides outside
 the
  nested tables for all items, but without luck.  It would need to send
 every
  item that has a quantity to the cart, but only those items.  The URL
 that
  would be passed needs to look like this:
 
 
 
 /shop.cgi?c=viewcart.htmitemid=P74Si_P74S=80S2448Si_S2448S=100ACi_AC=26
 
  (The above URL is sending 3 items and their quantities to the cart; 80 -
  P74S, 100 - S2448S and 26 - AC.)
 
 Thanks again for all your help.  I'm learning a lot on this list
 -
  albeit slowly! ;)
 
  Regards,
  Frank
 
  
 
  ?php
  $cats = array('02121-19222-13349-11451' = 'Stationary
  Posts','04103-99222-48340-11422' = 'Solid Galvanized Shelves');
 
  echo 'table border=1tr';
 
  foreach ( $cats AS $cat = $title) {
   echo START
 
  td valign=top
   table border=1
   trth align=center colspan=4{$title}/th/tr
   tr
   td class=text-header align=centerItem#/td
   td class=text-header align=centerDescriptionbr /
span class=text-small(Click for more
  info)/span/td
   td class=text-header align=centerPrice/td
   td class=text-header align=centerQty/td
   /tr
 
  START;
 
   $cat = mysql_real_escape_string($cat, $db);
   $SQL = SELECT itemid,description,unitprice
   FROM catalog
   WHERE categories='$cat'
   ORDER BY itemid;
 
   if ( ($result = mysql_query($SQL, $db)) !== false ) {
   while ( $item = mysql_fetch_assoc($result) ) {
   $price = $ . number_format($item['unitprice'],2);
   echo ROW
 
   tr
   td class=text-med{$item['itemid']}/td
   td class=text-meda
 
 href=/shop.cgi?c=detail.htmitemid={$item['itemid']}{$item['description']}/a/td
   td class=text-med align=right{$price}/td
   td class=text-med
   form action=/shop.cgi method=get
 input type=hidden name=itemid value={$item['itemid']}
 /
 input type=text name=i_{$item['itemid']} value=
 size=4
  /
 input type=hidden name=c value=viewcart.htm /
 input type=image src=/graphics/addtocart.png
  name=addToCartButton alt=Add To Cart /
   /form
 /td
   /tr
 
  ROW;
   }
 
   } else {
   echo No results for category #{$cat}!;
   }
   echo '/table/td';
  }
  echo '/tr/table';
  ?
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 You could do it with PHP, but you would still need to loop through all
 the data in the cart to find the element(s) to update. This can be
 done via a straight submit button where you send all the data to the
 server and the code walks thru the current contents

 --

 Bastien

 Cat, the other other white meat

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




Re: [PHP] Multiple MySQL Queries

2009-08-04 Thread Jerry Wilborn
If the form method is POST then set the 'c' variable with a hidden value
within the form: input type=hidden name=c value=viewcart.htm
Jerry Wilborn
jerrywilb...@gmail.com


On Tue, Aug 4, 2009 at 1:50 PM, sono...@fannullone.us wrote:


 On Aug 4, 2009, at 9:43 AM, Jerry Wilborn wrote:

  Keep in mind that you can use name=var[] value=value1, name=var[]
 value=value2 and php will create an array as $_REQUEST['var'] with each of
 your values. The keys are numbered and don't count on what order they'll
 come through.


Thanks for the tip, Jerry.  I'm still trying to figure this out, but
 in the meantime, I'm running into another problem.  I have the action on the
 form set as /shop.cgi?c=viewcart.htm but it keeps stripping out everything
 after the question mark.  I want c=viewcart.htm sent only once in the URL,
 so I can't place it in the form as it then gets sent along with every itemid
 in the form.

How does one append a path extension after the auto-generated
 question mark?

 Thanks,
 Frank



Re: [PHP] Multiple MySQL Queries

2009-08-04 Thread Jerry Wilborn
I re-read your original thread, and I think *now* I may know what you're
asking.

Bastien is right, you're not going to be able to selectively send data to
PHP with just HTML. Be careful though, as 'GET' has its
limits. POST has limits as well, but for adding items to a shopping
cart you're unlikely to hit those.

If you want to avoid JS,
you're going to have to send the whole page and then sort out what
needs to be updated on the server.

Jerry Wilborn
jerrywilb...@gmail.com


On Tue, Aug 4, 2009 at 2:03 PM, sono...@fannullone.us wrote:

  Sorry... I'm using GET.  I have used the code you supplied below, but as
 I mentioned, it gets sent for every itemid in the table.  I needs to be sent
 only once, and right after the action.  That's where I'm stumped.

 Frank

 On Aug 4, 2009, at 11:56 AM, Jerry Wilborn wrote:

 If the form method is POST then set the 'c' variable with a hidden value
 within the form: input type=hidden name=c value=viewcart.htm
 Jerry Wilborn
 jerrywilb...@gmail.com


 On Tue, Aug 4, 2009 at 1:50 PM, sono...@fannullone.us wrote:


 On Aug 4, 2009, at 9:43 AM, Jerry Wilborn wrote:

  Keep in mind that you can use name=var[] value=value1, name=var[]
 value=value2 and php will create an array as $_REQUEST['var'] with each of
 your values. The keys are numbered and don't count on what order they'll
 come through.


Thanks for the tip, Jerry.  I'm still trying to figure this out,
 but in the meantime, I'm running into another problem.  I have the action on
 the form set as /shop.cgi?c=viewcart.htm but it keeps stripping out
 everything after the question mark.  I want c=viewcart.htm sent only once
 in the URL, so I can't place it in the form as it then gets sent along with
 every itemid in the form.

How does one append a path extension after the auto-generated
 question mark?

 Thanks,
 Frank