Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Inserting Small Image Directly Into Database


How do you insert an image into a table directly using something like data studio?
I have tried googling it and it seems all the examples are using a language to do it for you. The images are between 2-4k and the table is just an int column followed by a blob column. I just thought the statement would go like

INSERT INTO sometable VALUES (1,'image.jpg');

The web suggests uploading and downloading in PHP (which im using) but im building the data first using data studio then just displaying the table information using PHP.

Before i go into displaying the information on the page i just wanted to make sure the insert query is correct.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Inserting Image Into MySQL Database
I understand that this is not the best way to use images and databases, but that is how the database is designes. So that is how i have to do it.

when i try it with the syntax:
INSERT INTO image_source(id, file_name, mime_type, image_data)
VALUES (13, 's620.jpg', 'image/gif', 'C:Inetpubwwwroots620.jpg')

I dont get any errors, but it doesnt insert the image either...
The image_data coulmn is of type blob as it is supposed to be, so im not sure what is going wrong here...

Inserting Image
I know its not the best way to store mime data in the mysql but the database is designed so i have to go that way.
I didnt have the idea to store and retrieve the mime data in the mysql.
Can anybody guide me in such case.

Inserting Image
I understand that this is not the best way to use images and databases, but that is how the database is designed. So that is how I have to do it.when i try it with the syntax:

Code:

INSERT INTO image_source(id, file_name, mime_type, image_data)
VALUES (13, 's620.jpg', 'image/jpeg', 'C:Inetpubwwwroots620.jpg')



I dont get any errors, but it doesnt insert the image either.The image_data coulmn is of type blob as it is supposed to be, so im not sure what is going wrong here

MySQL Administrator Backup Directly To Local Database
In MySQL administrator is there a way to backup directly to my local database from a remote host. I would ideally have this done automatically once a day.

I like to test locally and don't want to have to restore the database locally each time a backing from the remote site is done.

Backup A Small Database.
I'm looking to backup a small mysql database. The problem is mysqldump does not exist on the server I'm trying to export the database from.

Does a php script exist which I could use to do essentially the same thing as mysqldump?

Small SQL & Php Webpage Field Database Task
In a webpage, imagine a little section where the user fills in his/her contact details to register. Among this section is a field called "Country". The task is to make this field automatically generate the persons current country of residence. I am told, that the IP ranges and the country to which they belong is in a CSV .xls file. I am also told that the best way to do this is to:

1) Insert the CSV into database table (MySQL).
2) Use php to get that country name onto the website field.

How To Reset Yahoo Small Business MySQL Database
I am a new user of "Yahoo Small Business" web hosting service and I changed
a lot of settings in my "MySQL Database" using "phpMyAdmin" utility during my
learning period. Now, I want to reset my Yahoo Small Business MySQL Database
to default settings or to reinstall it (I want it to be the same as it was newly
activated).

Note: I tried to repair my database with Yahoo's "Database Setup" page and the
message "Database scheduled for repair" appeared for a few days but nothing
happened. And, I can not login to my database using "phpMyAdmin" utility.

If you can help me to reset my "Yahoo Small Business - MySQL Database" I will
be very pleased.

Storing Image Into Database
Hi..guys.How can I achieve to storing image into database?Is it necessary to create another table or able to mix with a table which store plain data?

How To Structure A Image Database
I would like to create a simple php / mysql image database.
But I'm a newbie and need some advises on how to structure the database.

Functions
Add images / select keywords for this picture
Add keywords
Search for images

Structure
Table "imageDb" Id added size description..........
Table "keywordDb" Id text
Table "conntectDb" Id Idkeyword IdImage

And the search could be something like:
select * from connectDb there id = 2 left join........... and then I'm unsure....

Image Name Isn't Posting To Database
I'm working on a form where an admin will type in a title and information about an event, as well as include a photo. The admin will have the ability to search for an image locally to associate with the event and when they click "submit" on the form, the title and info will go to the database, the image is uploaded to a folder on the server, and the image's name is to be written into the appropriate row in the table.

I have obviously mislabeled or completely missed something because the result of the following script is that the text goes to the database, the image gets uploaded to the folder on the server, but the image name does not make it to the database (so it obviously doesn't show up on the page).

Maybe someone with fresh eyes, and a whole lot more experience than I, can see what I'm doing wrong.

Top of code:

<?php
$imgdir = "images/";

session_start();
if(!session_is_registered(myusername)){
header("location:index.php");
}

if (isset($_POST['action'])) {
if (is_uploaded_file($_FILES['image_file']['tmp_name'])) {
$copy = copy($_FILES['image_file']['tmp_name'], $imgdir . $_FILES['image_file']['name']);..........................................................

Image Files On A Database
I'd like to know if it is possible to save an object (such as an image) embedded in a field of a table. I want to build a table where i can save information about products and an image (photo) for each product.

I've heard about blob fields, are they the answer to my problem? If so, how do I load the image to the field with PHP code? And how do I show the image from the table, with PHP code?

How To Upload Image Into Mysql Database
how to upload image into mysql database. my insert.php can move the uploaded images into upload directory(public_html/Upload). Now how can I have the SQL statement to insert the images from upload directory into the bob field ? I use the sql statement: Code:

Insert Image In Mysql Database
what is the code to insert image in the database.

How Do Insert Image/image Files
I have some image files. How do I insert into mysql?

Inserting IP Into Database
Im making a register script. And ive got a field on it called userIP and here is the code for it

<input type="text" name="UserIP" value="<?php echo $_SERVER['REMOTE_ADDR'];?>" size="32" disabled="disabled" />

but when i submit the form is says "Column 'UserIP' cannot be null", when it is clearly not null Code:

InnoDB Not Inserting In Database
I have a jsp form that does a simple insert into a database with InnoDB tables. I need this because of foreign keys and such.
Below the form on the same page is a list which does a select on the same table the insert goes.
So you insert one thing, the page refreshes and you see your insert in the list.
That happens!
BUT there is nothing inserted in the database. So i think the results that I see are stored in the session of the page or something (hash or something, i dunno).

When i try the same with a MyIsam database it inserts fine.
I've already set global transaction levels to READ-COMMITTED (what I understand from the manual is that this is what i need), I've set that by command line and also in my.ini file (restarted the server too).

The select@@global.transaction_level; shows that it is set good.

Need I to do something with auto commit also? I really don't understand that chapter, is it supposed to be on, off, set to 1 or what, for what i need?

Inserting Into MySQL Database
I have a MySQL database through my hosting company and have written an upload page for users to input information into a html form and submit it to my database. This works fine for short little answers (like "Test"), but when I want to put sentences in or anything longer than a couple of words, it doesn't insert itself into the database. I don't get any errors, it just doesn't do anything.

I've tried changing the fields to mediumtext and longtext and still getting the same problems.

Inserting A Colon Into A Database
I have a asp page where I am inserting a text into a mediumtext field. Lets just say the word is (we're). Whenever I insert a colon I get a error. It doesnt like it. I take the colon out and it works. Does anyone know of a work around.  

Inserting Records Into A Database
I am using mysql 4.1 and I am trying to insert a sql file into a database. I have the mysql> prompt but I cannot figure out the script to insert the sql file. I have tried using th database name followed by < then the file name but this doesnt work.

Inserting / Updating Database
I am using ASP with MySQL. This is code for a calendar application that saves info to the database based on date. It is not giving an error when processed. Nothing is being inserted into the database and nothing is being updated either. Code:

Using MyISAM Directly
Has anybody had experience accessing MySQL tables via MyISAM library?
I'm working on an application that has to have both SQL-like and DBM-like
(file-level) access to the table data. I thought that using MyISAM
directly would be a good idea. If anybody has any better suggestions, I am
all ears.

Also, I was wondering if it's possible to use Berkeley DB tools and
libraries to access MySQL data files, which are set to use BDB as the
storage engine. If it is, can somebody point me at some examples (except
what's in the source already).

Using MyISAM Directly
Has anybody had experience accessing MySQL tables via MyISAM library?
I'm working on an application that has to have both SQL-like and DBM-like
(file-level) access to the table data. I thought that using MyISAM
directly would be a good idea. If anybody has any better suggestions, I am
all ears.
Also, I was wondering if it's possible to use Berkeley DB tools and
libraries to access MySQL data files, which are set to use BDB as the
storage engine. If it is, can somebody point me at some examples (except
what's in the source already).

Inserting Blob Into MySQL Database
I'm facing a strange problem when I try to insert a blob in my SQL database. I'm implementing a web application using Struts and hibernate and My SQL for the database. The application runs fine when I insert the blob (which is an image in my case).

However, I'm unable to see the row in the table when I go to MySQL and do a "select" statement. All I get are a bunch of dashed lines that go on forever. I simply followed instructions given in a struts and hibernate tutorial to insert blob data and I don't get any errors when I run the application. Following are the details: Code:

Inserting Data Into Mysql Database
i need to insert data from a txt file that is updating continously, select those info that i need by line, and after that adding them,

i don't think that can be done in mysql; i've foud another program that i've made to read the file and select them, but now i don't know how to insert them in a data base, except php is there another program that can insert data into a mysql database?

Update Value Directly In The Same Query
Is it possible to update a value directly, adding text to it, without getting it first, adding the text in php and then do the update.

for example:
value in field users: ",45,"

and then adding ,34, to the field directly by doing something like:
update table set users='users,34,'

so the value in the field afterwards will be ",45,,34,"?

Inserting Special Characters Into MySQL Database
I am trying to add products to one of my clients' online shops and in the past it's all gone fine. I have a PHP script which handles a CSV file upload, digests the rows and inserts the data into a number of tables.

The upload I did today seemed fine until I realised that certain products have appeared with a ? in the name or description where there shouldn't be. Checking in the CSV, I find that the client has added a few hundred new products whose names include 'Hahnemühle Albrecht Dürer' (the product supplier) and other products whose names &/or descriptions include the micron symbol 'µ'. As you've probably guessed, the characters which are being replaced are ü and µ.

FYI, the site is still using MySQL 3.23.58 - I know it's old but we've just persuaded the client into a new .NET and MSSQL site re-design starting in a couple of weeks and we'll be dicthing that server so upgrading isn't an option.

I guess that I would be doing a search and replace for these characters in PHP (by ascii code?) and then inserting into the database. Then doing the reverse when displaying the product on the page?

Inserting Jpegs Or Any Non-text File Into Database
how to insert non-text entries into the rows of a database. The image files(jpegs) or video files(mpegs, avis). I heard from someone that you call those BLOB's(I forgot what that means). Could anyone teach or show me how its done.

Inserting Data Into A Mysql Database Using A Form
I have been looking for a couple of days now trying to figure out how I can add data into a mysql database using a form. I know html but I am a total newbie at php and mysql. I really need some help on this.

Joining Tables Which Aren't Directly Related
I'm struggling to get my head round a SQL query and wonder if you might be able to help (I'm using MySQL version 4.1.20-1).

I have three tables: accounts, items and invoices.

CREATE TABLE accounts (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
...
PRIMARY KEY (id)
) ENGINE = InnoDB;

CREATE TABLE items (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
accounts_id INT UNSIGNED,
...
PRIMARY KEY (id),
FOREIGN KEY (accounts_id) REFERENCES accounts (id) ON DELETE SET NULL
) ENGINE = InnoDB;

CREATE TABLE invoices (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
items_id INT UNSIGNED,
...
PRIMARY KEY (id),
FOREIGN KEY (items_id) REFERENCES items (id) ON DELETE CASCADE
) ENGINE = InnoDB;
Each account can have multiple items and each item can have multiple invoices. Hope you're with me so far?

So here's the question. If I have an account ID, how do I get a list of invoice IDs for that account when accounts and invoices aren't directly related?

Associative Table Or A Directly Foreign Key
I am working with hibernate and i want to map my Objects to tables structre.

There is two ways to map relation:
1. with associative table
2. directly foreign key (i mean without associative table)

Can you please explain what are the advantages for each way?

Is There A Query To Check Directly If A Datarecord Exists?
Is there a query to check directly if a datarecord exists?

How To Insert Images Directly Into Mysql Table
Im working on a page for photographer. And he wants some amount of photos to have there and change it whenever he would like to.

I thought i put all the photos in mysql db and i would pull it out to webpage using variables. But Im stuck already in the first step -

STORING THOSE IMAGES INSIDE A TABLE OF DB.

I read about BLOB and avr_row_length and max_rows, but nothing is working. The image is stored in many rows and the output is just strange symbols.

I also read those long, hard-mind taking scripts how to upload image using php. But i dont want to slowstep through php, uploading file etc, I just want something like:

LOAD DATA INFILE 'image.img' into table tbl_name;

and then using php on my page to display it.

Connect To Sqlserver Directly From Unix Prompt
How can I connect directly to sqlserver from a Unix Prompt? I am using DataDirect in the ODBC connectivity. Is there any way whether I can connect to SQLServer from the prompt,just a select stmt will do.

For eg: if I use select * from table|sqlplus -s usernmae/password@hostname

How To Connect Directly To Mysql Server Port (3306) Using TCP/IP Protocol
I want to develop an application in LabWindows/CVI (ANSI C developpment software for instrumentation) from which I could connect directly to mysql server port (3306) using TCP/IP protocol. This developpment environment allows me to use functions to connect, read and write to a certain port using TCP/IP protocol. I must say I'm new to using MySQL and I searched the manual without any response to my question.

One Big DB Or Several Small Ones ?
i'm about to build a DB which should be around 200 000 rows. Each line would be 2 fields: user_name, status

So i'm wondering about performances:
Is it better to build 26 tables: first one user beginning by "a" second one by "b" etc, or one big table with everyone? I guess the first solution will increase the speed? What about the cpu? the memory?

The queries will be mostly select, and some update to change the status field.

One Big Table Or Many Small Ones?
I am designing an interactive website consisting of a few pages and I want to track individual user progress. I was wondering if it would be better to create one big table for all values on all pages (Which may have a lot of columns, easily hundred or more), or created a separate table for each page (so I could have some 10 tables with 10 columns or more). Or does it not matter?

Big Select Vs Small Ones
I have an array of 10 IDs.
I need to query the db for values associated with these 10 IDs.

In a lot of places, I have seen people using a php foreach like this

foreach (ids in array)
{
query = SELECT values FROM tables WHERE id = [id 1 in array]
do query
store values
}

we could build one big select statement like this:

query = SELECT values FROM tables WHERE id = [id 1 in array] OR [id 2 in array] OR [id 3 in array].... until we have ids.

Small Databases
I am wondering if having a database for the client back office, a database for the static website and a database for website stats would be a good idea.

The client database would hold credit card info, user info, reg info, project info, client messages and more.
The website database would carry all the content for the pages of the public website like about us, contact, home page, news and such.
The website stats database would keep track of user agents, new hits, returning hits, keyword searches made on the client websites and all that jazz.
Should I make this all ONE giant database or three smaller database?

Small Favor Gone Wrong
I have a VPS account and I am trying to move my sister's professional organizations site onto my server more or less as a favor (getting paid a little - but not really worth my time). It is being hosted by a professional hosting company that supplied me with ftp access to download the site for the move.

I am running into a problem because I don't know how to set-up/use mySQL through UNIX. Previously I have used the Plesk interface provided with my VPS account. Plesk (or at least my hosting services configuration of it) won't allow me to create the user I need in order to import the database because the user ID is contained within the user PW. (this is the database coming from the vendor).

The original host has been unhelpful at best so I thought before I go to them and ask for assistance (that I am pretty sure I won't get anyway) that I would post here to find out if there is any easy way through this roadblock or if any the unix commands are simple enough, how I would proceed that way.

Small Query Optimization
I need this query optimized using indexes. So I was wondering how I could optimize it to work with an index for speed.The query is:

Quote: select ided from products where dates <= 2006-11-11 or cost=0.00 or url not like 'http://%' or imgurl not like 'http%'

I tried making an index on (dates,cost,url,imgurl) but it doesn't seem to use the index when I do the explain part. I find that even when I miss of the like parts of the query it still is not using the index. It seems to not use the index because of the "or" that is used in the query instead of the "and". Could this be the reason and how could I over come this so that it will use the index.

Small Binary Data
Can anybody tell me what way is best to save a small binary data (16 Byte) in MySQL?


Help With A Small Query Optimization Using An Index. THANKS!
I need this query optimized using indexes. So I was wondering how I could optimize it to work with an index for speed.

The query is:

Quote:

select ided from products where dates <= 2006-11-11 or cost=0.00 or url not like 'http://%' or imgurl not like 'http%'

I tried making an index on (dates,cost,url,imgurl) but it doesn't seem to use the index when I do the explain part. I find that even when I miss of the like parts of the query it still is not using the index. It seems to not use the index because of the "or" that is used in the query instead of the "and". Could this be the reason and how could I over come this so that it will use the index.

Several Small Calls Vs One Large Call
I am working on a php interface to a mySQL db which will pull lots of rows from the database. Assuming I am selecting a hundred rows by their auto_incremented ID's, is it better to do this with a loop of 100 "SELECT ... WHERE id=" calls, or to do it with one single "SELECT ... WHERE id IN(...)" call, with IN() holding a list of the hundred items.

One Large Table Or Many Small Tables?
I'm trying to decide whether to use one large table or many small tables.
I need to gather information from various devices (about 500). Each device
has its own Id and some data.

Should I use only one table with an indexed column for the ID and another
column for the data, or should I use 500 tables each with only one column
for the data?

One Huge Table As Appose To Many Small Ones
i have a very large XML DB (60gb+ and growing on a daily basis) which holds complete life cycles of stock option , i used to hold it all in folders with each folder named like the option paperId so it seemed logical to me to hold it now in diffrent tables for each paper even tough the are all the same exact table , now i'm having some problems with hibernate (one of the biggest reasons i left XML) and so many tables , is it more effiecent to keeeping data like that ?

ofcours i will have to change the PK from datetime to paperId+DateTime if i decide to change to one big table ... how can i calculate diffrence in retrieving data ?

One Large Table Vs. Many Small Tables
I'm working on a design using PHP & MySQL and I'd like to get some opinions on this.

My design has several tables that will be referenced but I'm wondering if those tables should be broken down even more and referenced more dynamically. The reason that I wonder about this is for long term goals. I hope that eventually there will be two or three thousand records that will be used on a regular basis. These records will need to be separated into groups, but I'm not sure if I should use a field in the database table or create a new table for each group.

If a few hundred records could be in each group, do you think it's better to use one large table with a field for the group ID, or a new table for each group?

Structure Of Small Social Network
I need to setup a social network type mysql database, but not as intense as friendster, thefacebook, myspace, etc.

i have a structure set up but it think it's weak and extremely limited:


Code:


+---------+-----------+
| user_id | friend_id |
+---------+-----------+
| 5 | 4 |
| 1 | 7 |
+---------+-----------+



i fear it's going to be a lot of redundant IDs in a column, which i think could be a problem when retreiving friends:


Code:


+---------+-----------+
| user_id | friend_id |
+---------+-----------+
| 5 | 4 |
| 1 | 7 |
| 1 | 9 |
| 7 | 9 |
+---------+-----------+



i want to do a "bob is friends with john" and a "jackie knows sally through richard" (aka friend of a friend). that's it and nothing more. how do i structure mySQL database to be able to this?

One Big Query Vs Lots Of Small Queries
I am in the process of migrating a MySQL database from one schema to another and am writing a script to extract the info from one table to be inserted into multiple tables on new new db.
My question is this, is it better for me to make one giant query (about 1 million records returned) on the source table, manipulate the data, then enter in the data by cycling through the results, or would it be better to split up the query on the source table into lots of smaller queries with a short pause in between?

MySQL Upload Small Files
I'm uploading small files (>10K) and mysql is deleting it. The one field is a blob field and everytime i test upload a file thru phpMyAdmin within 2 seconds mysql deletes the row. Theres nothing in mysqld.log, there another log i should be checking out?


Copyright © 2005-08 www.BigResource.com, All rights reserved