SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Getting an error trying to do an insert

    For testing inserts, I always use the name of Bnny'O so I can make sure my code can handle the various accent characters in different names. Today, however, I'm missing something because the database is returning an error when I try to insert. Here is part of the error, which proves it doesn't like the apostrophe after the y in the name.

    Error: mysql_errno() 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 'O'

    The weird thing is my insert PHP code is the same as all my other inserts:

    $emailBody = "User is Bnny'O Smith";

    $addNotification = "INSERT INTO notifications (messageHTML, address) VALUES ('".mysql_real_escape_string($emailBody)."', '$senderEmail')";

    mysql_query($addNotification) OR die("<p>Please email us the following information/p> <p>Query: $addNotification </p> <p>Error: mysql_errno() " . mysql_error() );

    Any thoughts on this?

    Thanks!
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Yes
    Put the closing ") at the end of the SQL statement. The entire OR DIE part isn't SQL, it's PHP.


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
  •