SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Joke Management System and authors

    So I've got the rest of my JMS up and running, but I still have the same prob with editing and deleting authors.
    When I click the 'edit' link is says: 'Error fetching author details: You have an error in your SQL syntax near " at line 3', this being the code in the deleteauthors.php page. And so, here's the relevant code. (Hell, I took it from the code archive and I still get it.....


    PHP Code:
    $sql "UPDATE Authors SET
              Name='
    $name',
              EMail='
    $email'
              WHERE ID='
    $id'"
    And though I've checked and rechecked the deleteauthor.php syntax, I can't find the error that's causing it to not delete the authopr but say it was deleted successfully. I'm not sure if its not within the table itself. I've cut and pasted the *.php pages from sitepoint for the rest of the exercise and changed nothing cept user/pass and everything works as its supposed too. Has anyone else had this prob?
    Also, where the hell is the jokes database hidden. I've looked for it, searched an dcome up dry....?????
    TIA
    Crimson
    The greatest trick the Devil pulled was convincing the world he didn't exist.

  2. #2
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when you click "edit" link is the variable "id" being passed?


    editauthors?id=6

    or

    deleteauthors.php?id=6
    http://redgoals.com ... my site ... nuff said

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm......It doesn't appear to do so. But what of that 'quote' error for editing the author? I still can;t see what is wrong there..........ARGGH
    The greatest trick the Devil pulled was convincing the world he didn't exist.

  4. #4
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post the form that edits posts? i got a feeling your missing a hidden field.
    http://redgoals.com ... my site ... nuff said

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code to editauthor.php:
    PHP Code:
    mysql_select_db("jokes");
    // Delete all jokes belonging to the author
    // along with the entry for the author.
    $ok1 = @mysql_query("delete from jokes where aid=$id");
    $ok2 = @mysql_query("delete from authors where id=$id");
    if(
    $ok1 and $ok2) {
    echo(
    "<p>Error deleting author from database!<br />" .
    "Error: " mysql_error() . "</p>");
        } 
        else {
        echo(
    "<p>Author deleted successfully!</p>");
        }
    ?> 
    and deleteauthor.php:
    PHP Code:
    mysql_select_db("jokes");

      if (
    $submit): // The author's details have
                    // been updated.

      
    $sql "UPDATE Authors SET
              Name='
    $name',
              EMail='
    $email'
              WHERE ID='
    $id'";
      if (@
    mysql_query($sql)) {
        echo(
    "<p>Author details updated.</p>");
      } else {
        echo(
    "<p>Error updating author details: " .
             
    mysql_error() . "</p>");
      }

    ?> 
    PS the 'quote' error apparently appears at this point $sql= "update authors set......"
    Can't see why as its identical to the newauthor.php code and THAT one doesn't throw the error:

    PHP Code:
     $sql "INSERT INTO Authors SET
              Name='
    $name',
              EMail='
    $email'";
      if (@
    mysql_query($sql)) 
    This is the only prob I have, everything else works great....
    TIA Crimson
    The greatest trick the Devil pulled was convincing the world he didn't exist.

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the form that edits posts for authors.

    PHP Code:
    <form action="<?=$PHP_SELF?>" method="post">
    <p>Edit the author:<br />
    Name: <input type="text" name="name" value="<?=$name?>" size="20" maxlength="255"><br />
    eMail: <input type="text" name="email" value="<?=$email?>" size="20" maxlength="255"><br />
    <input type="hidden" name="id" value="<?=$id?>" />
    <input type="submit" name="submit" value="SUBMIT" /></p>
    </form>
    Funny thing. When I go to add php code I get a script prompt to paste the text in. Why is that? I didn't get it before and haven;t changed my settings. Or anything in the IE6 browser.
    Odd.
    Crimson
    The greatest trick the Devil pulled was convincing the world he didn't exist.

  7. #7
    And your point is.... redgoals's Avatar
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the column id in the table in lower case? if so this should work

    PHP Code:
    mysql_select_db("jokes");

      if (
    $submit): // The author's details have
                    // been updated.

      
    $sql "UPDATE Authors SET
              Name='
    $name',
              EMail='
    $email'
              WHERE id='
    $id'";
      if (@
    mysql_query($sql)) {
        echo(
    "<p>Author details updated.</p>");
      } else {
        echo(
    "<p>Error updating author details: " .
             
    mysql_error() . "</p>");
      }

    ?> 
    not sure about you but i need to get some kip..im sure someone of the nice ppl here at sitepoint can help you.
    Last edited by redgoals; Apr 7, 2002 at 15:39.
    http://redgoals.com ... my site ... nuff said

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah. It is all lower case. What else? Sheesh, this really stumps me. Ideas?
    The greatest trick the Devil pulled was convincing the world he didn't exist.

  9. #9
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Ontario
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Redgoals. I found the problem. It was a bad capitalization in the 'authors.php' page. ID instead of id. Man, one small thing and BOOM.. HA! Thanks for your brain and the help/suggestions. I love this place. If I have more probs, <Arnold>I'll be beck!</Arnold>
    Thanks again
    Crimson
    The greatest trick the Devil pulled was convincing the world he didn't exist.


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
  •