28, August 2008

Could anyone tell me how to...? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Could anyone tell me how to...?
« previous next »
Pages: 1 [2] Print

Author Topic: Could anyone tell me how to...?  (Read 1377 times)
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #20 on: Jan 25, 2007, 03:54:22 PM »

Alright, it happened that I translated the file to english to post it here, but it seems that I forgot to translate back to spanish a variable... my bad.
Anyway, the query is still not working. S:
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #21 on: Jan 25, 2007, 04:03:55 PM »

It didn't show anything. mhmmm...

check the var names in your URL:

...189.153.101.203/lagunadesign/recibir_pago.php?cliente=eliezer.com&monto=127


Last blog : Is your website is down? Know before your visitors do!
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #22 on: Jan 25, 2007, 04:17:57 PM »

That's alright now. I realized that if I exchange the '," marks, so the query looks like this:
Code:
$sql="UPDATE clientes SET saldo = saldo - " . (int)$_GET['monto'] . " WHERE

id_cliente=" . $id_cliente . "";
then I get this error:
Unknown column 'eliezer.com' in 'where clause'

I don't know why it's taking the value as a column it has the equal mark and everything.
« Last Edit: Jan 25, 2007, 04:19:37 PM by eliezer »
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #23 on: Jan 25, 2007, 04:23:32 PM »

because you have to place strings into SINGLE quotes:

$sql="UPDATE clientes SET saldo = saldo - " . (int)$_GET['monto'] . " WHERE

id_cliente= ' " . $id_cliente . " ' "; (remove the spaces and maybe you should use LIKE and not =)

and of course it is time start with some beginners tutorials, your problems are really mistakes made by newbies
« Last Edit: Jan 25, 2007, 04:26:06 PM by olaf »


Last blog : Is your website is down? Know before your visitors do!
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #24 on: Jan 25, 2007, 04:29:23 PM »

I love you. ( :
It worked!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #25 on: Jan 25, 2007, 04:29:34 PM »

here is also the sprintf version (and tell me what is better to read)
Code:
<?php
$sql
sprintf("UPDATE clientes SET saldo = saldo - %d WHERE id_cliente = '%s'"$_GET['monto'], $id_cliente);


btw. you need to validate the value $id_cliente to prevent SQL injections


Last blog : Is your website is down? Know before your visitors do!
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #26 on: Jan 25, 2007, 04:45:29 PM »

For some reason, if I use sprintf on 'saldo' column when I register a payment of 100.00 its gets off 200.00 from the balance. If I input 50.00 it gets 100.00 off, if I input 150.50 it gets 200 off.
It seems like it's taking the total to the closer integer.
Huh

MySQL 'saldo' column properties..
Code:
  `saldo` DECIMAL(10,2) NOT NULL,
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #27 on: Jan 25, 2007, 04:47:48 PM »

in this case you need this one:

<?php
$sql= sprintf("UPDATE clientes SET saldo = saldo - %f WHERE id_cliente = '%s'", $_GET['monto'], $id_cliente);


note the %f


Last blog : Is your website is down? Know before your visitors do!
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #28 on: Jan 25, 2007, 04:51:28 PM »

I would like to know what are those letters about. I guess they define arguments or something...
anyway...
last query does take the decimals exactly, BUT every amount I input it gets doubled.

( any amount ) * ( 2 )
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #29 on: Jan 25, 2007, 04:55:32 PM »

I would like to know what are those letters about. I guess they define arguments or something...
anyway...
last query does take the decimals exactly, BUT every amount I input it gets doubled.

( any amount ) * ( 2 )

www.php.net/sprintf Visit through proxy


Last blog : Is your website is down? Know before your visitors do!
OMG!I am geek
**
Gender: Male
Posts: 55
366 credits
Members referred : 0


my day will come..


« Reply #30 on: Jan 25, 2007, 05:02:32 PM »

Always in debt!!!  Smiley
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5738
Tags : math mysql operations balance account Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: 1 [2] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Could anyone tell me how to...?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Aug 28, 2008, 11:22:55 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.161
Total Topics: 7.461
Total Members: 3.855
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: givvig

38 Guests, 5 Users online :

17 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.