Venkat Venkataraju | 1 Jul 01:09 2006
Picon

Re: Update or add?

Hi All,

there is not-so-used format of SQL format that is

INSERT INTO table SET col1=data1, col2=data2... ON DUPLICATE KEY UPDATE 
col1=data1, col2=data2...;

you have to define a primary or unique key in the table and all will 
work well. for more info

http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html

Cheers
/V

Brian Dunning wrote:
> I have a table where I want to update each record with today's date as 
> it's hit, or add the record if it's not in there:
> 
> +------+-----------------+------------+
> |  id  |  creation_date  |  last_hit  |
> +------+-----------------+------------+
> 
> I'm trying to do this with a minimum of hits to the db, so rather than 
> first searching to see if a matching record is in there, I thought I'd 
> just go ahead and update the matching record, check to see if it failed, 
> and if it failed then add a new one, like this:
> 
> $id = $_GET['id'];
> // Update
(Continue reading)

tedd | 1 Jul 01:26 2006

RE: Multiple "if()" statements

At 4:26 PM +0100 6/30/06, Ford, Mike wrote:
>On 30 June 2006 13:37, tedd wrote:
>
>> At 11:07 PM -0600 6/29/06, John Meyer wrote:
>> > Larry Garfield wrote:
>> > >
>> > >[1] switch is fine if your elseif comparisons are equality
> > based.  If they're not equality based, then they don't map to
>> switch as well.
>> >
> > > [2] In other words, if you look at a logical ladder as the roots
> > of the tree, as long as each root has the same number of
>> forks (say each fork ends only one way), your fine with a
>> switch.  If you have one, however, that has only one
>> condition, and another that has  two, then you need an
>> if...elseif logic tree.
>>
>> Interesting -- can you give me an example?
>
>How about this -- a paraphrase of which occurs in many of my scripts:
>
>   if (isset($_POST['id'])):
>      $id = $_POST['id'];
>      // etc. -- other initializations based on $id
>   elseif ($_POST['action']=='add'):
>      $id = generate_id();
>      // initialize stuff to empty values
>   elseif (potential_other_test_to_detect_other_valid_states()):
>      // other stuff
>   else:
(Continue reading)

chris smith | 1 Jul 02:52 2006
Picon

Re: mysqli_stmt::bind_param(), Number of variables doesn't match number of parameters in prepared statement

On 7/1/06, gg15 <gg15 <at> gmx.net> wrote:
> I wanted to use the prepared statements of mysqli, but the following
> problem occured:
>
> If I just use one parameter everything works fine
> $prep = $this->mysqli->prepare('INSERT INTO guestbook (Von, Datum)
> VALUES (?, NOW())');
> $prep->bind_param('s', $this->Von);
>
> but if I try to use two
> $prep = $this->mysqli->prepare('INSERT INTO guestbook (Von, Betreff,
> Datum) VALUES (?, ?, NOW())');
> echo $prep->param_count; // echos 2
> $prep->bind_param('ss', $this->Von, $this->Betreff);
>
> I get an error
> Warning: mysqli_stmt::bind_param() : Number of variables doesn't
> match number of parameters in prepared statement in ...

Is $this->Betreff empty? I wonder if its having issues with an empty var..

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--

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

(Continue reading)

Martin Alterisio | 1 Jul 06:26 2006
Picon

Re: Sad PHP Poem

2006/6/26, Martin Alterisio <malterisio777 <at> gmail.com>:
>
> <offtopic type="slightly offtopic" class="poetic literary">
>
> A sad poem of an algorithm where solitude brought excessive use of cpu
> cycles and memory allocation for redundant data (it copied over and over
> again the same image till all memory was filled with it)
>
> ------------------------------
>
> $timeWaiting = 0;
> while (!$you->near($me)) {
>   $me->thinkAbout($you);
>
>   switch (true) {
>     case $timeWaiting < 5:
>       $me->wait($you);
>       break;
>
>     case $timeWaiting < 10:
>       $me->worry();
>       break;
>
>     case $timeWaiting < 20:
>       $me->lookFor($you) ;
>       break;
>
>     case $timeWaiting < 40:
>       $me->worry();
>        $me->lookFor($you) ;
(Continue reading)

BBC | 1 Jul 11:23 2006
Picon

Re: ONE PAGE CONNECTS MANY DATABASE

Yes I'm using MySQL and the DataBases I mean are in different servers 
but the problem is I don't know how to set the host.
All input will be very helpful...

----- Original Message ----- 
From: "Brad Bonkoski" <bbonkoski <at> mediaguide.com>
To: "BBC" <bbc_danang <at> telkom.net>
Cc: "PHP" <php-general <at> lists.php.net>
Sent: Friday, June 30, 2006 11:07 AM
Subject: Re: [PHP] ONE PAGE CONNECTS MANY DATABASE

> Yes.
> For Mysql..
> http://www.php.net/manual/en/function.mysql-connect.php
> 
> -B
> 
> BBC wrote:
> 
> >Hi again..
> >
> >I'm wondering is it possible to make one page which connects to many
> >DataBase?
> >
> >If it's possible please tell me where can I get the references?
> >
> >Thank
> >
> >                     Best Regards
> >============BBC============
(Continue reading)

BBC | 1 Jul 11:45 2006
Picon

IMAGECOPYRESIZED(); DOESN'T WORK...

I thought I have typed this function correctly, and I didn't know why my
browser couldn't run these script :
<?php
$filename = 'test.jpg';
$percent = 0.5;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);  //1*ERROR
$source = imagecreatefromjpeg($filename);              //2*ERROR
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width,
$height); //3*ERROR
imagejpeg($thumb);
?>
and the error output is : "call to undefined function"
btw, I'm using PHP 4.1.1. Is there any possible that my PHP version can not
run those script?
So, what is the best solution for my problem..?

                     Best Regards
============BBC============
                     **o<0>o**

--

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

BBC | 1 Jul 11:45 2006
Picon

Re: ONE PAGE CONNECTS MANY DATABASE

Yes I'm using MySQL and the DataBases I mean are in different servers 
but the problem is I don't know how to set the host.
All input will be very helpful...

----- Original Message ----- 
From: "Brad Bonkoski" <bbonkoski <at> mediaguide.com>
To: "BBC" <bbc_danang <at> telkom.net>
Cc: "PHP" <php-general <at> lists.php.net>
Sent: Friday, June 30, 2006 11:07 AM
Subject: Re: [PHP] ONE PAGE CONNECTS MANY DATABASE

> Yes.
> For Mysql..
> http://www.php.net/manual/en/function.mysql-connect.php
> 
> -B
> 
> BBC wrote:
> 
> >Hi again..
> >
> >I'm wondering is it possible to make one page which connects to many
> >DataBase?
> >
> >If it's possible please tell me where can I get the references?
> >
> >Thank
> >
> >                     Best Regards
> >============BBC============
(Continue reading)

sempsteen | 1 Jul 11:58 2006
Picon

Re: global class instance

> i don't want to:
>    - declare global $foo,

there is a mistake. it was not global $foo, it is global $a
:)

--

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

chris smith | 1 Jul 12:06 2006
Picon

Re: IMAGECOPYRESIZED(); DOESN'T WORK...

On 7/1/06, BBC <bbc_danang <at> telkom.net> wrote:
> I thought I have typed this function correctly, and I didn't know why my
> browser couldn't run these script :
> <?php
> $filename = 'test.jpg';
> $percent = 0.5;
> header('Content-type: image/jpeg');
> list($width, $height) = getimagesize($filename);
> $newwidth = $width * $percent;
> $newheight = $height * $percent;
> $thumb = imagecreatetruecolor($newwidth, $newheight);  //1*ERROR
> $source = imagecreatefromjpeg($filename);              //2*ERROR
> imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width,
> $height); //3*ERROR
> imagejpeg($thumb);
> ?>
> and the error output is : "call to undefined function"
> btw, I'm using PHP 4.1.1. Is there any possible that my PHP version can not
> run those script?
> So, what is the best solution for my problem..?

PHP doesn't have the GD library installed or loaded.

Create a phpinfo page:

<?php
phpinfo();
?>

there needs to be a big "GD" section.
(Continue reading)

chris smith | 1 Jul 12:07 2006
Picon

Re: ONE PAGE CONNECTS MANY DATABASE

On 7/1/06, BBC <bbc_danang <at> telkom.net> wrote:
> Yes I'm using MySQL and the DataBases I mean are in different servers
> but the problem is I don't know how to set the host.
> All input will be very helpful...

Read the documentation, it's all there.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--

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


Gmane