trudge 8 Junior Poster

Haven't you received enough replies here? Please refrain from double posting or at least let us know you have posted somewhere else so that multiple people don't end up wasting their time for coming up with the solution of a same problem.

Yes, I have received replies in that newsgroup, but no solution as yet. And no solutions here either. If I had a solution, it would have been noted and posted here. Thanks for your help. You can delete this thread.

trudge 8 Junior Poster

I have code that successfully displays results, but throws an error in
Fx 3 and IE 6.

A sample of the XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mycds>
<cd>
        <title>Wolf City</title>
        <artist>Amon Duul II</artist>
        <artist_id>1</artist_id>
        <track_id>1</track_id>
        <sequence>1</sequence>
        <track_name> Surrounded By The Stars</track_name>
        <track_id>2</track_id>
        <sequence>2</sequence>
        <track_name> Green Bubble Raincoated Man</track_name>
        <track_id>3</track_id>
        <sequence>3</sequence>
        <track_name> Jail-House-Frog</track_name>
        <track_id>4</track_id>
        <sequence>4</sequence>
        <track_name> Wolf City</track_name>
        <track_id>5</track_id>
        <sequence>5</sequence>
        <track_name> Wie Der Wind Am Ende Einer Strabe</track_name>
        <track_id>6</track_id>
        <sequence>6</sequence>
        <track_name> Deutsch Nepal</track_name>
        <track_id>7</track_id>
        <sequence>7</sequence>
        <track_name> Sleepwalker's Timeless Bridge</track_name>
</cd>
</mycds>

I get the sequence and tracks with code like this:

var x=xmlDoc.getElementsByTagName("cd");

function show(i)
{
for (j=0; j < tracks.length; j++)
{
sequence = x[i].getElementsByTagName("sequence")
[j].childNodes[0].nodeValue;
.
.
.

}
}

But that produces the error:
Error: x.getElementsByTagName("sequence")[j] is undefined

Note: var i is successfully passed in.

As mentioned, the code works - but throws an error.
Can someone shed some light on why this might be getting the error,
and how to 'correct' it?

trudge 8 Junior Poster

How have you determined that the data is lost? Just by trying to connect through the MySQL server?

Look for the actual files that make up your database. Since we still don't know what OS you are running under I don't know where that might be. If you can confirm that the actual physical files are gone, then yes your data is lost. Until then there is still hope.

trudge 8 Junior Poster

Your data is probably fine, but it sounds like you may have to install the mysql server again.

trudge 8 Junior Poster

How did you 'copy all the files over'?

What versions of MySQL are running on your original host, and on your new host?

There are a few things that can munge a migration, but knowing the answers to these 2 questions will give us a better idea of where to look.

trudge 8 Junior Poster

Huh. Yes that is very strange. Glad you got it figured out though. And thanks for posting the solution in case someone else runs into this.

trudge 8 Junior Poster

Can you execute

DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1;

from the command line?

Can you execute that literal string from your script?

Your script might not have the same permissions you do from the command line. Do other of your scripts execute OK when accessing the database?

1064 seems to refer to using a reserved word, but I see none in your query.

trudge 8 Junior Poster

What does

SELECT * FROM images WHERE image_id = 803 AND plant_num = 2277\G

show you? If you can't find that image, then obviously you can't delete it.

trudge 8 Junior Poster

What does your PHP query statement print out as? I'm betting it's not what you think it is.

Also, a

describe images

would help us help you.

trudge 8 Junior Poster

It is generally more practical to save the path to the images in the database, rather than the images. This applies to any binary file. Let the OS file system take care of the files.

If you save the images in the database you have just doubled the disk space required to store the images. And what happens when an image is moved, renamed, or deleted?

Plus what is the point? The database can't search an image so why keep it in a database?

trudge 8 Junior Poster

bcasp is pointing you in the right direction. As a further enlightenment, any time you ask yourself the question 'what if column X has more than Y choices' is an indication that that column should be broken out into a separate table.

trudge 8 Junior Poster

Again, I have to ask: does your query work from the command line? If you are not sending the right query, then you won't get the right results.

I don't know what 'annons.område' is but you are comparing it to 'områden.id'. Are they both the same data type?

You also have 'annons.rubrik=annons.id'. Are those both the same data types?

And if all you want is $id2, why are you selecting 11 fields? Or do they all make up $id2?

Your first priority is to find out exactly what your queries contain. Print them out. Or test them from the command line before you try to get it working in your script. If you know your SQL query works, then the problem is your programming, and this is the wrong forum for that.

trudge 8 Junior Poster

I notice you have some non-standard characters in the query. You might be trying to match something from one character set to something in a different character set.

WHERE annons.område=områden.id

Make sure the correct character set (and same character set) is enabled for the whole database, each table, and the collation.

Does your query return the correct result set when you just use the command line?

trudge 8 Junior Poster

This is good advice. Whenever you have a field / column with multiple values that's a clue to pull it out and put it in a separate table.

trudge 8 Junior Poster

I'm not sure what you mean by 'FE' or 'BE', but if you are planning on mounting this database on a web server I suggest you forget about using Access. Actually Access is not even the database, but Microsoft's front-end to their JET database.

It is not designed for multi-user use.

Look at MySQL or some other RDBMS. Anything you can do with your current set up can be done in MySQL. It's a matter of migrating your data over, and writing the program front-end.

trudge 8 Junior Poster

What have you got so far?

trudge 8 Junior Poster

In order for your images to be available via a web link, they have to be in the 'public' tree of your web server. Think of where you put images to be displayed on a web site. The images you want to send in the email have to be under that same tree.

But this isn't really a MySQL question. It is more of a server / CGI question.

trudge 8 Junior Poster

it is possible to display images in an email i have already got some of them to display on the email that is being sent out but none of the images from the databases will display within the email.

to gat images to display within the email then the absolute paths must be used for the images and they will display. to get an image to display using the absolute path the the code looks some thing like this

www.yourdomain.com/images/image1.jpg

i have used this code to get the absolute path of the images bing stored in the database

$path = getcwd();
echo "The absolute path to this directory is: ";
echo $path;

and this prints out the absolute path to the directory where the mysql table is stored i now need to know how to use this path to get the images to display from the server when the email is sent out.

You are correct. In this case the message has to be sent as HTML.
Use

Content-Type: multipart/mixed;
trudge 8 Junior Poster

You can't 'display' an image in an email. You can however attach a file to an email and send that. However that is not a MySQL topic. You would be better in a forum for the language you are using to do this in.

trudge 8 Junior Poster

Can you not use the \G switch?

select * from customers \G

This displays the field names vertically instead of across the top. At least in 5.* it does.

Otherwise you will have to play with your window size / font size.

trudge 8 Junior Poster

Why not just access the database using the 'mysql' client side program?

mysql -hwww.yourwebsite.com -uyourusername -p

This will prompt you for the password. Once you are logged in you have direct access to the database.

Unless of course the admins have not granted permissions to access from remote. In which case you are stuck using PHPmyAdmin - yuck. I stopped using that after a few databases got mangled during a dump.

Best option is the one I suggested if it is available. Otherwise I use HeidiSQL.

trudge 8 Junior Poster
trudge 8 Junior Poster

Where have you looked?

The Perl FAQ that comes with every Perl distribution contains
'How can I lock a file?' I suggest you start there.

trudge 8 Junior Poster

The use of 'strict' controls the scope of your variables. It forces you to practice good programming by not using global variables, and to declare all variables before use. There are some situations where you may want to turn this off in a block of code, and this can be done similarly to the 'no warnings' pragma.

When you use 'my $variable', you are telling Perl to use this version of the variable (in the current block or file) and not to confuse it with another variable of the same name, but outside the block. Generally you try to declare / initialize your variables as close to the point in your code where you begin to use them. So you could have several subroutines with a variable named '$filename', but if you 'use strict' at the beginning of your script, and then use 'my $filename' in each subroutine, they will all be treated as different variables.

Search the documentation for both pragmas - 'strict' and 'warnings'.

trudge 8 Junior Poster

Try to get in the habit of putting

use strict;
use warnings;

at the start of your scripts and it will save you a lot of frustration and time later on. Also, if you ever post to comp.lang.perl.misc, you will get flamed or ignored if you don't do this.

Also check result codes on any explicitly closed files.

KevinADC commented: very good point +3
trudge 8 Junior Poster

The typical solution to this is not to save the image in the database, but the path to the image (or any large binary file for that matter).

MySQL can handle binary data but it is hardly worth the effort getting it to work - the actual image itself can't be searched or modified by the database anyway, so what's the point of putting it in there?

trudge 8 Junior Poster

47000 records is trivial - MySQL can handle billions of records, and many companies use it for large databases and heavy traffic.

I'm not sure what kinds of queries you will be making, but one point to consider in any relational database design, is that it is driven by those anticipated queries. Maybe post a few pseudo-queries that you expect to run into, and that might get some suggestions.

You mentioned some of your data already - 'closing price, volume, market cap, PE '. And 900 companies is also trivial. I would look at holding your various points of interests in one table, along with a company ID. Then you would need a bridge table to tie that with company data in a separate table.

Or you could put all your various points of interest in separate tables (how many of these are you tracking?). Again, bridge tables would be needed to tie these to the various companies.

It depends on how you are going to be using the data.

Indexing can greatly speed up queries too.

trudge 8 Junior Poster

First I suggest you sit down with a good book on relational database design ('Database Design For Mere Mortals' by Michael Hernandez and 'MySQL' by Paul DuBois come to mind). We can help you help yourself, but can't do your work for you.

trudge 8 Junior Poster

Well, you sort of have the right idea with primary keys and foreign keys. But really what you need is to get a good handle on design. I'm not familiar with that book, but if you can get your hands on 'Database Design For Mere Mortals' by Michael Hernandez, it covers everything you will need to know about RDB design. Check out the MySQL web site as well (mysql.com). Another good book is 'MySQL' by Paul DuBois.

If you give us an idea of what your database will be managing, we could help more too. But try to get as far as you can on your own.

trudge 8 Junior Poster

You might want to investigate indexing.

trudge 8 Junior Poster

If that is your only reason, then again, the suggested solution of setting a 'Display' field to True or False should suffice for your needs. If not can you explain why not? It seems to be quite a waste of space and maintenance to retain all those 'deleted' records, when all you need is an extra field of 1 character.

trudge 8 Junior Poster

From your description, blater's solution will do what you want. If you want to 'delete' a record, why move it to another table - just delete it. However for some reason you want to retain the data, but not display it, so just add another field for 'Display' and set it to either 0 or 1. Then use a WHERE clause to filter what you want.

You keep mentioning deleting and archiving in the same sentence. What exactly do you want to do?

trudge 8 Junior Poster

There may be a problem with that field named 'DATE', as that is a reserved word. It will always have to be quoted in every query. Perhaps better to rename it 'OrderDate' or something that makes sense.

trudge 8 Junior Poster

Your design seems to be well on the way to what you want. In your 'Job Task Table output' you might want to replace the task ID with what the actual task is, unless you can remember what a task_id of 1 (or 3, or 7, ...) is etc.

Remember that your design and relations are driven by the kinds of queries you anticipate making. Populate your tables with some dummy data and perform some queries that cover what you will eventually want. Check the results for correctness (neither false positives nor false negatives). If you find that you can't perform a certain query based on the current design, you may have to change your design to suit. Also, it's generally not a good idea to store any values that can be derived or computed from existing data.

trudge 8 Junior Poster

What command did you try to execute? Copy and paste exactly what is on your command line, and the resulting screen.

trudge 8 Junior Poster

I will have multiple clients with the same name in the clients field, which is data repetition.

You didn't mention this initially. I take it these are members of the same family, sharing a last name and address? In that case, then you could break out the address into a separate table.

trudge 8 Junior Poster

You might be on the right track for 3NF but I suggest you take a closer look at your overall design.

You have a client table, but it is mostly populated with IDs for other client-related data. Why not just put all the client data into the client table? Your design demands you now create several bridge tables to tie phone numbers, addresses, etc. to a particular client.

You already have the companies in a separate table, but again, you use IDs to tie information about the company address. You are creating more work for yourself, as again you will have to create and use a bridge table to get meaningful information back about a company.

Why do you have address, email, city, country, phone information in separate tables? Think about what a query would look like if you wanted all the contact information about a particular client or company. You would have to use about 6 tables just to get that.

What you are aiming for is to have all information about a particular thing or event in a table. So you would have all data pertaining to a client in a client table (name, address, phone, email, ID, etc.). Follow this thinking and you will be on your way.

trudge 8 Junior Poster

... so i need the html editor to store the data into a database so i can recall it on to the new page

Then you should be looking in the documentation for that editor, or posting your query in a forum for the same. There is no MySQL question here that I can see.

trudge 8 Junior Poster

If you are paying for your disk space then you shouldn't have a problem. However, my understanding (from others) is that any freebie host has to get revenue from somewhere, so they place ads on their client web pages. My advice, especially if you are going to be responsible for client data, is to move it to a paid hosting site.

trudge 8 Junior Poster

Unless your company plans on saving the order data for future use, a database is not necessary for this. Which is not to say you shouldn't log attempts to log in with date/time stamp, IP address, domain name, attempts, etc. You may also have to add a CAPCHA image.

A simple order form in the language of your choice would do. A word of advice on passwords: don't allow users to pick their own, and insist on a minimum length of about 6 characters, spanning alphanumeric sets.

Also, if you are hosting client data, I would strongly suggest to move away from godaddy as quick as possible. They are a 'freebie' site, and your clients have to put up with advertising. Also, they have a reputation for 'overbooking' their servers. Which means if you get close to your disk limit they may lock you out.

trudge 8 Junior Poster

I'm confused. Are you asking for help with MySQL or an HTML editor called InnovaStudio?

We can only help you with MySQL questions here. With that in mind, you say that

does not have any sql or connection to a db on it

So if there is no connection to the database, how do you expect the query to execute? Or am I missing something here? Have you confirmed that you are logged in to the database? Can you access it remotely from the command line using 'mysql'?

trudge 8 Junior Poster

It is generally not a good idea to include markup in your data.

trudge 8 Junior Poster

What tables? Do a 'describe' for each table and post it, along with what exactly you are having trouble with.

trudge 8 Junior Poster

You already have the basic information you need to start the database: item name, color, size, cost, price, etc. So make those fields in a Products table and start populating them. Include an ID field to tie in with future tables (suppliers, customers, invoices, etc.)

trudge 8 Junior Poster

I think that the tables are spread to thin. I need pair them down abit, I just want product inventory system that tells you how many red t-shirts in xlarge without have a column (red shirt - xl).

Something for quick look ups - shirts then more tables (I'm thinking) once a user drives down the search.

If all you want to know is how many of X you have, then why not just use a spreadsheet? Or is this supposed to be a web-based application?

trudge 8 Junior Poster

You mention that you are using MS Access to do this in. So you have 2 learning curves on your plate: how to use Access and how to design a relational database.

Access is the front end to the MS Jet database engine. It doesn't do a very good job of teaching you how to design relational databases.

Second, you mention that this is going to be a web-based application. I strongly recommend that you NOT use MS Access for this application. It is not designed for multi-user / multi-threaded usage.

To better understand relational database design, install MySQL client and server (it's free) and any decent host nowadays has it already installed.

Then get yourself a good book on relational database design. In other posts I've mentioned 3 that I use on a regular basis: 'Database Design for Mere Mortals' by Michael Hernandez; 'SQL Queries for Mere Mortals' by the same author; 'MySQL' by Paul DuBois.

trudge 8 Junior Poster

These don't look like any ER diagrams I've seen, but anyway.

What do you mean by 'it shows the opposite'?

What SQL query have you used to show you anything? YOU make the relationships between tables, not some diagram.

trudge 8 Junior Poster

Your tables suggest you may need to do some more work on RDBM design. You have features and attributes of Products spread throughout several tables, when I believe they could all be in one table, with the appropriate fields. You want to try and collect all information about a thing or event in one table. In your case, so far I've only seen mention of 'Products'. What else are you going to put in your database, if anything?

Try and get a good book on relational database design. Some good ones that I use are 'Database Design for Mere Mortals' by Michael Hernandez, 'SQL Queries for Mere Mortals' by same author, and 'MySQL' by Paul Dubois.

trudge 8 Junior Poster

Not sure you mean by 'entry'. But your first choice seems about right.

You will want a table with the following fields:
ID
Company
# bedrooms
Price

Then a user could select from your db where company=x AND #bedrooms = y AND price <= z

Of course if you want to be able to search for more criteria you will have to incorporate them.

trudge 8 Junior Poster

You may have to define 'character' a little better for your purposes. (Will you allow *?!@#$%^&()<>:;'~`)?

But the following works, while a bit kludgy:

#! /usr/bin/perl
use strict;
use warnings;

# Begin with a letter
# 4-8 characters long
# must include at least 1 digit

while (<DATA>)
{
	chomp;
	if ( (length($_) >= 4) && (length($_) <= 8) )
	{
		if ( /^[a-z]/)
		{
			if ( /\d+/g)
			{
				print "$_ : OK\n" ;
			}
		}
	}
	else
	{
		print "$_ : NO\n";
	}
}

__DATA__
1ab
abc
a1b
ab1
abc1
1abc
a1bc
ab1c
1a1bcdefg
a1bcdefg
ab1cdefg
abc1defg
abcd1efg
abcd1efg
abcdef1g
abcdefg1
a1234567
12345678
123456789
abcdefgh
abcdefghi