You are here: Re: [PHP] My Project « PHP « IT news, forums, messages
Re: [PHP] My Project

Posted by Robert Cummings on 07/20/05 05:03

On Tue, 2005-07-19 at 21:46, Jochem Maas wrote:
> Matt Darby wrote:
> > George B wrote:
> >
> >> Jay Blanchard wrote:
> >>
> >>> [snip]
> >>> $money -= 10;
> >>>
> >>> saves some chars ;)
> >>> [/snip]
> >>>
> >>> This actually requires two trips to the database, once to get $money and
> >>> once to update $money. Do it in the query instead...once.....
> >>>
> >>> $sqlUpdate = "UPDATE `myDatabase`.`myTable` SET `myMoney` =
> >>> (`myMoney`-10) WHERE `myCharacter` = `characterName` ";
> >>> $doUpdate = mysql_query($sqlUpdate, $myConnection);
> >>>
> >>> saves lots of characters ;)
> >>
> >>
> >> Hey, Look I made a new database just for this money testing stuff.
> >> This is the table:
> >>
> >> CREATE TABLE `money` (
> >> `money` varchar(255) NOT NULL default ''
> >> ) TYPE=MyISAM;
> >>
> >> Now, I use this code
> >>
> >> $sqlUpdate = "UPDATE `myDatabase`.`myTable` SET `myMoney` =
> >> (`myMoney`-10) WHERE `myCharacter` = `characterName` ";
> >> $doUpdate = mysql_query($sqlUpdate, $myConnection);
> >>
> >> And it should work, And it gives no error but it is not writing
> >> anything into the database.
> >>
> >
> > Lots of extra characters in that one... try this:
> >
> > $q=mysql_query("update myTable set myMoney=(myMoney-10) where
> > myCharacter='characterName'");
> > if(!$q){echo mysql_error();}
>
> so wasteful :-)
>
> $q=mysql_query("update u set m=(m-10) where c='$c'");if(!$q)die(mysql_error());

Ugh... ;)

if(!($q=mysql_query("update u set m=(m-10) where
c='$c'"))die(mysql_error());

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация