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
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Fri Aug 08, 2003 9:42 pm
Problem updating a record. It doesnt seem to update.... Here is the code that I have so far
Code: Select all
<?php
$reqlevel = 0;
include("membersonly.inc.php");
mysql_query("UPDATE admins SET csname=$csname, auth=$auth, paypal=$paypal, email=$email, password=$password, access=$access, datepurchase=$datepurchase, dateend=$dateend, status=$status WHERE id='$uid'");
printf ("Updated records: %d\n", mysql_affected_rows());
mysql_query("COMMIT");
echo '<br>' . $csname;
echo '<br>' . $auth;
echo '<br>' . $paypal;
echo '<br>' . $email;
echo '<br>' . $password;
echo '<br>' . $access;
echo '<br>' . $datepurchase;
echo '<br>' . $dateend;
echo '<br>' . $status;
echo '<br>' . $id;
?>
But its not updating. Its telling me "Updated records: -1" but i know thats not right, it shouldnt be. and my DB doesnt change
Last edited by
Bad HAL 9000 on Sat Aug 09, 2003 9:21 pm, edited 5 times in total.
Drachlen
Forum Contributor
Posts: 153 Joined: Fri Apr 25, 2003 1:16 am
Post
by Drachlen » Fri Aug 08, 2003 10:16 pm
Code: Select all
<?php
mysql_query("UPDATE admins SET csname='$csname', auth='$auth', paypal='$paypal', email='$email', password='$password', access='$access', datepurchase='$datepurchase', dateend='$dateend', status='$status' WHERE id='$uid'") or die(mysql_error());
?>
Try this, you need some single quotes around variables
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Fri Aug 08, 2003 11:24 pm
Ok, im not getting the -1 updates but now im getting 0 updates.... arg
Drachlen
Forum Contributor
Posts: 153 Joined: Fri Apr 25, 2003 1:16 am
Post
by Drachlen » Sat Aug 09, 2003 12:25 am
try echoing $uid, are you positive thats the variable name, and is it returning a value?
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Sat Aug 09, 2003 1:53 am
lol I remember i changed the vars name and I forgot to change the rest of the script to reflect that change thanks a bunch its workin now!
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Sat Aug 09, 2003 3:45 pm
Ok, new problem, Im stupid so bear with me
Code: Select all
<td><select name="gserver">
<option value="EP1" <?php if ($gserv = "EP1") { echo "selected"; } ?>>Eddie's Playground 1</option>
<option value="EP2" <?php if ($gserv = "EP2") { echo "selected"; } ?>>Eddie's Playground 2</option>
<option value="Both" <?php if ($gserv = "Both") { echo "selected"; } ?>>EP1 and EP2</option>
</select></td>
Its not workin it selects Both no matter what, and $gserv is returning the correct value.. im stumped
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sat Aug 09, 2003 4:37 pm
Bad HAL 9000 wrote: Ok, new problem, Im stupid so bear with me ;)
;)
Try changing the = to ==
Code: Select all
<?php
<td><select name="gserver">
<option value="EP1" <?php if ($gserv == "EP1") { echo "selected"; } ?>>Eddie's Playground 1</option>
<option value="EP2" <?php if ($gserv == "EP2") { echo "selected"; } ?>>Eddie's Playground 2</option>
<option value="Both" <?php if ($gserv == "Both") { echo "selected"; } ?>>EP1 and EP2</option>
</select></td>
?>
...as you allrady know, one = sets the variable to 'Both'...
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Sat Aug 09, 2003 8:12 pm
hahah boy do I feel stupid
. I guess im think VB instead of C syntax I had no idea i could say somthing that dumb
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sat Aug 09, 2003 9:40 pm
Yup, been coding VB/VBA, pascal and JML at work for about ½-year, so I know how that feels ...
Sidenote (to everyone watching)...
Did you change the topic of this post and added "SOLVED" to it?
In that case good! Everyone should do that upon their request/problem is solved, because beginners can see the topic and also know that inside there is a solution to it. Advanced users that scout the board helping out, do not need to tend to such topic, as it's obviously allready handled.
Some info similiar to this should get sticky!
And perhaps a function in the board's backend could make the posts closed if such topic is found... Just my 2cents...
Bad HAL 9000
Forum Newbie
Posts: 6 Joined: Fri Aug 08, 2003 9:42 pm
Location: Minnesota USA
Contact:
Post
by Bad HAL 9000 » Sat Aug 09, 2003 9:52 pm
Yea, I did that. When asking for help I dont want people helping me with somthing thats already done ya know? So yea, changed the title I did