|
Posted by Edward Vermillion on 07/20/05 18:08
Matt Darby wrote:
> It *is* a great book (I cut my teeth with it as well):
> PHP and MySQL Development (Welling and Thomson)
> http://www.amazon.com/exec/obidos/tg/detail/-/0672326728/qid=1121869940/sr=8-1/ref=pd_bbs_1/002-5827183-4477639?v=glance&s=books&n=507846
>
>
> Read it, learn it, live it.
>
> Matt Darby
>
> 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!
>>
>>
>>
>
Honestly, the best "book" I read when I was starting out, and one I've
been using ever since, is the manual. I actually spent $ on a very good
php book but I think I've only cracked the cover on it once or twice in
two years.
Way to go manual guys! :D
Navigation:
[Reply to this message]
|