UPDATING database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

UPDATING database

Post by anthony88guy »

When I try and update the database, nothing is changed to the database.
Last edited by anthony88guy on Thu May 12, 2005 5:40 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check what is being sent to mysql.. hint: echo the query string.
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

how do you echo the query?
Last edited by anthony88guy on Thu May 12, 2005 6:07 pm, edited 1 time in total.
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

echo &quote;UPDATE users SET pass = '$encryptedpass' WHERE user = '$username'&quote;;
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

ok, i did that and found 2 errors. Now when i use mysql_query with the correct values it doesnt change my armysize. I wanted to change strikeaction to 10,000,000 and it changed it to 0 in the database. I used str_replace(",","",$strikeaction) to get rid of the comma's. Whats wrong now?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ensure they don't have any non-numeric characters in them. Echo your query again, in a fixed width display, maybe you have a space stuck in there..
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

what about using trim() wouldn't that do it? I'm have no luck.
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

$onlyNumbers = preg_replace('#[^\d]#', '', $mixedText);
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

Are you sure that that could do it because, i did type in numbers. What else could prevent it from updating. Also if you type a number over 1 it sets it to 1. If i type 0 it sets it to 0. I think it is a true and false thing going on. But i would like to put numbers in, not true and false values.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post an SQL form of your table structure.
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

Is this what you meant?
Last edited by anthony88guy on Thu May 12, 2005 5:41 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

armysize is a string type. Can you post your newest code?
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

edited
Last edited by anthony88guy on Thu May 12, 2005 5:41 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

oh.. I didn't see this before... how silly of me.. 'AND' is the problem. You are supposed to seperate the fields using commas, not logicals. The logical is processed as part of the expression, therefore if $newstrikeaction and $newarmysize are non-zero, strikeaction will get one, otherwise zero.
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

thxs so much. So you use "AND" when you are Selecting, and use comma's when you are updating?
Post Reply