Web Analytics Made Easy -
StatCounter Uknown MySQL Error - CodingForum

Announcement

Collapse
No announcement yet.

Uknown MySQL Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uknown MySQL Error

    MySQL is giving me an error, but I can't figure out what is causing it.
    Here is my code
    PHP Code:
    function insert($author,$topic,$email,$mood,$entry)
        {
            
    $this->author $author;
            
    $this->topic $topic;
            
    $this->email $email;
            
    $this->mood $mood;
            
    $this->entry  addslashes($entry);
            
    $this->entry nl2br($entry);
            
    $this->date date("l, F j, Y");
            
    $this->month date("F");
            
    $this->unparsed $entry;
            
            
    $this->emoticons();
            
            
    $result "INSERT INTO `blog`(`id`,`author`,`topic`,`email`,`mood`,`date`,`entry`,`np`,`month`) VALUES('NULL','{$this->author}','{$this->topic}','{$this->email}','{$this->mood}','{$this->date}','{$this->entry}','{$this->unparsed}','{$this->month}')";
            
    mysql_query($result) or die(mysql_error());
            
            
    Header("Location: des.php?mode=view");
        } 
    Thanks to all.
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    What's the error say?

    Comment


    • #3
      Weird. I typed in some plain ole text and its fine. I was copying something from a word document when getting the error and the error is still coming up only for that.

      The error is
      Code:
      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 's Boarding School in Newport, Rhode Island. He received his und
      It is only doing it when there is a word with quotes, ie "American's" but I am adding slashes. Hmm. Anyone?

      Thanks
      Stevie Peele
      Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
      #dev - any programming,etc. question
      #design - design discussion and critque
      #central - general chat
      Come join us!

      Comment


      • #4
        you may want to have a look into mysql_escape_string() (http://www.php.net/mysql-escape-string)
        PHP Weekly - A PHP Developers Resource
        PHP 5.1.4 and Ruby on Rails web hosting
        Moderator of PHP and Work offers and Requests
        Install Apache/PHP/MySQL
        (by marek_mar) | TinyPlugin Architecture

        Comment


        • #5
          Ah, phooey.

          Same error.
          Stevie Peele
          Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
          #dev - any programming,etc. question
          #design - design discussion and critque
          #central - general chat
          Come join us!

          Comment


          • #6
            Well, I seemed to have fixed it.
            Here is how I done it
            PHP Code:
            insert.php
            <?php
            include_once('blog.php');
            $exe = new blog;
            $exe->connect("localhost","root","rootpass","test");
            $author $_POST['author'];
            $subject $_POST['topic'];
            $email $_POST['email'];
            $mood $_POST['mood'];
            $entry addslashes($_POST['info']);
            $exe->insert($author,$subject,$email,$mood,$entry);
            ?>
            I just add slashes outside of my class and it seems to work now.

            Thanks to all.
            Stevie Peele
            Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
            #dev - any programming,etc. question
            #design - design discussion and critque
            #central - general chat
            Come join us!

            Comment


            • #7
              try printing the code with added slashes to the page before inserting it into mysql. That way you should be able to see if there is a problem with the code being inserted.
              PHP Weekly - A PHP Developers Resource
              PHP 5.1.4 and Ruby on Rails web hosting
              Moderator of PHP and Work offers and Requests
              Install Apache/PHP/MySQL
              (by marek_mar) | TinyPlugin Architecture

              Comment


              • #8
                odd, im not really sure why that is. i cant see any immediate errors in your first code.
                PHP Weekly - A PHP Developers Resource
                PHP 5.1.4 and Ruby on Rails web hosting
                Moderator of PHP and Work offers and Requests
                Install Apache/PHP/MySQL
                (by marek_mar) | TinyPlugin Architecture

                Comment

                Working...
                X