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




How Do You Enter An Entry With A Newline Inside The Entry?


I'm trying to enter an entry into the table. However, my entries must have newlines inside each entry. Further more, i'm trying to do this from an excel file(ie. first by saving it to a text file and then using LOAD DATA INFILE..).




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Last Entry
When i view tables and rows in phpmyadmin, the latest entry (albeit the higher ID number) is on top. Does it work that way inthe internals of mysql? If I select 10 rows with a limit of 10, will i get the latest inserts (assuming the last row id was 49, 49 48 47 46 45... instead of 1,2,3... )?

Duplicate Entry For Key 1
This has me completely stumped, and I've never see anything like it.

Here's my query:

SELECT mus_searchsynonyms.good_term
, mus_searchsynonyms.alt_term
FROM s01_MUS_SearchSynonyms AS mus_searchsynonyms
WHERE mus_searchsynonyms.active = 1
AND mus_searchsynonyms.alt_term = ".quote_smart($search_query)."
AND mus_searchsynonyms.auto_replace = 0
When I use PHP to execute the query, I get the following error message (mysql_error()): (obviously <<$search_query>> is whatever the value of the variable is)

Quote:

Duplicate entry ?-<<$search_query>>' for key 1

When I run the query in phpmyadmin, the query is fine...

First, I don't know why I'd get a key error on a select query, 2nd, there aren't any duplicates in my table...

Most Popular Entry?
I have a quite simple question which I hope can be answered.

Whenever someone downloads a video from my site, a database entry is made with the time and name of the video. I run a php script everyday which discards entries older than 7 days. So I have all that figured out.

What I want to know is, how do I work out what the 10 most popular entries are in the database (by name)?

For example, 8 entries may have the name Video1.wmv, 4 entries may have the name Video4.wmv.etc.

I'm not sure if this can be done via a mysql query, or if php will somehow have to select the most popular entries.

Can't Get Newest Entry
I am trying to select two entries from two databases with one query:

$query = "SELECT ibf_members.id,ibf_members.members_display_name,ibf_member_extra.interests,ibf_member_extra.website,ibf_member_extra.avatar_location,ibf_members.joined FROM ibf_members,ibf_member_extra ORDER BY `joined`,`id` DESC LIMIT 1";
However, it won't show the latest member. It always shows member #1 which is the earliest member. I'm probably doing this wrong. Please help if you can.

Deleting An Entry?
I am using v4.0.20, and I need to figure out how to delete an entry. The database is for a game server I run. It is private, and so I have to add and remove members manually. Here is what I enter to add a person;

INSERT INTO Permissions VALUES ('Sue', 'PRIVATE');

I have never had to remove a player until now! How would I go about removing this entry?

If Entry Not Found
I want to query my data base for a certain user and id and I want to display a message user not found if the entry isn't there or display the entry if it is.

GUI For Data Entry
I am new to MySQL. 10 years ago I was into filemaker development. FileMaker has very nice built-in tools for creating user interface forms for data entry, retreival, editing, etc. So, what tools (preferable for Mac OS X) are available do this with MySQL?

Anyone know of any good apps for taking a MySQL database and automatically creating the PHP code to interact with the database? I've seen one or two for Mac OS X but the Mac OS X solutions seem to be somewhat half-baked compared to the Windows solutions.

Selecting Last Entry
All I need some help i have been trying to write this program for a friend that owns a internet cafe. The DB he uses is in sql he wants people to be able to see their time on his website i almost have it all written except for one problem when it selects there time it brings up all the changes to their account as in if he bought a hour yesterday it would so it i want it to show the current or last entry in the columns heres the code

SELECT userid, username, usertime, datetime
FROM users a, log b
where username = 'Their UserName'
order by datetime;

Is there any command so it shows only the last entry?

Double Entry
Howe can i prevent a double entry in a database.
Users can input their data into table.
But how to prevent a double entry.

Users can enter name and date
So users can enter their names only on one date.

Data Entry Via GUI
Is there a tool for MySQL for creating data-input forms, similar to the FORM VIEW in MS Access, that do not require programming to simply insert data into existing cells or to add rows for new data (and then insert the data)? I looked at the MySQL Browser GUI tool, but didn't see anything about data entry.

Only Allowing One Entry
I am trying to create a simple guetbook. I have it working, but the thing is, it only lets me enter one entry and can't work out why.

This is the insert code i have:


PHP Code:





 $insert="Insert into visitordata (name,email, location) values('$name','$email, '$location')";
mysql_query($insert) or die("Could not insert your entry");

Duplicate Entry
I'm currently developing a shopping cart for a local business using php and mysql. I was testing the registration form on the site when all of a sudden I got this error: "Duplicate entry 'tom@thisi.com' for key 1" (that's just a random test email by the way).

I worked out that I only get this error when I use an email that I've used before to signup. Even though I had deleted the previously used email address, it returns an error that it's a duplicate entry. Another strange thing is that the 'email' field is just an ordinary field so a duplicate entry shouldn't cause a problem anyway. If I truncate the table, it's all fixed of course - that's until I use that email address, then delete that account and try and use that email address again.

Match An Entry
Software receives alerts and feeds them into a database table. I need a stored procedure that takes each entry before it enters the table and compares it with the entries already in the table. If the entry about to be added matching one that is already in the table...I need it to cancel each other out and be removed from the database table. If the entry about to be added DOESN'T have a match then it should be added to the table. Is this possible?

Update Entry
Below is the code that I am using. It does the updating for me which is perfect but I cannot get the date part right. It updates all entries. I want it to update any entry that is one day older than presentday.
so update entry if curdat = yesterday.. Please help!

result = mysql_query("UPDATE `shows` SET status=81 WHERE date <= (CURDATE() - INTERVAL 1 DAY)");

Duplicate Entry
I have a table with 10 columns and i insert data into it which is unique in a column called (scrape), so to do that i use
Code:


<?
$reb = select count(*) from table where scrape = '$scrape';
if (mysql_result($reb,0) > 0) {
echo "Item Already Added!<br>";
} else {
add the item
}
?> //I know it's a n00bish way

Validate Entry
How can i validate entries based form Table1 before adding to table2. It means, all entries can be entered into table2 as long as it is already in table1

Table1
id val1
1 002
2 003
3 004

Table2
id val2
1
2
3

Duplicate Entry
I am with a hosting providing use xcart and i keep tgettin this error message:

Quote: INVALID SQL: 1062 : Duplicate entry '' for key 2
SQL QUERY FAILURE: INSERT INTO xcart_products (provider, add_date)
VALUES ('master', '1109438680')

First Letter Of An Entry
Is there a query that allows me to select an item that starts with a specific letter, or a range of letters?
for example, i have:

apple
banana
orange

in my table. Can i issue a query that selects anything that has the first letter in the range a-d?

Duplicate Entry Error ?
I have this table, now i won't it to be possible to have duplicated entrys. Is that possible with this table, or would i have to give it a column with autoincreasment or something?

Mysql, 2nd Highest Entry
how to pick 2nd highest entry from any table in mysql database??
for highest entry i can go by order by desc clause
well limit 0,2 can give me 2 highest entries
but what if i want only 2nd highest entry
any help would be gr8ly appreciated



DELETE DUPLICATE Except LAST ENTRY?
- HOW TO DELETE DUPLICATE FROM MYSQL EXCEPT LAST ENTRY?



CREATE TABLE `chatone` (
`id` int(255) NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`message` varchar(250) NOT NULL default '',
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `chatone`
--

INSERT INTO `chatone` VALUES (1, 'test', 'orange', &#55614;&#57159;-03-13 15:25:24');
INSERT INTO `chatone` VALUES (2, 'test', 'orange', &#55614;&#57159;-03-13 15:25:24');
INSERT INTO `chatone` VALUES (3, 'test', 'apple', &#55614;&#57159;-03-13 15:25:48');
INSERT INTO `chatone` VALUES (4, 'donald', 'hello', &#55614;&#57159;-03-13 15:25:48');

Pulling Out The 2nd Entry From A Table
i have an application already installed. It has an table to handle attachments to articles. The structure is;

attachment_id |question_id| file_path

Is it possible to pull out the 2nd entry in a table for a particular question (using its question_id)?

eg something like?
Select * From attachments WHERE question_id = $question_id Limit ROW 2

Ive search the mysql online manual but im getting really lost!

Duplicate Entry Error?
I am trying to insert new data into my database via a form, but i get this error:

Duplicate entry &#393;' for key 2

I think I have made a mistake while made my MySQL database.

ERROR: Duplicate Entry '1' For Key 1
I'm working on this little project. I'm learning the basics right now of SQL. I'm currently getting this error

Duplicate entry '1' for key 1

I have no idea what it means. I'm working with two files here. One is creating tables, while the other is inserting data. If you have any idea what the problem is I'd appreciate it. Here's the code.

creatmovie.php

<?php
//connect to mysql
$connect = mysql_connect("localhost", "root", "pass")
or die("Check your connection");

//create the main database
$create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite")
or die(mysql_error());

//make sure our recently created database is the active one
mysql_select_db("moviesite");

/....................................................................

Curdate() Is 0000-00-00 For New Entry
I have a web form that users submit information through and it gets stored in a MySQL table. I wanted to capture the "creation date" of the record. So, I do the following:

1) I connect to the database and ask for the curdate() assigning it to a variable.
2) Then I turn around and store the user input into the table along with the curdate() variable that I first retrieved.

However, I just noticed something while still testing this. If I drop/add the table, the first entry always retrieves a curdate() of 0000-00-00. And this is a issue as I later allow users to retrieve these records based upon their creation dates. So, the first one will be lost.

Why is the first record recording 0000-00-00? The table exists even without any data in it. And, how do I get around this?

Check If An Entry Exists
I have a table which records information on ratings that each user has given each movie, it looks a little like this:

Table = USER_VOTES

USER_ID MOVIE_ID VOTE
1 2 5
2 3 5
3 4 5
3 5 5
4 3 5

I an using a simple SELECT command to find if a user has already voted, ie. if a row already exists with their USER_ID and MOVIE_ID. I am having a little trouble with this SELECT statement and wonder if there is a better way of doing this simple check. My code looks like this:

$sql = "SELECT vote FROM user_votes WHERE movie_id='$id' && user_id='$usrID'";
if ($result = mysql_query($sql, $db)) {
//if vote already exists display error
$error = "You have already voted for this moive
(your rating was ".mysql_result($result,0,"vote").").";
} else {
//if no vote exists process vote...
}

If a user has not voted before I get an error like this:
Unable to jump to row 0 on MySQL result index 2

To me it appears that mysql_query() does not return false when no results are found. Is there a command which does check results and return false or is there a much easier way to check, perhaps there could be some checking code in the actual SQL query?

How To Access The Last Entry For Different Systems
How would I access the values of the last datetime stamp for different system id's present in the table?

For example, if i have 5 system id's their last entered datetime stamps might be different. How would i access the related values for the systems?

Data Entry Application...
I need to build a data entry application that will allow me to seek out a record in mysql by an index number and quickly modify the records contents.  This will be for dealing with direct mail response information.  

Any suggestions for a language to build this in?  Or existing programs to do this?

I tried to build it in a web environment with javascript, but am having trouble reducing the necessary key strokes/clicks to complete one cycle of entry. 

Selecting A Random Entry.
Is there any way to select a random entry?

to fit in with this statement...

SELECT * FROM `table` WHERE `type` = '1' LIMIT 1

Disabling An Entry More Then 3 Times A Day.
Like if you enter 3 times a day the same text. It echo's something instead of writing in the database. Do i need to add a date on where the line was added to it?

Insert Entry Doesn't Work
When I make a "select" request everything runs fine. But if I want to insert an entry, nothing happens. There isn't a error-message and the privileges are set right. (Syntax is ok :-)) Where is the problem?

Automating Data Entry
I know about stored procedures and that they can speed up data entry via the
SQL 'insert ' statement.

However, one drawback to this method is that using the stored procedure
still requires one to manually and individually enter each and every record
to be inserted to the database before the procedure is executed.

I want to circumvent this tedium by finding a way to use maybe a VB
application that prompts a user for the data to be entered into each record
and then stores it to the table.

This seems easier (is there an even EASIER way?) than creating a text file
and then executing it.

Deleting An Entry From A Table?
When the user logs out, it doesn't display an error message, but when I check the table Currentusers, they are still on it.

$username = $_SESSION['username'];

mysql_query("DELETE FROM Currentusers WHERE username=$username");
echo $username;
echo " is now logged out.";

I must be defining the WHERE username=$username"); part incorrectly because when I take out username=$username"); and replace it with username='Jane'); it removes Jane from the table. There isn't a problem with the $username variable because it displays the value correctly. What am I doing wrong?

Check Table For An Entry?
I'm currently working on some rudamentry administration, namely an IP ban list. I want to make it so that if the user trys to ban an IP that is already in the list, the entry will be removed instead. what would be the best way to go about this?

Duplicate Entry In An Auto_increment Key
I have a table with an int(11) primary key that is set to auto_increment. Now I have this script that keeps on failing because it says that there is a duplicate key but it doesn't even exist.

It's now at 1149447582 and it's stuck there. Is this a bug or something? I'm using MySQL 4.1.12 on CentOS 4.3 (64-bit).

Alter Table Entry
What I want to do is change the value of the column "hits" from the table "stats" where the column "page" equals the variable $page. In MYSQL talk, I want to change:

SELECT `hits` FROM `stats` WHERE `page` = $page

I want to change that value to 23. How do I do this.

Automating Data Entry
I know about stored procedures and that they can speed up data entry via the
SQL 'insert ' statement.

However, one drawback to this method is that using the stored procedure
still requires one to manually and individually enter each and every record
to be inserted to the database before the procedure is executed.

I want to circumvent this tedium by finding a way to use maybe a VB
application that prompts a user for the data to be entered into each record
and then stores it to the table.

This seems easier (is there an even EASIER way?) than creating a text file
and then executing it.

Display Newest Db Entry
i have tried the following and it comes up with this error: Queryproblem: 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 'BY date DESC' at line 1
---------------------
SELECT top1 FROM `cds` SORT BY date DESC
---------------------
i need to display the newest entry in the mysql database.

Duplicate Entry '0' For Key 1 Error
I have a table which is like:

[MYSQL]
CREATE TABLE word (
wordno DECIMAL(6) NOT NULL,
lemma VARCHAR(70) NOT NULL
);
ALTER TABLE word ADD CONSTRAINT pk_word PRIMARY KEY(wordno);
[/MYSQL]

and I have a word.sql data file like below:

[MYSQL]
(0, 'entity')
(1, 'physical thing')
(2, 'thing')
--and goes on
[/MYSQL]

I am trying to fill the db with data and use the command:

LOAD DATA INFILE 'word.sql' INTO TABLE word;

but I am getting the error:

#1062 - Duplicate entry '0' for key 1

Why I am getting this error? Is this because of PHP or MySQL version? I am running MySQL ver 3.23.49 with PHP 4.3.6.

Getting A Random Entry From A Table
Assume I have a table with 100 entries
I would like to run a query that will return a random entry from all those that match some condition

One way would be to run the query, getting ALL the entries that match the condition and then pick one of the randomly

Is there a way to tell MySQL to do it for me, so I won't have to pick the random entry myself?
This will reduce the size of result set from n to 1.

Insert When Entry Is Not Exist
I want to be able to insert the new entry if the old entry not exist. Do i need to do the select then insert? Is there a better way to do it for faster & large database?


Code:


$query = "select count(*) as itisexist from AA where BB='$var'";
$result = mysql_query($query);
$line = mysql_fetch_array($result, MYSQL_ASSOC)
if ($line['itisexist'] == 0 ) {
$query = "insert into AA set BB='$var'";
mysql_query($query);
}

Multiple Entry Field
I have a table for members and a table for trades and often a member will have many trades listed on thier record. There are only 2 columns in the trade table 'table_ID' (PK) and 'tradelist' (plumber, electrician, etc).

I have created an admin page in D/Weaver using PHP code, which you can add to the trade list as a new trade pops up and I have an add & edit member page with checkboxes that lists all of the trades and you can just check the ones that apply to that member.
Problem 1 - It only applies the first checked box to the database.

Field Entry As A Tablename
is it possible to use a fieldname from one table as the tablename in another query?

Here's how I'm doing it at the moment:
1: SELECT tname FROM lookuptable WHERE id = 1;
2: (store result as a variable $table in php)
3: SELECT * FROM $table;

Is there anyway of combining these steps in one query?

Retrieve MySQL Entry &
does anyone know a way how to do the following:
Use PHP maybe to retrieve a database entry from MySQL (Song Name) and set MSN Messenger's Personal Message (Or Display Name) to the Song Name?

Finding Closest Entry
I'm building a "spot the ball" app for a client in php/mysql.
I'm at the stage where the site needs to pick from all the entries, the one that is closest to the "correct" pair of co-ords.
Is there a simple way in SQL to select the record where x is closest to $x and y is closest to $y? where $x and $y are the correct values?

Auto Date Entry
Is there a way to have a date automatically entered into a form, so the user does not always have to add it manually? What table Type do I use? I see a TIMESTAMP, but no DATESTAMP.

Unique Entry In A Table
I am having a problem with trying to work out how I could select the lowest unique number in a field called MONEY. I am trying to find the record with the least money, but no other record in that table can have the same amount of money.

Here is the table:

CREATE TABLE lubidEntries (
partnerid smallint(5) unsigned NOT NULL default '0',
lubidCamp smallint(5) unsigned NOT NULL default '0',
keyword varchar(40) NOT NULL default '',
MONEY varchar(40) NOT NULL default '',
status enum('current','old', 'lubid') default NULL,
time datetime NOT NULL default '0000-00-00 00:00:00',
numberid int(10) unsigned NOT NULL default '0',
KEY lubidentries (partnerid,status,numberid)
) TYPE=MyISAM;

Select Random Entry
I have 3 seperate tables of people who have entered a competition. What I need to do now is select the 1 random winner from the 3 tables.
So is there any way I can do this in mysql or am I gonna need to write a script?

Finding And Deleting Entry
Code:

DELETE FROM `comments`
WHERE `uid`='x in more than one entry' AND `gid`='y in the same entry/entries'

how would you put that in MySQL?

basically, if those two fields are say 321 and 123, then if there is more than one entry with 321 and 123 for those fields, they will be deleted.


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