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 13 Jul 2004 03:12:45 -0000 Issue 2873

php-general-digest-helplists.php.net
Date: Mon Jul 12 2004 - 22:12:45 CDT


php-general Digest 13 Jul 2004 03:12:45 -0000 Issue 2873

Topics (messages 190240 through 190308):

Re: placing values in html teaxtarea
        190240 by: Travis Low
        190241 by: Jason Wong
        190246 by: Tom Rogers
        190249 by: José de Paula
        190250 by: Keith Greene
        190254 by: John W. Holmes

Re: Cannot send session cookie
        190242 by: Andre Dubuc
        190251 by: Michael Gale

Re: Echoing a value
        190243 by: Pablo Gosse
        190245 by: Jason Wong

Re: addslashes vs string unescape
        190244 by: Daniel Kullik
        190257 by: Skippy
        190268 by: Justin Patrin

easy data port
        190247 by: Edward Peloke

Re: SOLVED! [PHP] Echoing a value
        190248 by: Ed Curtis

warning: function registration failed
        190252 by: Josh Close
        190270 by: Red Wingate
        190281 by: Curt Zirzow

Re: unset empty elements in an array
        190253 by: Justin French
        190261 by: Paul Bissex
        190267 by: Curt Zirzow
        190269 by: Torsten Roehr

Trouble with arrays from within MySQL results where clause
        190255 by: Eric Boerner
        190256 by: Eric Boerner
        190258 by: John W. Holmes
        190259 by: Jason Wong

using the mssql functions on a linux server
        190260 by: Edward Peloke
        190266 by: Arnout Boks
        190273 by: Edward Peloke

File Upload Question
        190262 by: Vail, Warren
        190263 by: John W. Holmes
        190264 by: Arnout Boks
        190265 by: xin

PHPEclipse?
        190271 by: Dan Joseph
        190278 by: Ray Hunter
        190286 by: Dan Joseph
        190289 by: Andrei Verovski (aka MacGuru)
        190290 by: Dan Joseph
        190296 by: Andrei Verovski (aka MacGuru)

stripslashes() when reading from the DB
        190272 by: Jordi Canals
        190283 by: Justin Patrin
        190297 by: Philip Olson
        190301 by: John W. Holmes
        190304 by: Jordi Canals

How to use multiple cookie statements
        190274 by: Ronald \"The Newbie\" Allen
        190276 by: Jordi Canals
        190279 by: Jason Barnett
        190282 by: Matt M.
        190287 by: Michal Migurski
        190307 by: Curt Zirzow

if((strtolower(substr($author, 0, 1)) == $ausenquiry))
        190275 by: John Taylor-Johnston

OO woes
        190277 by: Matthew Sims
        190285 by: Dan Joseph
        190288 by: Matthew Sims
        190292 by: Keith Greene
        190293 by: Chris
        190300 by: Matthew Sims
        190302 by: John W. Holmes

auto-increment not working?? MySQL
        190280 by: barophobia
        190291 by: Jay Blanchard
        190294 by: Justin Patrin
        190298 by: barophobia

Exceptions
        190284 by: Jason Barnett
        190295 by: Matthew Sims

array indexes as arguments to a function
        190299 by: Dennis Gearon

PHP and HTML Conventions
        190303 by: Harlequin
        190305 by: Matthew Sims

[Q] Using $_SERVER['DOCUMENT_ROOT'] correctly
        190306 by: Michael T. Peterson

php reserved characters...
        190308 by: bruce

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:


Would you please turn off return receipt in your messages? Thanks!

Travis

Hull, Douglas D wrote:
> After doing calculations etc on my data I am wanting to place it in a textarea form in html. I am having trouble getting my data to show up in my texarea. For example, say after all my calculations I my field called $test ends up containing "This is a test". Here is what I tried:
>
> <textarea name="zoutput" rows="20" cols="70" wrap value="<? echo $test; ?>" /> </textarea>
> I can add the $test to input like this but not a textarea.
> Name: <input type="text" name="zfname" value="<? echo $test; ?>"/> <br>
> Is this possible?
>
> Thanks,
> Doug
>

--
Travis Low
<mailto:travisdawnstar.com>
<http://www.dawnstar.com>

attached mail follows:


On Monday 12 July 2004 23:09, Hull, Douglas D wrote:
> After doing calculations etc on my data I am wanting to place it in a
> textarea form in html. I am having trouble getting my data to show up in
> my texarea. For example, say after all my calculations I my field called
> $test ends up containing "This is a test". Here is what I tried:
>
> <textarea name="zoutput" rows="20" cols="70" wrap value="<? echo $test; ?>"
> /> </textarea> I can add the $test to input like this but not a
> textarea. Name: <input type="text" name="zfname" value="<? echo $test;
> ?>"/> <br> Is this possible?

Please refer to some decent HTML documentation on how the <textarea> tag
works.

--
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
------------------------------------------
/*
"Engineering without management is art."
-- Jeff Johnson
*/

attached mail follows:


Hi,

Tuesday, July 13, 2004, 1:09:25 AM, you wrote:
HDD> After doing calculations etc on my data I am wanting to
HDD> place it in a textarea form in html. I am having trouble getting
HDD> my data to show up in my texarea. For example, say after all my
HDD> calculations I my field called $test ends up containing "This is
HDD> a test". Here is what I tried:

HDD> <textarea name="zoutput" rows="20" cols="70" wrap value="<?
HDD> echo $test; ?>" /> </textarea>

HDD> I can add the $test to input like this but not a textarea.
HDD> Name: <input type="text" name="zfname" value="<? echo $test; ?>"/> <br>

HDD> Is this possible?

HDD> Thanks,
HDD> Doug

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

the text has to go between the <textarea></textarea> like

<textarea name="zoutput" rows="20" cols="70" wrap><?echo $test?></textarea>

--
regards,
Tom

attached mail follows:


On Mon, 12 Jul 2004 10:09:25 -0500, Hull, Douglas D <ddhullku.edu> wrote:
> After doing calculations etc on my data I am wanting to place it in a textarea form in html. I am having trouble getting my data to show up in my texarea. For example, say after all my calculations I my field called $test ends up containing "This is a test". Here is what I tried:
>
> <textarea name="zoutput" rows="20" cols="70" wrap value="<? echo $test; ?>" /> </textarea>
> I can add the $test to input like this but not a textarea.Name: <input type="text" name="zfname" value="<? echo $test; ?>"/> <br>
> Is this possible?
>
(along the lines of "Is your computer powered on?"):
Did you try:
<textarea ...>echo $test;</textarea>?
In HTML 4/XHTML 1 and later (might be true for earlier versions, too),
the tag <textarea> doesn't have a "value" attribute. Instead, the text
between the <textarea>..</textarea> tags is passed to your script.

> Thanks,
> Doug

attached mail follows:


textareas do not use the value attribute. instead, the value is placed
between the <textarea></textarea> tags:

<textarea name="zoutput" rows="20" cols="70" wrap /><? echo $test;
?></textarea>

At 08:09 AM 7/12/2004, Hull, Douglas D wrote:
>After doing calculations etc on my data I am wanting to place it in a
>textarea form in html. I am having trouble getting my data to show up in
>my texarea. For example, say after all my calculations I my field called
>$test ends up containing "This is a test". Here is what I tried:
>
><textarea name="zoutput" rows="20" cols="70" wrap value="<? echo $test;
>?>" /> </textarea>
>
>I can add the $test to input like this but not a textarea.
>Name: <input type="text" name="zfname" value="<? echo $test; ?>"/> <br>
>
>Is this possible?
>
>Thanks,
>Doug
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


Keith Greene wrote:
>> Here is what I tried:
>>
>> <textarea name="zoutput" rows="20" cols="70" wrap value="<? echo
>> $test; ?>" /> </textarea>
>
> textareas do not use the value attribute. instead, the value is placed
> between the <textarea></textarea> tags:
>
> <textarea name="zoutput" rows="20" cols="70" wrap /><? echo $test;
> ?></textarea>

Ensure you run $test through htmlentities() or htmlspecialchars() before
placing it in your <textarea> like this to prevent code injection.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


Hi Michael,

session_start(); must be the very first line of code on the page, with no
whitespaces trailing, else you'll get the 'header already sent' message:

<?php session_start(); ?>

Hth,
Andre

On Monday 12 July 2004 10:40 am, Michael Purdy wrote:
> Folks
>
> I am a new to php. I am currently learning about session handling and
> would appreciate some assistance with the following:
>
> I am using php 4.3.7 and I am using the default values in the php.ini for
>
> session.use_cookies = 1
> session.cache_limiter = nocache
>
> When experimenting with a few simple lines of code
>
> <script language='php'> ---- This is line 14
> session_start();
> </script>
>
> I get the following errors:
>
> Warning: session_start(): Cannot send session cookie - headers already sent
> by (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
>
> Warning: session_start(): Cannot send session cache limiter - headers
> already sent (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php
> on line 15
>
> Can anyone offer me a insight on the reason for the error.
>
> Mike

attached mail follows:


Hello,

        Do you have output buffering enabled in your php.ini file ?

--snip--
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = 4096
--snip--

The "session_start()" does not have to be the first line of PHP code on the page if you have output buffering enabled.
But it should be near the top.

Michael.

On Tue, 13 Jul 2004 00:40:04 +1000
"Michael Purdy" <michael.purdyoptusnet.com.au> wrote:

> Folks
>
> I am a new to php. I am currently learning about session handling and would appreciate some assistance with the
> following:
>
> I am using php 4.3.7 and I am using the default values in the php.ini for
>
> session.use_cookies = 1
> session.cache_limiter = nocache
>
> When experimenting with a few simple lines of code
>
> <script language='php'> ---- This is line 14
> session_start();
> </script>
>
> I get the following errors:
>
> Warning: session_start(): Cannot send session cookie - headers already sent by (output started at
> e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
>
> Warning: session_start(): Cannot send session cache limiter - headers already sent
> (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
>
> Can anyone offer me a insight on the reason for the error.
>
> Mike
>
>
>

--
Michael Gale
Network Administrator
Utilitran Corporation

attached mail follows:


Ed Curtis wrote:
> I'm having some trouble echoing a value to a file that is being
> pulled from a MySQL database. I've included my code below I'm sure
> it's something really simple but I'm not seeing it.
> $row['users.name'] and $row['users.company'] echo nothing while
> $row['cnt'] echoes it's expected values. If anyone can tell me what
> I'm doing wrong I'd appreciate it.
>
> Thanks,
>
> Ed
>
> $ap = fopen("$ad_path/AdCount$issue.txt", "w");
>
> mysql_connect ($local_host, $local_user, $local_pass);
>
> mysql_select_db ($local_db);
>
> $result = mysql_query ("SELECT *, COUNT(*) as cnt FROM users,
> listings WHERE listings.user_id = users.id AND listings.active = '1'
> GROUP BY users.company, users.name");
>
> if ($row = mysql_fetch_array($result)) {
>
> do {
>
> fputs($ap, $row['users.name']);
> fputs($ap, $sp);
> fputs($ap, $sp);
> fputs($ap, $row['users.company']);
> fputs($ap, $sp);
> fputs($ap, $sp);
> fputs($ap, $row['cnt']);
> fputs($ap, $nl);
>
> }
>
> while($row = mysql_fetch_array($result));
>
> mysql_close(); }
>
> fclose($ap);

I'm not sure about MySQL, but I know for PostgreSQL when I prefix a
field name with a table name in a query I don't need to specify the
table name when accessing that fieldname in the query result.

Try changing:

fputs($ap, $row['users.name']);
fputs($ap, $row['users.company']);

To:

fputs($ap, $row['name']);
fputs($ap, $row['company']);

That should do the trick.

Cheers,
Pablo

attached mail follows:


On Monday 12 July 2004 22:58, Ed Curtis wrote:
> I'm having some trouble echoing a value to a file that is being pulled
> from a MySQL database. I've included my code below I'm sure it's something
> really simple but I'm not seeing it. $row['users.name'] and
> $row['users.company'] echo nothing while $row['cnt'] echoes it's expected
> values. If anyone can tell me what I'm doing wrong I'd appreciate it.

  print_r($row)

--
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
------------------------------------------
/*
Marriage is the waste-paper basket of the emotions.
*/

attached mail follows:


Skippy wrote:
> I'm confronted with a somewhat weird problem and hopefully someone can make a
> suggestion. I have to perform the following 3-step task:
>
> Step 1. Someone provides a string (let's call it the formatting string) which
> contains a PHP expression, which will apply a PHP function on another string,
> let's call this one the random string. I don't control either the formatting
> nor the random string.
>
> Example of formatting string: "trim('%val%')"
>
> Step 2. As you may have guessed, I have to insert the random string in the
> formatting string before I can eval() the latter. So I need to replace %val%
> with the random string. But I have to be careful, since the random string may
> itself contain either double or single quotes, which will break the eval()
> later. So I also need an addslashes().
>
> Operations performed:
> $for_eval=str_replace('%val%',addslashes($random),$format);
> $for_eval='$final_result='.$for_eval.';';
> eval($for_eval);
>
> Step 3. After the above, I should have the formatted string in $final_result.
>
> ***
>
> So now for the problem: addslashes() indiscriminately escapes with backslashes
> both single and double quotes. Strings variables can be specified with either
> single or double quotes; each of the cases, in turn, will not un-escape the
> other type of quote. For example, a string enclosed in double quotes will not
> un-escape \' and a string enclosed in single quotes will not un-escape \".
>
> But my addslashes() escaped both types of quotes. And the formatting string
> (see step 1) will necessarily have enclosed the string to be (%val%) in only
> one of the two types of quotes. So, after all steps are performed, I may very
> well be left with either single or double quotes still escaped, depending on
> the type of quotes which were used in the formatting string.
>
> I was under the impression that double quote strings will be interpreted as to
> unescape single quotes too. However, the manual says they don't do that; they
> unescape some common print sequences (such as tab or newline), double quotes
> (of course), backslash itself, and octal or hexa expressions. NOT single quotes.
>
> If only I could be sure of the type of quotes which were used in the
> formatting string, I could only escape those by hand. But I can't be sure.
>
> Also, I can't forcefully strip slashes from the final result, because I don't
> know which sequences that look like escapes are really escapes or are just
> legitimate pieces of string.
>
> If only double quote strings would un-escape both types of quotes; they don't,
> so their un-escape action is not a 100% reversion of the addslashes() effect.
>
> Any ideas?
>

Can you use this?

[code]
<?php

// Formatting string from outside - apply a function on a random value
$format_string = 'trim();';

// Random value from outside - may contain quotes /-:
// Leading and trailing spaces for trim() included
$rand_string = <<<eod
  My name is "Bla", I want to do some 'foo'.
eod;

// Before and after - remember string's original length
$strlen_start = strlen($rand_string);

// Replacing all single-quotes with double-quotes
$rand_string = str_replace("'", '"', $rand_string);

// Combine format string with random string
$for_eval = sprintf(
   '%s"%s");',
   substr($format_string, 0, -2),
   addslashes($rand_string)
);

// Save return value of format-random-combo in $final
$for_eval = sprintf('$final = %s', $for_eval);

// Dump and eval
printf('<tt>%s</tt>', $for_eval);
eval($for_eval);

// Before and after - remember string's new length
$strlen_end = strlen($final);

// Results:
printf(
   '<br><tt>before: %d, after: %d</tt>',
   $strlen_start, $strlen_end
);

?>
[/code]

Daniel

--
WWE e-commerce IT GmbH
Eiffestrasse 462, D-20537 Hamburg
Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50

attached mail follows:


On Mon, 12 Jul 2004 17:15:15 +0200 Daniel Kullik <kullikwwe.biz> wrote:
> Skippy wrote:
> Can you use this?

It seems to work, at first test, but it's somewhat convoluted. I've found
another fairly reasonable solution: using $val instead of %val%. This way I
don't need to ever show the actual contents of the random string in the
eval() and the problem becomes void.

I said "fairly reasonable" because it will still require a painful porting
period and letting people know they should move to $val, but in the long run
it will work. Here's a lesson about not testing well enough before deploying.

Thank you for the help just the same.

--
Skippy - Romanian Web Developers - http://ROWD.ORG

attached mail follows:


On Mon, 12 Jul 2004 19:32:59 +0300, Skippy <skippyzuavra.net> wrote:
> On Mon, 12 Jul 2004 17:15:15 +0200 Daniel Kullik <kullikwwe.biz> wrote:
> > Skippy wrote:
> > Can you use this?
>
> It seems to work, at first test, but it's somewhat convoluted. I've found
> another fairly reasonable solution: using $val instead of %val%. This way I
> don't need to ever show the actual contents of the random string in the
> eval() and the problem becomes void.
>
> I said "fairly reasonable" because it will still require a painful porting
> period and letting people know they should move to $val, but in the long run
> it will work. Here's a lesson about not testing well enough before deploying.
>
> Thank you for the help just the same.
>

Assuming the formatting string is in $formatString and the random
string is in $randomString:

$evalStr = str_replace('%val%', '$randomString', $formatString);
$result = eval('return '.$evalStr);

No need to change the way that users format their format string.

--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

attached mail follows:


Hello,

I have a real estate customer who wants to keep data about their own
listings in a mysql db but wants to also pull data from the mls listing db
which is sql server. They want to basically use the mls software and enter
into the sql server db but have the php site pull from that server and pump
their stuff into the mysql db to add images, etc.

I have a list of views and columns from the sql server but is there an easy
way to simply move data from the sql sever to the mysql server on a button
click for example...short of me mapping every column in the sql server db to
a column in the mysql db?

Thanks,
Eddie

 WARNING: The information contained in this message and any attachments is
intended only for the use of the individual or entity to which it is
addressed. This message may contain information that is privileged,
confidential and exempt from disclosure under applicable law. It may also
contain trade secrets and other proprietary information for which you and
your employer may be held liable for disclosing. You are hereby notified
that any unauthorized dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify HIPAAechoman.com by E-Mail and then
destroy this communication in a manner appropriate for privileged
information.

attached mail follows:


On Mon, 12 Jul 2004, Pablo Gosse wrote:

> Try changing:
>
> fputs($ap, $row['users.name']);
> fputs($ap, $row['users.company']);
>
> To:
>
> fputs($ap, $row['name']);
> fputs($ap, $row['company']);
>
> That should do the trick.
>
> Cheers,
> Pablo
>

That did the trick! I knew it was something simple I was overlooking.

Thanks,

Ed

attached mail follows:


I installed php-5.0.0 and I get these error when doing "php -v"

PHP Warning: Function registration failed - duplicate name -
mssql_connect in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_pconnect in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_close in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_select_db in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_query in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_free_result in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_get_last_message in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_num_rows in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_num_fields in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_fetch_field in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_fetch_row in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_fetch_array in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_fetch_object in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_data_seek in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_field_seek in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_result in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_min_error_severity in Unknown on line 0
PHP Warning: Function registration failed - duplicate name -
mssql_min_message_severity in Unknown on line 0
PHP Warning: mssql: Unable to register functions, unable to load in
Unknown on line 0

I'm using gentoo linux. I downgraded back to php-4x and I'm still
getting the errors.

What's going on here? How do I fix this?

Is it because gentoo now has both the mssql and freetds flags?

--
-Josh

attached mail follows:


Try a clean install of PHP5 otherwise head over to the interals
list to make sure it won't be a showstopper for the Release
sceduled for today.

  -- red

Josh Close wrote:

> I installed php-5.0.0 and I get these error when doing "php -v"
>
> PHP Warning: Function registration failed - duplicate name -
> mssql_connect in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_pconnect in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_close in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_select_db in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_query in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_free_result in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_get_last_message in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_num_rows in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_num_fields in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_fetch_field in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_fetch_row in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_fetch_array in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_fetch_object in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_data_seek in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_field_seek in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_result in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_min_error_severity in Unknown on line 0
> PHP Warning: Function registration failed - duplicate name -
> mssql_min_message_severity in Unknown on line 0
> PHP Warning: mssql: Unable to register functions, unable to load in
> Unknown on line 0
>
> I'm using gentoo linux. I downgraded back to php-4x and I'm still
> getting the errors.
>
> What's going on here? How do I fix this?
>
> Is it because gentoo now has both the mssql and freetds flags?
>
>

attached mail follows:


* Thus wrote Josh Close:
> I installed php-5.0.0 and I get these error when doing "php -v"
>
> PHP Warning: Function registration failed - duplicate name -
> mssql_connect in Unknown on line 0

Usually means that that module tried to get loaded twice or that
you have that module staticly compiled in and are trying to load
the module via an so as well.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


On 12/07/2004, at 6:38 PM, Thomas Seifert wrote:

> Really what do you need an internal function for something simple like
> that?

It may be simple, but it's 60 characters I have to type over and over,
or a user defined function I have to include() from a library file (and
I have to ensure that library file is up to date on 30+ web
applications).

My view of internal functions is that they solve common, repetitive
problems. Sure, some of those problems are quite complex, but others
are not. A perfect example would be array_walk() -- it can be solved
in a "one liner" too:

        foreach ($in as $k => $v ) { $in[$k] = myFunction($v); }

... but someone decided it was useful as an internal function. My hope
was that there was such a function to delete empty array elements
already defined in PHP, but since it appears there isn't, I'll just
keep including my own from a library file.

---
Justin French
http://indent.com.au

attached mail follows:


On Tue, 13 Jul 2004 01:57:48 +1000, Justin French
<justin.frenchindent.com.au> wrote:
> [...] My hope
> was that there was such a function to delete empty array elements
> already defined in PHP, but since it appears there isn't, I'll just
> keep including my own from a library file.

How about array_filter()? From the docs: "If the callback function is
not supplied, array_filter() will remove all the entries of input
that are equal to FALSE."

  $a = array ('a' => 'foo', 'b' => '', 'c' => null, 'd' => 99, 'e' => 0);
  print_r (array_filter ($a));

// Output:

Array
(
    [a] => foo
    [d] => 99
)

As a previous poster noted, though, this will only work for you if "0"
and the empty string et al. are not significant in your application.

pb

--
paul bissex, e-scribe.com -- database-driven web development
413.585.8095
69.55.225.29
01061-0847
72°39'71"W 42°19'42"N

attached mail follows:


* Thus wrote Justin French:
> On 12/07/2004, at 6:38 PM, Thomas Seifert wrote:
>
> My view of internal functions is that they solve common, repetitive
> problems. Sure, some of those problems are quite complex, but others
> are not. A perfect example would be array_walk() -- it can be solved
> in a "one liner" too:
>
> foreach ($in as $k => $v ) { $in[$k] = myFunction($v); }
>
> ... but someone decided it was useful as an internal function. My hope
> was that there was such a function to delete empty array elements
> already defined in PHP, but since it appears there isn't, I'll just
> keep including my own from a library file.

The problem with your function you want is that it is very
specific, the name would have to be something like:

  unset_array_items_only_if_val_is_empty($array);

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


"Curt Zirzow" <php-generalzirzow.dyndns.org> wrote in message
news:20040712181820.GC45209bagend.shire...
> * Thus wrote Justin French:
> > On 12/07/2004, at 6:38 PM, Thomas Seifert wrote:
> >
> > My view of internal functions is that they solve common, repetitive
> > problems. Sure, some of those problems are quite complex, but others
> > are not. A perfect example would be array_walk() -- it can be solved
> > in a "one liner" too:
> >
> > foreach ($in as $k => $v ) { $in[$k] = myFunction($v); }
> >
> > ... but someone decided it was useful as an internal function. My hope
> > was that there was such a function to delete empty array elements
> > already defined in PHP, but since it appears there isn't, I'll just
> > keep including my own from a library file.
>
> The problem with your function you want is that it is very
> specific, the name would have to be something like:
>
> unset_array_items_only_if_val_is_empty($array);

What about:

array_unset_empty_values() or array_remove_empty_values()

:-)

Torsten

attached mail follows:


Hello all,

I am having trouble setting array data from within a MySQL results
query. I have modified data from the result and wish to enter it into
it's own array ($data). That then is used to generate a graph. The
following code basically gives me an empty array...

I am pulling out a timestamp and signal strength from a live data stream
to chart how strong a tower's signal is during the day. The data streams
once a minute from several sources. I compare each incoming signal with
the if statement and keep the highest signal strength. Each row is then
put into the new array.

CODE:

$data = array();
while ($row1 = mysql_fetch_row ($queryexe1)){

        $datetime = $row1[2];
        $sig1 = $row1[3];
        $sig2 = $row1[6];
        $sig3 = $row1[9];
        list($date,$time) = explode(" ",$datetime);
        if ($sig1 > "-150") { $aval = "$sig1"; }
        if ($sig2 > "-150") { $bval = "$sig2"; } if ($bval > $aval)
{$aval = bval;}
        if ($sig3 > "-150") { $bval = "$sig3"; } if ($bval > $aval)
{$aval = $bval;}

        $data[] = array('$time' => '$time','$aval' => 'aval');

        $aval = "-999";

}
$graph->SetDataValues($data);

END CODE:

attached mail follows:


Nevermind, I figured it out. Simple case of duh...

        $data[] = array('$time' => '$time','$aval' => 'aval');

Should have been:

        $data[] = array('$time' => "$time" ,'$aval' => "aval");

Thanks. :)

-----Original Message-----
From: Eric Boerner [mailto:ericmojavedata.gov]
Sent: Monday, July 12, 2004 9:06 AM
To: php-generallists.php.net
Subject: [PHP] Trouble with arrays from within MySQL results where
clause

Hello all,

I am having trouble setting array data from within a MySQL results
query. I have modified data from the result and wish to enter it into
it's own array ($data). That then is used to generate a graph. The
following code basically gives me an empty array...

I am pulling out a timestamp and signal strength from a live data stream
to chart how strong a tower's signal is during the day. The data streams
once a minute from several sources. I compare each incoming signal with
the if statement and keep the highest signal strength. Each row is then
put into the new array.

CODE:

$data = array();
while ($row1 = mysql_fetch_row ($queryexe1)){

        $datetime = $row1[2];
        $sig1 = $row1[3];
        $sig2 = $row1[6];
        $sig3 = $row1[9];
        list($date,$time) = explode(" ",$datetime);
        if ($sig1 > "-150") { $aval = "$sig1"; }
        if ($sig2 > "-150") { $bval = "$sig2"; } if ($bval > $aval)
{$aval = bval;}
        if ($sig3 > "-150") { $bval = "$sig3"; } if ($bval > $aval)
{$aval = $bval;}

        $data[] = array('$time' => '$time','$aval' => 'aval');

        $aval = "-999";

}
$graph->SetDataValues($data);

END CODE:

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

attached mail follows:


Eric Boerner wrote:

> Hello all,
>
> I am having trouble setting array data from within a MySQL results
> query. I have modified data from the result and wish to enter it into
> it's own array ($data). That then is used to generate a graph. The
> following code basically gives me an empty array...

I doubt the array is empty. It may not contain what you think it should,
though. Try using print_r() on $data as you run through the code so you
can see what it contains.

> if ($sig1 > "-150") { $aval = "$sig1"; }

Don't put quotes around -150. As you have it right now, you're comparing
  strings. If $sig1 is a number, PHP plays nice and assumes you mean
-150 instead of "-150", though. Also, you don't need quotes around $sig1
at the end of the line.

> if ($sig2 > "-150") { $bval = "$sig2"; } if ($bval > $aval)
> {$aval = bval;}

Missing a dollar sign for "bval" on this line, unless "bval" is really a
constant. Same deal with the quotes, too.

> if ($sig3 > "-150") { $bval = "$sig3"; } if ($bval > $aval)
> {$aval = $bval;}

Same deal here with the quotes, also.

> $data[] = array('$time' => '$time','$aval' => 'aval');

Variables in single quotes are not evaluated. '$val' is not the same as
"$val". Either way, you don't need any quotes here (assuming you mean
$aval for the last entry.

$data[] = array($time=>$time, $aval=>$aval);

> $aval = "-999";

$aval = -999;

Again, $data has something in it so long as your query is running. It is
probably just not what you think it is.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


On Tuesday 13 July 2004 00:05, Eric Boerner wrote:

> I am having trouble setting array data from within a MySQL results
> query. I have modified data from the result and wish to enter it into
> it's own array ($data). That then is used to generate a graph. The
> following code basically gives me an empty array...
>
> I am pulling out a timestamp and signal strength from a live data stream
> to chart how strong a tower's signal is during the day. The data streams
> once a minute from several sources. I compare each incoming signal with
> the if statement and keep the highest signal strength. Each row is then
> put into the new array.
>
> CODE:
>
> $data = array();
> while ($row1 = mysql_fetch_row ($queryexe1)){
>
> $datetime = $row1[2];
> $sig1 = $row1[3];
> $sig2 = $row1[6];
> $sig3 = $row1[9];
> list($date,$time) = explode(" ",$datetime);
> if ($sig1 > "-150") { $aval = "$sig1"; }
> if ($sig2 > "-150") { $bval = "$sig2"; } if ($bval > $aval)
> {$aval = bval;}
> if ($sig3 > "-150") { $bval = "$sig3"; } if ($bval > $aval)
> {$aval = $bval;}
>
> $data[] = array('$time' => '$time','$aval' => 'aval');
>
> $aval = "-999";
>
> }
> $graph->SetDataValues($data);
>
> END CODE:

1) print_r() ALL variables of interest, in particular $data - I think you'll
find that it doesn't contain what you expect.

2) Read manual > Types > Strings, to find out the difference between enclosing
a string in single-quotes and double-quotes.

--
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
------------------------------------------
/*
The biggest difference between time and space is that you can't reuse time.
                -- Merrick Furst
*/

attached mail follows:


This may be a dumb question but how do I enable the mssql extension on a
Linux server...if possible? I have a site which needs to connect to a mssql
db. On my windows server, I just enable the mssql.dll extension...how do I
do it on the Linux server?

Thanks,
Eddie

 WARNING: The information contained in this message and any attachments is
intended only for the use of the individual or entity to which it is
addressed. This message may contain information that is privileged,
confidential and exempt from disclosure under applicable law. It may also
contain trade secrets and other proprietary information for which you and
your employer may be held liable for disclosing. You are hereby notified
that any unauthorized dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify HIPAAechoman.com by E-Mail and then
destroy this communication in a manner appropriate for privileged
information.

attached mail follows:


== Quote from http://php.us.themoes.org/manual/en/ref.mssql.php: ==
To use the MSSQL extension on Unix/Linux, you first need to build and
install the FreeTDS library. Source code and installation instructions are
available at the FreeTDS home page: http://www.freetds.org/

Hope this helps you,
Arnout

"Edward Peloke" <epelokeechoman.com> schreef in bericht
news:NKEFLLFBJFIKEGAGKPCAKEPHDHAA.epelokeechoman.com...
> This may be a dumb question but how do I enable the mssql extension on a
> Linux server...if possible? I have a site which needs to connect to a
mssql
> db. On my windows server, I just enable the mssql.dll extension...how do
I
> do it on the Linux server?
>
> Thanks,
> Eddie
>
> WARNING: The information contained in this message and any attachments
is
> intended only for the use of the individual or entity to which it is
> addressed. This message may contain information that is privileged,
> confidential and exempt from disclosure under applicable law. It may also
> contain trade secrets and other proprietary information for which you and
> your employer may be held liable for disclosing. You are hereby notified
> that any unauthorized dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify HIPAAechoman.com by E-Mail and
then
> destroy this communication in a manner appropriate for privileged
> information.

attached mail follows:


Is this the only way around it? Can I get to mssql without using the mssql
extension?

-----Original Message-----
From: Arnout Boks [mailto:arnoutbokshotmail.com]
Sent: Monday, July 12, 2004 1:59 PM
To: php-generallists.php.net
Subject: [PHP] Re: using the mssql functions on a linux server

== Quote from http://php.us.themoes.org/manual/en/ref.mssql.php: ==
To use the MSSQL extension on Unix/Linux, you first need to build and
install the FreeTDS library. Source code and installation instructions are
available at the FreeTDS home page: http://www.freetds.org/

Hope this helps you,
Arnout

"Edward Peloke" <epelokeechoman.com> schreef in bericht
news:NKEFLLFBJFIKEGAGKPCAKEPHDHAA.epelokeechoman.com...
> This may be a dumb question but how do I enable the mssql extension on a
> Linux server...if possible? I have a site which needs to connect to a
mssql
> db. On my windows server, I just enable the mssql.dll extension...how do
I
> do it on the Linux server?
>
> Thanks,
> Eddie
>
> WARNING: The information contained in this message and any attachments
is
> intended only for the use of the individual or entity to which it is
> addressed. This message may contain information that is privileged,
> confidential and exempt from disclosure under applicable law. It may also
> contain trade secrets and other proprietary information for which you and
> your employer may be held liable for disclosing. You are hereby notified
> that any unauthorized dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify HIPAAechoman.com by E-Mail and
then
> destroy this communication in a manner appropriate for privileged
> information.

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

attached mail follows:


Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
be set up to allow a list of files to be uploaded. How does one get the
pop-up window to allow a user to select (ctrl-click or whatever) multiple
files in the same pop-up window? Everything I have tried has left the user
restricted to selecting one file only.
 
thanks in advance.
 
Warren Vail
 
 

attached mail follows:


Vail, Warren wrote:

> Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
> be set up to allow a list of files to be uploaded. How does one get the
> pop-up window to allow a user to select (ctrl-click or whatever) multiple
> files in the same pop-up window? Everything I have tried has left the user
> restricted to selecting one file only.

You can only select one file at a time. There's no way to change that.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


As far as I know, this is not possible.
You can however generate more file-upload boxes dynamicly.
In this way, users can click an 'Upload another file'-button to display an
extra upload form-element.
Check the 'variable variables'-part in the PHP reference (user notes) for an
example of this construction.
Hope this is good solution for your application.

greetz,
Arnout Boks

"Warren Vail" <Warren.Vailschwab.com> schreef in bericht
news:72138202E59CD6118E960002A52CD9D211FAAB0Cn1025smx.nt.schwab.com...
> Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
> be set up to allow a list of files to be uploaded. How does one get the
> pop-up window to allow a user to select (ctrl-click or whatever) multiple
> files in the same pop-up window? Everything I have tried has left the
user
> restricted to selecting one file only.
>
> thanks in advance.
>
> Warren Vail
>
>
>

attached mail follows:


you might need to resolve to Java applet or other means to select more than
one files at same time. The following is an example:

http://barleypop.vrac.iastate.edu/BarleyBase/test/upload/version_05/Upload.php

yours,
xin

----- Original Message -----
From: "Vail, Warren" <Warren.Vailschwab.com>
To: <php-generallists.php.net>
Sent: Monday, July 12, 2004 12:15 PM
Subject: [PHP] File Upload Question

> Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
> be set up to allow a list of files to be uploaded. How does one get the
> pop-up window to allow a user to select (ctrl-click or whatever) multiple
> files in the same pop-up window? Everything I have tried has left the
user
> restricted to selecting one file only.
>
> thanks in advance.
>
> Warren Vail
>
>
>

attached mail follows:


Hi,

        I was wondering, is anyone running Eclipse 3.0 w/PHPEclipse 1.1.0?
I'm having trouble getting it working. I downloaded the July .ZIP file and
unzipped it into the plugins directory. Its not recognizing it. Anyone
have this working?

-Dan Joseph

attached mail follows:


On Mon, 2004-07-12 at 12:39, Dan Joseph wrote:
> I was wondering, is anyone running Eclipse 3.0 w/PHPEclipse 1.1.0?
> I'm having trouble getting it working. I downloaded the July .ZIP file and
> unzipped it into the plugins directory. Its not recognizing it. Anyone
> have this working?

I tried it, however, i had no success getting it to work. I tried
Trustudio php plugin and got the editor to work. The editor was okay,
yet the preferences did not work all that great. The debugger did not
work and i did not try and figure out what was wrong with it.

This is linux eclipse too.

--
Ray

attached mail follows:


LOL.. I read all these "PHPEclipse is great!" reviews. It relaly does look
good. Bummer you couldn't get it working either. I have EPIC installed, a
Perl plug-in, its working fine, so I know plugins are working. Ahh well,
maybe someone will read the list and have an answer.

-Dan Joseph

> -----Original Message-----
> From: Ray Hunter [mailto:bigdogventicon.com]
> Sent: Monday, July 12, 2004 4:02 PM
> To: php-generallists.php.net
> Subject: Re: [PHP] PHPEclipse?
>
> On Mon, 2004-07-12 at 12:39, Dan Joseph wrote:
> > I was wondering, is anyone running Eclipse 3.0
> w/PHPEclipse 1.1.0?
> > I'm having trouble getting it working. I downloaded the July .ZIP
> > file and unzipped it into the plugins directory. Its not
> recognizing
> > it. Anyone have this working?
>
> I tried it, however, i had no success getting it to work. I
> tried Trustudio php plugin and got the editor to work. The
> editor was okay, yet the preferences did not work all that
> great. The debugger did not work and i did not try and figure
> out what was wrong with it.
>
> This is linux eclipse too.
>
> --
> Ray
>
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Hi,

I am currently using Eclipse 3.0 with latest build of PHPEclipse on Linux.
Just great. Did not tried debugger, however.

On Monday 12 July 2004 09:39 pm, Dan Joseph wrote:
> Hi,
>
> I was wondering, is anyone running Eclipse 3.0 w/PHPEclipse 1.1.0?
> I'm having trouble getting it working. I downloaded the July .ZIP file and
> unzipped it into the plugins directory. Its not recognizing it. Anyone
> have this working?
>
> -Dan Joseph

--

************************************************
***   with best regards
***   Andrei Verovski (aka MacGuru)
***   Mac, Linux, DTP, Programming Web Site
***
***   http://snow.prohosting.com/guru4mac/
************************************************

attached mail follows:


How did you get it installed? Did you just extract the zip into the plugins
directory?

-Dan Joseph

> -----Original Message-----
> From: Andrei Verovski (aka MacGuru) [mailto:andreil1starlett.lv]
> Sent: Monday, July 12, 2004 4:36 PM
> To: php-generallists.php.net
> Cc: Dan Joseph
> Subject: Re: [PHP] PHPEclipse?
>
> Hi,
>
> I am currently using Eclipse 3.0 with latest build of
> PHPEclipse on Linux.
> Just great. Did not tried debugger, however.
>
>
> On Monday 12 July 2004 09:39 pm, Dan Joseph wrote:
> > Hi,
> >
> > I was wondering, is anyone running Eclipse 3.0
> w/PHPEclipse 1.1.0?
> > I'm having trouble getting it working. I downloaded the July .ZIP
> > file and unzipped it into the plugins directory. Its not
> recognizing
> > it. Anyone have this working?
> >
> > -Dan Joseph
>
> --
>
> ************************************************
> ***   with best regards
> ***   Andrei Verovski (aka MacGuru)
> ***   Mac, Linux, DTP, Programming Web Site
> ***
> ***   http://snow.prohosting.com/guru4mac/
> ************************************************
>
>

attached mail follows:


On Monday 12 July 2004 11:27 pm, Dan Joseph wrote:
> How did you get it installed?  Did you just extract the zip into the
> plugins directory?

Yes.

--

************************************************
***   with best regards
***   Andrei Verovski (aka MacGuru)
***   Mac, Linux, DTP, Programming Web Site
***
***   http://snow.prohosting.com/guru4mac/
************************************************

attached mail follows:


Hi,

I usually stripslashes() when I read the info from the database (MySQL).
  Because the information was inserted after adding slashes, or the
system has magic_quotes_gpc set to ON.

I'd like to know, if I can do stripslashes() directly, as it is suposed
that all data was inserted into DB after slashing the vars. I mean,
should I check or not before if magic_quotes_gpc are on ?

As I know, magic_quotes_gpc has nothing to do with info readed from the
DB, as it only affects Get/Post/Cookie values.

I think to make a check like this:

$result = mysql_query("SELECT ....");
$row = mysql_fetch_assoc($result);

foreach ($row as $key => $value) {
     $row[$key] = stripslashes($value);
}

But not sure if it really necessary, as i'm getting some confusing results.

Any help will be welcome
Regards,
Jordi.

attached mail follows:


On Mon, 12 Jul 2004 20:45:12 +0200, Jordi Canals <jordijcanals.net> wrote:
> Hi,
>
> I usually stripslashes() when I read the info from the database (MySQL).
> Because the information was inserted after adding slashes, or the
> system has magic_quotes_gpc set to ON.
>
> I'd like to know, if I can do stripslashes() directly, as it is suposed
> that all data was inserted into DB after slashing the vars. I mean,
> should I check or not before if magic_quotes_gpc are on ?
>
> As I know, magic_quotes_gpc has nothing to do with info readed from the
> DB, as it only affects Get/Post/Cookie values.
>
> I think to make a check like this:
>
> $result = mysql_query("SELECT ....");
> $row = mysql_fetch_assoc($result);
>
> foreach ($row as $key => $value) {
> $row[$key] = stripslashes($value);
> }
>
> But not sure if it really necessary, as i'm getting some confusing results.
>

What you *should* be doing is check for magic quotes when inserting into the DB.

if(!get_magic_quotes_gpc()) {
  $value = mysql_real_escape_string($value);
}

$query = 'INSERT INTO table (field) VALUES ("'.$value.'")';
mysql_query($query);

--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

attached mail follows:


> > I usually stripslashes() when I read the info from the database (MySQL).
> > Because the information was inserted after adding slashes, or the
> > system has magic_quotes_gpc set to ON.
> >
> > I'd like to know, if I can do stripslashes() directly, as it is suposed
> > that all data was inserted into DB after slashing the vars. I mean,
> > should I check or not before if magic_quotes_gpc are on ?
> >
> > As I know, magic_quotes_gpc has nothing to do with info readed from the
> > DB, as it only affects Get/Post/Cookie values.
> >
> > I think to make a check like this:
> >
> > $result = mysql_query("SELECT ....");
> > $row = mysql_fetch_assoc($result);
> >
> > foreach ($row as $key => $value) {
> > $row[$key] = stripslashes($value);
> > }
> >
> > But not sure if it really necessary, as i'm getting some confusing results.
> >
>
> What you *should* be doing is check for magic quotes when inserting into the DB.
>
> if(!get_magic_quotes_gpc()) {
> $value = mysql_real_escape_string($value);
> }
>
> $query = 'INSERT INTO table (field) VALUES ("'.$value.'")';
> mysql_query($query);

To add further comment. If you're required to run stripslashes() on
data coming out of your database then you did something wrong. Your
code would have essentially looked like the following before insertion:

  $var = addslashes(addslashes($var));

Where 'magic_quotes_gpc = on' essentially executed one of those
addslashes(). The above use of get_magic_quotes_gpc() shows you
how to add slashes just once thus not having a bunch of \' type
badness inside your database. Remember backslashes are only
added to make proper strings for db insertion so the backslashes
should never actually make it into the database.

Regards,
Philip

attached mail follows:


Jordi Canals wrote:

> I usually stripslashes() when I read the info from the database (MySQL).
> Because the information was inserted after adding slashes, or the
> system has magic_quotes_gpc set to ON.

I remember being taught this lesson long ago. :)

You do not need to strip slashes from the data being read from the
database. If you find yourself having to do that, then you're escaping
the data twice before it's inserted. You more than likely have
magic_quotes_gpc enabled which escapes all incoming GET, POST and COOKIE
data and then you are running addslashes() yourself.

You should check the magic_quotes setting with get_magic_quotes_gpc()
and then determine if you need to use addslashes or
mysql_real_escape_string().

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


Philip Olson wrote:

>>>I usually stripslashes() when I read the info from the database (MySQL).
>>> Because the information was inserted after adding slashes, or the
>>>system has magic_quotes_gpc set to ON.
>>>

> To add further comment. If you're required to run stripslashes() on
> data coming out of your database then you did something wrong. Your
> code would have essentially looked like the following before insertion:
>
Wow, here where just my mistake :p I have magic_quotes_gpc at ON and I
do not use addslashes. I use a custom .htaccess file to ensure
magic_quotes_gpc are ON ...

But in a class used to create the forms, there is a striplashes(), so
the extrange I've seen. Removed stripslashes from the function, solved
the problem.

Just have to work to see how manage the form when data comes from a
previos post (Which have slashes) or comes from DB (Which have NOT).

Thanks to all to help me to clarify this point.
Jordi.

attached mail follows:


aHere is my code...

<?
setcookie("cookie[name]","$_POST['name']", time()+86400)
setcookie ("cookie[email]","$_POST['email']", time()+86400)
setcookie ("cookie[bgcolor]","$_POST['bgcolor']", time()+86400)
setcookie ("cookie[tcolor]", "$_POST['tcolor']", time()+86400)

?>
I have to use cookies, since I am taking a class and it dictates that we use
cookies, but I can't email my instructor since she never responds. So how
do I use a cookie to record multiple values? Help would be appreciative.a

attached mail follows:


Ronald "The Newbie" Allen wrote:

> aHere is my code...
>
> <?
> setcookie("cookie[name]","$_POST['name']", time()+86400)
> setcookie ("cookie[email]","$_POST['email']", time()+86400)
> setcookie ("cookie[bgcolor]","$_POST['bgcolor']", time()+86400)
> setcookie ("cookie[tcolor]", "$_POST['tcolor']", time()+86400)
>
> ?>
> I have to use cookies, since I am taking a class and it dictates that we use
> cookies, but I can't email my instructor since she never responds. So how
> do I use a cookie to record multiple values? Help would be appreciative.a
>

As the standard says, 1 cookie = 1 value, no way to have more than one
value in a cookie.

But you can think about some workarounds, a quick example just to give
you an idea:

$cookie = implode(':', $array)

Here you will have all values from the array in the cookie, and using :
as a separator.

To reverse the values: $values = explode(':', $cookie) and here you will
have all values in the array $values, starting with index 0.

Of course, in this way you can only set values, not the array keys. Look
in the manual for implode() and explode() and see if is usefull for you.

Regards,
Jordi.

attached mail follows:


Or if you feel lazy... then you can use serialize / unserialize.

attached mail follows:


> <?
> setcookie("cookie[name]","$_POST['name']", time()+86400)
> setcookie ("cookie[email]","$_POST['email']", time()+86400)
> setcookie ("cookie[bgcolor]","$_POST['bgcolor']", time()+86400)
> setcookie ("cookie[tcolor]", "$_POST['tcolor']", time()+86400)
>
> ?>

you could try this:

setcookie ('values', serialize($_POST), time()+86400);

then when you want to retrieve it use

$values = unserialize($_COOKIE['values']);

attached mail follows:


> I have to use cookies, since I am taking a class and it dictates that we
> use cookies, but I can't email my instructor since she never responds.
> So how do I use a cookie to record multiple values? Help would be
> appreciative.a

A few options: use multiple cookies, e.g. setcookie('cookie_a'),
setcookie('cookie_b'), etc. Jordi's suggestion is also good, though I
would suggest using serialize() to make a single string out of your
values, like this: serialize(array('name1' => 'value', 'name2' =>
'value'). Or, use PHP's built-in session support. The cookie stores a
unique ID, whie the actual values are stored on the server.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html

attached mail follows:


* Thus wrote Jason Barnett:
> Or if you feel lazy... then you can use serialize / unserialize.

I'll be even lazier...

setcookie('foo[bar]', 'is ok');
setcookie('foo[qaz]', 'is better');

// after cookie is set.
$myFoo = $_COOKIE['foo'];

print_r($myFoo);

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Hi,
I'm trying to sort my array. My Usort works, but this line only chooses those that begin with an "e":

    if((strtolower(substr($author, 0, 1)) == $ausenquiry))

http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
is different from:
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é

So how would I recode $ausenquiry so if ausenquiry=e, it will choose words that begin
with "e", "é" sorted this way:

usort($authors, 'usort_callback');

Here is my source: http://compcanlit.usherbrooke.ca/new1/db/ausenquiry.phps

Sorry to throw the entire .inc at you.

John

attached mail follows:


PHP version 5.0.0RC3 (cgi) (built: Jul 9 2004 13:18:24)

I'm just getting my feet wet with OO and have run into a problem that I'm
not familiar with...yet.

I have a class that does a database connection and query all together. It
all works nicely until....until my query has a word with quotes around it.

I've tried addslashes and mysql_escape_string but when I do I get a Fatal
Error. It occurs in the execute($query) function down below.

I'm also using the recommended php.ini file...magic quotes off and all.

*****************************************
class DB_Mysql {

  protected $user; // Database username
  protected $pass; // Database password
  protected $dbhost; // Database host
  protected $dbname; // Database name
  protected $dbh; // Database handle

  public function __construct($user, $pass, $dbhost, $dbname) {
        $this->user = $user;
        $this->pass = $pass;
        $this->dbhost = $dbhost;
        $this->dbname = $dbname;
  }

  protected function connect() {
        $this->dbh = mysql_connect($this->dbhost, $this->user, $this->pass);

        if (!is_resource($this->dbh)) {
          throw new Exception;
        }

        if (!mysql_select_db($this->dbname, $this->dbh)) {
          throw new Exception;
        }
  }

  public function execute($query) {
        if (!$this->dbh) {
          $this->connect();
        }

        // My $query has quotes in it
        // I try to escape the quotes
        $query = mysql_escape_string($query);
        // It causes an error
        $ret = mysql_query($query, $this->dbh);

        if (!$ret) {
          // An Exception error is thrown
          throw new Exception;
        } elseif (!is_resource($ret)) {
          return TRUE;
        } else {
          $statment = new DB_MysqlStatement($this->dbh, $query);
          return $statement;
        }
  }
}
*****************************************

My query statement is:
$query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';

I call the class as follows:
$dbh = new DB_Mysql("user","passwd","localhost","test");
$query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';
$dbh->execute($query);

If the $_POST variable does not contain any quotes, the class works
perfectly. But whenever quotes are passed through, I get the following
error:

Fatal error: Uncaught exception 'Exception' in
/www/htdocs/classes/db_class.php:53 Stack trace: #0
/www/htdocs/letter.php(51): DB_Mysql->execute('INSERT into aeM...') #1
{main} thrown in /www/htdocs/classes/db_class.php on line 53

--Matthew Sims
--<http://killermookie.org>

attached mail follows:


Hi,

        Doesn't sound like an OO issue, sounds like you're kiling the query
with the '. You should go thru and maybe do an str_replace( "'", "\'",
$_POST['test'] ) on all your post variables.

-Dan Joseph

> -----Original Message-----
> From: Matthew Sims [mailto:mattkillermookie.org]
> Sent: Monday, July 12, 2004 4:08 PM
> To: php-generallists.php.net
> Subject: [PHP] OO woes
> Importance: High
>
> PHP version 5.0.0RC3 (cgi) (built: Jul 9 2004 13:18:24)
>
> I'm just getting my feet wet with OO and have run into a
> problem that I'm not familiar with...yet.
>
> I have a class that does a database connection and query all
> together. It all works nicely until....until my query has a
> word with quotes around it.
>
> I've tried addslashes and mysql_escape_string but when I do I
> get a Fatal Error. It occurs in the execute($query) function
> down below.
>
> I'm also using the recommended php.ini file...magic quotes
> off and all.
>
> *****************************************
> class DB_Mysql {
>
> protected $user; // Database username
> protected $pass; // Database password
> protected $dbhost; // Database host
> protected $dbname; // Database name
> protected $dbh; // Database handle
>
> public function __construct($user, $pass, $dbhost, $dbname) {
> $this->user = $user;
> $this->pass = $pass;
> $this->dbhost = $dbhost;
> $this->dbname = $dbname;
> }
>
> protected function connect() {
> $this->dbh = mysql_connect($this->dbhost,
> $this->user, $this->pass);
>
> if (!is_resource($this->dbh)) {
> throw new Exception;
> }
>
> if (!mysql_select_db($this->dbname, $this->dbh)) {
> throw new Exception;
> }
> }
>
> public function execute($query) {
> if (!$this->dbh) {
> $this->connect();
> }
>
> // My $query has quotes in it
> // I try to escape the quotes
> $query = mysql_escape_string($query);
> // It causes an error
> $ret = mysql_query($query, $this->dbh);
>
> if (!$ret) {
> // An Exception error is thrown
> throw new Exception;
> } elseif (!is_resource($ret)) {
> return TRUE;
> } else {
> $statment = new DB_MysqlStatement($this->dbh, $query);
> return $statement;
> }
> }
> }
> *****************************************
>
> My query statement is:
> $query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';
>
> I call the class as follows:
> $dbh = new DB_Mysql("user","passwd","localhost","test");
> $query = 'INSERT into aeMail set
> test=\''.$_POST["test"].'\''; $dbh->execute($query);
>
> If the $_POST variable does not contain any quotes, the class
> works perfectly. But whenever quotes are passed through, I
> get the following
> error:
>
> Fatal error: Uncaught exception 'Exception' in
> /www/htdocs/classes/db_class.php:53 Stack trace: #0
> /www/htdocs/letter.php(51): DB_Mysql->execute('INSERT into
> aeM...') #1 {main} thrown in /www/htdocs/classes/db_class.php
> on line 53
>
> --Matthew Sims
> --<http://killermookie.org>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


> Hi,
>
> Doesn't sound like an OO issue, sounds like you're kiling the query
> with the '. You should go thru and maybe do an str_replace( "'", "\'",
> $_POST['test'] ) on all your post variables.
>
> -Dan Joseph
>

Ha! That did it. Thanks!

--Matthew Sims
--<http://killermookie.org>

>> -----Original Message-----
>> From: Matthew Sims [mailto:mattkillermookie.org]
>> Sent: Monday, July 12, 2004 4:08 PM
>> To: php-generallists.php.net
>> Subject: [PHP] OO woes
>> Importance: High
>>
>> PHP version 5.0.0RC3 (cgi) (built: Jul 9 2004 13:18:24)
>>
>> I'm just getting my feet wet with OO and have run into a
>> problem that I'm not familiar with...yet.
>>
>> I have a class that does a database connection and query all
>> together. It all works nicely until....until my query has a
>> word with quotes around it.
>>
>> I've tried addslashes and mysql_escape_string but when I do I
>> get a Fatal Error. It occurs in the execute($query) function
>> down below.
>>
>> I'm also using the recommended php.ini file...magic quotes
>> off and all.
>>
>> *****************************************
>> class DB_Mysql {
>>
>> protected $user; // Database username
>> protected $pass; // Database password
>> protected $dbhost; // Database host
>> protected $dbname; // Database name
>> protected $dbh; // Database handle
>>
>> public function __construct($user, $pass, $dbhost, $dbname) {
>> $this->user = $user;
>> $this->pass = $pass;
>> $this->dbhost = $dbhost;
>> $this->dbname = $dbname;
>> }
>>
>> protected function connect() {
>> $this->dbh = mysql_connect($this->dbhost,
>> $this->user, $this->pass);
>>
>> if (!is_resource($this->dbh)) {
>> throw new Exception;
>> }
>>
>> if (!mysql_select_db($this->dbname, $this->dbh)) {
>> throw new Exception;
>> }
>> }
>>
>> public function execute($query) {
>> if (!$this->dbh) {
>> $this->connect();
>> }
>>
>> // My $query has quotes in it
>> // I try to escape the quotes
>> $query = mysql_escape_string($query);
>> // It causes an error
>> $ret = mysql_query($query, $this->dbh);
>>
>> if (!$ret) {
>> // An Exception error is thrown
>> throw new Exception;
>> } elseif (!is_resource($ret)) {
>> return TRUE;
>> } else {
>> $statment = new DB_MysqlStatement($this->dbh, $query);
>> return $statement;
>> }
>> }
>> }
>> *****************************************
>>
>> My query statement is:
>> $query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';
>>
>> I call the class as follows:
>> $dbh = new DB_Mysql("user","passwd","localhost","test");
>> $query = 'INSERT into aeMail set
>> test=\''.$_POST["test"].'\''; $dbh->execute($query);
>>
>> If the $_POST variable does not contain any quotes, the class
>> works perfectly. But whenever quotes are passed through, I
>> get the following
>> error:
>>
>> Fatal error: Uncaught exception 'Exception' in
>> /www/htdocs/classes/db_class.php:53 Stack trace: #0
>> /www/htdocs/letter.php(51): DB_Mysql->execute('INSERT into
>> aeM...') #1 {main} thrown in /www/htdocs/classes/db_class.php
>> on line 53
>>
>> --Matthew Sims
>> --<http://killermookie.org>
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/) To
>> unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>

attached mail follows:


$query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';

Your quotes look screwy to me. You seem to be missing both trailing single
quotes.
try this:

$query = 'INSERT into aeMail set test=\'''.$_POST["test"].'\''';

At 01:07 PM 7/12/2004, Matthew Sims wrote:
>PHP version 5.0.0RC3 (cgi) (built: Jul 9 2004 13:18:24)
>
>I'm just getting my feet wet with OO and have run into a problem that I'm
>not familiar with...yet.
>
>I have a class that does a database connection and query all together. It
>all works nicely until....until my query has a word with quotes around it.
>
>I've tried addslashes and mysql_escape_string but when I do I get a Fatal
>Error. It occurs in the execute($query) function down below.
>
>I'm also using the recommended php.ini file...magic quotes off and all.
>
>*****************************************
>class DB_Mysql {
>
> protected $user; // Database username
> protected $pass; // Database password
> protected $dbhost; // Database host
> protected $dbname; // Database name
> protected $dbh; // Database handle
>
> public function __construct($user, $pass, $dbhost, $dbname) {
> $this->user = $user;
> $this->pass = $pass;
> $this->dbhost = $dbhost;
> $this->dbname = $dbname;
> }
>
> protected function connect() {
> $this->dbh = mysql_connect($this->dbhost, $this->user, $this->pass);
>
> if (!is_resource($this->dbh)) {
> throw new Exception;
> }
>
> if (!mysql_select_db($this->dbname, $this->dbh)) {
> throw new Exception;
> }
> }
>
> public function execute($query) {
> if (!$this->dbh) {
> $this->connect();
> }
>
> // My $query has quotes in it
> // I try to escape the quotes
> $query = mysql_escape_string($query);
> // It causes an error
> $ret = mysql_query($query, $this->dbh);
>
> if (!$ret) {
> // An Exception error is thrown
> throw new Exception;
> } elseif (!is_resource($ret)) {
> return TRUE;
> } else {
> $statment = new DB_MysqlStatement($this->dbh, $query);
> return $statement;
> }
> }
>}
>*****************************************
>
>My query statement is:
>$query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';
>
>I call the class as follows:
>$dbh = new DB_Mysql("user","passwd","localhost","test");
>$query = 'INSERT into aeMail set test=\''.$_POST["test"].'\'';
>$dbh->execute($query);
>
>If the $_POST variable does not contain any quotes, the class works
>perfectly. But whenever quotes are passed through, I get the following
>error:
>
>Fatal error: Uncaught exception 'Exception' in
>/www/htdocs/classes/db_class.php:53 Stack trace: #0
>/www/htdocs/letter.php(51): DB_Mysql->execute('INSERT into aeM...') #1
>{main} thrown in /www/htdocs/classes/db_class.php on line 53
>
>--Matthew Sims
>--<http://killermookie.org>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


Your problem has nothing to do with the Objects (or really even PHP for
that matter). You're not supposed to run mysql_escape_string on an
entire query. Here's an example of its usage:

$sString = "This string contains a single-quote (')";

$sQuery = "INSERT INTO mytable SET
mystrcolumn='{$sString}',mynumbercolumn=24";

"INSERT INTO mytable SET mystrcolumn='This string contains a
single-quote (')',mynumbercolumn=24" == $sQuery; // This just shows
what's in $sQuery

If you were to run $sQuery as it is, it would not parse because the
single-quote in $sString would indicate the end of that string, and the
characters following it aren't valid SQL.

But, if you were to use mysql_escape_string on $sString, before putting
it in the query, everything would work out fine.

$sString = "This string contains a single-quote (')";

$sString = mysql_escape_string($sString);

$sQuery = "INSERT INTO mytable SET
mystrcolumn='{$sString}',mynumbercolumn=24";

"INSERT INTO mytable SET mystrcolumn='This string contains a
single-quote (\')',mynumbercolumn=24" == $sQuery; // This just shows
what's in $sQuery

Now the single-quote in $sString has been escaped, and MySQL doesn't see
it as the string delimiter.

On a side note, mysql_real_escape_string would probably be prefferable,
as it takes into accoutnt he character set of the current connection.

Chris

Matthew Sims wrote:

>PHP version 5.0.0RC3 (cgi) (built: Jul 9 2004 13:18:24)
>
>I'm just getting my feet wet with OO and have run into a problem that I'm
>not familiar with...yet.
>
>I have a class that does a database connection and query all together. It
>all works nicely until....until my query has a word with quotes around it.
>
>I've tried addslashes and mysql_escape_string but when I do I get a Fatal
>Error. It occurs in the execute($query) function down below.
>
>I'm also using the recommended php.ini file...magic quotes off and all.
>
>*****************************************
>class