Derleek Posted June 10, 2008 Share Posted June 10, 2008 i am basically wondering what the syntax for a MySQL command that is the same as $variable+= 5; in php... $upPoints = "UPDATE fans SET pPoints= pPoints+'$totalPoints' WHERE id = '$guy'"; doesn't seem to be working... Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/ Share on other sites More sharing options...
luca200 Posted June 10, 2008 Share Posted June 10, 2008 doesn't seem to be working... what do you mean by this? Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-561860 Share on other sites More sharing options...
Barand Posted June 10, 2008 Share Posted June 10, 2008 do you execute the query and check for errors? mysql_query ($upPoints) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-561901 Share on other sites More sharing options...
Derleek Posted June 10, 2008 Author Share Posted June 10, 2008 yeah, i got the standard error message... SQL syntax error or whatever Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-562380 Share on other sites More sharing options...
Barand Posted June 10, 2008 Share Posted June 10, 2008 That's why it doesn't work, then. Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-562410 Share on other sites More sharing options...
luca200 Posted June 10, 2008 Share Posted June 10, 2008 yeah, i got the standard error message... SQL syntax error or whatever Do you think posting the actual error could help or think we all are geniuses of the lamp? Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-562508 Share on other sites More sharing options...
fenway Posted June 11, 2008 Share Posted June 11, 2008 yeah, i got the standard error message... SQL syntax error or whatever Why the single quotes around your PHP variable? Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-563045 Share on other sites More sharing options...
revraz Posted June 11, 2008 Share Posted June 11, 2008 Not really a "standard" error, it will state what the actual error is. yeah, i got the standard error message... SQL syntax error or whatever Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-563125 Share on other sites More sharing options...
Derleek Posted June 11, 2008 Author Share Posted June 11, 2008 sorry about the lack of activity. as it turns out I was trying to update and add to a null value... which doesn't work to well in addition, i put the ' ' around my php variables because i thought they were needed for some reason.. guess not eh? Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-563186 Share on other sites More sharing options...
revraz Posted June 11, 2008 Share Posted June 11, 2008 If it's a string you do, if it's a number/int you don't. Link to comment https://forums.phpfreaks.com/topic/109487-solved-adding-a-number-to-an-existing-number-in-mysql/#findComment-563191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.