/    Sign up×
Community /Pin to ProfileBookmark

modify user that is logged in

Hi all i am trying to update the currant logged in users details,

i select the info from the database with this?

[code=php]<?
//SQL QUERY TO SELECT THE USER LOGGED IN
$sql2 = “SELECT FROM users WHERE username = ‘”. $_SESSION[‘uname’] .”‘”;
$sql2 = mysql_query($sql2);

//WHILE USERS ARE IN THE DATABASE DO THE FOLLOWING
while($result2 = mysql_fetch_assoc($sql2)) { ?>[/code]

Then list and populate the feilds with this data like so

[code=php]<input value=”<?php print($result2[‘name’]); ?>” type=”text” style=”width:260px” name=”name” tab-index=”1″></php>

then alter the the table with this code

[code=php] $putinguestbook=”UPDATE users SET
name = $name,
email = $email,
username = $username,
password = $password,
perms = $perms,
phone1 = $phone1,
phone2 = $phone2,
address = $address,
city = $city,
country = $country,
served = $served,
unit = $unit,
snumber = $snumber,
year = $year,
rank = $rank,
partner = $partner,
comments = $comments WHERE id = ‘”. $_SESSION[‘uname’] .”‘ “;
mysql_query($putinguestbook);[/code]

BUT I GET THIS ERROR

[code]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/sheldon/public_html/test/mva/modify.php on line 14[/code]

Attached is the file, can any one tell me what is wrong???

Thanks Sheldon

[upl-file uuid=f8de2ba6-57c2-4a40-a95b-805f18ef7bb5 size=3kB]modify.zip[/upl-file]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@artoAug 16.2005 — Your query is invalid, because you didn't specify columns to select: [code=php]SELECT * FROM...[/code]Arto
Copy linkTweet thisAlerts:
@ffurnaiAug 16.2005 — Your query is invalid, because you didn't specify columns to select: [code=php]SELECT * FROM...[/code]Arto[/QUOTE]

I don't think that's it.

How about doing away with the variable for the query and just have

[code=php]
<?php

$result = mysql_query("UPDATE users SET
name = '$name',
email = '$email',
username = '$username',
password = '$password',
perms = '$perms',
phone1 = '$phone1',
phone2 = '$phone2',
address = '$address',
city = '$city',
country = '$country',
served = '$served',
unit = '$unit',
snumber = '$snumber',
year = '$year',
rank = '$rank',
partner = '$partner',
comments = '$comments' WHERE id = '$_SESSION['uname']' ");
?>
[/code]


<shrug>I also put in single quotes around your variables for the field values.</shrug>
Copy linkTweet thisAlerts:
@SheldonauthorAug 17.2005 — ill change that but the error is with the first part of the code?
[code=php]<?
//SQL QUERY TO SELECT THE USER LOGGED IN
$sql2 = "SELECT FROM users WHERE username = '". $_SESSION['uname'] ."'";
$sql2 = mysql_query($sql2);

//WHILE USERS ARE IN THE DATABASE DO THE FOLLOWING
while($result2 = mysql_fetch_assoc($sql2)) { ?>[/code]



Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/sheldon/public_html/test/mva/modify.php on line 14


Thanks Sheldon
×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...