OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 11 Dec 2003 17:48:33 -0000 Issue 2467

php-general-digest-helplists.php.net
Date: Thu Dec 11 2003 - 11:48:33 CST


php-general Digest 11 Dec 2003 17:48:33 -0000 Issue 2467

Topics (messages 172441 through 172502):

url rewriting within sessions - confused newbie needs help
        172441 by: Peter Walter
        172455 by: Jason Wong
        172491 by: Peter Walter
        172500 by: Ford, Mike [LSS]

calling include inside a function?
        172442 by: Louie Miranda
        172443 by: Louie Miranda
        172490 by: Chris W. Parker

Re: Write on image in faint color
        172444 by: Justin Patrin
        172445 by: Justin Patrin
        172457 by: David T-G
        172473 by: Ryan A

Re: Error that I can't find causing header() to fail
        172446 by: Justin Patrin

Re: treu type fonts
        172447 by: David Robley

Need help with "UPDATE" and "DELETE"
        172448 by: irinchiang.justeducation.com
        172454 by: Jason Wong

PHP's MySQL Query Length Limit? (Long SQL failing!)
        172449 by: Galen
        172451 by: Rich Gray

Best way to increment an integer column in mysql
        172450 by: John Clegg
        172452 by: Rich Gray
        172453 by: Terence
        172458 by: David T-G

Re: Compiling...hellllp!
        172456 by: Ford, Mike [LSS]
        172472 by: Ryan A
        172474 by: David T-G
        172475 by: Ryan A

Re: question on which day is the first day of the week
        172459 by: David T-G
        172460 by: Pavel Jartsev

Change html links according to returned result
        172461 by: PAUL FERRIE

PHP Logging problem
        172462 by: Edward Prendergast

$_POST[$variable]
        172463 by: Christian Jancso
        172464 by: CPT John W. Holmes
        172465 by: Chris Garaffa
        172466 by: Mike
        172467 by: Christian Jancso

[OTHER TOPIC - Please Help] Looking for file sync software (Linux)
        172468 by: Keith
        172470 by: David T-G

PHP and Java
        172469 by: Mark Ackroyd

XML Strategdy
        172471 by: Mark Roberts
        172478 by: Matt Matijevich
        172480 by: Lucian Cozma

Re: Array problem....
        172476 by: Jas
        172493 by: Chris W. Parker
        172497 by: Jas

How to reduce CPU usage in a cycle? [ag]
        172477 by: TauAlex
        172488 by: Jas
        172489 by: Brent Baisley

(0t) SSH cp (copy help)
        172479 by: Ryan A
        172483 by: Pablo Gosse
        172484 by: Glenn E. Sieb
        172486 by: David T-G

Palm OS Processor
        172481 by: Stephen Craton

Re: PHP, XML, UTF-8
        172482 by: Lucian Cozma

Re: Images in MySQL vs directory/file?
        172485 by: Derrick Fogle

Re: Age from birthdate?
        172487 by: pete M

Php ftp client recommendations?
        172492 by: MIKE YRABEDRA
        172496 by: David T-G

Re: how to determine if shopping cart has been abandoned?
        172494 by: Daniel Guerrier
        172495 by: Chris W. Parker

Uploaded images
        172498 by: Jarmila Kedr¹tová
        172501 by: Jay Blanchard
        172502 by: David T-G

Re: Modify: Server is unwilling to perform
        172499 by: Phil Dowson

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


 From the book "Core PHP programming", 3ed ;

"As stated earlier, PHP sends session identifiers with cookies, but a
browser may refuse them. PHP can detect when a browser does not accept
cookies, and in this situation it modifies all forms and links to
include the session identifier."

My php pages all include start_session() before any content is sent to
the browser, and my browser is configured to accept cookies.
Nevertheless, any coded relative url links (<a href=...) are all
modified to include PHPSESSID=12345, although the cookie *should* be
set. I am using PHP 4.x. Why is this happening?

Peter

attached mail follows:


On Thursday 11 December 2003 14:16, Peter Walter wrote:
> From the book "Core PHP programming", 3ed ;
>
> "As stated earlier, PHP sends session identifiers with cookies, but a
> browser may refuse them. PHP can detect when a browser does not accept
> cookies, and in this situation it modifies all forms and links to
> include the session identifier."
>
> My php pages all include start_session() before any content is sent to
> the browser, and my browser is configured to accept cookies.
> Nevertheless, any coded relative url links (<a href=...) are all
> modified to include PHPSESSID=12345, although the cookie *should* be
> set. I am using PHP 4.x. Why is this happening?

When your browser first hits the page (ie when no session has been started
yet) the links and the URL will have the session ID appended. This is because
at that stage the server does not know your browser is accepting cookies.

When you continue browsing your browser will send the session cookie thus
signalling to the server that cookies are being accepted and should then no
longer append the session ID.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
90. Wow....that seemed _fast_.....

        --Top 100 things you don't want the sysadmin to say
*/

attached mail follows:


Jason,

Thanks for your help. It is a little clearer to me now. However, I have
visited php sites that *claim* to be using session management but where
the links do not have the session id appended, and there are no
variables being passed in the url for links. The url is always in the
form "www.somesite.com/index.php" or just "www.somesite.com". In these
cases, how is the url rewriting being suppressed for the links on the
page? I simply want to understand the technique.

Peter

Jason Wong wrote:
> On Thursday 11 December 2003 14:16, Peter Walter wrote:
>
>> From the book "Core PHP programming", 3ed ;
>>
>>"As stated earlier, PHP sends session identifiers with cookies, but a
>>browser may refuse them. PHP can detect when a browser does not accept
>>cookies, and in this situation it modifies all forms and links to
>>include the session identifier."
>>
>>My php pages all include start_session() before any content is sent to
>>the browser, and my browser is configured to accept cookies.
>>Nevertheless, any coded relative url links (<a href=...) are all
>>modified to include PHPSESSID=12345, although the cookie *should* be
>>set. I am using PHP 4.x. Why is this happening?
>
>
> When your browser first hits the page (ie when no session has been started
> yet) the links and the URL will have the session ID appended. This is because
> at that stage the server does not know your browser is accepting cookies.
>
> When you continue browsing your browser will send the session cookie thus
> signalling to the server that cookies are being accepted and should then no
> longer append the session ID.
>

attached mail follows:


On 11 December 2003 16:54, Peter Walter wrote:

> Jason,
>
> Thanks for your help. It is a little clearer to me now.
> However, I have
> visited php sites that *claim* to be using session management
> but where
> the links do not have the session id appended, and there are no
> variables being passed in the url for links. The url is always in the
> form "www.somesite.com/index.php" or just "www.somesite.com".
> In these
> cases, how is the url rewriting being suppressed for the links on the
> page? I simply want to understand the technique.

If "url rewriting" (session.use_trans_sid) is enabled, and your browser is
accepting cookies, then the sequence of events goes like this:

1. First request to your site -- browser has no cookie set, so cannot send
it.

2. PHP responds with a page, including a header to set the PHPSESSID cookie;
because, at this stage, PHP has no idea whether your browser will accept
cookies, it also rewrites all URLs contained in the page to include a
PHPSESSID= parameter.

3. Your browser displays the page, and sets the cookie.

4. You click a link to get the next page -- in addition to sending a request
for the URL containing the PHPSESSID= parameter, your browser also sends the
newly-set PHPSESSID cookie.

5. PHP responds with the new page, but, because it has received the
PHPSESSID cookie in the previous step it now knows your browser is accepting
cookies and does not bother to do any URL rewriting.

6. None of the URLs in the new page have the PHPSESSID= parameter appended
-- transmission of the session id is now solely via the PHPSESSID cookie.

Various things can influence this behaviour:

- If your browser is not accepting cookies, URL rewriting will always occur
and you will continue to see PHPSESSID= parameters appended.

- If session.use_trans_sid is not set, PHP will do no URL rewriting but will
attempt to use cookies (if enabled) -- if your browser doesn't accept
cookies, sessions will fail to work (unless you manually append PHPSESSID=
parameters where needed -- the SID built-in constant is provided for this).

- If session.use_cookies is not set, PHP will not even attempt to use a
cookie for the session id.

- If session.use_only_cookies is set, PHP will use *only* cookies to store
the session id -- again, if your browser is not accepting cookies, sessions
will not work.

As you can see, there are many ways of setting this up, with a few subtle
nuances -- and some of the combinations don't actually make much sense
(use_trans_sid=1 and use_only_cookies=1, for instance). Note that you *can*
set it up so that PHP does no automatic PHPSESSID setting at all
(use_trans_sid=0 and use_cookies=0) -- then it's up to you to manually
append the PHPSESSID= parameter to all appropriate URLs.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

attached mail follows:


I can't call an include inside a function, is this possible?

--
function elo() {
    include ("what.txt");
}
--

even

--
$point = include ("what.txt");
function elo() {
    echo $point;
}
--

-- -
Louie Miranda
http://www.axishift.com

attached mail follows:


Its possible

-- -
Louie Miranda
http://www.axishift.com

----- Original Message -----
From: "Louie Miranda" <louieaxishift.ath.cx>
To: <php-generallists.php.net>
Sent: Thursday, December 11, 2003 3:34 PM
Subject: [PHP] calling include inside a function?

> I can't call an include inside a function, is this possible?
>
> --
> function elo() {
> include ("what.txt");
> }
> --
>
> even
>
> --
> $point = include ("what.txt");
> function elo() {
> echo $point;
> }
> --
>
> -- -
> Louie Miranda
> http://www.axishift.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Louie Miranda <mailto:louieaxishift.ath.cx>
    on Wednesday, December 10, 2003 11:40 PM said:

> Its possible

How did you solve your problem?

Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

attached mail follows:


Al wrote:

>>4) I'd love to see a PEAR IM module a la PerlMagick (but I haven't even
>>looked yet, so please don't flame me for missing something obvious). One
>>of these days I'll have The Great Rewrite and that will go in then. I'd
>>love to be rid of the system() calls to convert and mogrify.
>
>
> The closest thing out there at the moment (that I know of) is a PHP
> extension available through PECL, the PHP extension library. According to
> the docs, it "provides a wrapper to the ImageMagick/GraphicsMagick library."
> You can find it and download it at http://pecl.php.net/package/imagick.
>
> Hope that helps.
>
> Al

Or, as was said long ago in this thread, you just use the PHP GD
extension, read in the image, write a bit of text to it, then write it
back out. You can write a loop that loops through the file sin the
directory and does this to all of them.

And because I'm such a nice guy:
#!/usr/bin/php
<?php
//remember the trailing slash
$dir = '/path/to/files/';
$text = 'www.example.com';
$fontsize = 2;//1 - 5
$dh = opendir($dir);
while(false !== ($file = readdir($dh))) {
     if($file[0] != '.') {
         echo 'Adding watermark to '.$dir.$file."\n";
         $fileinfo = pathinfo($file);
         switch(strtolower($fileinfo['extension'])) {
         case 'png':
             $ih = imagecreatefrompng($dir.$file);
             break;
         case 'jpg':
         case 'jpeg':
         case 'jpe':
             $ih = imagecreatefromjpeg($dir.$file);
             break;
         case 'gif':
             $ih = imagecreatefromgif($dir.$file);
             break;
         default:
             echo 'I don\'t know what to do with the extension
'.$fileinfo['extension']."\n";
             break;
         }
         imagealphablending($ih, true);
         $color = imagecolorallocatealpha($ih, 255, 255, 255, 50);
         $x = (imagesx($ih) - strlen($text) * imagefontwidth($fontsize))
/ 2;
         $y = imagesy($ih) - imagefontheight($fontsize) * 1.2;
         imagestring($ih, $fontsize, $x, $y, $text, $color);
         imagepng($ih, $dir.basename($file, $fileinfo['extension']).'png');
     }
}
closedir($dh);
?>
--
paperCrane <Justin Patrin>

attached mail follows:


Justin Patrin wrote:

> imagepng($ih, $dir.basename($file, $fileinfo['extension']).'png');

Oops, the above line should probably be:

imagepng($ih, $dir.'-watermark'.basename($file,
$fileinfo['extension']).'png');

so as not to trample your previous files (if any are pngs).

--
paperCrane <Justin Patrin>

attached mail follows:


Justin --

...and then Justin Patrin said...
%
% Al wrote:
%
% >The closest thing out there at the moment (that I know of) is a PHP
% >extension available through PECL, the PHP extension library. According to
...
%
% Or, as was said long ago in this thread, you just use the PHP GD
% extension, read in the image, write a bit of text to it, then write it
% back out. You can write a loop that loops through the file sin the
% directory and does this to all of them.

I confess that I'm somewhat partial to IM, since we use that throughout
the rest of our scripts, but that's good to know.

%
% And because I'm such a nice guy:
% #!/usr/bin/php
[sinp]

Hey, thanks! That will come in very handy.

HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2FFEGb7uCXufRwARAsiMAJ4zxBGJEfw/uOK6zh0trO380LtOuwCfWbuA
wIWVDFDGtaOH8r4xkQ6Dqj8=
=Jc1p
-----END PGP SIGNATURE-----

attached mail follows:


> And because I'm such a nice guy:
> #!/usr/bin/php
> <?php
> //remember the trailing slash
> $dir = '/path/to/files/';
> $text = 'www.example.com';
> $fontsize = 2;//1 - 5
> $dh = opendir($dir);
> while(false !== ($file = readdir($dh))) {
> if($file[0] != '.') {
> echo 'Adding watermark to '.$dir.$file."\n";
> $fileinfo = pathinfo($file);
> switch(strtolower($fileinfo['extension'])) {
> case 'png':
> $ih = imagecreatefrompng($dir.$file);
> break;
> case 'jpg':
> case 'jpeg':
> case 'jpe':
> $ih = imagecreatefromjpeg($dir.$file);
> break;
> case 'gif':
> $ih = imagecreatefromgif($dir.$file);
> break;
> default:
> echo 'I don\'t know what to do with the extension
> '.$fileinfo['extension']."\n";
> break;
> }
> imagealphablending($ih, true);
> $color = imagecolorallocatealpha($ih, 255, 255, 255, 50);
> $x = (imagesx($ih) - strlen($text) * imagefontwidth($fontsize))
> / 2;
> $y = imagesy($ih) - imagefontheight($fontsize) * 1.2;
> imagestring($ih, $fontsize, $x, $y, $text, $color);
> imagepng($ih, $dir.basename($file,
$fileinfo['extension']).'png');
> }
> }
> closedir($dh);
> ?>

Hey,
You REALLY are a nice guy :-)
Thanks.

-Ryan.

attached mail follows:


Rogue wrote:

> Yes. The html is after the call to header(). I am very clear on header()
> now :)
>
> That isn't the problem since the header() should be called way before
> any output... this is something bizarre here... The offending code is a
> block right smack in the middle of a bunch of other html stuff - which
> is totally similar and removing these lines of code fixes it. So
> strange. AND it is not just one of the rows or something - it is that
> block as a unit for some reason.
>
>
>
>
>
> On Dec 10, 2003, at 11:53 PM, TheHeadSage wrote:
>
>> Is the HTML code before or after the header? As the header(); function
>> should be before any output is passed to the browser.
>>
>> I advise you read about the header() function in the PHP manual.
>>
>> ----- Original Message -----
>> From: "rogue" <roguemail.rightcode.net>
>> To: <php-generallists.php.net>
>> Sent: Thursday, December 11, 2003 2:34 PM
>> Subject: [PHP] Error that I can't find causing header() to fail
>>
>>
>>> Hi all,
>>>
>>> This template I have, has been driving me nuts. I am trying to debug
>>> someone else's code and have narrowed the problem down to a few lines,
>>> but I can't see what would be causing the problem.
>>>
>>> Here is the scoop. When this template loads it is making:
>>>
>>> header("Location: http://www.myurl.com")
>>>
>>> Fail. If I remove the following hunk of code, everything works as it
>>> should on the template (redirecting me to the right place). Removing
>>> any ONE row or combination does not seem to fix it, so there is
>>> something to do with this whole block? I am at a loss here and could
>>> really use another pair of eyes.
>>>
>>> <snip>
>>>
>>> <tr>
>>> <td nowrap align="right">
>>> <b>Fax:</b>
>>> </td>
>>> <td>
>>> <input name="fax" type="text" size="35" maxlength="20" value="<?php
>>> echo $fax; ?>">
>>> </td>
>>> </tr>
>>> <tr>
>>> <td nowrap align="right">
>>> <b>Street:</b>
>>> </td>
>>> <td>
>>> <input name="street1" type="text" size="35" maxlength="100"
>>> value="<?php echo $street1; ?>">
>>> </td>
>>> </tr>
>>> <tr>
>>> <td nowrap align="right">
>>>
>>> </td>
>>> <td>
>>> <input name="street2" type="text" size="35" maxlength="100"
>>> value="<?php echo $street2; ?>">
>>> </td>
>>> </tr>
>>> <tr>
>>> <td nowrap align="right">
>>> <b>City:</b>
>>> </td>
>>> <td>
>>> <input name="city" type="text" maxlength="20" value="<?php echo
>>> $city; ?>"> State:
>>> <select name="state">
>>> <?php
>>> mysql_select_db("main_db",$db) or die ("Unable to select database");
>>> $sql = "SELECT * FROM states WHERE display='yes' ORDER BY state";
>>> $result = mysql_query($sql,$db) or die ("Error in query: $sql".
>>> mysql_error());
>>> while($stateNow = mysql_fetch_array($result)) {
>>> $state_name = $stateNow[state];
>>>
>>> print "<option value='$state_name'";
>>> if ($state_name == $state) {
>>> print " SELECTED ";
>>> }
>>> elseif ($state_name == "NJ") {
>>> print " SELECTED ";
>>> }
>>> print ">$state_name</option>\n";
>>> }
>>> ?>
>>> </select>
>>> </td>
>>> </tr>
>>>
>>> </snip>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

1) Look in any files you're including before the header() call and see
if they have any whitespace after a closing php tag (?>).

2) Remove all ?> HTML HERE <?php syntax and replace with echo or print.
I've seen using that syntax screw up headers before even if it's after
the header() call.

3) Use output buffering up to the header call. Put ob_start() before the
beginning of it all, then get to the header() point. If you don't need
to use the header, use ob_end_flush() to flush the captured output. OR
you can do ob_end_flush() at the very end of the script.

--
paperCrane <Justin Patrin>

attached mail follows:


In article <000501c3bec0$67925f30$96c8a8c0summit>, cjglennies.com.au
says...
> G'day all
> I was wandering I have php installed with GD with freetype fonts compiled in
> I ran this php script
> <?php
> header("Content-type: image/gif");
> $im = imagecreate(400,30);
> $white = imagecolorallocate($im, 255,255,255);
> $black = imagecolorallocate($im, 0,0,0);
> // Replace path by your own font path
> imagettftext($im, 20, 0, 10, 20, $black, "./arial", "Testing... Omega:
> &amp;#937;");
> imagegif($im);
> imagedestroy($im);
> ?>
>
> and nothing gets displayed on the screen.
> Also if i right click in the top right hand corner and click properties the
> type is gif image.
> Can any one tell me what I should double check and what to look for.
> As I am getting no errors messages, I guess that means that free type fonts
> support is installed correctly? or please correct me if im wrong.
>
> Thanks
> CJ

That looks remarkably like an example from the docs; as a first debugging
process try removing the header() and see what error messages you may get.

My guess is that your fontfile string is wrong - I would expect, unless
you have renamed the file, that it would be ./arial.ttf. You might also
find that you need a full path to the font file.

Cheers
--
Quod subigo farinam

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?

attached mail follows:


Hi all,
       I am trying to do a "Modify(UPDATE)" and DELETE but I keep on getting
DB ERROR whenever I clicked on the links to "Modify" and "Delete"...Gone thru
my code a few times but can't spot any error. Anyone can help??
Below is a snip of the code:
-------------------------------------------------------------------------------
 <?

$dsn = "mysql://root:***********localhost/tb1";

$db = DB::connect ($dsn);
   if (DB::isError ($db))
       die ($db->getMessage());

$result = $db->query($sql);
if( DB::isError($result) ) {
    die ($result->getMessage());
}

<?
if($action==delete)
{
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'");
echo "The entry has been deleted <br><br>";
echo "<a href='../index/timetable_main.php'>Back to main</a>";
}

if($action==edit)
{
$sql = mysql_query ("SELECT * FROM tutor WHERE id='$id'");
$row = mysql_fetch_array($sql);
echo "<form name='edit_tutor' method='post' action='edit2.php'>";
echo "Tutor ID : ".$tutor_id."<br>";
echo "<input type='hidden' name='tutor_id' value='".$row[tutor_id]."'>";
echo "Name : <input name='tutor_name' type='text' value='" .$row
[tutor_name]."'><br>";
echo "Contact No : <input type='text' name='tutor_contact' value='" .$content
[tutor_contact]."'><br>";
echo "E-mail : <input type='texecho "Profile : <input type='text'
name='tutor_profile' value='" .$content[tutor_profile]."'><br>";
echo "<input type='submit' name='Submit' value='Update'>";
echo "</form>";
}t' name='tutor_email' value='" .$content[tutor_email]."'><br>";

?>
-------------------------------------------------------------------------------

Irin.

attached mail follows:


On Thursday 11 December 2003 17:45, irinchiangjusteducation.com wrote:

Please post php/db related questions to the php-db list!

> I am trying to do a "Modify(UPDATE)" and DELETE but I keep on
> getting DB ERROR whenever I clicked on the links to "Modify" and
> "Delete"...Gone thru my code a few times but can't spot any error. Anyone
> can help??

What exactly is the DB ERROR that you're getting?

Turn on FULL error reporting whilst you're developing your code. You can do so
by including these lines at the top of your code:

  error_reporting (E_ALL);
  ini_set('display_errors', 1);

> Below is a snip of the code:

If the code posted is in the order that it is run then it looks like $sql is
undefined at the moment you're trying to use it. If you had full error
reporting on you would have seen that error.

For debugging ALWAYS echo $sql just before you use it.

> $result = $db->query($sql);
> if( DB::isError($result) ) {
> die ($result->getMessage());
> }
>
> <?
> if($action==delete)

Unless you really mean to be using a constant, the above should "delete",
ditto for "edit" below.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Are we THERE yet? My MIND is a SUBMARINE!!
*/

attached mail follows:


I've been doing PHP for a pretty good while now, and I've been able to
solve most of my own problems. Before I spend hours troubleshooting
this one, I think I should ask the list:

I have a script that accepts large files (images) and inserts them into
a MySQL table. The images are manipulated and whatnot, no problems at
all getting the image into a string and running addslashes() on it.
Then I go and use it with a mysql query. This is something I've coded
dozens of times, but now there's a twist. The files are bigger than
I've ever worked with. In theory, I didn't think there would be a
problem, but there is. When I try in insert a file of about 800K or
larger (9-10 MB is as large as I ever try to insert) the insert fails.
The query is written correctly AKAIK, but no data reaches the table I'm
writing to.

The only difference between queries that work and those that do not
work is the size of the file I'm trying to insert.

I'm running the same basic code a few times, once to save the original
image (only lightly used), once to save a preview image, and once more
to save a thumbnail image. I use the same SQL query and code to run all
the queries. All the tables use mediumblobs except for the originals
which uses longblobs, so there should be no problem in terms of size.
I've upped my memory limit for php scripts and the file upload size but
I'm not having any success getting the query to go through, even though
I'm confident I have the correct data to insert (I can echo it back to
the browser or write it to a file, no problem.) The problem is
happening between mysql_query($query) and the mysql app. FYI, I'm
running PHP 4.3.x (not sure which version, ATM), MySQL 4.0.14 and
Apache 1.x under Mac OS X. I could dig out the exact versions, this is
just a testing box that is quite reliable so I'm not real concerned
with those kinds of things.

And before you guys tell me I should save my files in the filesystem,
I'm very aware of how that works but I'd rather not do it for various
reasons. I'm trying to solve this problem of long queries failing. If I
can't solve it, I'll look into other options to do what I need to do.

Thanks!

-Galen

attached mail follows:


> I have a script that accepts large files (images) and inserts them into
> a MySQL table. The images are manipulated and whatnot, no problems at
> all getting the image into a string and running addslashes() on it.
> Then I go and use it with a mysql query. This is something I've coded
> dozens of times, but now there's a twist. The files are bigger than
> I've ever worked with. In theory, I didn't think there would be a
> problem, but there is. When I try in insert a file of about 800K or
> larger (9-10 MB is as large as I ever try to insert) the insert fails.
> The query is written correctly AKAIK, but no data reaches the table I'm
> writing to.
>
[chop]

Hi Galen

I'd hazard a guess that it is probably your MySQL server settings that are
cause of the problem - in particular check the max_allowed_packet_size (?? -
you'll probably need to check this name as I haven't any docs to hand at the
moment) setting in your my.ini file...

HTH
Cheers
Rich

attached mail follows:


Hi

I was wondering if there is a php / mysql function call that will
increment an integer column in a database.
ie. the equivalent to
    $foo++;

Cheers

John Clegg

attached mail follows:


> I was wondering if there is a php / mysql function call that will
> increment an integer column in a database.
> ie. the equivalent to
> $foo++;
>

Hi John
Well you can specify the column as auto_increment to let MySQL handle the
incrementation else I suppose - mysql_query('update mytable set
my_int_column = my_int_column + 1 where blah blah ...');
HTH
Rich

attached mail follows:


There's an autoincrement feature for mysql colums, why don't you consider
that?

CREATE TABLE auto_increment (id INT (4) NOT NULL AUTO_INCREMENT, PRIMARY
KEY(id), UNIQUE(id), INDEX(id))

----- Original Message -----
From: "John Clegg" <john.cleggattglobal.net>
To: <php-generallists.php.net>
Sent: Thursday, December 11, 2003 6:07 PM
Subject: [PHP] Best way to increment an integer column in mysql

Hi

I was wondering if there is a php / mysql function call that will
increment an integer column in a database.
ie. the equivalent to
    $foo++;

Cheers

John Clegg

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

attached mail follows:


John -

...and then John Clegg said...
%
% I was wondering if there is a php / mysql function call that will
% increment an integer column in a database.
% ie. the equivalent to
% $foo++;

I didn't see that, but you can at least let mysql do the math:

  update tablename set field = field + 1 where condition

Just make sure you don't forget "where condition" :-) And beware that if
you have a timestamp field in the table you'll need to set it to itself
in order to avoid updating it.

%
% Cheers
%
% John Clegg

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2FNiGb7uCXufRwARAv7ZAKCzPCr/gOd+n691L3s8zIi6C4RBwgCfcCXg
A2HcKPb5NqjLq7vWDekJFPk=
=ummC
-----END PGP SIGNATURE-----

attached mail follows:


On 11 December 2003 01:24, Ryan A wrote:

> Hi,
>
> Its been quite some time since I have done any compiling, the last
> time was java and before that C...which was years back.
>
> I want to install Turck MMCache for php on one of our new dedicated
> servers as we will be running a crapload of scripts there...differient
> applications...we estimate around 2k - 4k or even a few more
> scripts....
>
> I myself have been working on a windows machine for a lonnng time
> (yes, i said windows, you *unix users can stop spitting) and really
> have no idea about "compiling" MMCache...can anybody tell me how to
> do it please? and what i'll need?
>
> This is what I got from their page:
> (http://turck-mmcache.sourceforge.net/#install)
> Step 1. Compiling Turck MMCache
> export PHP_PREFIX="/usr"
> $PHP_PREFIX/bin/phpize

AFAIR, all the Windows-specific downloads for MMCache include everything you
need pre-compiled, and don't even contain the sources, so no compiling
required -- the instructions are a bit misleading in this respect.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

attached mail follows:


Hi,
Problem is, I want to compile on my win2k pro machine for the linux
dedicated machine......
I have never compiled php before, I got one of those "ready to go packages"
(PHP+MySql+Apache - in one .exe file)

Cheers,
-Ryan

> On Wednesday 10 December 2003 08:23 pm, Ryan A wrote:
> > Hi,
> >
> > Its been quite some time since I have done any compiling, the last time
was
> > java and before that C...which was years back.
> >
> > I want to install Turck MMCache for php on one of our new dedicated
servers
> > as we will be running a crapload of scripts there...differient
> > applications...we estimate around 2k - 4k or even a few more scripts....
>
> honestly, i've never run turck, but the build process seems rather
standard.
>
> >
> > I myself have been working on a windows machine for a lonnng time (yes,
i
> > said windows, you *unix users can stop spitting) and really have no idea
> > about "compiling" MMCache...can anybody tell me how to do it please? and
> > what i'll need?
>
> I'm going to assume you're compiling on a real OS, and your desktop is
> Windows. If not, can't really help...
>
> >
> > This is what I got from their page:
> > (http://turck-mmcache.sourceforge.net/#install)
> > Step 1. Compiling Turck MMCache
> > export PHP_PREFIX="/usr"
> > $PHP_PREFIX/bin/phpize
>
> Odds are phpize is in your $PATH, so you can just cd into the turck
directory,
> and type phpize. If not, try typing `locate phpize` to find it, then type
> /path/to/phpize instead.
>
> >
> >
> > ./configure --enable-mmcache=shared
> > --with-php-config=$PHP_PREFIX/bin/php-co nfig
> > make
>
> then you move into the PHP source directory, since PHP needs to be
recompiled
> with support for turck. See http://www.php.net/manual/en/installation.php
>
> the only requirement is that you must include '--enable-mmcache=shared' as
an
> argument to the configure script. If the server is already set up, you
should
> do a phpinfo() to see what was sent to configure, and use that exact
command
> plus the mmcache thing above. This will decrease the likelyhood of a
snafu.
>
> >
> >
> > Thanks,
> > -Ryan
> >
> >
> > http://Bestwebhosters.com
>
> --
> Evan Nemerson
> evancoeus-group.com
> http://coeusgroup.com/en
>
> --
> "I am indeed amazed when I consider how weak my mind is and how prone to
> error. "
>
> -Rene Descartes
>
>
>
>

attached mail follows:


Ryan --

...and then Ryan A said...
%
% Hi,

Hi!

% Problem is, I want to compile on my win2k pro machine for the linux
% dedicated machine......
% I have never compiled php before, I got one of those "ready to go packages"
% (PHP+MySql+Apache - in one .exe file)

While it's not impossible, you are *way* out of your league trying to
cross-compile (compile under Win to run under Linux) like that. [Don't
feel bad; I compile packages regularly and I'd be way out of MY league
trying to bite that off.]

Compile the code on the box, or at least under the OS, where it will run.

%
% Cheers,
% -Ryan

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2IoaGb7uCXufRwARAsFdAJ959VDpfrsphU/7F3DeOZBJJoPSwQCgnv+o
Tgkue8G8AIFM/TC5Ad7yAD8=
=Sm2Y
-----END PGP SIGNATURE-----

attached mail follows:


Hey David,
Thanks, no offense taken.

>HTH

Sure did.

Cheers,
-Ryan

attached mail follows:


Hi!

...and then ____ said...
%
% Dear Sir,
% >
% > In the computer's memory, I find out that the first day of the week is Monday. But actually, the first day of the week is Sunday, not Monday. When I try to use the date function to number the week, I find some difficulty. For example, the second week of 2004 should be January 11 to 17, whereas Jan 11 is Sunday and 17 is Saturday. But in the computer, the 2nd week is January 12 to 18. It confuses me. How can readjust the date function to make each week start with Sunday, instead of Monday?

0) Could it be that, although Monday is day 1, you've overlooked that
Sunday is day 0?

1) Show us some code and output :-)

%
% thank you

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2FPYGb7uCXufRwARAkZfAJ9QB7LYpmzLE955TkRbQ0YurV3bKgCdH1tP
5frBwIpPXBdwvaJIJvorgfI=
=aiy1
-----END PGP SIGNATURE-----

attached mail follows:


>??? wrote:
>
> ...
> How can readjust the date function to make each week start with
Sunday, instead of Monday?
>
>
> thank you

http://www.php.net/manual/en/function.strftime.php

Look at conversion specifiers like "%U" and "%W".

--
Pavel a.k.a. Papi

attached mail follows:


Right here goes :(

Just when i thougfht i had done everything that had to be done the client
wants something else as well. that something else is another 2 tables in
the database that are of a diffrent layout from the original 2. This means i
need to build a few more pages with diffrent layouts to acommidate the data
being returned, this is fine.
What my problem is:

Here is the url to the admin area
http://thor.ancilenetworks.co.uk/~pferrie/vinrev/adm/index.html
username: paul ferrie
pass: admin

the first 2 db's in the drop down menu are fine, it's the third and the
fourth. I need to build a "if" statement that checks the name of tablename
and then echo the relivent links
Here is the code in the links page as it is
--------------
<?php
if (isset($_GET['tablename'])) {
    echo "<b>{$_GET['tablename']}</b> loaded <br><BR>";

} else {
 "<i>$tablename</i> did not get sent";
}
?>
<a href="view.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">View
database</a><br>
<a href="search.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Search database</a><br>
<a href="insert.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Insert record</a><br>
<a href="delete.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Delete record</a><br>
<a href="edit.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Edit record</a><br>

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

I had a tinker about witht the code but my php is not that good i was
thinking something like:
-------------
<?php
if (isset($_GET['tablename'])) {
    echo "<b>{$_GET['tablename']}</b> loaded <br><BR>";

} else {
 "<i>$tablename</i> did not get sent";
}
if($tablename="blah"){
echo"<a href="view.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">View
database</a><br>"
echo"<a href="search.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Search database</a><br>"
echo"<a href="insert.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Insert record</a><br>"
echo"<a href="delete.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Delete record</a><br>"
echo"<a href="edit.php?tablename=<? echo $_GET['tablename'] ?>"
target="main">Edit record</a><br>"
}else if($tablename="blah2"){
and so on
}
?>
-------------

I cant get the links to echo
Any help much appreciated

cheers
Paul

attached mail follows:


Hi,
I’m having a problem when I try and log to a file.
I cracked open /etc/php.ini and altered the following settings:

error_reporting = E_ALL

log_errors = On

error_log = /path/to/file.htm

The problem I'm having here is that file.htm produces one error when I
reload apache - but isn't accepting any other error, notice, etc messages
and I can't figure out why. I've checked the bugs list and nothing seems to
come up under this.

The only error it makes a note of is as follows:
[11-Dec-2003 09:55:36] PHP Warning: Cannot open 'extra/browscap.ini' for
reading in Unknown on line 0

I realise that logging this way creates a higher overhead but it's an
acceptable price for what I'm working on.

The system is as follows:
Linux 2.4.18-18.7.x i686
PHP 4.3.2

Many thanks,
Edward

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.518 / Virus Database: 316 - Release Date: 11/09/2003
 

attached mail follows:


Hi there,

I have the following problem:
How can I use variables in the $_POST statement?
Here is my code:

$old_station[$o] = $_POST['$i'];
$new_station[$o] = $_POST['$i'];

echo "<form name='station_change' method='post'
action='station_change.php'>";
echo "<TABLE BORDER=0>";

while ($status_array = mysql_fetch_array($status))
{
        $i++;
        echo "<tr>";
        echo "<td>"."<FONT FACE='Helvetica' SIZE=-1>";
            echo $status_array[1];
        echo "</td>";
        echo "<td>";
            echo "<input type='text' size=2 name='$i'
value='$status_array[1]'>"."<input type='hidden' name='$i'
value='$test'>"."<br>";
        echo "</td>";
        echo "</tr>";
}

echo "</table>";
echo "<input type='hidden' name='counter' value='$i'>";
echo "<br>";
echo "<br>";
echo "<input type='submit' name='action' value='Change'>";
echo "<input type='submit' name='action' value='Delete'>";
echo "</form>";

can anyone help me?

thx for your help

Christian

attached mail follows:


From: "Christian Jancso" <christiancafe.ch>

> I have the following problem:
> How can I use variables in the $_POST statement?
> Here is my code:
>
> $old_station[$o] = $_POST['$i'];
> $new_station[$o] = $_POST['$i'];

$old_station[$o] = $_POST[$i];
$new_station[$o] = $_POST[$i];

Variables are not evaluated within single quotes, so you were making a
literal key of "$i".

$old_station[$o] = $_POST["$i"];
$new_station[$o] = $_POST["$i"];

Will work, also, as the variable $i will be evaulated within the double
quote string.

---John Holmes...

attached mail follows:


On Dec 11, 2003, at 8:02 AM, Christian Jancso wrote:

> Hi there,
>
> I have the following problem:
> How can I use variables in the $_POST statement?
> Here is my code:
>
> $old_station[$o] = $_POST['$i'];
> $new_station[$o] = $_POST['$i'];

Christian,

My biggest question is: What are $i and $o set to?
Unless $i is set to a string with the same name as POST variable you're
trying to access, this code won't work.

--
Chris Garaffa
chrisnilzero.com

attached mail follows:


If you change the name of the data field to something[] then the
$_POST['something'] will be an array containing your data

The code you have will result in 2 fields (one hidden one normal) with
the same name ($i), this will cause lots of problems

It is not a good idea to give form fields numeric names,
"form_field_".$i would be better

you need to take care with using _POST - it is accessed like this
$_POST['name'] NOT $_POST['$name']

Mike

Christian Jancso wrote:
> Hi there,
>
> I have the following problem:
> How can I use variables in the $_POST statement?
> Here is my code:
>
> $old_station[$o] = $_POST['$i'];
> $new_station[$o] = $_POST['$i'];
>
>
> echo "<form name='station_change' method='post'
> action='station_change.php'>";
> echo "<TABLE BORDER=0>";
>
> while ($status_array = mysql_fetch_array($status))
> {
> $i++;
> echo "<tr>";
> echo "<td>"."<FONT FACE='Helvetica' SIZE=-1>";
> echo $status_array[1];
> echo "</td>";
> echo "<td>";
> echo "<input type='text' size=2 name='$i'
> value='$status_array[1]'>"."<input type='hidden' name='$i'
> value='$test'>"."<br>";
> echo "</td>";
> echo "</tr>";
> }
>
> echo "</table>";
> echo "<input type='hidden' name='counter' value='$i'>";
> echo "<br>";
> echo "<br>";
> echo "<input type='submit' name='action' value='Change'>";
> echo "<input type='submit' name='action' value='Delete'>";
> echo "</form>";
>
> can anyone help me?
>
> thx for your help
>
> Christian

attached mail follows:


thx Mike that works :-)

thx also to the others for their help :-))

Christian

attached mail follows:


Hi all,

[Apologies for the off-topic question. Hope you will bear with me]

Given that this is a PHP General newsgroup I figured there's a good chance
someone here would know the answer to this question. Can anyone here
recommend a file-sync application/package for Linux servers that has the
following features:

1. Enables file sync across 2 drives on same server.
2. Enables file-sync between remote and host servers.
3. Enables file-sync for whole drives as well as for selected folders.
4. Includes some aspect of GUI for easy task management.
5. Includes function for restoring (again, whole drives or just selected
folders).

I have come across the likes of 'rsync' and 'unison' but they both seem to
be command line intensive and I can't find much in the way of descent
documentation for them. For instance I don't understand if or how they
achieves 'Data Restore', and for my purposes the ability to restore is a
prerequisite.

Any advice would be most appreciated.

Thank you
Keith

attached mail follows:


Keith --

...and then Keith said...
%
% Hi all,

Hi!

%
% [Apologies for the off-topic question. Hope you will bear with me]
%
% Given that this is a PHP General newsgroup I figured there's a good chance

Um, why? Do you expect to find such a tool written in php??

% someone here would know the answer to this question. Can anyone here
% recommend a file-sync application/package for Linux servers that has the
% following features:
...
% I have come across the likes of 'rsync' and 'unison' but they both seem to
% be command line intensive and I can't find much in the way of descent

I was going to recommend unison, but you seem to have tried it already.
Of course, it does have a GUI interface, and the documentation, while
curiously contained within, is quite comprehensive. There is also a
mailing list.

However, it sounds like what you really want is a backup tool. If you're
only handling data (logical since you probably don't have two machines
with identical host names and addresses) then it would be easy enough to
just delete the archive checksum files and run unison again and let it
populate the [possibly partially-]empty tree -- or just tar or zip over
the data.

Anyway, take a look again at what level of restore you need; if you're
talking about bringing a dead system back to life, then use a real backup
tool whether or not you use a file sync tool to keep them rolling along.

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2IVOGb7uCXufRwARAq4cAJ0TeMKthVvVFoqC8GSVCv0jeVc1XgCgsogZ
Cil6ZS4jnKVRHPWZGiMbpM4=
=Ew70
-----END PGP SIGNATURE-----

attached mail follows:


Hi,

I am not so sure where the problem lies with this. I have installed
JDK1.3.1 on a FreeBSD 4.9 server. It seems to work fine. I have written
a small java program and it compiles and runs without any issues.

I want to get the PHP intgration with java working, I must admit I know
more about compiling and tinkering with PHP source then java. So I have
set all the right options in PHP for this intergration and got the thing
to compile.

in my small PHP script to test the system is this.

#!/usr/local/bin/php -q
<?
   $system_inst = new Java('java.lang.System');
   echo $system_inst->getProperty("java.version");
?>

when this is run it produces this.

PHP Fatal error: Unable to load Java Library
/usr/local/jdk1.3.1/jre/lib/i386/classic/libjvm.so, error:
/usr/local/jdk1.3.1/jre/lib/i386/classic/libjvm.so: Undefined symbol
"setFPMode" in /root/test on line 3

I know the setFPmode is due to the threads in java so I have set

LD_LIBRARY_PATH=/usr/local/jdk1.3.1/jre/lib/i386/green_threads

Either way this problem doesn`t seem to go away with the LD references?

anyone got an ideas of what I am doing wrong?

Mark

--

Mark Ackroyd
e: markackroyd.net

attached mail follows:


I am about to embark on a project that requires me to access several mysql
files (customer order entry), gather the information and output an XML
formatted file that will be used as an input file to another accounting
application.

Question is this. As a seasoned developer, my natural instinct is to just
write a script(s) to access all the information that I need and write the
appropriate information out to the file. Is there a better way to do this?
Is there some type of application that has been developed that will take a
select statement as input and automatically generate XML output?

Just courious...any suggestions, thoughts, comments?

Thanks.
Mark Roberts, Roberts Computing Systems
Webmaster Services $29.50/mo

mailto:mark.robertsrobertscomputing.com

attached mail follows:


<snip>
Question is this. As a seasoned developer, my natural instinct is to
just
write a script(s) to access all the information that I need and write
the
appropriate information out to the file. Is there a better way to do
this?
Is there some type of application that has been developed that will
take a
select statement as input and automatically generate XML output?
</snip>

I have used php adodb (http://php.weblogs.com/ADODB) but I have never
any of these to convert result sets to xml but they look like they will
do the trick http://phplens.com/lens/lensforum/msgs.php?id=3430

and this pear package looks like it might do the trick
http://pear.php.net/manual/en/package.xml.xml-sql2xml.php

attached mail follows:


Try Krysalis (http://www.interakt.ro/products/Krysalis/) if you're trying
something more complex. It's a PHP/XML platform.
If you want simple stuff (just generate XML's), I recomend doing for
yourself a custom class/function for it.

Here is a code sample:

<psql:execute-query connection="krysalis">
 <psql:query>
  select * from department_dep inner join employee_emp on iddep_emp = id_dep
order by id_dep
 </psql:query>
<psql:results>
  <psql:row-results>
     <department>
            <id><psql:get-string column="id_dep"/>/id>
            <name><psql:get-string column="name_dep"/>/name>
            <!-- get the employees for the same department-->
            <psql:row-results field="id_dep>
                <employee>
                    <id><psql:get-string column="id_emp"/></id>
                    <name><psql:get-string column="name_emp"/></name>
                 </employee>
            </psql:row-results>
        </department>
    </psql:row-results>
 </psql:results>
</psql:execute-query>

"Mark Roberts" <phplistrobertscomputing.com> wrote in message
news:OFEIJHBPMMPKIOEGIMAIIEEPGFAA.phplistrobertscomputing.com...
> I am about to embark on a project that requires me to access several mysql
> files (customer order entry), gather the information and output an XML
> formatted file that will be used as an input file to another accounting
> application.
>
> Question is this. As a seasoned developer, my natural instinct is to just
> write a script(s) to access all the information that I need and write the
> appropriate information out to the file. Is there a better way to do this?
> Is there some type of application that has been developed that will take a
> select statement as input and automatically generate XML output?
>
> Just courious...any suggestions, thoughts, comments?
>
> Thanks.
> Mark Roberts, Roberts Computing Systems
> Webmaster Services $29.50/mo
>
>
>
> mailto:mark.robertsrobertscomputing.com
>
>

attached mail follows:


Well just so you understand "why" I needed something like that here is
the finished result below

<?php
function show() {
        require 'path/to/dbconnector.inc';
        $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or die(mysql_error());
           $i = 0;
           while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) =
mysql_fetch_row($sql_subs)) {
                   $_SESSION[$i] = "subnet $sub<br>netmask $msk {<br>option
domain-name-servers $dns01, $dns02;<br>option routers $rtrs;<br>range
$rnge;<br>}<br>";
                   $i++; }
?>

Then ...
<?php
call_user_func("show");
echo $_session['0'];
echo $_session['1'];
...
?>
And you get...

subnet 128.110.22.110
netmask 255.255.255.0 {
option domain-name-servers 128.110.22.4, 128.110.29.3;
option routers 128.110.22.1;
range ;
}

Which allows for easy reading of configuration variables and the ability
to modify the individual vars using a form etc.

Thanks again for all who gave me some pointers on using numbers instead
of names for my session vars.
Jas

Chris W. Parker wrote:
> Jas <mailto:jason.gerfenscl.utah.edu>
> on Wednesday, December 10, 2003 3:44 PM said:
>
>
>>having no idea you could use numbers as session variable names I kinda
>>feel like a retard right now. You solution worked, thank you very
>>much.
>
>
> It's an array just like any other which you probably realize now. ;)
>
> Also, unless you're doing some math or something with those variables
> you might to split them up into their own cells (I don't really know if
> this is going to be useful for you or not):
>
> {
> $_SESSION[$iCtr]['var1'] = $var1;
> $_SESSION[$iCtr]['var2'] = $var2;
> $_SESSION[$iCtr]['var3'] = $var3;
> $_SESSION[$iCtr]['var4'] = $var4;
> $_SESSION[$iCtr]['var5'] = $var5;
> ...
> }
>
>
>
> HTH,
> Chris.
> --
> Don't like reformatting your Outlook replies? Now there's relief!
> http://home.in.tum.de/~jain/software/outlook-quotefix/

attached mail follows:


Jas <mailto:jason.gerfenscl.utah.edu>
    on Thursday, December 11, 2003 7:21 AM said:

> Well just so you understand "why" I needed something like that here is
> the finished result below

[snip]

> $i = 0;
> while(list(...) = mysql_fetch_row(...)) {
> $_SESSION[$i] = "...";
> $i++;
> }

I want to change my suggestion and recommend that you go along with what
John Holmes suggested a little after my post. Read his post again and
see if it is helpful to you. Keep note of the following aspect:

You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
"..."; to $_SESSION[] = "...";.

i.e. The following two code blocks perform the same task:

Current:
$i = 0;
while(list(...) = mysql_fetch_row(...)) {
    $_SESSION[$i] = "...";
    $i++;
}

New:
while(list(...) = mysql_fetch_row(...)) {
    $_SESSION[] = "...";
}

Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

attached mail follows:


Yeah I understand that and it would be perfect if I only had to call
this type of function once on a page... and on any other pages that need
something like this I will do it that way but with the counter set to 0
or whatever number I choose which is a sort of view all page so your
solutions works better for this page. Thanks again.
Jas

Chris W. Parker wrote:

> Jas <mailto:jason.gerfenscl.utah.edu>
> on Thursday, December 11, 2003 7:21 AM said:
>
>
>>Well just so you understand "why" I needed something like that here is
>>the finished result below
>
>
> [snip]
>
>
>>$i = 0;
>>while(list(...) = mysql_fetch_row(...)) {
>> $_SESSION[$i] = "...";
>> $i++;
>>}
>
>
> I want to change my suggestion and recommend that you go along with what
> John Holmes suggested a little after my post. Read his post again and
> see if it is helpful to you. Keep note of the following aspect:
>
> You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
> "..."; to $_SESSION[] = "...";.
>
> i.e. The following two code blocks perform the same task:
>
> Current:
> $i = 0;
> while(list(...) = mysql_fetch_row(...)) {
> $_SESSION[$i] = "...";
> $i++;
> }
>
> New:
> while(list(...) = mysql_fetch_row(...)) {
> $_SESSION[] = "...";
> }
>
>
>
> Chris.
> --
> Don't like reformatting your Outlook replies? Now there's relief!
> http://home.in.tum.de/~jain/software/outlook-quotefix/

attached mail follows:


Hello!

I'm having a problem with my php script on my linux web server. In that
script there is a cycle with some math calculations (about ~30 steps), the
execution time is less 1 second, but the script loads the server CPU up to
90%...
I've optimized script already to the minimum math function, anyway, it still
overloads the CPU.
How can I reduce the CPU load? It seems that usleep() does not help much,
especially in Windows (it's not supported).
How can I give system a portion of time in the end of each step (I don't
mind if it will increase the job time)? Is there a solution for both Windows
and Linux?

For instance, in C++ under Windows I would do this:

do
{
    [... math calculations ...]
    while(::PeekMessage(&message,NULL,0,0,PM_NOREMOVE))
        if (!theApp.PumpMessage()) break;
} while(!quit);

This gives system to redraw screen, process any other events during long
cycles...
Is there similar approach in PHP for web server programming?

p.s. Would be nice to know other techniques to reduce CPU load ;)

Thank you!

attached mail follows:


Can we get the code posted so we know what is going on?
Sometimes there are a dozen different ways to accomplish the same
objective and looking at what your code is doing may assist us in
assisting you.
Jas

Taualex wrote:

> Hello!
>
> I'm having a problem with my php script on my linux web server. In that
> script there is a cycle with some math calculations (about ~30 steps), the
> execution time is less 1 second, but the script loads the server CPU up to
> 90%...
> I've optimized script already to the minimum math function, anyway, it still
> overloads the CPU.
> How can I reduce the CPU load? It seems that usleep() does not help much,
> especially in Windows (it's not supported).
> How can I give system a portion of time in the end of each step (I don't
> mind if it will increase the job time)? Is there a solution for both Windows
> and Linux?
>
> For instance, in C++ under Windows I would do this:
>
> do
> {
> [... math calculations ...]
> while(::PeekMessage(&message,NULL,0,0,PM_NOREMOVE))
> if (!theApp.PumpMessage()) break;
> } while(!quit);
>
> This gives system to redraw screen, process any other events during long
> cycles...
> Is there similar approach in PHP for web server programming?
>
> p.s. Would be nice to know other techniques to reduce CPU load ;)
>
> Thank you!

attached mail follows:


Personally, I wouldn't worry about it unless it is actually interfering
with other processes. The OS will give any process or thread 100% of
the CPU if there is nothing else that needs the CPU. What does you
context switching numbers look like? If there is a lot of context
switching, then your processes or threads are getting kicked off the
CPU before they can accomplish much. And that's a problem.

The duration of your script is less than a second, so that's not
really a long enough time have an affect on other parts of the system.
Heck, it may even being completing within just a couple of time slices
(the length of time the OS allows a process/thread to use the CPU).

You could always adjust the priority level (nice value in Unix) of
whatever PHP is running under (i.e. Apache). Although you should
understand what you are doing if you are adjusting nice values.

On Dec 11, 2003, at 10:03 AM, TauAlex wrote:

> Hello!
>
> I'm having a problem with my php script on my linux web server. In that
> script there is a cycle with some math calculations (about ~30 steps),
> the
> execution time is less 1 second, but the script loads the server CPU
> up to
> 90%...
> I've optimized script already to the minimum math function, anyway, it
> still
> overloads the CPU.
> How can I reduce the CPU load? It seems that usleep() does not help
> much,
> especially in Windows (it's not supported).
> How can I give system a portion of time in the end of each step (I
> don't
> mind if it will increase the job time)? Is there a solution for both
> Windows
> and Linux?
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

attached mail follows:


Hi,
I'm on a win2k pro machine and need to copy a modified httpd.conf file to my
linux box,
I dont really know much about SSH and just learned a bit with my pals help
(google)

I am able to navigate around the directories, get a directory listing and
delete...am unable to copy files from my harddisk for some reason....

I am using PUTTY to connect.

This is what I have tried:

the file is located in my
c:\
I tried using
cp c:\filename

and also
cp c:filename /remote/path/

and also
cp c:filename /remote/path/samefilename

and also
cp filename /remote/path/

etc

without any luck.

how do i copy it?

Thanks,
-Ryan

attached mail follows:


<snip>
Hi,
I'm on a win2k pro machine and need to copy a modified httpd.conf file
to my
linux box,
I dont really know much about SSH and just learned a bit with my pals
help
(google)

I am able to navigate around the directories, get a directory listing
and
delete...am unable to copy files from my harddisk for some reason....
</snip>

Hey Ryan. I'd suggest going to
http://www.ssh.com/support/downloads/secureshellwks/ and downloading
either the commercial evaluation version or non-commercial version. It
has the standard SSH terminal, but it also features an SSH File Transfer
client which will allow you to do what you want.

Cheers,
Pablo

attached mail follows:


Or go up to http://winscp.vse.cz/

Great little program :)

G.
--
Glenn E. Sieb
System Administrator
Lumeta Corporation
+1 732 357-3514 (V)
+1 732 564-0731 (Fax)

> -----Original Message-----
> From: Pablo Gosse [mailto:gossepunbc.ca]
> Sent: Thursday, December 11, 2003 10:50 AM
> To: Ryan A; php-generallists.php.net
> Subject: RE: [PHP] (0t) SSH cp (copy help)
>
>
> <snip>
> Hi,
> I'm on a win2k pro machine and need to copy a modified
> httpd.conf file to my linux box, I dont really know much
> about SSH and just learned a bit with my pals help
> (google)
>
> I am able to navigate around the directories, get a directory
> listing and delete...am unable to copy files from my harddisk
> for some reason.... </snip>
>
> Hey Ryan. I'd suggest going to
> http://www.ssh.com/support/downloads/secureshe> llwks/ and
> downloading either the commercial evaluation
> version or non-commercial version. It has the standard SSH
> terminal, but it also features an SSH File Transfer client
> which will allow you to do what you want.
>
> Cheers,
> Pablo
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Ryan --

Let's see, here... You're planning to write an scp replacement in php
and so this is on topic, right? ;-)

...and then Ryan A said...
%
% Hi,
% I'm on a win2k pro machine and need to copy a modified httpd.conf file to my
% linux box,

Step 1: reformat your w2k box and run linux. All problems solved :-)

% I dont really know much about SSH and just learned a bit with my pals help
% (google)
%
% I am able to navigate around the directories, get a directory listing and
% delete...am unable to copy files from my harddisk for some reason....

ssh (here putty.exe) is for doing things on the remote system; it's a
secure telnet program.

scp (here pscp.exe) is for copying things back and forth; it (and sftp,
available sometimes and perhaps here as psftp.exe) is a secure ftp program.

%
...
% and also
% cp filename /remote/path/

Try

  c:
  cd \path\to\filename
  pscp filename userhost:/path/to/filename

and then enter the password for "user".

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2Jb2Gb7uCXufRwARAjY4AJ9ABliSOs0iIslIAaJKcTwgzV8YtQCggt9Q
c89enHvcDajZpev9g9wgrIE=
=rFju
-----END PGP SIGNATURE-----

attached mail follows:


Hello,

I was just wondering if there were such a program for Palm OS 4.1 that processes PHP code. Just wondering so that I can maybe make some complex calculator functions on it and use it for school work or whatever else may come my way. Thanks!

Stephen Craton

attached mail follows:


Answer: Multi-Byte String Functions.
You could take a look at the function:
    string mb_convert_encoding ( string str, string to-encoding [, mixed
from-encoding] )
You must have php_mbstring extension enabled in your php.ini file.

Regards,
Lucian COZMA

"Russell P Jones" <rjonesemail.unc.edu> wrote in message
news:Pine.A41.4.44+UNC.0312081334320.59572-100000login7.isis.unc.edu...
> Im storing a lot of user-entered data in XML files but i have a problem
> with folks submitting stuff just by copying and pasting from microsoft
> word. "Smart Quotes" and other awkward text then gets submitted and ruins
> the xml, meaning i am searching and replacing item by item to replace
> stuff.
>
> Does anyone know how I could do this automatically, as in is there
> anything that will convert a string to UTF-8 automatically
>
> ideally $fixed = convert-to-utf($oldmessedupstring)
>
> any ideas? Will CDATA sections allow non UTF-8 text?
>
> Russ Jones

attached mail follows:


Thanks for the feedback. Just to clear up a couple questions regarding
my particular needs...

1. server has *plenty* of capacity
2. traffic is *very* low; max load would be 20 visitors looking at 4
images apiece over a 4-hour period
3. images will only be retrieved once or twice by one or two different
browsers, over the period of a week (then they will be deleted).
4. I *don't* need, or want, the files to be backed up

It seems to me that I can get more/better control over the tracking and
use of the images if I store them in the DB. On the other hand, the
'simple' solution to the open directory problem is to put it outside
the www root and fread the file from there to spit out to the browsers.

I'm going to go with the database option for now, despite the fact that
it will include the stuff in backups if I do, for a couple of selfish
reasons: I've already got the code written and working, while moving
the directory around and having to fread and then puke out the data
will be more work, and I *do* have more control/access over database
records than I do server directories.

Thanks for everyone's help!

-Derrick

attached mail follows:


have you looked at to_days() and to_years() in the mysql manual

Dvdmandt wrote:

> How would I get the age of someone if I store the birthdate in a date field?
> I just realized FLOOR((UNIX_TIMESTAMP(NOW()) -
> UNIX_TIMESTAMP(birthdate))/60/60/24/365.25) wont work for persons born
> before 1970... :p I must get the current age in years, and I must be able to
> select by age... :p Any ideas?
>

attached mail follows:


Can anyone recommend a good, secure, stable php ftp client?

And please save the "look at hotscripts" responses. I am looking for actual
user input.

Thanks.

+--------------------------------------------+
Mike Yrabedra (President)
323 Incorporated
Home of MacDock.com, MacAgent.com and MacShirt.com
+--------------------------------------------+
W: http://www.323inc.com/
P: 770.382.1195
F: 734.448.5164
E: mike323inc.com
I: ichatmacdock
+--------------------------------------------+
"Whatever you do, work at it with all your heart,
as working for the Lord, not for men."
~Colossians 3:23 <{{{><
+--------------------------------------------+

attached mail follows:


Mike --

...and then MIKE YRABEDRA said...
%
% Can anyone recommend a good, secure, stable php ftp client?

What is a "php ftp client"? The server-side php uses its own ftp
connection or could use curl or the like to get files, while from your
desktop you'll use ftp or ncftp or winf or cuteftp or fetch or whatever
to connect to your server. The only thing I can imagine from that short
three-word description is that you're trying to find or write an ftp
client for browser use, which to me seems pretty silly but, hey, maybe
there is a need for it.

So what functionality do you want?

%
...
% P: 770.382.1195

Hey, you're local! I should just circumvent the list and call and ask :-)

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2KVWGb7uCXufRwARAu8hAJ0VN+Fz/zRzHMe4z004OYP8lBxZqQCdEV7q
AA9pmri2bx3mO5ktEY4e+6c=
=iE/T
-----END PGP SIGNATURE-----

attached mail follows:


Why not just maintain carts for users with accounts
and maintain them indefinately. Users with out
accounts can have there carts stored in a session and
will become invalid when the session expires.
--- "Chris W. Parker" <cparkerswatgear.com> wrote:
> Hey there everyone.
>
> I haven't had time much to work on my cart program
> recently but I was
> just thinking about abandoned carts and can't figure
> something out
> completely.
>
> How do you determine if a shopping cart has been
> abandoned or not?
>
> What I am thinking is that when the customer adds an
> item to their cart
> an entry is made in a db table. That means a cart is
> created, and that's
> about as far as I get. ;P
>
> Actually that's not totally true, so let me
> continue.
>
> The only reason I can think of to determine if a
> cart has been abandoned
> or not would be based on how old the shopping cart
> is. That is, when it
> was last modified (had a product
> added/modified/deleted from it). But
> who's the say that the customer that created that
> cart is not going to
> come back to the site at some point and then
> checkout?
>
> So then we have to decide how long an unmodified
> cart is considered
> abandoned as opposed to active. Let's make that time
> 1 day (24-hours).
>
> Now let's imagine that there are four abandoned
> carts in the database.
> Now what do we do? Does the program automatically
> delete the carts after
> a certain (definable) period of time, i.e. 7 days?
> OR do we allow the
> merchant to manually delete the carts at any point
> they want? And how do
> you determine your abandoned cart rate? That is, do
> I take a survey of
> the db evey week to see how many abandoned carts I
> have and then average
> those results?
>
> The problem I see is that a cart could be considered
> abandoned for 4
> days but then become active again because the
> customer has come back to
> it and has added more products to it. In this case
> I'd say it was never
> abandoned in the first place and in which case it
> would be innacurate to
> include it your abandoned cart total.
>
> WHAT TO DO?
>
> A BIT CONFUSED I AM!
>
>
>
> Thanks,
> Chris.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

attached mail follows:


Daniel Guerrier <mailto:dan_guerrieryahoo.com>
    on Thursday, December 11, 2003 9:08 AM said:

> Why not just maintain carts for users with accounts
> and maintain them indefinately. Users with out
> accounts can have there carts stored in a session and
> will become invalid when the session expires.

Not a bad idea, in fact I think I like it (as it's been suggested
before). I will probably use it for the rewrite.

Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

attached mail follows:


I would like to know how to insert uploaded file(image) into database
(mysql) into Blob column type. As I upload the file, convert it into string
by using file_get_contents function, there are many aphostrophes in it and
inserting is not possible. Is there some way to solve this problem? For me
is unacceptable to organize images into filesystem because application which
I programme expect uploading of huge amount of images and pictures,
organised by persons, themas and so on, where is using database organized
tables and hierarchy the best way. Thanks for your answer.
Jarmila Kedrstova

attached mail follows:


[snip]
I would like to know how to insert uploaded file(image) into database
(mysql) into Blob column type. As I upload the file, convert it into string
by using file_get_contents function, there are many aphostrophes in it and
inserting is not possible. Is there some way to solve this problem? For me
is unacceptable to organize images into filesystem because application which
I programme expect uploading of huge amount of images and pictures,
organised by persons, themas and so on, where is using database organized
tables and hierarchy the best way. Thanks for your answer.
[/snip]

How about storing the images in the filesystem but organizing their locations using the database?

attached mail follows:


Jarmila --

...and then Jarmila Kedr_tová said...
%
% I would like to know how to insert uploaded file(image) into database
% (mysql) into Blob column type. As I upload the file, convert it into string
% by using file_get_contents function, there are many aphostrophes in it and
% inserting is not possible. Is there some way to solve this problem? For me

You could addslashes() the string, but why not just whip up a query using
the mysql load_file() function? I haven't used it before, and I don't
see immediately how to do it all in one call (because the mysql manual
gives an UPDATE example), but surely creating the record first and
getting the record number and then something like

  update tbl set col = load_file("/path/to/file") where id = recno ;

would work.

% is unacceptable to organize images into filesystem because application which
% I programme expect uploading of huge amount of images and pictures,
% organised by persons, themas and so on, where is using database organized
% tables and hierarchy the best way. Thanks for your answer.

I hear this sort of thing a lot, and I'm still not sold on the
requirement of having the files inside the database. Oh, I agree that
you should let the database handle the organization, but that has nothing
to do with storing the files in the filesystem. Whether you have one big
directory or a whole tree structure, whether you assign a filename based
on record number or store the path and file name or even just use raw
inod numbers, doesn't matter; no matter how you slice it you end up with
a pointer to the data. And it seems a lot simpler to store the data in a
file, and a lot faster to query the db without having to go over the
image data every time, and in general just better to use the filesystem
(which, after all, is a sort of database anyway :-)

% Jarmila Kedrstova

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/2K3sGb7uCXufRwARAqMAAKCfONkBA2pyBIGkztNv/mYHGmKq9wCfZUh7
CFqeipAAhErAIRvF8iclnV4=
=Hli4
-----END PGP SIGNATURE-----

attached mail follows:


Hi,

I am trying to write a script that will allow users within the Windows 2000
Active Directory to be able to change thier personal details on an intranet
website. I have included the script I am using below.

The first part of the script commented as "Search Script" works flawlessly,
even though $base_dn is not set. The problem I am having is with the "Modify
Script", when I try and modify a field it returns with the error:

Warning: ldap_modify(): Modify: Server is unwilling to perform in change.php
on line xx

Is there something in AD that stops ldap_modify? Is my problem with the
unset $base_dn? I had left the $base_dn blank, as I had no idea what it
should be. I would appreciate any help, comments or suggestions.

Thanks!

Phil Dowson

\/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ Script Below \/ \/ \/
\/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/

<?
$base_dn = '';
$ldappass = 'mypassword';
$ldaprdn = 'AD\\'.$ldapuser;
$ldapconn = ldap_connect("ad.domain.com", 3268);

//Search Script Start

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);