View Full Version : Question
Billybob54
11-24-01, 08:10 AM
How do you delete a Table? Also What are the different types of string data you can have in a colom? When I used varchar, it only allowed me to put the number of charicters i said in the (), I thought it was supposed to allow any number of charicters up to that number.
To delete a table, use the statement:
drop table table_name
Columns can contain about 27 different data types, most anything you'll need. The most common are probably Char, Varchar, text, int & mediumint.
Char(15) is a fixed length string, it will pad (add empty spaces and remove them upon retrival) any data that is under the specified length, 15 in the case above. It will truncate any data over the specified length. The specified length can be from 0 - 255 characters.
Varchar(15) is a variable length string, it does not pad the data and will accept anything up to the specified length. It also will truncate anything over the specified length. The specified length can be from 1 - 255 characters.
If you've used Varchar, it should accept anything up to the amount you specify in ().
I like programming all my interfaces in Perl, but for manual database updating and table building, I use Mascon. It allows me to easily set up and maintain databases from my desktop and it saves me a lot of time. I think the address is http://www.scibit.com if you'd like to check it out.
~bud
Billybob54
11-26-01, 08:31 AM
I have my data type for my column set on varchar and it will still only allow the number of charicters in () only, and no less or else i get a error. When i looked at it in the program it had Allow null checked. What does Allow null do?
Setting a column to allow null will let you add new rows to the database without adding anything to this column (leaving it blank).
If a column is set to NOT allow null (not null), then you must add something to this column when adding a new row to the table or else the insert statement will fail.
As far as the problem you're having with Varchar, putting Varchar(15) should allow anything up to 15 characters. What are you using to create the tables? Php, perl, a database program?
If you are using php or perl, post the code here that you are using to create the table and I'll take a look and see if I can find anything that might be causing the problem.
~bud
Billybob54
11-27-01, 04:02 AM
I got the problem fixed, but now I am getting premeture end of script headers. I have the CHMOD set to 500, and I konw that can not be the problem. If place and error in the code, then it shows the error messange and no premeture end of script headers error happens. Do you know what the problem could be?
To correct the error you're getting, you'll need to quote the variables in the SQL statement. Ordinarily, in Perl, variables do not need to be quoted but in an SQL statement all variables used within the values() list must be quoted.
To make it a little more efficient, you could place the statement in the prepare line:
sth = $dbh->prepare(qw{INSERT INTO MemberStuff (MemberID, Password, Email, Paypal, Month) VALUES ("$userid", "$password1", "$email2", "$paypal2", "$month")});
This should get you past the error. :)
Is there any particular reason you want to use a floating point integer for the MemberID? I assume by the userid incrementation ($userid++) you are trying to automate member id numbers in the database. If so, it would be better to use auto-increment with a mediumint (medium integer). The code would be something like:
MemberID mediumint(15) NOT NULL AUTO_INCREMENT
If you don't want it to start it with #1 you can place a dummy entry in the first row and give it whatever number you like.
~bud
Billybob54
11-27-01, 05:34 AM
I got the problem fixed, but now I am getting premeture end of script headers. I have the CHMOD set to 500, and I konw that can not be the problem. If place and error in the code, then it shows the error messange and no premeture end of script headers error happens. Do you know what the problem could be?
Owner permissions on cgi scripts should be set to 7, while Group and World permissions should be set to 5, this insures it can be executed and read from the browser.
You'll need to set permissions to 755.
~bud
Billybob54
11-27-01, 06:03 AM
I changed the CHMOD to 755 and i still get the error. I am not using ws ftp so that can not be the problem. I don't think it is a CHMOD problem, it must be something else, but i don't know what.
It's probably a dumb question but are you setting a header within the script? Most premature end of headers either comes from a bad chmod or a lack of header declaration in the script.
The easiest way to set a header is to include the CGI module with "all" and then print header:
use CGI qw(:all);
print header;
if this isn't the problem, it may be a syntax error somewhere. Try (carefully) removing small related portions of code to narrow down where the error is being caused. If you pull a part out and the script runs, you know the error is within the part you pulled.
~bud
Billybob54
11-27-01, 06:36 AM
It was because i did not have the cgi qw(:all) thing that was the problem. Thanks alot for all of you help bud, you are the best!!!:)
Excellent work Billybob54, glad ya got it working!! :)
~bud
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.