php-general Digest 6 Feb 2006 15:01:42 -0000 Issue 3948
Topics (messages 229910 through 229949):
how to show 6 randomly selected featured products?
229910 by: afan.afan.net
229912 by: Chris
229914 by: Sumeet
229946 by: afan.afan.net
Re: problem with Mail function
229911 by: sub.drewpydraws.com
229913 by: sunaram patir
can't output sql query with php code.
229915 by: Paul Goepfert
229918 by: Chris
229919 by: Brady Mitchell
229922 by: Paul Goepfert
229926 by: Sumeet
229927 by: Brady Mitchell
229929 by: Paul Goepfert
Submitting form without JavaScript
229916 by: Peter Lauri
229917 by: Chris
229923 by: Peter Lauri
229924 by: Sumeet
229925 by: Peter Lauri
229928 by: Sumeet
Re: Serious bug ?
229920 by: Marco Kaiser
229941 by: Bogdan Ribic
Strip comments but leave URI's which are in between ( and )
229921 by: Mathijs
Re: PHP 4.2.2 Float->Mysql addition problem
229930 by: Barry
Re: system('bell'); ?
229931 by: Oli Howson
Re: system( bell ); ?
229932 by: Angelo Zanetti
Re: mail() and Return-Path header
229933 by: Marcus Bointon
DOM/XML Query
229934 by: Andrew Clarke
229935 by: Barry
string lenght?
229936 by: William Stokes
229937 by: Barry
229938 by: Richard Davey
229939 by: William Stokes
Results In Variable
229940 by: Pastor Steve
229942 by: Peter Lauri
229943 by: Austin Denyer
229945 by: Arno Kuhl
Re: Reverse Engineering of Smarty
229944 by: Finner, Doug
LIMIT?
229947 by: William Stokes
229948 by: Larry E. Ullman
229949 by: Albert
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hi,
I have to show 6 of up to 1000 (most likely 200-600) featured products on
my online store.
My first thought was using this query:
$query = mysql_query("
SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
pr.qty, pr.price, pr.sale_price, chp.cat_id
FROM products as p
LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
ORDER BY RAND() LIMIT 6
");
but I needed 4 to 6 secunds to finish downloading the page.
Then I tried as a solution to grab all featured products from db, store
them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
actually just grab randomly 6 products form the array.
The home page is now much faster, of course, but I'm not sure how "smart"
is keep an array with 1000 elements in $_SESSION?
Thanks for any opinion!
:)
-afan
--- End Message ---
--- Begin Message ---
Hi,
Sounds like your query isn't indexed properly.
Check you have an index on:
products.prod_id (primary key - should be indexed already)
prices.prod_id
categories_has_products.prod_id
[EMAIL PROTECTED] wrote:
Hi,
I have to show 6 of up to 1000 (most likely 200-600) featured products on
my online store.
My first thought was using this query:
$query = mysql_query("
SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
pr.qty, pr.price, pr.sale_price, chp.cat_id
FROM products as p
LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
ORDER BY RAND() LIMIT 6
");
but I needed 4 to 6 secunds to finish downloading the page.
Then I tried as a solution to grab all featured products from db, store
them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
actually just grab randomly 6 products form the array.
The home page is now much faster, of course, but I'm not sure how "smart"
is keep an array with 1000 elements in $_SESSION?
Thanks for any opinion!
:)
-afan
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Hi,
I have to show 6 of up to 1000 (most likely 200-600) featured products on
my online store.
My first thought was using this query:
$query = mysql_query("
SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
pr.qty, pr.price, pr.sale_price, chp.cat_id
FROM products as p
LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
ORDER BY RAND() LIMIT 6
");
but I needed 4 to 6 secunds to finish downloading the page.
Then I tried as a solution to grab all featured products from db, store
them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
actually just grab randomly 6 products form the array.
The home page is now much faster, of course, but I'm not sure how "smart"
is keep an array with 1000 elements in $_SESSION?
Thanks for any opinion!
:)
-afan
hello afan,
it is not "smart" at all..
1. array takes valuable computer memory. 1000 (arrays) is a lot. 1 char
= 1 byte, 40 chars each string. and several fields.
2. sessions actually store the same on file in the session directory.
reading of files is slower and requires a lot of computer overheads.
the sql is easier to use and much efficient.
moreover u must try to use a Profiler. a profiler is a software that
gives you more details on all the functions and the time taken and the
number of times used. you will be able to determine the frequency of the
usage of the function and can improve or developed further the most
commonly used functions.
Pear's Benckmark Profiler is easy to install and to use...try it.
Use session only for dynamic data that CANNOT be stored in a database.
like carts, navigation info, or form elements etc.
--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India
--- End Message ---
--- Begin Message ---
I think(hope :)) I got it right:
table products
prod_id is primary key
table prices
price_id is primary key
prod_id is foreign key
table categories_has_products (since one product can be in more then one
category, I have this table with only two columns: cat_id and prod_id, to
link table between categories and products)
cat_id, prod_id - product key
> Hi,
>
> Sounds like your query isn't indexed properly.
>
> Check you have an index on:
>
> products.prod_id (primary key - should be indexed already)
> prices.prod_id
> categories_has_products.prod_id
>
> [EMAIL PROTECTED] wrote:
>> Hi,
>>
>> I have to show 6 of up to 1000 (most likely 200-600) featured products
>> on
>> my online store.
>>
>> My first thought was using this query:
>> $query = mysql_query("
>> SELECT p.prod_id, p.prod_name, p.prod_no, pr.price_id, pr.method,
>> pr.qty, pr.price, pr.sale_price, chp.cat_id
>> FROM products as p
>> LEFT JOIN prices as pr ON pr.prod_id = p.prod_id
>> LEFT JOIN categories_has_products as chp ON chp.prod_id = p.prod_id
>> ORDER BY RAND() LIMIT 6
>> ");
>> but I needed 4 to 6 secunds to finish downloading the page.
>>
>> Then I tried as a solution to grab all featured products from db, store
>> them as an array in $_SESSION[FEFATURED_PRODUCTS] and then evey time
>> actually just grab randomly 6 products form the array.
>> The home page is now much faster, of course, but I'm not sure how
>> "smart"
>> is keep an array with 1000 elements in $_SESSION?
>>
>> Thanks for any opinion!
>> :)
>>
>> -afan
>>
>
>
--- End Message ---
--- Begin Message ---
This may be a bit to obvious, but I miss little stuff all the time.
You wouldn't happen to have the if(mail(...)) in some form of loop would
you?
or perhaps $to is getting assigned the e-mail address like
"[EMAIL PROTECTED] [EMAIL PROTECTED]" can you check the value of $email
before you assign it?
~Drew
www.drewpydraws.com
----- Original Message -----
From: "Tariq Dalvi" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>
Sent: Sunday, February 05, 2006 6:55 PM
Subject: [PHP] problem with Mail function
> Hello everyone,
>
> I m using php mail function it dose everyting fine besides it prints
> message twise in the email body can someone please have a look
> what i m doing wrong the code is as follows :
>
> $to = "$email";
> $subject = "someting goes here \n\n";
> $headers = "From: [EMAIL PROTECTED]" .
> "X-Mailer: Mailserver at somewhere.com\n" .
> "Date: $date\n" .
> "MIME-Version: 1.0\n" .
> "Content-Type: text/plain; charset=ISO-8859-1\n" ;
>
> message <<<EOF
> ...................
> .......................
> .........................
> .....
> ...
> EOF;
>
> if (mail($to,$subject,$message,$headers)){
>
> $say = "<p />E Mail sent successfully to $email. <br>";
> }
> else{
>
> $say = "\n\n<p />Ohoho! Sending failed Please inform to Webmaster. <br>";
>
> }
>
> I shall highly appreciate any help
>
> Thanks
> Tariq
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 2/4/2006
>
>
--- End Message ---
--- Begin Message ---
Dude,
Do not use $to = "$email"; instead $to=$email;
But i didn't even know what is your problem!
On 2/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> This may be a bit to obvious, but I miss little stuff all the time.
>
> You wouldn't happen to have the if(mail(...)) in some form of loop would
> you?
>
> or perhaps $to is getting assigned the e-mail address like
> "[EMAIL PROTECTED] [EMAIL PROTECTED]" can you check the value of $email
> before you assign it?
>
>
>
> ~Drew
> www.drewpydraws.com
>
>
> ----- Original Message -----
> From: "Tariq Dalvi" <[EMAIL PROTECTED]>
> To: <php-general@lists.php.net>
> Sent: Sunday, February 05, 2006 6:55 PM
> Subject: [PHP] problem with Mail function
>
>
> > Hello everyone,
> >
> > I m using php mail function it dose everyting fine besides it prints
> > message twise in the email body can someone please have a look
> > what i m doing wrong the code is as follows :
> >
> > $to = "$email";
> > $subject = "someting goes here \n\n";
> > $headers = "From: [EMAIL PROTECTED]" .
> > "X-Mailer: Mailserver at somewhere.com\n" .
> > "Date: $date\n" .
> > "MIME-Version: 1.0\n" .
> > "Content-Type: text/plain; charset=ISO-8859-1\n" ;
> >
> > message <<<EOF
> > ...................
> > .......................
> > .........................
> > .....
> > ...
> > EOF;
> >
> > if (mail($to,$subject,$message,$headers)){
> >
> > $say = "<p />E Mail sent successfully to $email. <br>";
> > }
> > else{
> >
> > $say = "\n\n<p />Ohoho! Sending failed Please inform to Webmaster. <br>";
> >
> > }
> >
> > I shall highly appreciate any help
> >
> > Thanks
> > Tariq
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 2/4/2006
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi all,
I have a mysql database setup to use with my php web page. I have
been able to access the database and get values into my drop down
menus. However when I tried to output the contents into two two
diferent variables the code does not work. To be more specific I will
show you the code both the one that works and the one that doesn't
Doesn't work
-------------------------------------------------
<?php
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($row = mysql_fetch_array($month_query))
{
$val = $row["m_id"];
$out = $row["months"];
echo "<option value=$val>$out</option>";
}
?>
---------------------------------------------
Code that works
---------------------------------------------
<?php
echo ' <select name="equipment" size="1" id="equip"
onChange="addRow()">';
$Equip_query = mysql_query("SELECT equip FROM Equipment ORDER BY
equip ASC");
while ($r = mysql_fetch_array($Equip_query))
{
$val = $r["equip"];
echo "<option value=$val>$val</option>\n";
}
echo "</select></td>";
?>
Also I should tell you that the code that works comes after the code
that doesn't work in my web page.
Oh for the values that are outputted in the code that doesn't work are
val is numeric and out is a string.
I know my sql query works because I tested it in mysql.
Thanks for the help
Paul
--- End Message ---
--- Begin Message ---
Hi Paul,
If "equip" contains a space it will probably break the dropdown.
Change it to:
echo "<option value='" . htmlspecialchars($val) . "'>$val</option>\n";
in case it has quotes, spaces, < or > in it.
Paul Goepfert wrote:
Hi all,
I have a mysql database setup to use with my php web page. I have
been able to access the database and get values into my drop down
menus. However when I tried to output the contents into two two
diferent variables the code does not work. To be more specific I will
show you the code both the one that works and the one that doesn't
Doesn't work
-------------------------------------------------
<?php
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($row = mysql_fetch_array($month_query))
{
$val = $row["m_id"];
$out = $row["months"];
echo "<option value=$val>$out</option>";
}
?>
---------------------------------------------
Code that works
---------------------------------------------
<?php
echo ' <select name="equipment" size="1" id="equip"
onChange="addRow()">';
$Equip_query = mysql_query("SELECT equip FROM Equipment ORDER BY
equip ASC");
while ($r = mysql_fetch_array($Equip_query))
{
$val = $r["equip"];
echo "<option value=$val>$val</option>\n";
}
echo "</select></td>";
?>
Also I should tell you that the code that works comes after the code
that doesn't work in my web page.
Oh for the values that are outputted in the code that doesn't work are
val is numeric and out is a string.
I know my sql query works because I tested it in mysql.
Thanks for the help
Paul
--- End Message ---
--- Begin Message ---
> Doesn't work
> -------------------------------------------------
> <?php
> $month_query = mysql_query("SELECT m_id, months FROM Month");
> while ($row = mysql_fetch_array($month_query))
> {
> $val = $row["m_id"];
> $out = $row["months"];
> echo "<option value=$val>$out</option>";
> }
> ?>
You're missing the <select> tags.
> while ($r = mysql_fetch_array($Equip_query))
> {
> $val = $r["equip"];
> echo "<option value=$val>$val</option>\n";
> }
On a seperate note, if all you are doing with the $val variable is using it to
echo, it's not needed. Put brackets { } around the var to echo ie:
{$r["equip]} - makes it easier to read later when you come back to tweak your
code.
Brady
--- End Message ---
--- Begin Message ---
This is the full code for the code that doesn't work.
<?php
echo '<select name="month" >\n';
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($r = mysql_fetch_array($month_query));
{
$v = $r["m_id"];
$out = $r["months"];
echo "<option value=$v>$out</option>\n";
}
echo '</select>\n';
?>
On 2/6/06, Brady Mitchell <[EMAIL PROTECTED]> wrote:
> > Doesn't work
> > -------------------------------------------------
> > <?php
> > $month_query = mysql_query("SELECT m_id, months FROM Month");
> > while ($row = mysql_fetch_array($month_query))
> > {
> > $val = $row["m_id"];
> > $out = $row["months"];
> > echo "<option value=$val>$out</option>";
> > }
> > ?>
>
> You're missing the <select> tags.
>
> > while ($r = mysql_fetch_array($Equip_query))
> > {
> > $val = $r["equip"];
> > echo "<option value=$val>$val</option>\n";
> > }
>
> On a seperate note, if all you are doing with the $val variable is using it
> to echo, it's not needed. Put brackets { } around the var to echo ie:
> {$r["equip]} - makes it easier to read later when you come back to tweak your
> code.
>
> Brady
>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
Paul Goepfert wrote:
This is the full code for the code that doesn't work.
<?php
echo '<select name="month" >\n';
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($r = mysql_fetch_array($month_query));
{
$v = $r["m_id"];
$out = $r["months"];
echo "<option value=$v>$out</option>\n";
}
echo '</select>\n';
?>
dear sir,
overall, i can see no visible error. but u must debug the process.
1. please add print_r($r) within the while loop to see the contents.
2. check the num of rows returned by mysql_query.
3. check it mysql_query is not returning an error.
--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India
--- End Message ---
--- Begin Message ---
> <?php
> echo '<select name="month" >\n';
> $month_query = mysql_query("SELECT m_id, months FROM Month");
> while ($r = mysql_fetch_array($month_query));
Remove the semi-colon at the end of the above line and it works like a charm.
> {
> $v = $r["m_id"];
> $out = $r["months"];
> echo "<option value=$v>$out</option>\n";
> }
> echo '</select>\n';
> ?>
--- End Message ---
--- Begin Message ---
Thanks everyone for your help. I should have seen the semi-colon at
the end of the while loop. I must have looked at the code 20 times
and I can't believe I missed it.
Paul
On 2/6/06, Brady Mitchell <[EMAIL PROTECTED]> wrote:
> > <?php
> > echo '<select name="month" >\n';
> > $month_query = mysql_query("SELECT m_id, months FROM Month");
> > while ($r = mysql_fetch_array($month_query));
>
>
> Remove the semi-colon at the end of the above line and it works like a charm.
>
> > {
> > $v = $r["m_id"];
> > $out = $r["months"];
> > echo "<option value=$v>$out</option>\n";
> > }
> > echo '</select>\n';
> > ?>
>
>
--- End Message ---
--- Begin Message ---
Best mailing list member,
I have an external payment gateway provider (similar to PayPal) and need to
send POST variables to them to initiate the Payment Process.
Is there any function in PHP that can send POST variables to a URL without
using <form> and then a javascript that submits it when the page is loaded?
My dream is to have a function (or class) that would be used this way:
$url="url_to_submit_post_variables_to";
$ps = new SubmitPost($url);
$ps->addPostVar($name, $value);
$ps->submitPost();
Anyone with ideas about this?
Best regards,
Peter Lauri
--- End Message ---
--- Begin Message ---
Hi Peter,
Curl can do it.
http://www.php.net/curl
Peter Lauri wrote:
Best mailing list member,
I have an external payment gateway provider (similar to PayPal) and need to
send POST variables to them to initiate the Payment Process.
Is there any function in PHP that can send POST variables to a URL without
using <form> and then a javascript that submits it when the page is loaded?
My dream is to have a function (or class) that would be used this way:
$url="url_to_submit_post_variables_to";
$ps = new SubmitPost($url);
$ps->addPostVar($name, $value);
$ps->submitPost();
Anyone with ideas about this?
Best regards,
Peter Lauri
--- End Message ---
--- Begin Message ---
But if I do not have LIBCURL?
-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED]
Sent: Monday, February 06, 2006 2:13 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Submitting form without JavaScript
Hi Peter,
Curl can do it.
http://www.php.net/curl
Peter Lauri wrote:
> Best mailing list member,
>
> I have an external payment gateway provider (similar to PayPal) and need
to
> send POST variables to them to initiate the Payment Process.
>
> Is there any function in PHP that can send POST variables to a URL without
> using <form> and then a javascript that submits it when the page is
loaded?
>
> My dream is to have a function (or class) that would be used this way:
>
> $url="url_to_submit_post_variables_to";
> $ps = new SubmitPost($url);
> $ps->addPostVar($name, $value);
> $ps->submitPost();
>
> Anyone with ideas about this?
>
> Best regards,
> Peter Lauri
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
> Best mailing list member,
>
> I have an external payment gateway provider (similar to PayPal) and
need to
> send POST variables to them to initiate the Payment Process.
>
> Is there any function in PHP that can send POST variables to a URL
without
> using <form> and then a javascript that submits it when the page is
loaded?
You can submit pages to a url without using forms. there are several
ways. check Snoopy class from sourceforge.net. but this is not an
efficient way, because there are lot of redirection and responses and
header informations with the payment gateway.
Instead you should create a "confirmation" page. After submitting all
the details of the form, php should then process it and create a
"confirmation" page which the user has to again click to "confirm" the
action. then the variables go to paypal via browser.
>
> My dream is to have a function (or class) that would be used this way:
"dream"...really?.. mine is to own a merc.
--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India
--- End Message ---
--- Begin Message ---
Yes this is a solution, but I want to keep the data sent to PayPal out of
the HTML code. If you would use that solution someone can get the username
from just checking the source from the page.
/Peter
-----Original Message-----
From: Sumeet [mailto:[EMAIL PROTECTED]
Sent: Monday, February 06, 2006 2:55 PM
Cc: php-general@lists.php.net
Subject: Re: [PHP] Submitting form without JavaScript
Peter Lauri wrote:
> Best mailing list member,
>
> I have an external payment gateway provider (similar to PayPal) and
need to
> send POST variables to them to initiate the Payment Process.
>
> Is there any function in PHP that can send POST variables to a URL
without
> using <form> and then a javascript that submits it when the page is
loaded?
You can submit pages to a url without using forms. there are several
ways. check Snoopy class from sourceforge.net. but this is not an
efficient way, because there are lot of redirection and responses and
header informations with the payment gateway.
Instead you should create a "confirmation" page. After submitting all
the details of the form, php should then process it and create a
"confirmation" page which the user has to again click to "confirm" the
action. then the variables go to paypal via browser.
>
> My dream is to have a function (or class) that would be used this way:
"dream"...really?.. mine is to own a merc.
--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
Yes this is a solution, but I want to keep the data sent to PayPal out of
the HTML code. If you would use that solution someone can get the username
from just checking the source from the page.
/Peter
i believe in paypal, the username is the email id... why do u want to
hide that?... infact people have to mention the email to others or
similarly send bank details to clients for bank transfer.
even if the visitor gets the username... he cannot login without password.
most of all payment gateways make sure that the html code submitted to
them are not insecure otherwise it would beat the purpose of ecommerce.
i came across this
http://www.phpclasses.org/browse/package/2249/download/zip.html
--
Sumeet Shroff
http://www.prateeksha.com
Web Design and Ecommerce Development, Mumbai India
--- End Message ---
--- Begin Message ---
Hi,
i tested it with php 5.1.3-dev snap and it works correctly for me.
btw. $return = $notdefined_variable; is a bad style for coding and this
happens in your situation in a undefined behavior.
If you think this is a bug please go to http://bugs.php.net and report them
there.
2006/2/4, Bogdan Ribic <[EMAIL PROTECTED]>:
>
> Hi all,
>
> I've found a strange bug with extract($GLOBALS, EXTR_REFS), and it
> only shows up if you try to access a non-existent variable or array
> member before that. Here's a demo script:
>
>
> // Uncomment this line to see the problem
> // $return = @$_GET['xx'];
>
> function extr_globals() {
> extract($GLOBALS, EXTR_REFS);
> };
>
> function test($msg) {
> $x = 'OK';
> $msg = 'wrong';
> return $x;
> };
>
>
> echo test('login') . "\n";
> extr_globals();
> echo test('login');
>
> If you run this script, it will output two OKs, as it should. If you
> however uncomment the first line, one with $_GET assignment, it will
> output an OK and then text "wrong". Tested with php 4.3.10 and 5.0.3 on
> a windows machine.
>
> What actually happens is that extract($GLOBALS, EXTR_REFS) really messes
> up nametables. If you step into test function with debugger, you will
> see that all variables inside the function will already be "initialized"
> to the value of the parameter $msg, and assigning to one var will
> overwrite values in unrelated variables. I repeat, this only happens if
> you tried to access non-existent var or array member before that.
>
> So it's a bug. Do I get a PHP T-shirt ? :-)
>
> Boban.
>
>
> --
>
> Open source PHP code generator for DB operations
> http://sourceforge.net/projects/bfrcg/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Marco Kaiser
--- End Message ---
--- Begin Message ---
Marco Kaiser wrote:
Hi,
i tested it with php 5.1.3-dev snap and it works correctly for me.
btw. $return = $notdefined_variable; is a bad style for coding and this
happens in your situation in a undefined behavior.
If you think this is a bug please go to http://bugs.php.net and report them
there.
I checked on bugs.php.net and apparently it was resolved meanwhile (I
was testing it on server with older PHP), and they don't take bug
reports on previous versions. I should have checked before posting here,
my bad :)
Btw, I agree, bad style, but I like doing this:
$id = max(0, (int)@$_GET['id']);
a lot more than writing isset() ? :
--
Open source PHP code generator for DB operations
http://sourceforge.net/projects/bfrcg/
--- End Message ---
--- Begin Message ---
Hello there,
I Have the following PREG.
I Want to remove comments from an file (Javascript or CSS), but i want
to leave the URI's that are within an function.
So i thought to exclude any match which is between an ( and ).
But i can't seem to figure out exactly how.
I have the following atm:
\/\*.*?\*\/|\/\/(?!(w)).*?([\r\n])|[\t]+
I now exclude any // comment with an w besides this, but that isn't the
solution.
Is there some way to have it exclude it when it is between ( and )?
Thx in advanced.
--- End Message ---
--- Begin Message ---
Hi!
>I forget the rules of float contagion in PHP, but it "should" work, I
>would expect...
That's what i also did, though.
>I don't suppose that by sheer chance the decimal portions add up to an
>even integer?...
>0.3333 + 0.6666
>might, for example, turn into: 1
>(Or might not, depending on a low-level float implementation)
It prints out 0.9999
>Some other options:
>Cast them in MySQl and let MySQL add them up.
Works fine, just needs 3 seconds for the query.
3 seconds for the table + 3 seconds for the summary.
This is taking a bit to long ;)
>I forget MySQL's typecast operator/function, but it's in the manual:
>http://dev.mysql.com
>Something like:
>select sum(cast(floatval, 'decimal')) from somewhere
>
>You may also need to use coalesce to change NULL into 0.
>
>You'd have to tell use what the actual string values ARE for us to do
>any more than guess, though.
Normal prices like:
345.76
234.09
324.54
And so on
Greets
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
each of the terminals could then use a web based POS interface but
there was only a
single cash drawer.
It would also be possible to have each 'till' running a copy of apache
server, and communicating with a central database server. I can't for
the life of me think of any way the client could open the drawer
otherwise.
--- End Message ---
--- Begin Message ---
maybe a javascript button that somehow does the dos command or calls
another program (exe) that will do the command to open the
till...anywayz this is getting OT!
Oli Howson wrote:
each of the terminals could then use a web based POS interface but
there was only a
single cash drawer.
It would also be possible to have each 'till' running a copy of apache
server, and communicating with a central database server. I can't for
the life of me think of any way the client could open the drawer otherwise.
--- End Message ---
--- Begin Message ---
On 2 Feb 2006, at 13:00, Søren Schimkat wrote:
I'm using the mail function for sending mail, and I would like to
specify the
Return-Path header, but it would seem that PHP or Apache is
modyfying the
header.
Strictly speaking, you should not set a return-path header at all.
You should set a 'sender' header, and the return-path header will be
generated for you by your MTA. The reason for this is that a message
may gain multiple return-path headers on its journey so that its full
path can be traced backwards to the source. The common exception to
this is if you're on Windows and don't have a local MTA (or on any
platform and have PHPMailer's IsSMTP set), and your script is sending
directly via SMTP and thus IS the MTA.
If you want to do proper bounce handling, you should also look into
VERP addressing, as it's the only way to guarantee that you get
tracable bounces - MS Exchange server sometimes bounces messages with
no indication of the address the original message was sent to!
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk
--- End Message ---
--- Begin Message ---
I'm having some problems using PHP5 on Windows 2000 Server, running IIS 5.
When trying to access a document from a "xmldoc()" function the system
responds with the following,
*Fatal error*: Call to undefined function xmldoc() in *"XML Document"* on
line *Number*
**
How do I fix this problem? Is there a fix for this?
Thanks for your help
--- End Message ---
--- Begin Message ---
Andrew Clarke wrote:
I'm having some problems using PHP5 on Windows 2000 Server, running IIS 5.
When trying to access a document from a "xmldoc()" function the system
responds with the following,
*Fatal error*: Call to undefined function xmldoc() in *"XML Document"* on
line *Number*
**
How do I fix this problem? Is there a fix for this?
Thanks for your help
Install xml support for your PHP.
PHP is telling you that such function is not included in your current
PHP version.
->Call to undefined function xmldoc()
Translated: I don't have that function xmldoc()
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
Hello,
How can I test whether a string is 1 or 2 digits long?
Thanks
-Will
--- End Message ---
--- Begin Message ---
William Stokes wrote:
Hello,
How can I test whether a string is 1 or 2 digits long?
Thanks
-Will
strlen() -_-
RTFM
www.php.net/strlen
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
On 6 Feb 2006, at 12:18, William Stokes wrote:
How can I test whether a string is 1 or 2 digits long?
Cast it to an int (or float if required) and strlen() it.
Cheers,
Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services
--- End Message ---
--- Begin Message ---
Cheers!
"Richard Davey" <[EMAIL PROTECTED]> kirjoitti
viestissä:[EMAIL PROTECTED]
>
> On 6 Feb 2006, at 12:18, William Stokes wrote:
>
>> How can I test whether a string is 1 or 2 digits long?
>
> Cast it to an int (or float if required) and strlen() it.
>
> Cheers,
>
> Rich
> --
> http://www.corephp.co.uk
> Zend Certified Engineer
> PHP Development Services
--- End Message ---
--- Begin Message ---
Greetings,
I am attempting to put the results of a ³while² loop into a variable.
Example:
$result = mysql_query(³SELECT filename, page_title FROM table²);
while ($row = mysql_fetch_assoc($result))
{
$var = ³<a
href=\²$htmldir{$row[filename¹]}\²>{$row[page_title¹]}</a><br />²;
echo ³$var²;
}
I would like for the the entire ³while² statement result to be in a variable
for use outside of the statement. Is that possible?
Thank you for your help,
--
Steve Marquez
Marquez Design
--- End Message ---
--- Begin Message ---
Put it in an array?
-----Original Message-----
From: Pastor Steve [mailto:[EMAIL PROTECTED]
Sent: Monday, February 06, 2006 8:14 PM
To: PHP eMail List
Subject: [PHP] Results In Variable
Greetings,
I am attempting to put the results of a ³while² loop into a variable.
Example:
$result = mysql_query(³SELECT filename, page_title FROM table²);
while ($row = mysql_fetch_assoc($result))
{
$var = ³<a
href=\²$htmldir{$row[Œfilename¹]}\²>{$row[Œpage_title¹]}</a><br />²;
echo ³$var²;
}
I would like for the the entire ³while² statement result to be in a variable
for use outside of the statement. Is that possible?
Thank you for your help,
--
Steve Marquez
Marquez Design
--- End Message ---
--- Begin Message ---
On Mon, 06 Feb 2006 07:14:21 -0600
Pastor Steve <[EMAIL PROTECTED]> wrote:
>
> Greetings,
>
> I am attempting to put the results of a ³while² loop into a variable.
>
>
> Example:
>
> $result = mysql_query(³SELECT filename, page_title FROM table²);
> while ($row = mysql_fetch_assoc($result))
>
> {
>
> $var = ³<a
> href=\²$htmldir{$row[filename¹]}\²>{$row[page_title¹]}</a><br />²;
> echo ³$var²;
>
> }
>
> I would like for the the entire ³while² statement result to be in a
> variable for use outside of the statement. Is that possible?
Try this:
$result = mysql_query(³SELECT filename, page_title FROM table²);
$var = ""; // Make sure $var is empty.
while ($row = mysql_fetch_assoc($result))
{
$var .= ³<a // Note the period before the equals!
href=\²$htmldir{$row[filename¹]}\²>{$row[page_title¹]}</a><br />²;
}
echo ³$var²; // Echo $var to the screen.
The .= instead of just plain = will append the result to $var instead
of over-writing it, so by the end of the while loop $var will contain
the whole thing. Then, just echo $var once at the end of the while loop.
Note - script not tested...
Regards,
Ozz.
pgp7tBJUHbVsE.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
Or just append it...
Example:
$var = "";
$result = mysql_query(³SELECT filename, page_title FROM table²);
while ($row = mysql_fetch_assoc($result))
{
$var .= "<a
href=\²$htmldir{$row[filename¹]}\²>{$row[page_title¹]}</a><br />";
}
echo $var;
Arno
________________________
DotContent
www.dotcontent.net
-----Original Message-----
From: Pastor Steve [mailto:[EMAIL PROTECTED]
Sent: 06 February 2006 03:14
To: PHP eMail List
Subject: [PHP] Results In Variable
Greetings,
I am attempting to put the results of a ³while² loop into a variable.
Example:
$result = mysql_query(³SELECT filename, page_title FROM table²);
while ($row = mysql_fetch_assoc($result))
{
$var = ³<a
href=\²$htmldir{$row[filename¹]}\²>{$row[page_title¹]}</a><br />²;
echo ³$var²;
}
I would like for the the entire ³while² statement result to be in a variable
for use outside of the statement. Is that possible?
Thank you for your help,
--
Steve Marquez
Marquez Design
--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 05, 2006 2:47 PM
To: [EMAIL PROTECTED]
Cc: PHP-General
Subject: Re: [PHP] Reverse Engineering of Smarty
On Sun, 2006-02-05 at 01:12, Sumeet wrote:
> Rory Browne wrote:
> > If you don't have backups, then:
> >
> > 1: Why do you not have backups?
> > 2: Are you insane?
>
> hmm..... totally uncalled for ....
I don't know that it's "uncalled for". I think Rory was drawing to
attention that not having some kind of backup of important code is
tantamount to incompetence. I would have to agree with Rory that if the
code was important enough to seek a method of reverse engineering to
retrieve the original, then some kind of system should have been in
place long ago. Might I suggest CVS? I would have to say that "are you
insane" is a bit softer on the ego than "are you a complete moron".
Cheers,
Rob.
--
=====================================================================
Interesting thread. I'd suggest that what this thread really gets to an
important issue - how to _ask_ a question. The orignal poster asked a
question but didn't provide enough information for the list to really
respond properly. If you have backups and know you can restore from
backup and want to learn if you can reverse engineer something for
grins, well then say so and help the group provide you useful
information rather than whack you about the head and shoulders for
failing to properly backup your system.
Great resource here -->
http://www.catb.org/~esr/faqs/smart-questions.html
OK, I'm off to tilt at other windmills.
Doug Quixote...
_______________________________________________________________________
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.
--- End Message ---
--- Begin Message ---
Hello
I have a news page which is getting quite long now and I would like to split
the news to two pages. Now I have one SQL query for all the rows and I think
I could use LIMIT to limit the results but how to limit the results for
example to 15 rows for page one and from 16 to the last on second page?
Number of rows increase daily.
One page one there's headline and short summary and the second page should
be "archive" with only the headline so all remaining rows can be printed to
one page.
Something like: "SELECT * FROM `x_news` LIMIT 0 , 15" but how to do the
archive page SELECT * FROM `x_news` LIMIT 16 , xx?
Thanks
-Will
--- End Message ---
--- Begin Message ---
I have a news page which is getting quite long now and I would like
to split
the news to two pages. Now I have one SQL query for all the rows
and I think
I could use LIMIT to limit the results but how to limit the results
for
example to 15 rows for page one and from 16 to the last on second
page?
Number of rows increase daily.
One page one there's headline and short summary and the second page
should
be "archive" with only the headline so all remaining rows can be
printed to
one page.
Something like: "SELECT * FROM `x_news` LIMIT 0 , 15" but how to
do the
archive page SELECT * FROM `x_news` LIMIT 16 , xx?
What you're describing is called "pagination". There are examples
online. Basically you just need to pass to the second (and other)
pages the LIMIT values (16 and xx above).
Larry
--- End Message ---
--- Begin Message ---
William Stokes wrote:
> One page one there's headline and short summary and the second page should
> be "archive" with only the headline so all remaining rows can be printed
> to one page.
>
> Something like: "SELECT * FROM `x_news` LIMIT 0 , 15" but how to do the
> archive page SELECT * FROM `x_news` LIMIT 16 , xx?
I've scanned the MySQL Reference Manual (for up to Version 5.0.4-beta) and:
"
To retrieve all rows from a certain offset up to the end of the result set,
you can use some large number for the second parameter. This statement
retrieves all rows from the 96th row to the last:
mysql> SELECT * FROM table LIMIT 95,18446744073709551615;
"
HTH
Albert
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 2006/02/04
--- End Message ---