Re: My Project

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay Blanchard wrote:

[snip]
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.
[/snip]

Anyone else want to go for shorter? :)

The reason is George, as someone so aptly pointed out, it appears that
you have jumped in without any basic knowledge. And thus far we have all
been nice (because we usually get chided for our terseness). So let me
be the first to say RTFM, STFW and STFA and get a better book such as
PHP and MySQL Development (Welling and Thomson) or one of a dozen
others. Google for PHP tutorials. Read them, try them, learn them. Now
let me explain where you went wrong above....

Your table needs two columns, one for money and one for characterName.
Make money decimal(8,2) and characterName char(64) then do the following
query

INSERT INTO `money` (`money`, `characterName`) VALUES ('100.00',
'Village_Id10t');

Now do a select from the table to see the values entered. See them?
Good!

Now perform the following query;

$sqlUpdate = "UPDATE `money` SET `money` =
(`money`-10) WHERE `characterName` = `Village_Id10t` ";
$doUpdate = mysql_query($sqlUpdate, $myConnection);

Now do a select again and look at the values, did it work? Excellent!
Run this query;

$sqlUpdate = "UPDATE `money` SET `money` =
(`money`-10) WHERE `characterName` = `Town_Drunk` ";
$doUpdate = mysql_query($sqlUpdate, $myConnection);

Now do a select from the table and note that the value of money did not
change. The reason is because there is no Town_Drunk in the money table.
Does that make sense? Wonderful!

lol, jay that was beautiful

Both the PHP and MySQL manuals are great tools and should be consulted first. Youe ambition is nice, but you will get nowhere if you do not learn how to do these things on your own.
--jzf

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux