RE: [PHP] Problem updating[Scanned]
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> > SJ> > SJ> > SJ> > SJ> $title > SJ> > SJ> > SJ> > SJ> Real Name: > SJ> SJ> value ='$realname'> > SJ> > SJ> > SJ> Preferred Name: > SJ> SJ> value ='$nickname'> > SJ> > SJ> > SJ> Company: > SJ> SJ> value ='$company'> > SJ> > SJ> > SJ> Email Address: > SJ> SJ> value ='$email'> > SJ> > SJ> > SJ> Requested Email Format:"; > SJ> echo " SJ>if ($mimetype == 'T') > SJ> echo " selected"; > SJ>echo ">Text Only SJ>if ($mimetype == 'H') > SJ> echo " selected"; > SJ>echo ">HTML"; > SJ> print " > SJ> > SJ> "; > SJ> display_form_button('save-changes'); > SJ> print ""; > 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$query".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
RE: [PHP] Problem updating
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> > SJ> > SJ> > SJ> > SJ> $title > SJ> > SJ> > SJ> > SJ> Real Name: > SJ> SJ> value ='$realname'> > SJ> > SJ> > SJ> Preferred Name: > SJ> SJ> value ='$nickname'> > SJ> > SJ> > SJ> Company: > SJ> SJ> value ='$company'> > SJ> > SJ> > SJ> Email Address: > SJ> SJ> value ='$email'> > SJ> > SJ> > SJ> Requested Email Format:"; > SJ> echo " SJ>if ($mimetype == 'T') > SJ> echo " selected"; > SJ>echo ">Text Only SJ>if ($mimetype == 'H') > SJ> echo " selected"; > SJ>echo ">HTML"; > SJ> print " > SJ> > SJ> "; > SJ> display_form_button('save-changes'); > SJ> print ""; > 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$query".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
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? SJ> I get a result of 1 when I echo $result but it doesn't want to update at SJ> all. SJ> The action of this form index.php?action=update-account is just a switch SJ> case SJ> Which asks you to use the function update_subscriber_account() below... SJ> SJ> SJ> SJ> SJ> $title SJ> SJ> SJ> SJ> Real Name: SJ> value ='$realname'> SJ> SJ> SJ> Preferred Name: SJ> value ='$nickname'> SJ> SJ> SJ> Company: SJ> value ='$company'> SJ> SJ> SJ> Email Address: SJ> value ='$email'> SJ> SJ> SJ> Requested Email Format:"; SJ> echo "if ($mimetype == 'T') SJ> echo " selected"; SJ>echo ">Text Onlyif ($mimetype == 'H') SJ> echo " selected"; SJ>echo ">HTML"; SJ> print " SJ> SJ> "; SJ> display_form_button('save-changes'); SJ> print ""; 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$query".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
Re: [PHP] Problem updating
Is this HTML in a print or echo statement? If not, then the variables will not display. You can View Source to verify this. - Original Message - From: "Steve Jackson" <[EMAIL PROTECTED]> To: "PHP General" <[EMAIL PROTECTED]> Sent: Thursday, March 06, 2003 8:27 AM Subject: [PHP] Problem updating Been on this a couple of hours... anyone see what I'm doing wrong? I get a result of 1 when I echo $result but it doesn't want to update at all. The action of this form index.php?action=update-account is just a switch case Which asks you to use the function update_subscriber_account() below... $title Real Name: Preferred Name: Company: Email Address: Requested Email Format:"; echo "Text OnlyHTML"; print " "; display_form_button('save-changes'); print ""; } } function update_subscriber_account() { db_connect(); $query = "update subscribers set email = '$new_email', nickname = '$new_nickname', fullname = '$new_realname', company = '$new_company', mimetype = '$new_mimetype' where email = '$old_id'"; $result = mysql_query($query)or die("Error: Could not update query$query".mysql_error()); if (!$result) { echo "An error occurred when trying to update the DB"; } else { echo "$result & Successfully updated the details"; } } -- 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
Re: [PHP] Problem updating post on a basic weblog system
if ($post == "post") { postBlog ($post,$input,$title); }elseif ($post == "edit"){ updateBlog ($input,$edit_post); // < BINGO! } Just looking at the code you posted to your site, there's only one thing obvious to me: You want to use $edit_blog in that call to updateBlog instead of $edit_post? g.luck, ~Chris On Thu, 12 Sep 2002, Jesse Lawrence wrote: > Hello all, > > I've got a bit of a code problem that's been baffling > me for a while now. > > I'm working on a basic weblog system for personal use, > using MySQL. I've got the "new post" and "delete a > post" aspects working fine, but for some reason, I > can't get the "update a post" part happening. > > What happens is I select a post to update, and then > the post comes up in a textarea box. You then make > your update, and submit. > > Doing this calls the following function: > > function updateBlog($input,$edit_blog) { > > > include 'db_connect.php'; > $update_query = "update $table set blog='$input' > where id='$edit_blog'"; > if(mysql_db_query ($database, $update_query, > $link)) { >print "Successfully Edited!!"; > }else{ > print "no"; > > } > > The variables being passed to the function are: > $input = "The body of the post" > and > $edit_blog = id # of post > > At this point everything appears to have been a > success. The "Successfully Edited!!" confirmation > appears, and everything seems fine, but when I look at > my database, nothing has been updated or changed in > any way. > > Does anyone have any suggestions or help they could > lend me? I've been facing this problem for a while > now, and can't seem to get my head around it. > > You can view the entire code here: > http://soniceast.d2g.ca/~jalaw/blog/admin.txt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php