Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,842 members, 7,820,934 topics. Date: Wednesday, 08 May 2024 at 03:51 AM

Mysql Help Needed - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Mysql Help Needed (1140 Views)

Localhost Not Allowed To Connect To MySQL. Help!!!! / Php/mysql Help:how To Run Sql Query From A Link / Porting PHP/MYSQL Applications to Micro-Controller Based Devices (2) (3) (4)

(1) (Reply) (Go Down)

Mysql Help Needed by IronFist(m): 2:48pm On Feb 21, 2007
Can anybody in the house help me out with the SQL syntax for inserting an already existing pdf document into a MySQL DB. I tried this out
/* INSERT INTO new_book VALUES(1,"C:\Documents and Settings\OBl OKOYE\My Documents\pdfs\ajax in action"wink;*/
but it never works.
N.B:I set the column type to be a BLOB
Re: Mysql Help Needed by Cactus(m): 5:23pm On Feb 21, 2007
Provide the table Create statement
Re: Mysql Help Needed by IronFist(m): 5:34pm On Feb 21, 2007
create table new_book
>ID INTEGER not null autoincrement PRIMARY KEY,
>NAME VARCHAR(45) not null,
>ISBN INTEGER NULL,
>BOOK BLOB NOT NULL;
Do bear with my syntactical errors because i used a GUI tool when i created the table.It's been a while i did this the hard way.Thanks
Re: Mysql Help Needed by Cactus(m): 6:59pm On Feb 21, 2007
you are inserting values into the ID column and Name column however, The NAME column is a varchar(45) and the value you're inserting is way more than 45 characters, but really u want that information to go into the BOOK column. so that is not going to work because your ID, NAME, BOOK, columns are not null, and u are only passing values into two columns making one not null column empty.
you don't have to pass a value into the autoincrement field since the db takes care of that

this is the fix you have to pass a value into a NOT NULL column if you don't, it is not going to work

INSERT INTO new_book (NAME,BOOK) VALUES('name of book','C:\Documents and Settings\OBl OKOYE\My Documents\pdfs\ajax in action' )

Always remember to check your table structures before writing your statements
Re: Mysql Help Needed by alexis(m): 7:36pm On Feb 21, 2007
why not paste the error message you receive so that we can know what went wrong
Re: Mysql Help Needed by Cactus(m): 8:07pm On Feb 21, 2007
look at the table structure and look at the insert statement, you should be able to figure out what is wrong.

incompatible data types, field mismatch, error in syntax.

you dont need error message to see what is wrong
Re: Mysql Help Needed by IronFist(m): 8:17pm On Feb 21, 2007
i redid the INSERT this time it worked. One thing though, the file size in the DB (88 bytes)is different from the file size in my filesystem(34mb). I don't know if this is wrong.Thanks for all the help anyways.
Re: Mysql Help Needed by Cactus(m): 8:28pm On Feb 21, 2007
provide detailed description of the file size, which file or if u can provide screenshot that will be helpful

i am glad the statement is working now GL.


r u refering to the blob size of the pdf compared to the actual pdf file itself?
Re: Mysql Help Needed by IronFist(m): 8:51pm On Feb 21, 2007
I actually was talking about the pdf's blob size in the DB being 88bytes while the pdf in my filesystem is 34.8mb. i actually expected that both of them be the same size. Pardon me i've only been toying around with varchars and integers.Appreciate the help
Re: Mysql Help Needed by Cactus(m): 9:19pm On Feb 21, 2007
u r storing the file path (C:\Documents and Settings\OBl OKOYE\My Documents\pdfs\ajax in action) as a blob that is in my opinion that is where the 88bytes come from. If u r only storing the path file well maybe the blob data type may not be the best to use. u can look into text, or varchar(255).

I am not really familiar with blobs and how it works
Re: Mysql Help Needed by Bossman(m): 11:27pm On Feb 21, 2007
As already mentioned, you are just storing the file path, and not the pdf itself. I am thinking you wanted to store the pdf and that's why the column is defined to hold a BLOB. Verify your requirements and define the columns appropriately or change your insert statement. No need to define a column as BLOB if it's only going to store a string as you are doing.

You can also use the describe statement to verify your table's structure. As in DESCRIBE yourTableName
Re: Mysql Help Needed by IronFist(m): 11:47pm On Feb 21, 2007
i've attached a description of the table. how exactly do i insert the pdf into the DB. all the texts i've read refer to BLOBs as the means by which such info is inserted.

Re: Mysql Help Needed by Cactus(m): 12:34am On Feb 22, 2007
look at this link

http://www.devarticles.com/c/a/MySQL/MySQL-and-BLOBs/3/

good luck blobbing


Do you want to store the pdf in a folder or u want to store it in the database?
Re: Mysql Help Needed by IronFist(m): 2:06am On Feb 22, 2007
I want to store pdfs in a Database
Re: Mysql Help Needed by Cactus(m): 4:41am On Feb 22, 2007
Dont know how that will work look at the link in my previous post that should give u an idea.

good luck

if u have problems next time, post detailed descripitions of everything, someone may know all the solutions or some of the solutions, post pictures if possible, post codes whenever applicable

that will make things faster. because someone that saw your previous post only asking about insert statement and the person knows the solution to the inserting the pdf in database may not even bother about looking at this thread again. so to get the most post all your questions.
Re: Mysql Help Needed by IronFist(m): 9:12am On Feb 22, 2007
Thanks for all the help.Ciao

(1) (Reply)

Any Dba In D House,pls Help / Java Rocks: Java Rules / Football Headlines App For Android

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.