SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot skipdawg95's Avatar
    Join Date
    Oct 2004
    Location
    Strasburg, VA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySql syntax error!

    Can someone give me a hand! I'm working on a forum and I was in the middle of testing it out when, after two posts, my MySql die error appeared. Now I can't post anything. Any ideas?

    Here's the code that is in question:

    PHP Code:
    mysql_query("INSERT INTO forumposts (title, date_time, owner, forum, crew, text) VALUES ('$title', '$dateTime', '$char', '$forumpost', '$crew', '$postText')"$conn) or die ("Error entering post data!"); 

  2. #2
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would check with your host....the query looks valid, and if 2 posts went and the 3rd one didn't it would seem to be a server problem (unless you have other unposted code around your query which is the problem).

  3. #3
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this problem may, for some reason lie within your input...show me your HTML and what you inputted.
    Fesh
    imagine what it's going to be like

  4. #4
    get into it! bigduke's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And just why is a MySQL syntax error thread posted in the PHP forum ?

    However, yes this looks like a bad input problem. Try a test and enter a single quote in any one of those values through the form. If your date_time field is a datetime datatype in the db check the incoming string format.

  5. #5
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya know bigduke...I didn't even think why a MySQL thread is in the PHP...good point, sir
    Fesh
    imagine what it's going to be like

  6. #6
    SitePoint Zealot skipdawg95's Avatar
    Join Date
    Oct 2004
    Location
    Strasburg, VA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! I was able to figure it out. It did have something to do with my input. A previous select query I had in the code was the problem. Sometimes you just need someone to show you the path before you can find your way. Oh, and sorry for posting in the wrong area. I'm so used to posting in the php area that I didn't even think about it. Thanks again!

  7. #7
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I take it you're sanitizing that input?


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
  •