SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict seanmayhew's Avatar
    Join Date
    Aug 2002
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error submitting Update statement

    I know this has something to do with double or single quotes and the fact that the MySQL field is set to INT but I keep recieving this error that I cant seem to fix.

    The link that tells the editArticle form what article to edit
    PHP Code:
    echo ("<td><a href="$PHP_SELF?editArticle=$articleID">
    <img src="
    ../images/designElements/buttons/edit.gif" width='30' height='30' border='0'></a>&nbsp;" ); 
    Which fills in all of the information into this form and tells the form what article to edit:
    PHP Code:
    //If the user want to edit an article
    if(isset($editArticle)){
    $editArticleDetails = @mysql_query("Select articleID,article.title,article.digest,
    article.fullArticle,article.userid,article.status,users.userid,users.username 
    from article,users where articleID=$editArticle and article.userid = users.userid" );
    if(!$editArticleDetails){
    echo("<p>Error performing query: ".mysql_error()."</p>" );
    exit();
    }
    while($articleEditRow = mysql_fetch_array($editArticleDetails)){
    $updatearticleID = $articleEditRow[articleID];
    $userid = $articleEditRow["userid"];
    $updateusername = $articleEditRow["username"];
    $updatetitle = $articleEditRow["title"];
    $updatedigest = $articleEditRow["digest"];
    $updatefullarticle = $articleEditRow["fullArticle"];
    $updatestatus = $articleEditRow["status"];
    }
    ?>
    <div align='center'>
    <table width='300' class="FormText">
    <tr><td colspan="2"><br><div class="BoldPink" align="center"><?=$updatetitle?><br>
    <div class="FormText">Article Details</div></div></td></tr>
    <form action="<?=$PHP_SELF?>" method="post" class="FormText">
    <tr><td>Username:</td><td><?=$updateusername?></td></tr>
    <tr><td>Title:</td><td>
    <input type="text" name="updatetitle" value="<?=$updatetitle?>" class="FormText"></td></tr>
    <tr><td>Digest:</td><td>
    <textarea name="updatedigest" value="<?=$updatedigest?>"
    class="FormText"><?=$updatedigest?></textarea></td></tr>
    <tr><td>Full Article:</td><td>
    <textarea name="updatefullarticle" cols="40" rows="20" class="FormText" value="<?=$updatefullarticle?>">
    <?=$updatefullarticle?></textarea></td></tr>
    <tr><td>Status:</td><td><select name="updatestatus" class="FormText">
    <option value="<?=$updatestatus?>" selected><?=updatestatus?></option>
    <option value="Inactive">Inactive</option>
    <option value="Active">Active</option>
    <option value="Archive">Archive</option>
    </select></td></tr>
    <input type="hidden" name="updatearticleID" value="<?=updatearticleID?>"/>
    <tr><td></td><td><input type="submit" name="updateArticle" value="UPDATE" class="FormText"/></td></tr>
    </form>
    </table></div>
    <?
    }
    But when the form is submitted and this SQL statement executes:
    PHP Code:
    //Update an Article
    if($updateArticle == "UPDATE" ){
    $sqlUpdate "Update article set
    title = '
    $updatetitle',
    digest = '
    $updatedigest',
    fullarticle = '
    $updatefullarticle',
    status = '
    $updatestatus',
    where articleID = '
    $updatearticleID'
    "
    ;
    if(@
    mysql_query($sqlUpdate)){
    echo (
    "<div align='center' class='NormalBlack'><br>Updated!
    <br><br></div><div align='center' class='BoldHeader'>
    <a href="
    $PHP_SELF?viewArticle=$articleID">$title</a></div><br>" );
    }
    else{
    echo(
    "<p>Error changing article details: ".mysql_error()."</p>" );
    }

    I receive this error:
    Code:
    Error changing article details: 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 'where articleID = ''' at line 6
    Any help would be greatly appreciated.

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have an extra comma after $updatestatus

    try this as your sql query:

    $sqlUpdate = "Update article set
    title = '$updatetitle',
    digest = '$updatedigest',
    fullarticle = '$updatefullarticle',
    status = '$updatestatus'
    where articleID = '$updatearticleID'
    "
    ;


    it should work.


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
  •