SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQLIte Creating a Databse

    I am trying to use SQLite to create a simple database however I just canít seem to get it to work. I am using the code supplied when I first downloaded SQLite. I am also unsure what should come after the blob data type?? Like after a char I have (100) is there something that needs to come after blob???

    Cheers for any help
    Code:
    <?php
    		try { 
    			$db = sqlite_open("distributorlogin1.db"); 
    			//sqlite_query($db , "CREATE TABLE tbllogin (username CHAR(100), password CHAR(100), company CHAR(200), timestamp CHAR(200) salesimage BLOB); 
    		}catch (Exception $e){ 
    			echo 'Caught Exception ', $e->getMessage(), "\n";  
    		} 
    		echo 'Created Database distributorlogin1.db.';
    		// close database connection 
    		sqlite_close($db); 
    ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    A blob field doesn't use a field length, (it's set to aboout 65kb). The timestamp should be set to an Int or TimeStamp field. Also, (and I'm not completely positive on this) you shouldn't use CHAR for long fields - use VARCHAR instead.

    You say you can't get it to work - what's the error?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is no error the script works fine but the database when it has been created as no data in it its just a blank file. Cab you set the blob field to store higher quality pictures like say 1mb???

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, by using "MediumBlob" and "LongBlob".
    Have you tried inserting data into the database?

    I recommend using MySQL instead of SQLite - it's much better at handling alot of data (and it's much more supported on forums such as sitepoint).
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •