Join the club. I spent some time looking at your original post - submitted a response - but associated it with the wrong thread!
Apologies to all! Michael -----Original Message----- From: Steve Jackson [mailto:[EMAIL PROTECTED] Sent: 06 March 2003 15:00 To: 'Tom Rogers' Cc: 'PHP General' Subject: RE: [PHP] Problem updating[Scanned] Actually it didn't need the globals, But I did need to pass the variables into the function! Update_subscriber_account($var1, $var2 etc....) I feel a right plonker now! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 > -----Original Message----- > From: Tom Rogers [mailto:[EMAIL PROTECTED] > Sent: 6. maaliskuuta 2003 16:28 > To: Steve Jackson > Cc: PHP General > Subject: Re: [PHP] Problem updating > > > Hi, > > Friday, March 7, 2003, 12:27:27 AM, you wrote: > SJ> Been on this a couple of hours... anyone see what I'm > doing wrong? I > SJ> get a result of 1 when I echo $result but it doesn't want > to update > SJ> at all. The action of this form > index.php?action=update-account is > SJ> just a switch case > SJ> Which asks you to use the function > update_subscriber_account() below... > > SJ> <form method='post' action='index.php?action=update-account'> > SJ> <input type='hidden' name='old_id' value='$email'> > SJ> <tr> > SJ> <th colspan = 2 bgcolor = '#5B69A6'> > SJ> $title > SJ> </th> > SJ> </tr> > SJ> <tr> > SJ> <td>Real Name:</td> > SJ> <td><input type = text name='new_realname' maxlength = 100 > SJ> value ='$realname'></td> > SJ> </tr> > SJ> <tr> > SJ> <td>Preferred Name:</td> > SJ> <td><input type = text name='new_nickname' maxlength = 100 > SJ> value ='$nickname'></td> > SJ> </tr> > SJ> <tr> > SJ> <td>Company:</td> > SJ> <td><input type = text name='new_company' maxlength = 100 > SJ> value ='$company'></td> > SJ> </tr> > SJ> <tr> > SJ> <td>Email Address:</td> > SJ> <td><input type = text name='new_email' maxlength = 100 > SJ> value ='$email'></td> > SJ> </tr> > SJ> <tr> > SJ> <td>Requested Email Format:</td>"; > SJ> echo "<td><select name='new_mimetype'><option"; > SJ> if ($mimetype == 'T') > SJ> echo " selected"; > SJ> echo ">Text Only<option"; > SJ> if ($mimetype == 'H') > SJ> echo " selected"; > SJ> echo ">HTML</select></td>"; > SJ> print "</tr> > SJ> <tr> > SJ> <td colspan=2 align=center>"; > SJ> display_form_button('save-changes'); > SJ> print "</td></tr></form></table></center><br>"; > SJ> } > SJ> } > > SJ> function update_subscriber_account() > SJ> { > > SJ> db_connect(); > SJ> $query = "update subscribers > SJ> set email = '$new_email', > SJ> nickname = '$new_nickname', > SJ> fullname = '$new_realname', > SJ> company = '$new_company', > SJ> mimetype = '$new_mimetype' > SJ> where email = '$old_id'"; > SJ> $result = mysql_query($query)or die("Error: Could not update > SJ> query<BR>$query<BR>".mysql_error()); > SJ> if (!$result) > SJ> { > SJ> echo "An error occurred when trying to update the DB"; > SJ> } > SJ> else > SJ> { > SJ> echo "$result & Successfully updated the details"; > SJ> } > SJ> } > > You will need to use the global vars and also escape quotes like this: > > function update_subscriber_account() > { > $new_email = addslashes($_POST['new_email']); > . > . > . > $query = "update subscribers > > set email = '$new_email', > . > . > > -- > regards, > Tom > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php