SQL error

  • marjune
  • Newbie
  • Newbie
  • marjune
  • Posts: 7

Post 3+ Months Ago

greeting....

As of now i'm in the middle of developing our website which is my thesis.,., about the blogs of the said study.,., I have a problem with this d**n textarea for my blog.,.,

the database:

Code: [ Select ]
CREATE TABLE   ‘blogs’ (
  `blogs_id` int(10) unsigned NOT NULL auto_increment,
  `blogger` varchar(15) NOT NULL,
  `blog_topic` varchar(75) NOT NULL,
  `blog_content` text NOT NULL,
  `date_created` varchar(20) NOT NULL,
  PRIMARY KEY  (`blogs_id`),
) ;
  1. CREATE TABLE   ‘blogs’ (
  2.   `blogs_id` int(10) unsigned NOT NULL auto_increment,
  3.   `blogger` varchar(15) NOT NULL,
  4.   `blog_topic` varchar(75) NOT NULL,
  5.   `blog_content` text NOT NULL,
  6.   `date_created` varchar(20) NOT NULL,
  7.   PRIMARY KEY  (`blogs_id`),
  8. ) ;




the code:
Code: [ Select ]
<?php
 
 $host = "localhost";
  $user = "root";
  $passwd = "*******";
  $database = "cssonlinedb";
 
 
  $connect_db = mysql_connect("$host","$user","$passwd");
   
    if (!$connect_db) {
     
       die ('Could not Connect: ' . mysql_error() );
    }
   
  mysql_select_db("$database", $connect_db) or die ('Cant connect the database: ' . mysql_error() );
 
             
      $id = $_GET['IDuser'];
      $topic = $_POST['blog_title'];/textarea for subject
      $content = $_POST['blog_content'];//textarea for content
      $date_time = date("m/d/y h:i:s");
       
              // Get first the name of the blogger
             
              $blogger = "SELECT username FROM css_registration WHERE memID = '$id';";
              $blogger_test = mysql_query($blogger);
             
              if ( !$blogger_test ) {
             
                  die ("ERROR: " . mysql_error() );
             
              }    
             
              else {
             
                  $blogger_field = mysql_fetch_array($blogger_test);
                                     
                  $blogger = $blogger_field['username'];
                 
                 // add the information in the database
                 
                 $sql = "INSERT INTO blogs ( blogger, blog_topic, blog_content, date_created )
                         VALUES ( '$blogger', '$topic', '$content', '$date_time');";  
             
                  $test = mysql_query($sql);
                 
                 if ( !$test ) {
                   
                    die ('ERROR: ' . mysql_error() );
                 }
                 else {
                 
                   echo cool;
                 }
              }
         
         
         
          mysql_close();  
          ?>
  1. <?php
  2.  
  3.  $host = "localhost";
  4.   $user = "root";
  5.   $passwd = "*******";
  6.   $database = "cssonlinedb";
  7.  
  8.  
  9.   $connect_db = mysql_connect("$host","$user","$passwd");
  10.    
  11.     if (!$connect_db) {
  12.      
  13.        die ('Could not Connect: ' . mysql_error() );
  14.     }
  15.    
  16.   mysql_select_db("$database", $connect_db) or die ('Cant connect the database: ' . mysql_error() );
  17.  
  18.              
  19.       $id = $_GET['IDuser'];
  20.       $topic = $_POST['blog_title'];/textarea for subject
  21.       $content = $_POST['blog_content'];//textarea for content
  22.       $date_time = date("m/d/y h:i:s");
  23.        
  24.               // Get first the name of the blogger
  25.              
  26.               $blogger = "SELECT username FROM css_registration WHERE memID = '$id';";
  27.               $blogger_test = mysql_query($blogger);
  28.              
  29.               if ( !$blogger_test ) {
  30.              
  31.                   die ("ERROR: " . mysql_error() );
  32.              
  33.               }    
  34.              
  35.               else {
  36.              
  37.                   $blogger_field = mysql_fetch_array($blogger_test);
  38.                                      
  39.                   $blogger = $blogger_field['username'];
  40.                  
  41.                  // add the information in the database
  42.                  
  43.                  $sql = "INSERT INTO blogs ( blogger, blog_topic, blog_content, date_created )
  44.                          VALUES ( '$blogger', '$topic', '$content', '$date_time');";  
  45.              
  46.                   $test = mysql_query($sql);
  47.                  
  48.                  if ( !$test ) {
  49.                    
  50.                     die ('ERROR: ' . mysql_error() );
  51.                  }
  52.                  else {
  53.                  
  54.                    echo cool;
  55.                  }
  56.               }
  57.          
  58.          
  59.          
  60.           mysql_close();  
  61.           ?>





the input

What's a blog?
A blog is a personal diary. A daily pulpit. A collaborative space. A political soapbox. A breaking-news outlet. A collection of links. Your own private thoughts. Memos to the world.
Your blog is whatever you want it to be. There are millions of them, in all shapes and sizes, and there are no real rules.
In simple terms, a blog is a web site, where you write stuff on an ongoing basis. New stuff shows up at the top, so your visitors can read what's new. Then they comment on it or link to it or email you. Or not.
Since Blogger was launched in 1999, blogs have reshaped the web, impacted politics, shaken up journalism, and enabled millions of people to have a voice and connect with others.
And we're pretty sure the whole deal is just getting started.
:




the error:

Quote:
ERROR: 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 new. Then they comment on it or link to it or email you. Or not. Since Blogge' at line 2



// this code really freaks me out.,.,. and i know that the datatype text has a maximum length of 65535 characters. is it in the textarea?

thanks.....
reynz
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Use "mysql_real_escape_string()" on your input text so that the apostrophes get escaped.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Please refer to the forum rules about using correct English/punctuation and naming your threads.

Thanks.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.