Live Articles
/>  
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <1164685915.556204.160890@80g2000cwy.googlegroups.com> [ref] => [htmlstate] => on_nl2br [postusername] => Gavin [ip] => GJPeacock@gmail [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> > > $count = $totalRows_live_articles; > ?> >
class="blue_body_header">Live Articles > >
> >
> > > > > > > >
id="active" value="" (!(strcmp($row_live_articles['include'],"yes"))) {echo > "checked=\"checked\"";} ?> /> value="" size="1" /> >   >
>
> ?> >
> > // Check if button name "Submit" is active, do this > if($Submit){ > for($i=0;$i<$count;$i++){ > $sql1="UPDATE news_items SET include='$active[$i]', order='$order[$i]' > WHERE news_id='$id[$i]'";[/ref] This statement doesn't show the offending comma, though.[ref] > $result1=mysql_query($sql1); > } > } > > if($result1){ > header("location:managenews.php"); > } > die(mysql_error()); > ?> >[/ref] -- Progress (n.): The process through which Usenet has evolved from smart people in front of dumb terminals to dumb people in front of smart terminals. -- demon.co.uk [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => <1164685915.556204.160890@80g2000cwy.googlegroups.com> [htmlstate] => on_nl2br [postusername] => Peter [ip] => hellsop@ninehel [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> > > > > > $count = $totalRows_live_articles; > > ?> > >
> class="blue_body_header">Live Articles > > > >
> > > >
> > > > > > > > > > > > > > > >
> id="active" value="" > (!(strcmp($row_live_articles['include'],"yes"))) {echo > > "checked=\"checked\"";} ?> /> > value="" size="1" /> > >   > >
> >
> > > ?> > >
> > > > > // Check if button name "Submit" is active, do this > > if($Submit){ > > for($i=0;$i<$count;$i++){ > > $sql1="UPDATE news_items SET include='$active[$i]', order='$order[$i]' > > WHERE news_id='$id[$i]'";[/ref] > > This statement doesn't show the offending comma, though.[ref] > > $result1=mysql_query($sql1); > > } > > } > > > > if($result1){ > > header("location:managenews.php"); > > } > > die(mysql_error()); > > ?> > >[/ref] > > > -- > Progress (n.): The process through which Usenet has evolved from > smart people in front of dumb terminals to dumb people in front > of smart terminals. > -- demon.co.uk[/ref] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <1164689136.258883.257930@j44g2000cwa.googlegroups.com> [ref] => <1164685915.556204.160890@80g2000cwy.googlegroups.com> [htmlstate] => on_nl2br [postusername] => Gavin [ip] => GJPeacock@gmail [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 3 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Updating multiple Records - Error Msg - MySQL

Updating multiple Records - Error Msg - MySQL

Hi All, I am having the hardest time getting a multiple record update form to work. I found a great tutorial at http://www.phpeasystep.com/mysql/10.html, and, from what i can tell, have followed all the steps/code correctly. My form is based on a dynamic table, and all i want to do is update changes to two fields for each record with one submit of the form. Whenever i submit the form i get the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order='5', WHERE ...

  1. #1

    Default Updating multiple Records - Error Msg

    Hi All,

    I am having the hardest time getting a multiple record update form to
    work. I found a great tutorial at
    http://www.phpeasystep.com/mysql/10.html, and, from what i can tell,
    have followed all the steps/code correctly.

    My form is based on a dynamic table, and all i want to do is update
    changes to two fields for each record with one submit of the form.

    Whenever i submit the form i get the error: You have an error in your
    SQL syntax; check the manual that corresponds to your MySQL server
    version for the right syntax to use near 'order='5', WHERE news_id='8''
    at line 1

    I have included the code i am using below. If anyone can find a problem
    with it, or know of a better/easier way, or even a good tutorial please
    let me know.

    Thanks in advance for your help.

    < ----- CODE ------>

    <?php
    $count = $totalRows_live_articles;
    ?>
    <form action="" method="POST" name="form1"><div
    class="blue_body_header"><strong>Live Articles</strong>
    <input type="submit" name="Submit" value="Submit" />
    </div>
    <?php do { ?>
    <div class="blue_body">
    <table width="100%" border="0" cellspacing="1" cellpadding="4">
    <tr>
    <td width="5%"><input name="active[]" type="checkbox"
    id="active" value="" <?php if
    (!(strcmp($row_live_articles['include'],"yes"))) {echo
    "checked=\"checked\"";} ?> /></td>
    <td width="5%"><input name="order[]" type="text" id="order"
    value="<?php echo $row_live_articles['order']; ?>" size="1" />
    &nbsp;</td>
    <td width="57%"><?php echo $row_live_articles['title']; ?>
    <input name="id[]" type="hidden" id="id" value="<?php echo
    $row_live_articles['news_id']; ?>" /></td>
    <td width="33%"><?php echo $count; ?></td>
    </tr>
    </table>
    </div>
    <?php } while ($row_live_articles = mysql_fetch_assoc($live_articles));
    ?>
    </form>

    <?php
    // Check if button name "Submit" is active, do this
    if($Submit){
    for($i=0;$i<$count;$i++){
    $sql1="UPDATE news_items SET include='$active[$i]', order='$order[$i]'
    WHERE news_id='$id[$i]'";
    $result1=mysql_query($sql1);
    }
    }

    if($result1){
    header("location:managenews.php");
    }
    die(mysql_error());
    ?>

    Gavin Guest

  2. #2

    Default Re: Updating multiple Records - Error Msg

    On 27 Nov 2006 19:51:55 -0800, Gavin wrote: 
    ^^^ 

    That comma definately doesn't belong there.
     

    This statement doesn't show the offending comma, though. 


    --
    Progress (n.): The process through which Usenet has evolved from
    smart people in front of dumb terminals to dumb people in front
    of smart terminals.
    -- demon.co.uk
    Peter Guest

  3. #3

    Default Re: Updating multiple Records - Error Msg

    Yes, the comma is not in the actual statement. I used a text crab from
    one errors of one of my many attempts at getting this working. Any
    ideas?

    Peter H. Coffin wrote:
     
    > ^^^ 
    >
    > That comma definately doesn't belong there.

    >
    > This statement doesn't show the offending comma, though. 
    >
    >
    > --
    > Progress (n.): The process through which Usenet has evolved from
    > smart people in front of dumb terminals to dumb people in front
    > of smart terminals.
    > -- demon.co.uk[/ref]

    Gavin Guest

  4. #4

    Default Re: Updating multiple Records - Error Msg

    >Yes, the comma is not in the actual statement. I used a text crab from 

    Order is a MySQL keyword. If you use it as a field name, you need to
    (back)quote it (`order`).


    Gordon Guest

  5. #5

    Default Re: Updating multiple Records - Error Msg

    Thanks,

    I added backquotes and this has stopped the error message. Now the
    problem is that it doesn't amend the correct record. I can make a
    change to the second record on the list, and it ends up making the
    change to the fourth (or any random combination).

    Any idea's? If someone could explain how the 'multiple update' code is
    working that would be great, it would put me on a path to figuring it
    out.

    Thanks again.

    Gordon Burditt wrote: 
    >
    > Order is a MySQL keyword. If you use it as a field name, you need to
    > (back)quote it (`order`).[/ref]

    Gavin Guest

Similar Threads

  1. Updating multiple records in a linked table simultaneously
    By Aaron Roberson in forum Coldfusion Database Access
    Replies: 2
    Last Post: January 25th, 06:41 PM
  2. Updating Multiple records fields in a database atonce
    By kris f in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: February 17th, 03:36 AM
  3. updating multiple records on one page
    By BP Prgm in forum ASP Database
    Replies: 1
    Last Post: September 17th, 02:52 AM
  4. updating multiple records via online form
    By dukeofwhelmsley in forum ASP
    Replies: 2
    Last Post: September 8th, 07:36 PM
  5. Updating Multiple Records
    By Jordan Marton in forum Macromedia Dreamweaver
    Replies: 5
    Last Post: July 10th, 08:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •