![]() |
Table User
Okay, i'm not very good at mySQL, which Is why I'm asking this:
First off, what do all the Tinyint, null, etc things mean? Second, Let's say I wanted to add a field to the table User, containing an on or off value, how would I do that? And, once that was done, how would I use php to check if it's "on" or "off", and to change it to "on" or "off"? ... :cross-eyed: |
TINYINT is a datatype like long, int, String, etc.
NULL means literally "nothing." [sql] ALTER TABLE user ADD yourfield TINYINT(1) NOT NULL DEFAULT 0; [/sql] PHP Code:
|
and how would I change it in php?
$DB_site => query (... *clueless...* but can prolly figure it out. :) thanx. |
Quote:
|
so, I'd just do
PHP Code:
|
Quote:
PHP Code:
|
I'm trying to change $bbuserinfo['myvar']
|
Permanently in the database, or only when the script is processed?
Doing: PHP Code:
PHP Code:
|
Quote:
PHP Code:
right? |
Yes.
|
Quote:
I'm trying to run that query, but I get this error: Error SQL-query : [sql] ALTER TABLE user ADD yourfield TINYINT( 1 ) NOT NULL DEFAULT0 [/sql] MySQL said: 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 'DEFAULT0' at line 1 |
You need a space between DEFAULT and 0.
And TINYINT( 1 ) should be TINYINT(1). |
Yes, it's like that when I enter it in, but afterwards, it messes it up...
Anyway, I added in some quotes, and it worked. :):):):):):):):):) |
Quote:
|
nother question:
HOw would I add in a field to store large amounts of text (10,000 chars) ? With default 'None' ? I tried, but it just gave me syntax errors... EDIT: Also, once that was done, how would I set it up so that I could do $post['thatfield'] and have it show the poster's data for that field in the postbit? |
Quote:
[sql]ALTER TABLE `tbl_name` ADD `col_name` TEXT;[/sql] For default, do you actually want the default to be the string: 'None' , or NULL (nothing there)? Answer #2: PHP Code:
|
Umm, yeah, the string "none" I would replace TEXT with that?
Also, I want to be able to use $post[col_name] and have it display the info for $post[username]... get what I'm saying? |
For the query, just use the one I gave, but replacing the tbl_name and col_name of course. TEXT means that it will contain text, to a maximum of 65535 characters.
Just like what I said at Answer #2; place the variable in the postbit wherever you want to display it. |
but, wouldnt' that make the person who's viewing the post see their own info there, instead of the poster's?
|
My mistake, it's $post[col_name].
|
and vbulletin will automatically figure that out? cool!
|
<font size="4">YES!!!</font> *Victory Dance*
Whooh-hooOO!!! Thank's y'all, It's working great. WHat's working? I'll tell ya!! My forum is an Animé forum, and I thought it'd be fun if members could, randomly, have a link appear in the header, allowing to 'catch' one of the characters from one of my site's featured Animés. !!! It works! I'ts awesome! Thank's again! *Gengar goes off to try to catch mimiru...* |
Quote:
|
ok :)
|
All times are GMT. The time now is 03:53 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|