php-general Digest 23 May 2006 13:29:09 -0000 Issue 4144
Topics (messages 236688 through 236718):
Re: Upgrade problems PHP 5.1.4 (Windows)
236688 by: Chris
236692 by: Tony Aldrich
Re: big downloads discuraged with php?
236689 by: Chris
Re: PHP Notice: Undefined index
236690 by: John Taylor-Johnston
Let's make a difference
236691 by: Jils Abhilash
Windows/Apache Shopping Cart Software
236693 by: P. Guethlein
Re: Graphics generation.
236694 by: Barry
Getting an advanced foreach to work
236695 by: Jonas Rosling
236697 by: cajbecu
236698 by: Chris
236700 by: Jonas Rosling
236715 by: Greg Beaver
Re: Getting an advanced foreach to work SOLVED
236696 by: Jonas Rosling
Re: Security Concerns with Uploaded Images:
236699 by: Rory Browne
date iteration
236701 by: Dave Goodchild
236703 by: Rabin Vincent
One works, but the other doesn't
236702 by: Jonas Rosling
236704 by: Chris
236705 by: Jonas Rosling
236709 by: Chris
236710 by: Jonas Rosling
236712 by: Chris
236713 by: Barry
236716 by: Jonas Rosling
Can a script run twice?
236706 by: Lester Caine
236707 by: Chris
236708 by: Stut
236711 by: Chris Kay
236714 by: Chris Kay
236717 by: Lester Caine
Re: Need Help Please
236718 by: Jay Blanchard
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Beauford wrote:
Hi,
I just upgraded to PHP 5.1.4 and now none of my sites will connect to MySQL.
I keep getting the error:
Fatal error: Call to undefined function mysql_connect()
I enabled php_mysql.dll in php.ini as one article suggested, but still no
go.
Firstly does the php_mysql.dll file exist in the php\extensions folder?
Did you restart your webserver?
I'm guessing the windows version of php has two different mysql dll's -
if it does, did you enable php_mysql.dll or php_mysqli.dll ? mysqli.dll
uses mysqli functions (http://www.php.net/mysqli) not the regular mysql
functions.
If it doesn't come with two dll's, then ignore that part ;) I'm too lazy
to download it and check.
Maybe this page would help..
http://www.php.net/manual/en/install.windows.manual.php
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I've understood, it's Windows.
If you added root php directory to Path environment variable it sometimes
does not take effect until you restart Windows. (???May be it's cached
somewhere?)
And don't forget to change in php.ini Extension Directory to ./ext or where
all extension dll's are placed.
Tony.
On 5/23/06, Beauford <[EMAIL PROTECTED]> wrote:
Hi,
I just upgraded to PHP 5.1.4 and now none of my sites will connect to
MySQL.
I keep getting the error:
Fatal error: Call to undefined function mysql_connect()
I enabled php_mysql.dll in php.ini as one article suggested, but still no
go.
Any suggestions?
Thanks
Beauford
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Michelle Konzack wrote:
Hello,
I have coded a webinterface to a (Debian) pbuilder (i386, amd64, m68k,
powerpc, sparc, mips, hppa, ia64 and arm) which can check and backport
Debian sources.
Now I have some trouble, because some people have tried to let php5
download source tarballs of 30-400 MByte... This let my system smoking!
How are you presenting the download?
fpassthru for example reads the whole lot into memory and then spits it out.
Using a loop like this:
while(!feof($fp)) {
echo fread($fp, $x);
}
will only read $x bytes and dump them.
Not that I have no bandwidth (SONET, Dual STM-4) or performance issues
(32 CPU's 650MHz, 64 GB memory) but I want to ask you about security
issues downloading such big files...
Same as with small files I assume ;)
Is it better, to span a shell with wget?
You can't push content to me - I have to come and get it.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hi,
Thanks.
I see it, I get it, it makes sense. But it seems like overkill.
So what version did this become necessary in?
> http://php.net/isset
New server, new version. Or I had errors turned off on the old server.
Thanks!
John
elseif (
(isset($_POST["number"])) and (isset($_POST["submitter"])) and
(!isset($_POST["finalize"])) and
($number) and (!$submitter)# and (!$finalize)
){
?>
<div class="special1"><h3>Step 99: <?php echo $submitter; ?>, You did
not enter your name.</h3>
We are sorry. Please <a href="<?php echo $PHP_SELF; ?>">Start
Again</a></div>
<?php
}
Richard Lynch wrote:
is provoking
[Fri May 19 19:05:10 2006] [error] PHP Notice: Undefined index:
submitter in
/home/jtjohnston/domains/jtjohnston.ca/public_html/comments.php on
line 29
Because $_POST['submitter'] is not set?
Because your script assumes it IS set?
Because sometimes your script is called to display the form, before
$_POST['submitter'] has anything in it, and sometimes it's called
after they hit submit and it has something in it?
if (isset($_POST['submitter']) && "yes" == $_POST['submitter']){
http://php.net/isset
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."
''' Cégep de Sherbrooke:
ô¿ô http://www.cegepsherbrooke.qc.ca/languesmodernes/
- 819-569-2064
--- End Message ---
--- Begin Message ---
I'm doing a little something for the mother earth, and I thought you
might like to join me:
http://friends.earthscreen.com/?r=UUF0GBMGMCdYB2cJAyMK&i=gmail&[EMAIL
PROTECTED]&p=2&z=1&tc=12
--- End Message ---
--- Begin Message ---
Anyone have any recommendations/Links to Shopping Cart Software that
will run on Windows/Apache/PHP ?
Thanks, -Pete
--- End Message ---
--- Begin Message ---
Carles Xavier Munyoz Baldó schrieb:
Hi,
Is there any free PHP class with which I can create lines and bars graphics ?
For example, for represent temperature samples over time, population of a
country over time, etc.
Greegints.
---
Carles Xavier Munyoz Baldó
[EMAIL PROTECTED]
http://www.unlimitedmail.net/
---
A very good one is:
JPgraph
http://www.aditus.nu/jpgraph/
Greets
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
I got the code as follows bellow. I'm having some problems to get it to
work. Maybe some of you are able to help me a bit.
First of all I got an array (salespersons) containing names of dynamic array
names. For example it can contain Johan, Mark, Jenny, Bill etc.
By calling for the possision in the array based on $count I'll get the name,
and that's the name of another array. The problem is in the foreach
with ( { } ).
$count = 0;
// Loopa så länge räknaren är mindre än storleken av arrayn $salespersons
while ($count < count($salespersons)) {
foreach (${$($salespersons[$count])} AS $key => $value) {
echo htmlentities($key).' - '.$value;
$count++;
}
}
Anyone?
Thaks // Jonas
--- End Message ---
--- Begin Message ---
this shoul work:
while ($count < count($salespersons)) {
foreach ($salespersons[$count] AS $key => $value) {
echo htmlentities($key).' - '.$value;
$count++;
}
}
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
I got the code as follows bellow. I'm having some problems to get it to
work. Maybe some of you are able to help me a bit.
First of all I got an array (salespersons) containing names of dynamic array
names. For example it can contain Johan, Mark, Jenny, Bill etc.
By calling for the possision in the array based on $count I'll get the name,
and that's the name of another array. The problem is in the foreach
with ( { } ).
$count = 0;
// Loopa så länge räknaren är mindre än storleken av arrayn $salespersons
while ($count < count($salespersons)) {
foreach (${$($salespersons[$count])} AS $key => $value) {
echo htmlentities($key).' - '.$value;
$count++;
}
}
Anyone?
Thaks // Jonas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Jonas Rosling wrote:
...
while ($count < count($salespersons)) {
I see you have solved it - just one comment.
This particular line will get evaluated every time. If you have a large
number of elements in $salespersons, it will slow things down considerably.
From a performance point of view you're much better off doing:
$sales_count = count($salespersons);
while($count < $sales_count) {
....
The only reason to leave the count in the while statement is if you are
adding/removing to that array within the loop, otherwise chuck it in a
temp variable and use that instead.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: Chris [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 10:24
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re: [PHP] Getting an advanced foreach to work
> From a performance point of view you're much better off doing:
> $sales_count = count($salespersons);
> while($count < $sales_count) {
> ....
> The only reason to leave the count in the while statement is if you are
> adding/removing to that array within the loop, otherwise chuck it in a
> temp variable and use that instead.
Thansk alot for the tip.
// Jonas
--- End Message ---
--- Begin Message ---
Chris wrote:
> Jonas Rosling wrote:
>
> ...
>
>> while ($count < count($salespersons)) {
>
>
> I see you have solved it - just one comment.
>
> This particular line will get evaluated every time. If you have a large
> number of elements in $salespersons, it will slow things down considerably.
Quick amendment to this statement: PHP stores the number of elements in
a userspace array directly in the internal zval, so calling count()
simply reads that value no matter how big the array is (in algorithmic
terms, it is O(1)). In other words, count(array(1)) is every bit as
efficient as count(array_pad(array(1), 1000000, 1)) if you eliminate the
cost of creating the 1000000 element array.
Having said this, there is potentially significant overhead involved in
calling a function as opposed to a variable lookup, and so you might end
up saving a few microseconds. However, because count() is O(1), it will
be a constant amount per loop. If you need to eke out that much extra
performance, you may be better off using a profiler to see where the
real bottlenecks in the code are.
Greg
>
> From a performance point of view you're much better off doing:
>
> $sales_count = count($salespersons);
>
> while($count < $sales_count) {
> ....
>
> The only reason to leave the count in the while statement is if you are
> adding/removing to that array within the loop, otherwise chuck it in a
> temp variable and use that instead.
>
--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: Jonas Rosling [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 10:06
Till: PHP List
Ämne: [PHP] Getting an advanced foreach to work
Should look like this:
foreach (${$salespersons[$count]} AS $key => $value) {
--- End Message ---
--- Begin Message ---
Use the unix command "file" to determiner what file you have.
I have had the same problem...
Don't depend on it.
graphic.php
GIF89
<?php do_bad_stuff(); ?>
ANY_GIF_FOOTERS_HERE
should according to file be a gif, but contains embedded php.
Many thanks!
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi all, I am writing an app that runs a prize draw, wherein the admin
chooses the duration by adding a start date and number of days for the draw
to run. These values are passed into a small function that generates an
array holding the start date, end date and all dates in between as follows:
function generateDates($first, $duration) {
$dates = array();
$date = getdate(mktime($first));
$month = $date['mon'];$day = $date['mday'];$year = $date['year'];
for ($i = 1;$i <= $duration; $i++) {
$added = getdate(mktime($day++ . "-" . $month . "-" . $year));
$dates[] = $added['mday'] . "-" . $added['mon'] . "-" .
$added['year'];
}
return $dates;
}
$series = generateDates('23-05-2006', 20);
var_dump($series);
...when I var_dump the array the iteration stops at May 24 - I am looking
into it but does anyone have any ideas why this is sticking ie is my date
arithmetic wrong? Cheers.
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
--- End Message ---
--- Begin Message ---
On 5/23/06, Dave Goodchild <[EMAIL PROTECTED]> wrote:
Hi all, I am writing an app that runs a prize draw, wherein the admin
chooses the duration by adding a start date and number of days for the draw
to run. These values are passed into a small function that generates an
array holding the start date, end date and all dates in between as follows:
function generateDates($first, $duration) {
$dates = array();
$date = getdate(mktime($first));
$month = $date['mon'];$day = $date['mday'];$year = $date['year'];
for ($i = 1;$i <= $duration; $i++) {
$added = getdate(mktime($day++ . "-" . $month . "-" . $year));
$dates[] = $added['mday'] . "-" . $added['mon'] . "-" .
$added['year'];
}
return $dates;
}
$series = generateDates('23-05-2006', 20);
var_dump($series);
...when I var_dump the array the iteration stops at May 24 - I am looking
into it but does anyone have any ideas why this is sticking ie is my date
arithmetic wrong? Cheers.
Your mktime() usage is off. I think you're confusing it with
strtotime(). Please see the function arguments in the docs:
php.net/mktime
php.net/strtotime
Also, inside the loop, instead of using getdate and then
concatenating to form the date string, consider using
the date() function to do it.
php.net/date
Rabin
--
http://rab.in
--- End Message ---
--- Begin Message ---
I find this problem very strange. I've got two parts of code (allmost the
same) in different TD's with vars and arrays (with same name) but it's only
the top code that gives result. I've allso tryied to rename the vars and
TD's in the bottom without any luck. The only vars/arrays that I haven't
mind changing name on yet are some dynamic, like:
${$row[0]} = array();
${$row[0]}[$row[1]] = $row[2];
But I think this could be the main cause, but I'm not really sure. If I
delete the top code the bottom works. Any idéas any one?
Thanks // Jonas
--- End Message ---
--- Begin Message ---
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
I find this problem very strange. I've got two parts of code (allmost the
same) in different TD's with vars and arrays (with same name) but it's only
the top code that gives result. I've allso tryied to rename the vars and
TD's in the bottom without any luck. The only vars/arrays that I haven't
mind changing name on yet are some dynamic, like:
${$row[0]} = array();
${$row[0]}[$row[1]] = $row[2];
But I think this could be the main cause, but I'm not really sure. If I
delete the top code the bottom works. Any idéas any one?
Without seeing the whole code involved, my guess is you're resetting
the array with every loop.
Guesses don't help but that's all we can do without seeing any actual code.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: chris smith [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 13:38
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> I find this problem very strange. I've got two parts of code (allmost the
> same) in different TD's with vars and arrays (with same name) but it's
only
> the top code that gives result. I've allso tryied to rename the vars and
> TD's in the bottom without any luck. The only vars/arrays that I haven't
> mind changing name on yet are some dynamic, like:
>
> ${$row[0]} = array();
>
> ${$row[0]}[$row[1]] = $row[2];
>
> But I think this could be the main cause, but I'm not really sure. If I
> delete the top code the bottom works. Any idéas any one?
Without seeing the whole code involved, my guess is you're resetting
the array with every loop.
Guesses don't help but that's all we can do without seeing any actual code.
Okej, all the code follows bellow. Remember that part 1 allways works. And
they work all seperatly.
<?php
// Skapar variabel med host, användarnamn och lösenord
$link = @mysql_connect("127.0.0.1", "intranet", "intranet0605")
or die ("Kunde inte ansluta");
// Skapar variabel med aktuell databas
$database=mysql_select_db("eitss_se_intranet");
// PART 1
// SELECT-sats som tar fram alla rader för nyförsäljning grupperat per
produkt och säljare
$sql = "SELECT c.salesperson_code, sl.description, SUM(sl.unit_price) AS
totalt, COUNT(sl.description) AS antal
FROM Sales_line AS sl JOIN Customer AS c
WHERE sl.sell_to_customer_no = c.no AND (LEFT(
sl.shipment_date, 2) =
'$year' AND MID(sl.shipment_date, 4, 2) = '$month') AND
RIGHT(sl.shipment_date, 2) = '$day' AND sl.quantity_invoiced =1
GROUP BY sl.description, c.salesperson_code
ORDER BY c.salesperson_code, sl.description";
// Utför SQL-satsen
$result=mysql_query("$sql");
// Skapar en tom array för aktuella säljare
$salespersons = array();
// Loppar igenom raderna
while($row=mysql_fetch_array($result)) {
// Kollar om arrayn för säljaren är deklarerad
if (!${$row[0]}) {
// Skapar array för säljaren
${$row[0]} = array();
// Lägger in värdena i arrayn - produkt och summering
antal produkter
${$row[0]}[$row[1]] = $row[2];
// Lägger in säljaren i arrayn för aktuella sälljare
array_push($salespersons, $row[0]);
}
// Om arrayn reda är deklarerad
else {
// Lägger in värdena i arrayn - produkt och summering
antal produkter
${$row[0]}[$row[1]] = $row[2];
}
}
// Räknare
$count = 0;
// Storlek på arrayn innhållande säljare
$sales_count = count($salespersons);
echo '<b>'.htmlentities('Nyförsäljning per produkt: ').'</b><br>';
// Loopa så länge räknaren är mindre än storleken av arrayn
$salespersons
while ($count < $sales_count) {
echo '<br><b>'.htmlentities($salespersons[$count]).'</b><br>';
foreach (${$salespersons[$count]} AS $key => $value) {
if ($key == '') {
echo 'Okänd - '.$value.'<br>';
}
else {
echo htmlentities($key).' - '.$value.'<br>';
}
}
// Öka värdet på räknaren med 1
$count++;
}
// PART 2
// SELECT-sats som tar fram alla rader för nyförsäljning grupperat per
produkt och säljare
$sql = "SELECT c.salesperson_code, sl.description, SUM(sl.unit_price) AS
totalt, COUNT(sl.description) AS antal
FROM Sales_line AS sl JOIN Customer AS c
WHERE sl.sell_to_customer_no = c.no AND (sl.status LIKE
'4%' OR sl.status
LIKE '5%' OR sl.status LIKE '6%') AND ( LEFT( sl.shipment_date, 2 ) =
'$year' AND MID( sl.shipment_date, 4, 2 ) = '$month' ) AND RIGHT(
sl.shipment_date, 2 ) = '$day' AND sl.quantity_invoiced = 1
GROUP BY sl.description, c.salesperson_code
ORDER BY c.salesperson_code, sl.description";
// Utför SQL-satsen
$result=mysql_query("$sql");
// Skapar en tom array för aktuella säljare
$salespersons_g = array();
// Loppar igenom raderna
while($row=mysql_fetch_array($result)) {
// Kollar om arrayn för säljaren är deklarerad
if (!${$row[0]}) {
// Skapar array för säljaren
${$row[0]} = array();
// Lägger in värdena i arrayn - produkt och summering
antal produkter
${$row[0]}[$row[1]] = $row[2];
// Lägger in säljaren i arrayn för aktuella sälljare
array_push($salespersons_g, $row[0]);
}
// Om arrayn reda är deklarerad
else {
// Lägger in värdena i arrayn - produkt och summering
antal produkter
${$row[0]}[$row[1]] = $row[2];
}
}
// Räknare
$count_g = 0;
// Storlek på arrayn innhållande säljare
$sales_count_g = count($salespersons_g);
echo '<b>'.htmlentities('Godkänd nyförsäljning per produkt:
').'</b><br>';
// Loopa så länge räknaren är mindre än storleken av arrayn
$salespersons
while ($count_g < $sales_count_g) {
echo
'<br><b>'.htmlentities($salespersons_g[$count_g]).'</b><br>';
foreach (${$salespersons_g[$count_g]} AS $key => $value) {
if ($key == '') {
echo 'Okänd - '.$value.'<br>';
}
else {
echo htmlentities($key).' - '.$value.'<br>';
}
}
// Öka värdet på räknaren med 1
$count_g++;
}
// Stänger databasen
mysql_close ($link);
?>
--- End Message ---
--- Begin Message ---
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
-----Ursprungligt meddelande-----
Från: chris smith [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 13:38
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> I find this problem very strange. I've got two parts of code (allmost the
> same) in different TD's with vars and arrays (with same name) but it's
only
> the top code that gives result. I've allso tryied to rename the vars and
> TD's in the bottom without any luck. The only vars/arrays that I haven't
> mind changing name on yet are some dynamic, like:
>
> ${$row[0]} = array();
>
> ${$row[0]}[$row[1]] = $row[2];
>
> But I think this could be the main cause, but I'm not really sure. If I
> delete the top code the bottom works. Any idéas any one?
Without seeing the whole code involved, my guess is you're resetting
the array with every loop.
Guesses don't help but that's all we can do without seeing any actual code.
Okej, all the code follows bellow. Remember that part 1 allways works. And
they work all seperatly.
Man you do things the hard way. Why use all those variable variables?
$my_data = array();
// Loppar igenom raderna
while($row=mysql_fetch_assoc($result)) {
$code = $row['salesperson_code'];
if (!isset($my_data[$code])) {
$my_data[$code] = array(
'description' => $row['description'],
'total' => $row['totalt'],
'antal' => $row['antal']
);
} else {
$my_data[$code]['description'] = $row['description'];
}
}
var_dump($my_data);
MUCH easier to read and you'll find debugging LOTS easier.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: chris smith [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 14:13
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> -----Ursprungligt meddelande-----
> Från: chris smith [mailto:[EMAIL PROTECTED]
> Skickat: den 23 maj 2006 13:38
> Till: Jonas Rosling
> Kopia: PHP List
> Ämne: Re: [PHP] One works, but the other doesn't
>
>
> On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> > I find this problem very strange. I've got two parts of code (allmost
the
> > same) in different TD's with vars and arrays (with same name) but it's
> only
> > the top code that gives result. I've allso tryied to rename the vars and
> > TD's in the bottom without any luck. The only vars/arrays that I haven't
> > mind changing name on yet are some dynamic, like:
> >
> > ${$row[0]} = array();
> >
> > ${$row[0]}[$row[1]] = $row[2];
> >
> > But I think this could be the main cause, but I'm not really sure. If I
> > delete the top code the bottom works. Any idéas any one?
>
> Without seeing the whole code involved, my guess is you're resetting
> the array with every loop.
>
> Guesses don't help but that's all we can do without seeing any actual
code.
>
> Okej, all the code follows bellow. Remember that part 1 allways works. And
> they work all seperatly.
Man you do things the hard way. Why use all those variable variables?
$my_data = array();
// Loppar igenom raderna
while($row=mysql_fetch_assoc($result)) {
$code = $row['salesperson_code'];
if (!isset($my_data[$code])) {
$my_data[$code] = array(
'description' => $row['description'],
'total' => $row['totalt'],
'antal' => $row['antal']
);
} else {
$my_data[$code]['description'] = $row['description'];
}
}
-------------------------
Well, I'm kind of a newbie at this. So you think this will solve my problem?
// Jonas
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
-----Ursprungligt meddelande-----
Från: chris smith [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 14:13
Till: Jonas Rosling
Kopia: PHP List
Ämne: Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> -----Ursprungligt meddelande-----
> Från: chris smith [mailto:[EMAIL PROTECTED]
> Skickat: den 23 maj 2006 13:38
> Till: Jonas Rosling
> Kopia: PHP List
> Ämne: Re: [PHP] One works, but the other doesn't
>
>
> On 5/23/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:
> > I find this problem very strange. I've got two parts of code (allmost
the
> > same) in different TD's with vars and arrays (with same name) but it's
> only
> > the top code that gives result. I've allso tryied to rename the vars and
> > TD's in the bottom without any luck. The only vars/arrays that I haven't
> > mind changing name on yet are some dynamic, like:
> >
> > ${$row[0]} = array();
> >
> > ${$row[0]}[$row[1]] = $row[2];
> >
> > But I think this could be the main cause, but I'm not really sure. If I
> > delete the top code the bottom works. Any idéas any one?
>
> Without seeing the whole code involved, my guess is you're resetting
> the array with every loop.
>
> Guesses don't help but that's all we can do without seeing any actual
code.
>
> Okej, all the code follows bellow. Remember that part 1 allways works. And
> they work all seperatly.
Man you do things the hard way. Why use all those variable variables?
$my_data = array();
// Loppar igenom raderna
while($row=mysql_fetch_assoc($result)) {
$code = $row['salesperson_code'];
if (!isset($my_data[$code])) {
$my_data[$code] = array(
'description' => $row['description'],
'total' => $row['totalt'],
'antal' => $row['antal']
);
} else {
$my_data[$code]['description'] = $row['description'];
}
}
-------------------------
Well, I'm kind of a newbie at this. So you think this will solve my problem?
Look at it this way - Which one is easier to read? Which one do you
think will be easier to work out what's going wrong?
Readability of your code will help you so much. If you come back to
this in a week, will you understand what's going on?
I don't know if my code will give you *exactly* what you want - test
it and see (backup your existing php file, change this code, see what
you get).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
-------------------------
Well, I'm kind of a newbie at this. So you think this will solve my problem?
Why don't you test it?
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: Barry [mailto:[EMAIL PROTECTED]
Skickat: den 23 maj 2006 14:24
Till: [email protected]
Ämne: Re: SV: [PHP] One works, but the other doesn't
> -------------------------
> Well, I'm kind of a newbie at this. So you think this will solve my
problem?
Why don't you test it?
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Okej, now I've tested it. I just changed the while part for the rows with
the code I got from Chris. But just doing that doesn't make the same result
as my code. Do I need to put in $my_data in the foreach part as well?
// Jonas
--- End Message ---
--- Begin Message ---
I'm having very occasional problems with my PHP5 applications which only
seem to be explained if the script is run twice.
Example - page has 'Add Ticket' button, which adds a record and marks it
as being processed by the location that created it. 99.99% of the time
no problems, but just now and again there are two records, with
different primary keys - so the database bit worked - but with very
close now times and identified as being at the same counter. The next
page does not have the 'Add Ticket' button, so it would seem the first
script was trigger twice?
Am I simply going mad ( which is the logical choice ;) ), or is this
something that can happen and needs to be handled?
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
On 5/23/06, Lester Caine <[EMAIL PROTECTED]> wrote:
I'm having very occasional problems with my PHP5 applications which only
seem to be explained if the script is run twice.
Example - page has 'Add Ticket' button, which adds a record and marks it
as being processed by the location that created it. 99.99% of the time
no problems, but just now and again there are two records, with
different primary keys - so the database bit worked - but with very
close now times and identified as being at the same counter. The next
page does not have the 'Add Ticket' button, so it would seem the first
script was trigger twice?
Am I simply going mad ( which is the logical choice ;) ), or is this
something that can happen and needs to be handled?
Someone hitting refresh prematurely?
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Lester Caine wrote:
I'm having very occasional problems with my PHP5 applications which
only seem to be explained if the script is run twice.
Example - page has 'Add Ticket' button, which adds a record and marks
it as being processed by the location that created it. 99.99% of the
time no problems, but just now and again there are two records, with
different primary keys - so the database bit worked - but with very
close now times and identified as being at the same counter. The next
page does not have the 'Add Ticket' button, so it would seem the first
script was trigger twice?
Am I simply going mad ( which is the logical choice ;) ), or is this
something that can happen and needs to be handled?
This can happen if a page contains a reference to an empty URL. For
example, <img src="" /> would cause the page to be loaded twice in some
browsers. That'd be the first thing I'd check.
Is the 'Add Ticket' button a GET or POST request? If it's a POST then
chances are the script itself has a logic error since the user would get
asked if they wanted to repost the data. If it's a get then you've
violated one of the cardinal rules of web-based application development
- GETs get, POSTs do.
-Stut
--- End Message ---
--- Begin Message ---
OK I found this out last week... if its not a coding error... its this..
There is a bug with IE7, I have some billing scripts for a large Sydney ISP
and I was working on a script on my laptop which I recently updated to
IE7... after tipping my hair out for a few hours cause I was certain it was
not a coding error I decided the run the script from my PC which was still
IE6 and would u believe it, the script only run once
I did some searching on (good old faithful) google and did discover a few
bugs with IE7... whats this have to do with PHP u ask... one was a session
bug.. and with my double script running bug which I could not find any
information on... I decided to lock the site to IE7 with javascript and told
the ISP to roll back or stay locked out....
A lot of money @ stake... damn u Micro$oft...
CK
> -----Original Message-----
> From: Stut [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 23 May 2006 10:06 PM
> To: Lester Caine
> Cc: PHP List
> Subject: Re: [PHP] Can a script run twice?
>
> Lester Caine wrote:
>
> > I'm having very occasional problems with my PHP5 applications which
> > only seem to be explained if the script is run twice.
> >
> > Example - page has 'Add Ticket' button, which adds a record and marks
> > it as being processed by the location that created it. 99.99% of the
> > time no problems, but just now and again there are two records, with
> > different primary keys - so the database bit worked - but with very
> > close now times and identified as being at the same counter. The next
> > page does not have the 'Add Ticket' button, so it would seem the first
> > script was trigger twice?
> >
> > Am I simply going mad ( which is the logical choice ;) ), or is this
> > something that can happen and needs to be handled?
>
> This can happen if a page contains a reference to an empty URL. For
> example, <img src="" /> would cause the page to be loaded twice in some
> browsers. That'd be the first thing I'd check.
>
> Is the 'Add Ticket' button a GET or POST request? If it's a POST then
> chances are the script itself has a logic error since the user would get
> asked if they wanted to repost the data. If it's a get then you've
> violated one of the cardinal rules of web-based application development
> - GETs get, POSTs do.
>
> -Stut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Futher to this...
I found thatit does not do it with all my scripts... well as far as I am
aware... how much is IE7 stuffing up I have NFI
CK
> -----Original Message-----
> From: Stut [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 23 May 2006 10:06 PM
> To: Lester Caine
> Cc: PHP List
> Subject: Re: [PHP] Can a script run twice?
>
> Lester Caine wrote:
>
> > I'm having very occasional problems with my PHP5 applications which
> > only seem to be explained if the script is run twice.
> >
> > Example - page has 'Add Ticket' button, which adds a record and marks
> > it as being processed by the location that created it. 99.99% of the
> > time no problems, but just now and again there are two records, with
> > different primary keys - so the database bit worked - but with very
> > close now times and identified as being at the same counter. The next
> > page does not have the 'Add Ticket' button, so it would seem the first
> > script was trigger twice?
> >
> > Am I simply going mad ( which is the logical choice ;) ), or is this
> > something that can happen and needs to be handled?
>
> This can happen if a page contains a reference to an empty URL. For
> example, <img src="" /> would cause the page to be loaded twice in some
> browsers. That'd be the first thing I'd check.
>
> Is the 'Add Ticket' button a GET or POST request? If it's a POST then
> chances are the script itself has a logic error since the user would get
> asked if they wanted to repost the data. If it's a get then you've
> violated one of the cardinal rules of web-based application development
> - GETs get, POSTs do.
>
> -Stut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Stut wrote:
Lester Caine wrote:
I'm having very occasional problems with my PHP5 applications which
only seem to be explained if the script is run twice.
Example - page has 'Add Ticket' button, which adds a record and marks
it as being processed by the location that created it. 99.99% of the
time no problems, but just now and again there are two records, with
different primary keys - so the database bit worked - but with very
close now times and identified as being at the same counter. The next
page does not have the 'Add Ticket' button, so it would seem the first
script was trigger twice?
Am I simply going mad ( which is the logical choice ;) ), or is this
something that can happen and needs to be handled?
This can happen if a page contains a reference to an empty URL. For
example, <img src="" /> would cause the page to be loaded twice in some
browsers. That'd be the first thing I'd check.
Is the 'Add Ticket' button a GET or POST request? If it's a POST then
chances are the script itself has a logic error since the user would get
asked if they wanted to repost the data. If it's a get then you've
violated one of the cardinal rules of web-based application development
- GETs get, POSTs do.
<a class="button" accesskey="A" href="ticketaddserve.php?enqno=0">Add
Ticket</a>
Just change enqno= for a different queue.
Found the simple answer - Double click - two records !
And I'm with you on the problems with IE7 Chris - but in this case even
Moz does the Double Click - two records :(
So next problem - how do I stop it !
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
[snip]
While tabindex is a neat thing to use it does not necessarily give focus
to the first element of the form, it merely dictates the order in which
form elements will be given focus when the tab key is pressed. The
action may vary from browser to browser. Likely, when going to a form
with tabindex defined, none of the elements will have focus until the
tab key is pressed once, at which time the element with tabindex="1"
will get focus.
If you want to give focus to the first input element of a form you must
still use a JavaScript widget to place the focus there after the entire
page has loaded, tabindex will make sure that the cursor goes in the
order you wish to go in after that.[/snip]
[snip]
Try to use Firefox to debug your javascript.
I guess, there are some javascript error.
[/snip]
I confirmed before I sent the above e-mail that tabindex did not work in
Firefox or Opera either.
--- End Message ---