[PHP] Multiple File Upload

2001-08-03 Thread Arne

Hi,

I want to upload multiple files in one step. I know how to handle the things
on PHP side, but how can I select more than one file in the select box. It
does not work with:



I can only select one file. Is there a possibillity to select more, like in
windows explorer?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problems with exec

2001-08-09 Thread Arne

hi,

i have some problems with "exec". i am using win2000, apache and latest php
version. always 'unable to fork' . what´s the problem?

thanks for help, arne



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Arne Rusek
Hello.

I read throughout this thread and it looks like I have encountered
the same problem. Everything looks just fine but somehow the PHP
does not parse the request data sent to the script. I did some research on
that but gave up since I couldn't find how and where those data were
parsed. But I've used the PHP for a few days maybe it's just my
stupidity. Some of you more acquainted with the topic will find some info
I've gathered useful eventually.

I used this form:


Your name: 
Email: 



The test.php script contained this code:

\n";
phpinfo();
echo "\n";
var_dump($_POST);
?>

Then I saw a pretty large page but at the end there was

array(0) { }

and _that_ seemed to me pretty strange.

If someone is interested in reading through the whole result it could
be downloaded from

http://zonk.matfyz.cz/php_post_problem

I tried to change the method to GET but it didn't work either. The result
could be seen at

http://zonk.matfyz.cz/php_get_problem

Take care.

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Arne Rusek <[EMAIL PROTECTED]>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Resistance is futile. Open your source code and prepare for assimilation."

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



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-16 Thread Arne Rusek
Hello.

On Sat, Nov 15, 2003 at 05:31:01PM -0800, Chris Shiflett wrote:
> That does seem strange. I glanced at this page of yours:
> 
> > http://zonk.matfyz.cz/php_post_problem
> 
> And I saw this:
> 
> REQUEST_METHOD => GET
> So, why was the request a GET request rather than a POST request? There is
> no content nor any entity headers either, so it doesn't seem like this
> line (telling us that the request method was GET) is wrong.
Sorry for that. Somehow me or my web browser tricked me into thinking I
saved the right file. There's a correct one now. I screwed it when I was
trying the GET method or whatever. Nonetheless it still does not work.
Neither with GET nor with POST. If you liked to glance a little bit more
maybe you'd like to see the request

http://zonk.matfyz.cz/request

It's the one used with the POST method. I sent this request to the
server with netcat and saved (hope that the right one that time:) the
result into

http://zonk.matfyz.cz/php_post_problem

again.

> However, I also don't see any URL variables, so it doesn't seem like the
> HTTP request contained any form data, whether GET or POST.
Whoa. What kind of variables did you say? Ok. This is what I thought: I
have a nonapache - boa - webserver, maybe it's POST handling could be
different. (That would be even more strange but maybe boa webserver does
not set these variables) So I'll try GET. You know how it ended. The
same way.

> echo $username;
> echo $_GET['username'];
> echo $_POST['username'];
> echo $_REQUEST['username'];
> echo $_SERVER['QUERY_STRING'];
Ok. I've put this little code of yours after var_dump($_GET):

array(0) { } 
Notice: Undefined variable: username in /home/zonk/public_html/test.php on line 11
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 12
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 13
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 14
username=zonk&email=zonk&submit=Submit+me%21 

You see. It looks like the intrepreter hates me, doesn't it? :-)

> Hopefully one of this will output something relevant. Otherwise, I suppose
> it's possible that there is a bug in the CGI SAPI, unless I'm missing
> something.
Or we both. But it looks more like a bug to me because it should work
with no preceding actions taken.

> Hope that helps.
Oh thanks a lot. And apologies for wrong background info:)

Take care.

Arne Rusek

-- 
Arne Rusek <[EMAIL PROTECTED]>

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



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-18 Thread Arne Rusek
On Mon, 17 Nov 2003 15:30:43 +, Curt Zirzow wrote:

> * Thus wrote Arne Rusek ([EMAIL PROTECTED]):

> Your problem exists here:
> 
> Server API => Command Line Interface
> _ENV["SERVER_SOFTWARE"] => Boa/0.94.13
> 
> Seeing this tells me your webserver is not configured correctly,
> Boa should not be using the CLI version of php it should be using
> the CGI version.

Thank you, that was it. Boa can't run php directly. So i made php files
executable and added '#!/usr/bin/php4' at the beginning of the script.
Instead of that I should have used the cgi version, as you suggested,
which was /usr/lib/cgi-bin/php4.

Take care.

Arne Rusek

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



[PHP] something like a C "struct" or "union" in PHP?

2001-05-05 Thread Arne Borkowski \(borko.net\)

Hi Folks,

I want to do the following:


$f = fopen($filename", "r");

while( !feof($f) ) {
 $len=1;
 $RECSIZE=128

 while($n=1;$n<=$len;$n++)
  $data = fread($f, $RECSIZE);

 $rectype = $data[4];

 switch($rectype) {

case "A": $numARec++;
$len=1;

// do something with the
// contents of $data

break;

case "C": $numCRec++;
$len=2; // at least!

// do something with the
// contents of $data

break;

case "E": $numERec++;
$len=1;

// do something with the
// contents of $data

break;
 } /* switch */

 fclose($f);

} /* while */

This snippet reads a data file in 128 bytes truncs
and needs to analyse the contents. As each 128 bytes
trunc has a certain structure (say: fields to access)
I would appreciate a thing like a C "struct" or so.

In C I could eaysly read the RECSIZE bytes into a
struct and access certain bytes via a "named" part
of it. Is there anything similar to this in PHP? I
couldn't find a "struct" or so in the manual. The
site's search engine said 41 hits for "struct" in
the Web Site content, but didn't show the matching
docs?! I need help on "struct" from you guys!

TIA

-Arne



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] something like a C "struct" or "union" in PHP?

2001-05-05 Thread Arne Borkowski \(borko.net\)

Hi Yasuo,

thanks for the hint ... I'll give WDDX a try after some thought
(and because I am using XML anyway).

Regards, Arne


> -Original Message-
> From: Yasuo Ohgaki [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, May 05, 2001 2:11 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] something like a C "struct" or "union" in PHP?
>
>
> PHP does not have struct. You can do similar things with class or
> array. You
> probably interested in wddx serialize or serialize function to
> make it work your
> snippet.
>
> Regards,
> --
> Yasuo Ohgaki
>
>
> ""Arne Borkowski (borko.net)"" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hi Folks,
> >
> > I want to do the following:
> >
> >
> > $f = fopen($filename", "r");
> >
> > while( !feof($f) ) {
> > $len=1;
> > $RECSIZE=128
> >
> > while($n=1;$n<=$len;$n++)
> >   $data = fread($f, $RECSIZE);
> >
> > $rectype = $data[4];
> >
> > switch($rectype) {
> >
> > case "A": $numARec++;
> > $len=1;
> >
> > // do something with the
> > // contents of $data
> >
> > break;
> >
> > case "C": $numCRec++;
> > $len=2; // at least!
> >
> > // do something with the
> > // contents of $data
> >
> > break;
> >
> > case "E": $numERec++;
> > $len=1;
> >
> > // do something with the
> > // contents of $data
> >
> > break;
> > } /* switch */
> >
> > fclose($f);
> >
> > } /* while */
> >
> > This snippet reads a data file in 128 bytes truncs
> > and needs to analyse the contents. As each 128 bytes
> > trunc has a certain structure (say: fields to access)
> > I would appreciate a thing like a C "struct" or so.
> >
> > In C I could eaysly read the RECSIZE bytes into a
> > struct and access certain bytes via a "named" part
> > of it. Is there anything similar to this in PHP? I
> > couldn't find a "struct" or so in the manual. The
> > site's search engine said 41 hits for "struct" in
> > the Web Site content, but didn't show the matching
> > docs?! I need help on "struct" from you guys!
> >
> > TIA
> >
> > -Arne
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] if $index=1 how can I create a variable named $column_1

2001-05-11 Thread Arne Borkowski \(borko.net\)

and that's pretty cool ... do you also have a solution
to access the name of this "dynamic" variable if I'd
like to use it also (e.g. with WDDX functions)? That' would 
be great!

TIA, Arne

> -Original Message-
> From: ..s.c.o.t.t.. [gts] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 10, 2001 5:07 PM
> To: Php-General
> Subject: RE: [PHP] if $index=1 how can I create a variable named
> $column_1
> 
> 
> And even though it's much less elegant than the
> solution by Sean below, you could also use 'eval'
> 
>  $toast = array("wheat", "rye", "pumpernickel");
>  $numbreads = count($toast);
>  for ($index = 0; $index < $numbreads; $index++) {
>   eval("\$column$index = '$toast[$index]';
>   echo \$column$index . '';") ;
>  }
> 
> > -Original Message-
> > From: Sean R. Bright [mailto:[EMAIL PROTECTED]]
> > To: 'Jay Lepore'; [EMAIL PROTECTED]
> > Subject: RE: [PHP] if $index=1 how can I create a variable named
> > 
> > $toast = array("wheat", "rye", "pumpernickel");
> > $numbreads = count($toast);
> > for ($index = 0; $index < $numbreads; $index++) {
> > ${"column" . $index} = $toasts[$index];
> > }
> > 
> > (A little less code and one less variable required.)
> > 
> > Sean
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] File upload !!!!

2001-05-13 Thread Arne Borkowski \(borko.net\)

Let us see the form code fragment in your HTML page and the
PHP code that accesses the variables...in order to see where
the problem is.

-Arne


> -Original Message-
> From: Matthias Roggendorf [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, May 13, 2001 8:15 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] File upload 
>
>
> Hi,
> sorry for asking such easy things but I really have a hard time
> to get this
> to work:
>
> I use exactly the scripts which are given on the PHP website to upload
> files. The problem is that the variable $userfile just contains "none" and
> $userfile_size is "0". The rest of the variables have the right values.
> When I use a larger file it takes more time so I assume that the file is
> uploaded, but I cannot save it because I don't know the temporary
> filename.
>
> Can anybody help me? I really need this to work.
>
> Thanks, Matthias
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Sockets with windows / win32 - 'call to undefined function: ...'

2002-04-04 Thread Odd Arne Beck

Hi..

The error I get is this one:
"Fatal error: Call to undefined function: socket() "

i'm 100% positive that all my code is correct..

anyone else have this problem, or anyone else NOT having this problem?

I have a win2000 with iis 5.0 and it's latest updates.

the latest version of php too..

Best regards,

-Oddis-



[PHP] Rational Rose plugin for generating php code ?

2001-12-12 Thread Arne Brune Olsen

Hi
Does anyone know if there is a module for rational rose for generating php code from 
UML diagrams ?

Arne




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Rational Rose plugin for generating php code ?

2001-12-21 Thread Arne Brune Olsen

> configure --help
> 
> ie. nope, nothing there.

uh?
This has nothing to do with compiling php!!
Rational Rose is a tool for uml modelling which can generate oo code from
uml diagrams... 

Arne


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Hmm.. this is strange..

2012-04-24 Thread Karl-Arne Gjersøyen
Hello.
I have a upload form in a html file and a corresponding PHP file that
shall take care of the information.
But I am doing something newbie error here..

What am I doing wrong? (The text is norwegian, but you still see and
understand the PHP code)

bildegalleri.html
-




Opplasting til Fotogalleri



Opplasting til Fotogalleri


Velg bilde for opplasting
Filbane







bildegalleri.php
-





Bildegalleri


Bildegalleri




When I run this script, I always get "Ok". Even when the input file
field is empty.. Can someone tell me what I am doing wroing in this?

Thanks for you time and effort to help me out.

Karl

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



Re: [PHP] Hmm.. this is strange..

2012-04-24 Thread Karl-Arne Gjersøyen
Here I try to check if the input file is empty or not. But still it
did not work. I receive OK even when the input file field is empty..






Bildegalleri


Bildegalleri




Den 16:48 24. april 2012 skrev Serge Fonville
 følgende:
> Hi,
>
> Instead of just checking if the variable is not set, additionally
> check if it is empty
>
> Kind regards/met vriendelijke groet,
>
> Serge Fonville
>
> http://www.sergefonville.nl
>
> Convince Google!!
> They need to add GAL support on Android (star to agree)
> http://code.google.com/p/android/issues/detail?id=4602
>
>
> 2012/4/24 Karl-Arne Gjersøyen :
>> Hello.
>> I have a upload form in a html file and a corresponding PHP file that
>> shall take care of the information.
>> But I am doing something newbie error here..
>>
>> What am I doing wrong? (The text is norwegian, but you still see and
>> understand the PHP code)
>>
>> bildegalleri.html
>> -
>> 
>> 
>> 
>> 
>> Opplasting til Fotogalleri
>> 
>> 
>> 
>> Opplasting til Fotogalleri
>> 
>>        
>>                Velg bilde for opplasting
>>                Filbane
>>                
>>                
>>        
>> 
>> 
>> 
>>
>> bildegalleri.php
>> -
>> > if(!isset($_POST['last_opp_fil'])){
>>        header('Location: bildegalleri.html');
>> }
>> elseif(empty($_FILES['filbane'])){
>>        header('Location: bildegalleri.html');
>> } else {
>> ?>
>> 
>> 
>> 
>> 
>> Bildegalleri
>> 
>> 
>> Bildegalleri
>> > echo "OK";
>> }
>> ?>
>> 
>> 
>>
>> When I run this script, I always get "Ok". Even when the input file
>> field is empty.. Can someone tell me what I am doing wroing in this?
>>
>> Thanks for you time and effort to help me out.
>>
>> Karl
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>

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



Re: [PHP] Hmm.. this is strange..

2012-04-24 Thread Karl-Arne Gjersøyen
Thank you very much Tolga!



if(empty($_FILES['filbane']['name']))


24.04.2012 17:54 tarihinde, Karl-Arne Gjersøyen yazdı:

> Here I try to check if the input file is empty or not. But still it
> did not work. I receive OK even when the input file field is empty..
>
>  if(!isset($_POST['last_opp_fil'])){
>        header('Location: bildegalleri.html');
> } else {
>        $bildefil = $_FILES['filbane'];
>        if(empty($bildefil)){
>                header('Location: bildegalleri.html');
>        } else {
> ?>
> 
> 
> 
> 
> Bildegalleri
> 
> 
> Bildegalleri
>         echo "OK";
>        }
> }
> ?>
> 
> 
>
> Den 16:48 24. april 2012 skrev Serge Fonville
>   følgende:
>>
>> Hi,
>>
>> Instead of just checking if the variable is not set, additionally
>> check if it is empty
>>
>> Kind regards/met vriendelijke groet,
>>
>> Serge Fonville
>>
>> http://www.sergefonville.nl
>>
>> Convince Google!!
>> They need to add GAL support on Android (star to agree)
>> http://code.google.com/p/android/issues/detail?id=4602
>>
>>
>> 2012/4/24 Karl-Arne Gjersøyen:
>>>
>>> Hello.
>>> I have a upload form in a html file and a corresponding PHP file that
>>> shall take care of the information.
>>> But I am doing something newbie error here..
>>>
>>> What am I doing wrong? (The text is norwegian, but you still see and
>>> understand the PHP code)
>>>
>>> bildegalleri.html
>>> -
>>> 
>>> 
>>> 
>>> 
>>> Opplasting til Fotogalleri
>>> 
>>> 
>>> 
>>> Opplasting til Fotogalleri
>>> 
>>>        
>>>                Velg bilde for opplasting
>>>                Filbane
>>>                
>>>                
>>>        
>>> 
>>> 
>>> 
>>>
>>> bildegalleri.php
>>> -
>>> >> if(!isset($_POST['last_opp_fil'])){
>>>        header('Location: bildegalleri.html');
>>> }
>>> elseif(empty($_FILES['filbane'])){
>>>        header('Location: bildegalleri.html');
>>> } else {
>>> ?>
>>> 
>>> 
>>> 
>>> 
>>> Bildegalleri
>>> 
>>> 
>>> Bildegalleri
>>> >> echo "OK";
>>> }
>>> ?>
>>> 
>>> 
>>>
>>> When I run this script, I always get "Ok". Even when the input file
>>> field is empty.. Can someone tell me what I am doing wroing in this?
>>>
>>> Thanks for you time and effort to help me out.
>>>
>>> Karl
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>



-- 
Hjemmeside: http://www.karl-arne.name/

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



[PHP] What is wrong here?

2012-04-24 Thread Karl-Arne Gjersøyen
Hello again.
I can't figure out what is wrong here.

move_uploaded_file() get error message from die() and can't copy/move
temp_file into directory bilder

I have try to chmod 0777 bilder/ but it did not help.
Also I have try to chown www-data.www-data bilder/ since Ubuntu Server
run apache as www-data user...

Here is my souce code
--
// Temfil lagres midlertidig på serveren som
// spesifisert i php.ini
$tmp_fil = $_FILES['filbane']['temp_name'];
// lagre filnavnet..
$filnavn = "bilder/" . $_FILES['filbane']['name'];
// ..og legg fila i katalogen bilder
move_uploaded_file($tmp_fil, $filnavn) or die("Feilmelding: Kunne
ikke flytte $filnavn");


Karl

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



[PHP] Sort question..

2012-04-25 Thread Karl-Arne Gjersøyen
Hello again.
I have a photo album that show all images in a specified directory.
but I like to sort them by filename as one possibillity and random
sort the photos as another feature.
I don't know how to do this.. Here is my soruce-code:





Bildegalleri



Bildegalleri
Last opp nye bilder | 
Sorter på filnavn 
| 
Tilfeldig 
sortering

valid()){
if(!$bilde->isDot()){
if($_GET['sorter_filnavn']){
echo '';
} elseif($_GET['tilfeldig_sortering']) {
echo '';
} else {
echo '';
}
}
$bilde->next();
}
unset($bilde);
?>




I will be lucky if somebode have time to help me out here.. I am sure
it is some functions in php that can do the trick, but haven't found
anything yet.
Thanks for your time.

Karl

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



[PHP] Find/count different word in a text

2012-04-25 Thread Karl-Arne Gjersøyen
Hello again.
I am looking for a way to find and count different word in a text..
I am thinking on save the text as array and iterate through the array.
Then I like to register all different words in the text.
For example. If bread is used more than one time, I will not count it.
After the check were I have found single (one) word of every words, I
count it and tell how many different word that is in the text.

Is this difficult to do? Can you give me a hint for were I shall look
on www.php.net for a solution to fix this problem? What function am I
in need of?

Thank you very much.
Kind Regards, Karl

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



[PHP] Newbie form question

2013-06-21 Thread Karl-Arne Gjersøyen
Hello.

I have an application that generete HTML5 form in PHP.
The form is written in a while loop and therefore the form field has exact
same name for every row in the loop.
And that is the problem. Because when my PHP document shall handle
submitted data it only take the very last row in the while loop and show
the result of it.

if(isset($_POST['update_explosive'])){
$item_serial_number = $_POST['item_serial_number'];
$update_item_in_store = $_POST['update_item_in_store'];

if($item_serial_number === "ETX1.22X1000"){
echo "$update_item_in_store";
}
if($item_serial_number === "ETX1.17X460"){
echo "$update_item_in_store";
}
}

I think the solution will be to create different and unike fieldname
dymamic. For example I tried to write " value=""> in
the HTML5/PHP form.

But the problem is that periode "." not is allowed as $variable_name.
I then try to write it this way:

if(isset($_POST['update_explosive'])){
$item_serial_number = $_POST['ETX1.22X1000'];
$update_item_in_store = $_POST['update_item_in_store'];

if($item_serial_number === "ETX1.22X1000"){
echo "$update_item_in_store";
}
if($item_serial_number === "ETX1.17X460"){
echo "$update_item_in_store";
}
}

But this last part did not make any sense to me. I recive no output when
tried that one.

One problem is that I have between 2 and 25 items with different serial
number. Sometimes only 5 of this shall be updated and other times all 25
items. I like to do this through one simple form and not for one time for
every single item. (I know how to do when select one by one and update
them, but that is a long and hard way for people using my application. A
better solution is to just use one form and view all items there. Then just
write the amount of item in  field.)

If you have time to help me *understand* this newbie question by explain or
give me an example or post a link to a tutorial that can help me though, I
am very thankful.

Karl


[PHP] Hmm remarkable things?

2013-06-23 Thread Karl-Arne Gjersøyen
Hello again.
Thanks for last answere. It works very well but now I have another
remarkable things. Perhaps logic but not for me yet..

I have this source code: (In norwegian but I translate my thoughts through
it in english.)

The problem with this source code is that it work very well if I select one
single item and post it. But when select 2 or more items the same amount
are filled in all field named stk_pa_lager in the database.

// count and increase the amount of tubes.
if(isset($_POST['oppdater_antall_stk_rorladning'])){

// Get store
$valgt_lager = $_POST['valgt_lager'];

// Get serial number   (Array )
  $varenr = $_POST['varenr'];

// number of items in store
$stk_pa_lager = $_POST['stk_pa_lager'];

// Create an array ()
$oppdater_antall_stk_rorladning =
$_POST['oppdater_antall_stk_rorladning'];

// Extract the array and save it induvidual as items in $rorladning
foreach($oppdater_antall_stk_rorladning as $rorladning){

// Multiply and add new items to that one already is in store
$oppdatert_antall_stk_rorladning = $stk_pa_lager + $rorladning;

// Extract serialnumber and save them one by one in $vnr
foreach($varenr as $vnr){

// Connect to MySQL database
include('../../tilkobling.php');

// Update table rorladning
$sql = "UPDATE rorladning SET stk_pa_lager =
'$oppdatert_antall_stk_rorladning' WHERE valgt_lager = '$valgt_lager' AND
varenr = '$vnr'";
mysql_query($sql, $tilkobling) or die(mysql_error());

}

// Output the result to screen
echo "Rørladning med varenr: $vnr er oppdatert fra
$stk_pa_lager til $oppdatert_antall_stk_rorladning på
lager: $valgt_lager.";
//echo "$oppdatert_antall_stk_rorladning";
unset($rorladning);
unset($vnr);
}
}


// My database table:
mysql> SELECT * FROM rorladning;
++-+---+-+--+-+--+-+
| leverandor | valgt_lager | un_nr | varenavn| varenr   | dim_mm  |
stk_pa_lager | kg_pa_lager |
++-+---+-+--+-+--+-+
| Orica  | Tengs   | 0081  | Hvit Rør   | ETX1.22X1000 | 22x1000 |
70   | 3.7 |
| Orica  | Tengs   | 0081  | Orange Rør | ETX1.17X460  | 17x460  |
70   | 0.95|
++-+---+-+--+-+--+-+
2 rows in set (0.00 sec)

mysql>

What I think i am doing wrong is the way I write the php/mysql stuff. What
I want is to store differt values in stk_pa_lager based on the particular
serialnumber. (field varenr).

I will be very thankful if you can tell me what is wrong here and point out
what to do with it.
Thanks for your time.

Karl


[PHP] One more newbie question. About foreach..

2013-06-23 Thread Karl-Arne Gjersøyen
Hello again. I Got the solution for my last mention problem. Now I can
update several rows at once by one single submit action.

In my form I have many records and therefor I use an checkbox to just mark
those records I like to update. This work just fine in PHP/HTML5 form and I
got it as I want.

But the problem now is, how to recognize just those selected records by
serialnumber?

include('../../connect.php');

// Foreach get all given serialnumbers as I want it
foreach($serialnumber as $snr){

// I got the number of serialnumbers given in the array
   $count = count($serialnumber);

// I thought that a for loop would do the trick together with foreach
// And repeat the $sql = SELECT below but that did not happen.
for($i = 0; $i <= $count; $i++){


// Connect and get only those records with given serialnumber
$sql = "SELECT * FROM explosive WHERE serialnumber = '$snr'";
} // End of for loop
} // End of foreach loop
$result = mysql_query($sql, $connect) or die(mysql_error());
$count = mysql_num_rows($result);

I have tried to search in google and on PHP.net but can't fine anything
that explain my problem.
I like to have new $sql = SELECT queries for every given serialnumber ($snr)

Thanks for your help.

Karl


[PHP] Re: One more newbie question. About foreach..

2013-06-24 Thread Karl-Arne Gjersøyen
WOW! Thank you very, very much!
This is so good! Thanks to all of you for spending time to learning me
programming!

Karl

2013/6/23 Maciek Sokolewicz 

> On 23-6-2013 17:11, Karl-Arne Gjersøyen wrote:
>
>> Hello again. I Got the solution for my last mention problem. Now I can
>> update several rows at once by one single submit action.
>>
>>  [...]
>
>  I have tried to search in google and on PHP.net but can't fine anything
>> that explain my problem.
>> I like to have new $sql = SELECT queries for every given serialnumber
>> ($snr)
>>
>> Thanks for your help.
>>
>> Karl
>>
>>
> Ok, Karl, I've seen quite a few messages from you to this list with
> various questions; from all these questions it becomes clear that you're
> trying to work with lists in a single form without understanding the basics
> of a form in the first place. You also seem to not understand what an array
> is exactly, or how to process it.
>
> So let's answer all these questions at once; I will attempt to explain (in
> short) how to do all this, using a custom form here. I don't speak
> Norwegian, and I find your variable names to be horribly long and complex,
> so let's not use them :)
>
> Say you want a simple form online which gives you a product name and asks
> you to update the amount of it in stock.
> 
> 
> 
> 
>
> When you submit this simple form, the PHP script defined in the action
> property is called, and the $_POST array looks like:
> $_POST = array(
>'number_in_stock' = '0'
> );
>
> You can then run your simple query
> mysql_query("UPDATE some_table SET stock='" . $_POST['number_in_stock']);
> // note: you should always sanitize these values; i.e. make sure it is
> EXACTLY what you expect, and CAN NOT possibly be anything else. So if you
> expect it to be a number, check if it IS a number before running this
> query!!!
>
> Now, you said you wanted to update multiple items.
> Imagine you have a form showing multiple items:
> 
> Item A: 
> Item B: 
> Item C: 
> 
> 
>
> If you do this, PHP will have no idea what is what, and it will just keep
> overwriting the number_in_stock value until it reaches the last one. So you
> would end up with a $_POST array looking like this:
> $_POST = array(
>'number_in_stock' = '258'
> );
>
> Obviously, you don't want that. The solution would be to tell PHP to turn
> all recieved values into an array. This can be done by manually specifying
> the key for each array item; or letting PHP do it automatically. This
> automatic way was suggested earlier, like so:
> 
> Item A: 
> Item B: 
> Item C: 
> 
> 
>
> This then results in a $_POST array like this:
> $_POST = array(
>'number_in_stock' = array(
>   0 => '8',
>   1 => '2',
>   2 => '258'
>)
> );
>
> So now, do you have any idea what is what? No. You don't. Why? because you
> don't supply a link between the value and the meaning. Instead, you could
> decide to supply a certain unique key per item, like so:
> 
> Item A: 
> Item B: 
> Item C: 
> 
> 
>
> This results in:
> $_POST = array(
>'number_in_stock' = array(
>   'ItemA' => '8',
>   'ItemB' => '2',
>   'ItemC' => '258'
>)
> );
>
> Wow, now you can actually use this info when updating your table in the DB!
> foreach($_POST['number_in_**stock'] as $item=>$number) {
>mysql_query("UPDATE table SET stock='".$number."' WHERE
> itemId='".$item);
> }
> This will run over each element in the $_POST['number_in_stock'] array. It
> will (for that single loop-run) stick the key in $item and the value in
> $number. For each run, it will run the update query. Then in the next run,
> a new set of values is supplied, and a new query is ran.
>
> If you want to expand this to give you the ability to define which items
> should be updated and which should not, you could add checkboxes. When
> checked, the item will be updated; otherwise it won't. Checkboxes have a
> great feature where if they are checked, they have the value supplied in
> their value attribute. If they are not checked, they have no value. So, you
> could add something like:
> 
>  Item A:  type="text" name="number_in_stock['ItemA']**" value="8">
> Item B:  type="text" name="number_in_stock['ItemB']**" value="2">
> 

[PHP] Is it possible???

2013-06-24 Thread Karl-Arne Gjersøyen
$item_amount_in_store = 223;
$update_amount = 7;
$update_item_amount_in_store += $update_amount;
$update_amoint_in_store is now 227;

Why? That should be 230!

Karl


[PHP] Fwd: Is it possible???

2013-06-24 Thread Karl-Arne Gjersøyen
Error in my last post This is corrected:

$item_amount_in_store = 223;
$update_amount = 7;
$item_amount_in_Store += $update_amount;

It show the result = 227 and not 230. Why is this happen?

Karl

-- Forwarded message --
From: Karl-Arne Gjersøyen 
Date: 2013/6/24
Subject: Is it possible???
To: PHP Mailinglist 


$item_amount_in_store = 223;
$update_amount = 7;
$update_item_amount_in_store += $update_amount;
$update_amoint_in_store is now 227;

Why? That should be 230!

Karl



-- 
Hjemmeside: http://www.karl-arne.name/


[PHP] Hello again. new newbie querstion

2013-07-03 Thread Karl-Arne Gjersøyen
I have done as you explain for me an it works very vell in the halft part
of my application.
But below is my snippet of my source code where the number of items and
weight not will update itself.
This code do as what number I write in the "oppdater_stk_nonel_tenner[]"
field is written as result, instead of the calculated result.
I am also using var_dump() to check my viariables but there is something
here I have missed.

I hope it is ok to post my norwegian search code as an exaple. If this
source code is to difficult because of my long norwegian name (Description
of the meaning of varable) i will re-write it all in English as I appricate
your good advice and help!

Tanks.

// My form with array's
"
">
">

">


if(isset($_POST['oppdater_nonel_tennere'])){
$valgt_lager = $_POST['valgt_lager'];
$varenr = $_POST['varenr'];
$kg_pa_lager = $_POST['kg_pa_lager'];
$stk_pa_lager = $_POST['stk_pa_lager'];
$oppdater_stk_nonel_tenner = $_POST['oppdater_stk_nonel_tenner'];

include('../../tilkobling.php');

// count how many serialnumber it is the the array for use later in for
loop.
$antall_varenr = count($varenr);

// Run for loop as long as $i is less than or equal to $antall_varenr.
for($i=0;$i<$antall_varenr;$i++){

// update amont in stock. Adding value of
$oppdater_stk_nonel_tenner[$i] to $stk_pa_lager
$stk_pa_lager[$i] += $oppdater_stk_nonel_tenner[$i];

// Get new weight in kg in stock
$kg_pa_lager =  $stk_pa_lager[$i] * 0.001;

// Update the database table
$sql = "UPDATE nonel_tennere SET stk_pa_lager = '$stk_pa_lager[$i]',
kg_pa_lager = '$kg_pa_lager' WHERE varenr = '$varenr[$i]' LIMIT 1";
mysql_query($sql,$tilkobling) or die(mysql_error());
var_dump($sql);
}
echo "Databasen er oppdatert";
?>

">








I can't figure out why $stk_pa_lager[$i]; is the same as written in
$oppdater_stk_nonel_tennere[$i] as long I have us this += operator in

$stk_pa_lager[$i] += $oppdater_stk_nonel_tenner[$i];

I have just copy and past it from a working example above and chance the
table name and $oppdater_stk_nonel_tenner[$i] variable.

Thanks for your time.

Karl


[PHP] Can this work?

2013-07-05 Thread Karl-Arne Gjersøyen
Hello. I have a form in HTML/PHP with for loops that generate a selected
list like this:
for($i = 1; $i< 25;$i++ ){
 
}

The lists look like this:

http://localhost/%7Ekarl/kasen/io/kp/index.php>"
method="post">1-2512345678910111213141516171819202122232425 Kg 26-5026272829303132333435363738394041424344454647484950 Kg 

What I try to do with it is to register the selected value and do something
with it. The lists is weight in KG. I hope to select only one value between
1-25kg OR 26-50kg. I don't know if this is possible? What do you think?

Thanks.
Karl


Re: [PHP] Can this work?

2013-07-05 Thread Karl-Arne Gjersøyen
2013/7/5 Stuart Dallas 

> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen  wrote:
>
> > Hello. I have a form in HTML/PHP with for loops that generate a selected
> > list like this:
> > for($i = 1; $i< 25;$i++ ){
> > 
> > }
> >
> > The lists look like this:
> >
> > http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> > method="post"> > value="1-25" selected="selected">1-25 > value="1">12 > value="3">34 > value="5">56 > value="7">78 > value="9">910 > value="11">1112 > value="13">1314 > value="15">1516 > value="17">1718 > value="19">1920 > value="21">2122 > value="23">2324 > value="25">25 Kg  > name="valgt_dynamit_polse_26-50kg"> > selected="selected">26-50 > value="26">2627 > value="28">2829 > value="30">3031 > value="32">3233 > value="34">3435 > value="36">3637 > value="38">3839 > value="40">4041 > value="42">4243 > value="44">4445 > value="46">4647 > value="48">4849 > value="50">50 Kg 
> >
> > What I try to do with it is to register the selected value and do
> something
> > with it. The lists is weight in KG. I hope to select only one value
> between
> > 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
>
> If the range of acceptable values is 1-50, why do you have two select
> fields instead of one?


The select list has values between 1 and 200. Therefore I split it up for
every 25th value.

Karl


Re: [PHP] Can this work?

2013-07-05 Thread Karl-Arne Gjersøyen
2013/7/5 Tedd Sperling 

> On Jul 5, 2013, at 9:56 AM, Karl-Arne Gjersøyen 
> wrote:
> > The lists look like this:
> >
> > http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> > method="post"> > value="1-25" selected="selected">1-25 > value="1">12
>
> Review this:
>
> http://sperling.com/php/select/
>
> Also, omit 'multiple' in the select statement.
>
> Other than that, the demo shows how to gather the information you want.
>
> Cheers,
>
> tedd
>
> _
> tedd.sperl...@gmail.com
> http://sperling.com


Thank you very much! <http://www.karl-arne.name/>


Re: [PHP] Can this work?

2013-07-05 Thread Karl-Arne Gjersøyen
2013/7/5 Stuart Dallas 

> On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen  wrote:
>
> > 2013/7/5 Stuart Dallas 
> >
> >> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen 
> wrote:
> >>
> >>> Hello. I have a form in HTML/PHP with for loops that generate a
> selected
> >>> list like this:
> >>> for($i = 1; $i< 25;$i++ ){
> >>> 
> >>> }
> >>>
> >>> The lists look like this:
> >>>
> >>> http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> >>> method="post"> >>> value="1-25" selected="selected">1-25 >>> value="1">12 >>> value="3">34 >>> value="5">56 >>> value="7">78 >>> value="9">910 >>> value="11">1112 >>> value="13">1314 >>> value="15">1516 >>> value="17">1718 >>> value="19">1920 >>> value="21">2122 >>> value="23">2324 >>> value="25">25 Kg  >>> name="valgt_dynamit_polse_26-50kg"> >>> selected="selected">26-50 >>> value="26">2627 >>> value="28">2829 >>> value="30">3031 >>> value="32">3233 >>> value="34">3435 >>> value="36">3637 >>> value="38">3839 >>> value="40">4041 >>> value="42">4243 >>> value="44">4445 >>> value="46">4647 >>> value="48">4849 >>> value="50">50 Kg 
> >>>
> >>> What I try to do with it is to register the selected value and do
> >> something
> >>> with it. The lists is weight in KG. I hope to select only one value
> >> between
> >>> 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
> >>
> >> If the range of acceptable values is 1-50, why do you have two select
> >> fields instead of one?
> >
> > The select list has values between 1 and 200. Therefore I split it up for
> > every 25th value.
>
> Ok, but why?


I will use my application on iPad and find it more easy to use multiple
select lists than one big list with all 200 values at once.

Karl


[PHP] Hmm.. I got NULL here. Why?

2013-07-05 Thread Karl-Arne Gjersøyen
My PHP Source
=
";
var_dump($kg_pa_lager);
?>

My var_dump() value;
==
string(84) "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = 'Tengs' AND
varenr = 'EDY22X180'"
NULL

My Database table:
===
mysql> SELECT * FROM dynamit;
++-+---++---+--++-+
| leverandor | valgt_lager | type  | dim_mm | un_nr | varenavn |
varenr | kg_pa_lager |
++-+---++---+--++-+
| Orica  | Tengs   | Papirpatroner | 22x180 | 0081  | Dynamit  |
EDY22X180K | 100 |
| Orica  | Tengs   | Papirpatroner | 25x180 | 0081  | Dynamit  |
EDY25X180  | 100 |
| Orica  | Tengs   | Plastpølse   | 45x540 | 0081  | Dynamit  |
EDY45X540  | 100 |
++-+---++---+--++-+
3 rows in set (0.00 sec)

mysql>

The Problem:
==
If I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'";
I got 100100100 for kg_pa_lager

But if I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'
AND varenr = '$varenr'";
I got NULL.

Look at varenr = EDY22X180 in the select where and that it is in the table
under varenr.
But why is kg_pa_lager NULL?

This is strange to me but I guess you know why?
Thanks for your advice.

Karl


[PHP] Fwd: Hmm.. I got NULL here. Why?

2013-07-05 Thread Karl-Arne Gjersøyen
My PHP Source
=
";
var_dump($kg_pa_lager);
?>

My var_dump() value;
==
string(84) "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = 'Tengs' AND
varenr = 'EDY22X180'"
NULL

My Database table:
===
mysql> SELECT * FROM dynamit;
++-+---++---+--++-+
| leverandor | valgt_lager | type  | dim_mm | un_nr | varenavn |
varenr | kg_pa_lager |
++-+---++---+--++-+
| Orica  | Tengs   | Papirpatroner | 22x180 | 0081  | Dynamit  |
EDY22X180K | 100 |
| Orica  | Tengs   | Papirpatroner | 25x180 | 0081  | Dynamit  |
EDY25X180  | 100 |
| Orica  | Tengs   | Plastpølse   | 45x540 | 0081  | Dynamit  |
EDY45X540  | 100 |
++-+---++---+--++-+
3 rows in set (0.00 sec)

mysql>

The Problem:
==
If I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'";
I got 100100100 for kg_pa_lager

But if I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'
AND varenr = '$varenr'";
I got NULL.

Look at varenr = EDY22X180 in the select where and that it is in the table
under varenr.
But why is kg_pa_lager NULL?

This is strange to me but I guess you know why?
Thanks for your advice.

Karl

I got the solution. I had forget to write "K" at end of the serial number.
Now it is OK.
Karl


[PHP] Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.

I like to register new products and the amount in number (for example 4)
and weight in kg.

I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10


[PHP] Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
Sorry, the first mail in this subject run out for me. This is an updated
one.



I am almost ready with my learning project in PHP/MySQL.
I can register new product in stock.
Add and increase the number and weight.
I can move products between different storehouses
I can also transfer products from store and onto a "truck document" but
that's it and here I need some advice.

I like to register new products and the amount in number (for example 4)
and weight in kg.

I like to write it in this way:
Dynamite - package 4 - Weight 200 kg
Lunt - Package 10 - Weight 10kg

Then I like to 4+10 = 14
and 200+10 = 210.

It shall looks like this:
==
Dynamite |  4  | 200
Lunt | 10 |  10
--
TOTAL| 14 | 210

It is easy to register this product by product on their own row.
but in what way can I multiply them? ned products be stored in arrays?
I think it will be similar to shopping cart in online store but i have no
clue about how to do this.
If you have links to pages were i can learn am i Happy for it. If you can
help me here is even better.

Thanks for your time and effort to learn me programming.

Karl




-- 
Hjemmeside: http://www.karl-arne.name/


Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
2013/7/10 Jim Giner 

> On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote:
>
>> Sorry, the first mail in this subject run out for me. This is an updated
>> one.
>>
>>
>>
>> I am almost ready with my learning project in PHP/MySQL.
>> I can register new product in stock.
>> Add and increase the number and weight.
>> I can move products between different storehouses
>> I can also transfer products from store and onto a "truck document" but
>> that's it and here I need some advice.
>>
>> I like to register new products and the amount in number (for example 4)
>> and weight in kg.
>>
>> I like to write it in this way:
>> Dynamite - package 4 - Weight 200 kg
>> Lunt - Package 10 - Weight 10kg
>>
>> Then I like to 4+10 = 14
>> and 200+10 = 210.
>>
>> It shall looks like this:
>> ==**
>> Dynamite |  4  | 200
>> Lunt | 10 |  10
>> --**--**--
>> TOTAL| 14 | 210
>>
>> It is easy to register this product by product on their own row.
>> but in what way can I multiply them? ned products be stored in arrays?
>> I think it will be similar to shopping cart in online store but i have no
>> clue about how to do this.
>> If you have links to pages were i can learn am i Happy for it. If you can
>> help me here is even better.
>>
>> Thanks for your time and effort to learn me programming.
>>
>> Karl
>>
>>
>>
>>
>>  Ahhh.
>
> So - you should run a query that selects the products and information that
> you want.  Then you start by creating an html table header and then loop
> through your query results and echo a table row for each result row.
>
> // start the table
> echo "";
> echo "Product**Amount";
>
> // loop thru each item found
> while ($results = $qrslts->fetch(PDO::FETCH_**ASSOC))
> {
>echo "".$results['product_**name']."".$results['**
> product_amt']."";
> }
>
> // finish the table html
> echo "

Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...

2013-07-10 Thread Karl-Arne Gjersøyen
2013/7/10 Lester Caine 

> Karl-Arne Gjersøyen wrote:
>
>> // start the table
>>>
>>
> $total = 0;
>
>  >echo "";
>>> >echo "ProductAmount";
>>>
>>> >
>>> >// loop thru each item found
>>> >while ($results = $qrslts->fetch(PDO::FETCH_ASSOC))
>>> >{
>>> >echo "".$results['product_name']."".$results['
>>> 
>>> >product_amt']."";
>>>
>> $total += $results['product_amt']
>
>> >}
>>> >
>>>
>>
> echo "Total:".$**total."";
>
>
>  >// finish the table html
>>> >echo ">>
>>
>> Yes that part is OK. I do have problem to add total weight and package at
>> bottom of the table like this:
>>
>> Product_one   40kg
>> Product_two   60kg
>> -
>> Total: 100kg
>> ===
>>
>
>
Thank you very Much, Both of you Jim and Lester!
You are amazing, folks!

Karl


[PHP] Split/Group date together.

2013-07-18 Thread Karl-Arne Gjersøyen
Hello again.
In my program I have this:

mysql> SELECT * FROM transportdokument WHERE dato >= '16/7/2013' AND dato
<= '18/7/2013';

This list all reccrds for 3 days. I need a way to split it up for every day
even when the requst is as above and don't know in what way I can do it.

I like to have all records for day 16 in one table in PHP/HTML and all
records for day 17 in another table.
i.e, Day 16 have 5 rows and day 17th and 18th have 7 and 8 rows.

I hope for your help and advice to do also this correct.

Thank you for your time and effort!

Karl


[PHP] Foreach and mydql_query problem

2013-07-21 Thread Karl-Arne Gjersøyen
Hello again.
I have this this source code that not work as I want...

THe PHP/HTHML form fields is generated by a while loop and looks like this:

" required="required">


the php source code look like this:
";

$sql = "UPDATE item_table SET number_item = '$item' WHERE date
= '$todays_date' AND sign = '$username'";
mysql_query($sql,$connect) or die(mysql_error());
 }
}

?>

The problem is:
Foreach list every items as expected in PHP doc and I thought that $sql and
mysql_query should be run five times when I have five items.
But the problem is that only the very last number_of_items is written when
update the form..
I believe this is becayse number_of_items = '$item in $sqk override every
earlier result.

So my querstion is. How to to update the database in this case?

Thanks again for your good advice  and time to help me.

Karl'


Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Tamara Temple 

>
> On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen 
> wrote:
>
> > Hello again.
> > I have this this source code that not work as I want...
> >
> > THe PHP/HTHML form fields is generated by a while loop and looks like
> this:
> >
> > " required="required">
> >
> >
> > the php source code look like this:
> >  > if(!empty($_POST['number_of_itemsi'])){
> >include('../../connect.php');
> >
> >foreach($number_of_items as $itemi){
> >echo "$itemi";
> >
> >$sql = "UPDATE item_table SET number_item = '$item' WHERE date
> > = '$todays_date' AND sign = '$username'";
> >mysql_query($sql,$connect) or die(mysql_error());
> > }
> > }
> >
> > ?>
> >
> > The problem is:
> > Foreach list every items as expected in PHP doc and I thought that $sql
> and
> > mysql_query should be run five times when I have five items.
> > But the problem is that only the very last number_of_items is written
> when
> > update the form..
> > I believe this is becayse number_of_items = '$item in $sqk override every
> > earlier result.
> >
> > So my querstion is. How to to update the database in this case?
> >
> > Thanks again for your good advice  and time to help me.
> >
> > Karl'
>
> Either the code you posted isn't the actual code, or if it is, the errors
> should be rather obvious. Post *actual* code.
>
>

// The acutual source code is below:
// ==
if(!empty($_POST['antall_kolli'])){
include('../../tilkobling.php');

foreach($antall_kolli as $kolli){
echo "$kolli";

//echo $kolli. "";
$sql = "UPDATE transportdokument SET antall_kolli_stk =
'$kolli' WHERE dato = '$dagens_dato' AND signatur = '$brukernavn'";
mysql_query($sql,$tilkobling) or die(mysql_error());
 }
}

// THE PHP/HTML Form below:
include('../../tilkobling.php');

$sql = "SELECT * FROM transportdokument WHERE dato = '$dagens_dato' AND
signatur = '$brukernavn'";
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
while($rad = mysql_fetch_array($resultat, MYSQL_ASSOC)){
$valgt_lager = $rad['valgt_lager'];
$un_nr = $rad['un_nr'];
$sprengstofftype = $rad['sprengstofftype'];
$varenavn = $rad['varenavn'];
$varenr = $rad['varenr'];
$antall_kolli = $rad['antall_kolli_stk'];
$adr_vekt_kg = $rad['adr_vekt_kg'];
$varenavn = $rad['varenavn'];
$emb = $rad['emb'];
?>


Sprengstoff,

1.1D
 


">
" required="required">

" required="required">


include('../../tilkobling.php');

$sql = "SELECT * FROM transportdokument WHERE dato = '$dagens_dato' AND
signatur = '$brukernavn'";
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
while($rad = mysql_fetch_array($resultat, MYSQL_ASSOC)){
$valgt_lager = $rad['valgt_lager'];
$un_nr = $rad['un_nr'];
$sprengstofftype = $rad['sprengstofftype'];
$varenavn = $rad['varenavn'];
$varenr = $rad['varenr'];
$antall_kolli = $rad['antall_kolli_stk'];
$adr_vekt_kg = $rad['adr_vekt_kg'];
$varenavn = $rad['varenavn'];
$emb = $rad['emb'];
?>


Sprengstoff,

1.1D
 


">
" required="required">

" required="required">




Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Stuart Dallas 

>
> On 22 Jul 2013, at 08:04, Tamara Temple  wrote:
>
> > On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen 
> wrote:
> >
> >> Hello again.
> >> I have this this source code that not work as I want...
> >>
> >> THe PHP/HTHML form fields is generated by a while loop and looks like
> this:
> >>
> >> " required="required">
> >>
> >>
> >> the php source code look like this:
> >>  >> if(!empty($_POST['number_of_itemsi'])){
> >>   include('../../connect.php');
> >>
> >>   foreach($number_of_items as $itemi){
> >>   echo "$itemi";
> >>
> >>   $sql = "UPDATE item_table SET number_item = '$item' WHERE date
> >> = '$todays_date' AND sign = '$username'";
> >>   mysql_query($sql,$connect) or die(mysql_error());
> >>}
> >> }
> >>
> >> ?>
> >>
> >> The problem is:
> >> Foreach list every items as expected in PHP doc and I thought that $sql
> and
> >> mysql_query should be run five times when I have five items.
> >> But the problem is that only the very last number_of_items is written
> when
> >> update the form..
> >> I believe this is becayse number_of_items = '$item in $sqk override
> every
> >> earlier result.
> >>
> >> So my querstion is. How to to update the database in this case?
> >>
> >> Thanks again for your good advice  and time to help me.
> >>
> >> Karl'
> >
> > Either the code you posted isn't the actual code, or if it is, the
> errors should be rather obvious. Post *actual* code.
>
> The error is rather obvious: it loops around an array running an update
> statement that will modify a single row in the table, so it's not
> surprising that it appears like only the last entry in the array has been
> stored.
>
> Yes, i know that only one a singe row is updated and that is the problem.
What can I do to update several rows at the same time?
Thank you very much for all your good adivce.

Karl


[PHP] Re: Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Tim Streater 

> On 22 Jul 2013 at 12:56, Karl-Arne Gjersøyen  wrote:
>
> > Yes, i know that only one a singe row is updated and that is the problem.
> > What can I do to update several rows at the same time?
>
> Which several rows? The row that will be updated is that (or those) that
> match your WHERE clause. Seems to me you should make sure your WHERE is
> correct.
>

Thanks, Tim.
Yes the form is generated in a while loop and have ">. This
field is in several product rows and when I update the form the foreach
loop write all (5) products correct. But the other way: Update actual rows
in the  database did not work. Only the latest row is updated..

Karl


Re: [PHP] Foreach and mydql_query problem

2013-07-22 Thread Karl-Arne Gjersøyen
2013/7/22 Stuart Dallas 

> On 22 Jul 2013, at 12:56, Karl-Arne Gjersøyen  wrote:
>
> > 2013/7/22 Stuart Dallas 
> >
> >>
> >> On 22 Jul 2013, at 08:04, Tamara Temple 
> wrote:
> >>
> >>> On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen 
> >> wrote:
> >>>
> >>>> Hello again.
> >>>> I have this this source code that not work as I want...
> >>>>
> >>>> THe PHP/HTHML form fields is generated by a while loop and looks like
> >> this:
> >>>>
> >>>> " required="required">
> >>>>
> >>>>
> >>>> the php source code look like this:
> >>>>  >>>> if(!empty($_POST['number_of_itemsi'])){
> >>>>  include('../../connect.php');
> >>>>
> >>>>  foreach($number_of_items as $itemi){
> >>>>  echo "$itemi";
> >>>>
> >>>>  $sql = "UPDATE item_table SET number_item = '$item' WHERE
> date
> >>>> = '$todays_date' AND sign = '$username'";
> >>>>  mysql_query($sql,$connect) or die(mysql_error());
> >>>>   }
> >>>> }
> >>>>
> >>>> ?>
> >>>>
> >>>> The problem is:
> >>>> Foreach list every items as expected in PHP doc and I thought that
> $sql
> >> and
> >>>> mysql_query should be run five times when I have five items.
> >>>> But the problem is that only the very last number_of_items is written
> >> when
> >>>> update the form..
> >>>> I believe this is becayse number_of_items = '$item in $sqk override
> >> every
> >>>> earlier result.
> >>>>
> >>>> So my querstion is. How to to update the database in this case?
> >>>>
> >>>> Thanks again for your good advice  and time to help me.
> >>>>
> >>>> Karl'
> >>>
> >>> Either the code you posted isn't the actual code, or if it is, the
> >> errors should be rather obvious. Post *actual* code.
> >>
> >> The error is rather obvious: it loops around an array running an update
> >> statement that will modify a single row in the table, so it's not
> >> surprising that it appears like only the last entry in the array has
> been
> >> stored.
> >>
> >> Yes, i know that only one a singe row is updated and that is the
> problem.
> > What can I do to update several rows at the same time?
> > Thank you very much for all your good advice.
>
> Are you sure you want to update several rows, or do you actually want to
> insert several rows?
>
> This is pretty basic database stuff, and is off-topic for this list.
>


OK. Sorry. I thought it was a PHP question for a way to update several
mysql rows by PHP code.

Karl


Re: [PHP] Foreach and mydql_query problem

2013-07-23 Thread Karl-Arne Gjersøyen
It works now and it was a php thing.When I combine a for and while loop
together with Limit in my query it works.
Karl

mandag 22. juli 2013 skrev Liam følgende:

> Shouldn't $_POST['number_of_itemsi'] be $_POST['number_of_items']
>
>
> Kind Regards,
>
> Liam.
> 3Sharp Ltd.
>
> T: 0845 6018370
> F: 0845 6018369
>
> -Original Message-
> From: Karl-Arne Gjersøyen [mailto:karlar...@gmail.com ]
> Sent: 22 July 2013 12:39
> To: PHP Mailinglist
> Subject: Re: [PHP] Foreach and mydql_query problem
>
> 2013/7/22 Tamara Temple >
>
> >
> > On Jul 22, 2013, at 1:19 AM, Karl-Arne Gjersøyen 
> > 
> >
> > wrote:
> >
> > > Hello again.
> > > I have this this source code that not work as I want...
> > >
> > > THe PHP/HTHML form fields is generated by a while loop and looks like
> > this:
> > >
> > > " required="required">
> > >
> > >
> > > the php source code look like this:
> > >  > > if(!empty($_POST['number_of_itemsi'])){
> > >include('../../connect.php');
> > >
> > >foreach($number_of_items as $itemi){
> > >echo "$itemi";
> > >
> > >$sql = "UPDATE item_table SET number_item = '$item' WHERE
> date
> > > = '$todays_date' AND sign = '$username'";
> > >mysql_query($sql,$connect) or die(mysql_error());
> > > }
> > > }
> > >
> > > ?>
> > >
> > > The problem is:
> > > Foreach list every items as expected in PHP doc and I thought that $sql
> > and
> > > mysql_query should be run five times when I have five items.
> > > But the problem is that only the very last number_of_items is written
> > when
> > > update the form..
> > > I believe this is becayse number_of_items = '$item in $sqk override
> every
> > > earlier result.
> > >
> > > So my querstion is. How to to update the database in this case?
> > >
> > > Thanks again for your good advice  and time to help me.
> > >
> > > Karl'
> >
> > Either the code you posted isn't the actual code, or if it is, the errors
> > should be rather obvious. Post *actual* code.
> >
> >
>
> // The acutual source code is below:
> // ==
> if(!empty($_POST['antall_kolli'])){
> include('../../tilkobling.php');
>
> foreach($antall_kolli as $kolli){
> echo "$kolli";
>
> //echo $kolli. "";
> $sql = "UPDATE transportdokument SET antall_kolli_stk =
> '$kolli' WHERE dato = '$dagens_dato' AND signatur = '$brukernavn'";
> mysql_query($sql,$tilkobling) or die(mysql_error());
>  }
> }
>
> // THE PHP/HTML Form below:
> include('../../tilkobling.php');
>
> $sql = "SELECT * FROM transportdokument WHERE dato = '$dagens_dato' AND
> signatur = '$brukernavn'";
> $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
> while($rad = mysql_fetch_array($resultat, MYSQL_ASSOC)){
> $valgt_lager = $rad['valgt_lager'];
> $un_nr = $rad['un_nr'];
> $sprengstofftype = $rad['sprengstofftype'];
> $varenavn = $rad['varenavn'];
> $varenr = $rad['varenr'];
> $antall_kolli = $rad['antall_kolli_stk'];
> $adr_vekt_kg = $rad['adr_vekt_kg'];
> $varenavn = $rad['varenavn'];
> $emb = $rad['emb'];
> ?>
> 
> 
> Sprengstoff, "$sprengstofftype"; ?>
> 
> 1.1D
>  
> 
> 
> ">
> " required="required">
> 
>  size="6" value="" required="required">
> 
>  $total_mengde_kg_adr += $rad['adr_vekt_kg'];
> $total_antall_kolli += $rad['antall_kolli_stk'];
> }
>
> ?>
> include('../../tilkobling.php');
>
> $sql = "SELECT * FROM transportdokument WHERE dato = '$dagens_dato' AND
> signatur = '$brukernavn'";
> $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
> while($rad = mysql_fetch_array($resultat, MYSQL_ASSOC)){
> $valgt_lager = $rad['valgt_lager'];
> $un_nr = $rad['un_nr'];
> $sprengstofftype = $rad['sprengstofftype'];
> $varenavn = $rad['varenavn'];
> $varenr = $rad['varenr'];
> $antall_kolli = $rad['antall_kolli_stk'];
> $adr_vekt_kg = $rad['adr_vekt_kg'];
> $varenavn = $rad['varenavn'];
> $emb = $rad['emb'];
> ?>
> 
> 
> Sprengstoff, "$sprengstofftype"; ?>
> 
> 1.1D
>  
> 
> 
> ">
> " required="required">
> 
>  size="6" value="" required="required">
> 
>  $total_mengde_kg_adr += $rad['adr_vekt_kg'];
> $total_antall_kolli += $rad['antall_kolli_stk'];
> }
>
> ?>
>


-- 
Hjemmeside: http://www.karl-arne.name/


[PHP] What wrong am I doing now?

2013-07-24 Thread Karl-Arne Gjersøyen
mysql> SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC;
+---+
| DATE_FORMAT(dato, '%e-%c-%Y') |
+---+
| 24-7-2013 |
| 23-7-2013 |
+---+
2 rows in set (0.00 sec)

mysql>


// My PHP code looks like this.
// -
$sql = "SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC";
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

while($rad = mysql_fetch_array($resultat)){
$dato = $rad['dato'];
var_dump($dato);

I gott NULL,NULL here and believe it is something with my PHP Source that
is wrong when using DATE_FORMAT. As you see above it work in terminal.

I hope this not is off-topic for the list. If so, I am sorry for it and
hope you can give me advice about a good MySQL list for newbie's.

Thanks again for your help!

Karl


[PHP] Fwd: What wrong am I doing now?

2013-07-24 Thread Karl-Arne Gjersøyen
http://www.php.net/manual/en/datetime.format.php have the solution. Sorry
for asking before I look at php.net!!!

Karl

-- Forwarded message --
From: Karl-Arne Gjersøyen 
Date: 2013/7/24
Subject: What wrong am I doing now?
To: PHP Mailinglist 


mysql> SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC;
+---+
| DATE_FORMAT(dato, '%e-%c-%Y') |
+---+
| 24-7-2013 |
| 23-7-2013 |
+---+
2 rows in set (0.00 sec)

mysql>


// My PHP code looks like this.
// -
$sql = "SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC";
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

while($rad = mysql_fetch_array($resultat)){
$dato = $rad['dato'];
var_dump($dato);

I gott NULL,NULL here and believe it is something with my PHP Source that
is wrong when using DATE_FORMAT. As you see above it work in terminal.

I hope this not is off-topic for the list. If so, I am sorry for it and
hope you can give me advice about a good MySQL list for newbie's.

Thanks again for your help!

Karl


[PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Karl-Arne Gjersøyen
Below is something I try that ofcourse not work because of rsosort.
Here is my code:
---
$lagret_dato = $_POST['lagret_dato'];
foreach($lagret_dato as $dag){

$dag = explode("/", $dag);
   rsort($dag);
$dag = implode("-", $dag);
var_dump($dag);

What I want is a way to rewrite contents of a variable like this:

>From 24/7/2013 to 2013-07-24

Is there a way in PHP to do this?

Thank you very much.

Karl


Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Karl-Arne Gjersøyen
2013/7/26 Davi Marcondes Moreira 

> Hi! I suggest you to try this:
>
> $foo = DateTime::createFromFormat('d/m/Y');
> $newDate = $foo->format('Y-m-d');
>


Thank you veyr much. With a small modification this work perfec!

Karl


>  Em 26/07/2013 09:19, "Karl-Arne Gjersøyen" 
> escreveu:
>
> Below is something I try that ofcourse not work because of rsosort.
>> Here is my code:
>> ---
>> $lagret_dato = $_POST['lagret_dato'];
>> foreach($lagret_dato as $dag){
>>
>> $dag = explode("/", $dag);
>>rsort($dag);
>> $dag = implode("-", $dag);
>> var_dump($dag);
>>
>> What I want is a way to rewrite contents of a variable like this:
>>
>> From 24/7/2013 to 2013-07-24
>>
>> Is there a way in PHP to do this?
>>
>> Thank you very much.
>>
>> Karl
>>
>


[PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Karl-Arne Gjersøyen
Hello again, folks!
I wish to delete records in my database that is older than 3 months.

$todays_date = date('Y-m-d');
$old_records_to_delete =  ???

if($old_records_to_delete){
include(connect.php);
$sql = "DELETE FROM table WHERE date >= '$old_records_to_delete'";
mysql_query($sql, $connect_db) or die(mysql_error());
}

Thank you very much for your help to understand also this question :)

Karl


Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Karl-Arne Gjersøyen
2013/8/2 Dušan Novaković 

> $query = "DELECT FROM `__table_name__` WHERE `__date__` BETWEEN NOW() -
> INTERVAL 3 MONTH AND NOW()"
>

This delete everything from now and 3months backwards. I want to store 3
months from now and delete OLDER than 3 months old records.

Karl


[PHP] Operand error...

2013-08-08 Thread Karl-Arne Gjersøyen
$oppdater_lager_med_antall_kg = $kg_pa_lager +
$kg_fra_transportdokument_inn_pa_valgt_lager;


result:
*Fatal error*: Unsupported operand types in *
/Users/karl/Sites/kasen/io/kp/index.php* on line *2970

*I have also tried this:
$kg_pa_lager += $kg_fra_transportdokument_inn_pa_valgt_lager;

Both of them return this Fatal error.
I am using Dreamweaver CS6 and the syntax check in my software say: "No
syntax error"

What am I doing wrong this time?

Thanks for your good advice!

Karl


Re: [PHP] Re: Operand error...

2013-08-08 Thread Karl-Arne Gjersøyen
2013/8/8 Jim Giner 

> On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:
>
>> $oppdater_lager_med_antall_kg = $kg_pa_lager +
>> $kg_fra_transportdokument_inn_**pa_valgt_lager;
>>
>>
>> result:
>> *Fatal error*: Unsupported operand types in *
>> /Users/karl/Sites/kasen/io/kp/**index.php* on line *2970
>>
>> *I have also tried this:
>>
>> $kg_pa_lager += $kg_fra_transportdokument_inn_**pa_valgt_lager;
>>
>> Both of them return this Fatal error.
>> I am using Dreamweaver CS6 and the syntax check in my software say: "No
>> syntax error"
>>
>> What am I doing wrong this time?
>>
>> Thanks for your good advice!
>>
>> Karl
>>
>>  You do a var_dump on each variable to see what type they were defined as.


NULL array(2) { [0]=> string(3) "100" [1]=> string(3) "340" }


Re: [PHP] Re: Operand error...

2013-08-08 Thread Karl-Arne Gjersøyen
2013/8/8 Jim Giner 

> On 8/8/2013 1:43 PM, Karl-Arne Gjersøyen wrote:
>
>> 2013/8/8 Jim Giner 
>>
>>  On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:
>>>
>>>  $oppdater_lager_med_antall_kg = $kg_pa_lager +
>>>> $kg_fra_transportdokument_inn_pa_valgt_lager;
>>>>
>>>>
>>>>
>>>> result:
>>>> *Fatal error*: Unsupported operand types in *
>>>> /Users/karl/Sites/kasen/io/kp/index.php* on line *2970
>>>>
>>>>
>>>> *I have also tried this:
>>>>
>>>> $kg_pa_lager += $kg_fra_transportdokument_inn_pa_valgt_lager;
>>>>
>>>>
>>>> Both of them return this Fatal error.
>>>> I am using Dreamweaver CS6 and the syntax check in my software say: "No
>>>> syntax error"
>>>>
>>>> What am I doing wrong this time?
>>>>
>>>> Thanks for your good advice!
>>>>
>>>> Karl
>>>>
>>>>   You do a var_dump on each variable to see what type they were defined
>>>> as.
>>>>
>>>
>>
>> NULL array(2) { [0]=> string(3) "100" [1]=> string(3) "340" }
>>
>>  That is one var. What is the other var?


Thank you very much!
Now I know the error.. One of those variables are NULL! When I fix it I
think it work!

Karl


Re: [PHP] Re: Operand error...

2013-08-08 Thread Karl-Arne Gjersøyen
2013/8/8 Jim Giner 

> On 8/8/2013 1:56 PM, Karl-Arne Gjersøyen wrote:
>
>> 2013/8/8 Jim Giner 
>>
>>  On 8/8/2013 1:43 PM, Karl-Arne Gjersøyen wrote:
>>>
>>>  2013/8/8 Jim Giner 
>>>>
>>>>   On 8/8/2013 1:32 PM, Karl-Arne Gjersøyen wrote:
>>>>
>>>>>
>>>>>   $oppdater_lager_med_antall_kg = $kg_pa_lager +
>>>>>
>>>>>> $kg_fra_transportdokument_inn_**pa_valgt_lager;
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> result:
>>>>>> *Fatal error*: Unsupported operand types in *
>>>>>> /Users/karl/Sites/kasen/io/kp/**index.php* on line *2970
>>>>>>
>>>>>>
>>>>>>
>>>>>> *I have also tried this:
>>>>>>
>>>>>> $kg_pa_lager += $kg_fra_transportdokument_inn_**pa_valgt_lager;
>>>>>>
>>>>>>
>>>>>>
>>>>>> Both of them return this Fatal error.
>>>>>> I am using Dreamweaver CS6 and the syntax check in my software say:
>>>>>> "No
>>>>>> syntax error"
>>>>>>
>>>>>> What am I doing wrong this time?
>>>>>>
>>>>>> Thanks for your good advice!
>>>>>>
>>>>>> Karl
>>>>>>
>>>>>>You do a var_dump on each variable to see what type they were
>>>>>> defined
>>>>>> as.
>>>>>>
>>>>>>
>>>>>
>>>> NULL array(2) { [0]=> string(3) "100" [1]=> string(3) "340" }
>>>>
>>>>   That is one var. What is the other var?
>>>>
>>>
>>
>> Thank you very much!
>> Now I know the error.. One of those variables are NULL! When I fix it I
>> think it work!
>>
>> Karl
>>
>>  actually, the null is ok I think.  The array is wrong - you can't 'add'
> an array to a scalar variable, which an integer or null is.


Yes, it is me and arrays again :D

$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
$antall = mysql_num_rows($resultat);
for($i = 0; $i < $antall; $i++){
$rad = mysql_fetch_array($resultat, MYSQL_ASSOC);

and write it tis way can perhaps make someting more correct?
For example $variable[$i] ?

Karl


[PHP] List problem again...

2013-08-09 Thread Karl-Arne Gjersøyen
In my HTML5/PHP form I have this two rows..

0082Exan ELEXE25NO200
 0081Dynamit -
papirpatron - 22x180EDY22X180K100
   
 
Then I have this in PHP source to handle it...

$antall_varenr = count($varenr_inn_pa_lager);
$i = 0;
if($i < $antall_varenr){

foreach($varenr_inn_pa_lager as $vnr){
echo "$vnr";
}
}
++$i;

This source code get the serialnumber ($varenr_inn_pa_lager).
The problem I struggling with is that it is two different products.
The product with serialnumber "LEXE25NO" is named Exan and the other
product with serialnumber "EDY22X180K" is Dynamite.
I need a way to extract products and put them into their own table.
The database have one table for Exan and another table for Dynamite,
and I recive products for both at the same time. I do not know where
to start for put product in their own table knowing by their own
serialnumber.

I think this is a list problem but need some help to understand this stuff.

Thank you very much. I am very thankful for all your help.

Karl


[PHP] Ambiguous?

2013-08-09 Thread Karl-Arne Gjersøyen
1) query
foreach($varenr_inn_pa_lager as $vnr){
include('../../tilkobling.php');
$sql = "SELECT * FROM exan,dynamit WHERE varenr = '$vnr' LIMIT
1";
$resultat = mysql_query($sql, $tilkobling) or
die(mysql_error());

2) Result:
Column 'varenr' in where clause is ambiguous

3) Tables in MySQL database

mysql> SELECT * FROM exan;
++-+---+--+--+-+
| leverandor | valgt_lager | un_nr | varenavn | varenr   | kg_pa_lager |
++-+---+--+--+-+

mysql> SELECT * FROM dynamit;
++-+---++---+-++-+
| leverandor | valgt_lager | type  | dim_mm | un_nr |
varenavn| varenr | kg_pa_lager |
++-+---++---+-++-+

4) My question:
What means with "ambiguous" here?

Thanks.
Karl


[PHP] Pear Auth problem

2012-03-21 Thread Karl-Arne Gjersøyen
Hello.
I am trying to use pear Auth packet but am doing something wrong.
I am currently looking at the simple example in the documentation, but
something is wrong in my source code, because if I write a username
and a password in the fields and hit the submit button, I receive a
blank pages without any informatio at all..

Here is my source code:
---




  
Login:

Username:



Password:








 "mysql://username:password@localhost/database",
);
$a = new Auth("DB", $options, "loginFunction");
$a->start();

if($a->checkAuth()){
header("Location: http://www.karl-arne.name/";);
}
}   
?>

The example is located at:
http://pear.php.net/manual/en/package.authentication.auth.intro.php

Thanks for your time.
Karl

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



[PHP] PEAR_Error reporting

2012-03-21 Thread Karl-Arne Gjersøyen
Hello.
I ran into trouble with a PEAR module and got only a blank (empty)
page after filling in a loginform with PEAR::Auth
I have error reporting in php.ini that create ordinary error message
on my CentOS box, but it do not write error message when using PEAR.
In a book I have is PEAR_Error mention, but it did not explain how to
get it or run it.

If you can help me in this question I am thankful for your time.

Karl

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



[PHP] Att: saeed ahmed

2012-03-31 Thread Karl-Arne Gjersøyen
Try this:

mysql> CREATE DATABASE addressbook;
Query OK, 1 row affected (0.00 sec)

mysql> USE addressbook;
Database changed

mysql> CREATE TABLE userData(id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 firstName VARCHAR(50) NOT NULL,
 lastName VARCHAR(50) NOT NULL,
 telephone INT(12) NOT NULL,
 email VARCHAR(100) NOT NULL);
Query OK, 0 rows affected (0.11 sec)

Now when you have the databse created and a table to store data, you
need to write a PHP page that do the trick.
Here is a simpe sample. Read all comments and look at the source code...

http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en">


Addressbook







   Contact info:
   
   First Name:
   
   
   
   Last Name:
   
   
   
   Telephone:
   
   
   
   Email Address:
   
   
   
   
   




The Contact information is registred";
}
?>

View Contact Info

First Name: $firstName";
echo "Last Name: $lastName";
echo "Telephone: $telephone";
echo "Email: $email";
echo "";
}
}

?>



Hope this can be in help for you.

Karl
-- 
Hjemmeside: http://www.karl-arne.name/



Den 08:45 31. mars 2012 skrev saeed ahmed  følgende:
> i have made a php script with a tutorial helpi dont know where is a
> error.please have a look
>
>
>  //connect and select a database
> mysql_connect("localhost","root"," " );
> mysql_select_db("addressbook");
> //Run a query
> $result=mysql_query("select("SELECT*FROM COLLEAGUE");
> ?>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> Address Book
>  
> 
> Address Book
>  summary="table holda colleague contacts information">
> 
>  ID
> First Name
> Last Name
> Telephone
> Email Address
> 
>  //LOOP through all table rows
> while ($row=mysql_fetch_array($result)) {
> echo"";
> echo"".$row['id'] . ";
> echo "" . $row['firstName'] . "";
> echo "" . $row['lastName'] . "";
> echo "" . $row['telephone'] . "";
> echo "" . Srow['email'] . " echo"";
> }
> //free result memory and close database connection
> mysql_free_result($result);
> mysql_close();
> ?>
> 
> 
> 
> thanks

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



[PHP] Test, trying to send to NEWSGROUP

2004-02-16 Thread Jon Arne Jørgensen


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


[PHP] RE: [PHP-DB] & [PHP] .htpasswd?

2001-02-04 Thread Thor Arne Madland

Hi,

you might want to take a look at this one:

http://www.thewebmasters.net/php/Htpasswd.phtml

Works in both php3 and php4.

Give you functions for adding/deleting/listing/renaming users + much more,
in standard .htpaccess password files.
I use it myself on several sites, it works great.

- t.a.madland -

--- original
message --

From: Cody Caughlan [mailto:[EMAIL PROTECTED]]
Sent: 5. februar 2001 04:53
To: Victor Foitzik; php-db
Subject: Re: [PHP-DB] .htpasswd?


You could also run something like:

system("htpasswd -b passwordilf $user $password"),,,basically get the shell
to
run a the htpasswd program supplied by apache. you might have to play around
with the permissions to do this, so the webserver can execute the htpasswd
binary.

/cody caughlan

Victor Foitzik wrote:

> James Smith wrote:
>
> >Is there a way that when a user signs up for a
> >user/pass on a site, to automatically update the
> >.htpasswd on the site?  Right now I'm running a Win2k
> >Pro, with Apache installed and MySQL/PHP.
> >
> >Thanks,
> >
> >James
>
> The quite simpliest method is to put appropriate directives in a .htaccess
> file in appropriate (e.g. to be protected) directories like this:
>
> AuthName "Restricted Area"
> AuthUserFile /www/users/users
> AuthGroupFile /www/users/groups
> AuthType Basic
> Require registeredusers
>
> Then all you have to do is to regenerate the user and the group file
> according to your needs.
>
> Another way to do this directly with MySQL is to use the apache auth_mysql
> module which allows you to store authentication data in a MySQL DB. See
> http://mysql.com/downloads/contrib.html
> and
> http://httpd.apache.org/docs/misc/FAQ-G.html
> for more info.
>
> HTH
> Victor
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]