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
Post
by anthony88guy » Sat Apr 02, 2005 10:28 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 10:47 am
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 » Sat Apr 02, 2005 11:13 am
how do you echo the query?
Last edited by
anthony88guy on Thu May 12, 2005 6:07 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 11:20 am
Code: Select all
echo "e;UPDATE users SET pass = '$encryptedpass' WHERE user = '$username'"e;;
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Sat Apr 02, 2005 12:31 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 12:41 pm
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 » Sat Apr 02, 2005 2:51 pm
what about using trim() wouldn't that do it? I'm have no luck.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 2:55 pm
Code: Select all
$onlyNumbers = preg_replace('#[^\d]#', '', $mixedText);
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Sat Apr 02, 2005 3:24 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 3:42 pm
post an SQL form of your table structure.
anthony88guy
Forum Contributor
Posts: 246 Joined: Thu Jan 20, 2005 8:22 pm
Post
by anthony88guy » Sat Apr 02, 2005 4:52 pm
Is this what you meant?
Last edited by
anthony88guy on Thu May 12, 2005 5:41 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 5:19 pm
armysize is a string type. Can you post your newest code?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Apr 02, 2005 8:20 pm
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 » Sat Apr 02, 2005 9:11 pm
thxs so much. So you use "AND" when you are Selecting, and use comma's when you are updating?