[SOLVED] check one row one column, insert int into same row

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

feyd

Post by fresh »

were you guys holding that info back on purpose... lol, your going to give me grey hair man... :) thanks alot for your help feyd and weirdan, you guys got it working for me... regards

hey by the way could you show me how to add to it, right now it's just over writing:

Code: Select all

<?php
require('dbconnect.php');
require('check_login.php');
$pts = 100;
$uname = $_GET['uname'];
$pass = $_GET['pass'];
if($pass != "test") {

die("wrong");

} else {
$sob = "SELECT users FROM points WHERE username='".$uname."'";
$sql = "UPDATE users SET points='".$sob."+".$pts."' WHERE username='".$uname."'";
$sun = @mysql_query($sql) or die(mysql_error());

echo "<center>".$sun."</center>"; 
}
?>
thanks alot :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what's the point of the $sob variable you have in that?
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

...

Post by fresh »

to get the value of the point row for that specific user... what would you do??

edit: do you mean whats the sob stand for??? haha select or bust :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$sql = "UPDATE `users` SET `points` = `points`+ {$pts} WHERE `username` = '{$uname}'";
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

yes

Post by fresh »

finally, after 6 hours or so, I finally successfully updated the right row with the right outcome!! Thanks to feyd and weirdan for putting up with me, feyd i need to read the same books you do, I would never of thought to code that like you did with the brackets and such... like always I appreciate the help and learning experience ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the only book I "read": http://php.net
Post Reply