PDA

View Full Version : Table User


gengar003
05-27-2003, 12:33 AM
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:

filburt1
05-27-2003, 12:46 AM
TINYINT is a datatype like long, int, String, etc.
NULL means literally "nothing."


ALTER TABLE user ADD yourfield TINYINT(1) NOT NULL DEFAULT 0;


if ($bbuserinfo['yourfield'])
{
echo "on!";
}
else
{
echo "off!";
}
`

gengar003
05-28-2003, 12:56 AM
and how would I change it in php?

$DB_site => query (... *clueless...*

but can prolly figure it out. :)


thanx.

Gary King
05-28-2003, 02:16 AM
Today at 09:56 PM gengar003 said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=400885#post400885)
and how would I change it in php?

$DB_site => query (... *clueless...*

but can prolly figure it out. :)


thanx.

You don't need to, vBulletin already grabs all the columns from the user table.

gengar003
05-28-2003, 08:37 PM
so, I'd just do


$bbuserinfo[myvar] = newval



?

Gary King
05-28-2003, 08:52 PM
Today at 05:37 PM gengar003 said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=401239#post401239)
so, I'd just do


$bbuserinfo[myvar] = newval



?

What exactly are you trying to do again?

$bbuserinfo['myvar'] will already be set to whatever there is in the user table.

gengar003
05-30-2003, 04:33 PM
I'm trying to change $bbuserinfo['myvar']

Gary King
05-30-2003, 07:10 PM
Permanently in the database, or only when the script is processed?

Doing: $bbuserinfo['myvar'] = "newval"; will only set the variable for that moment. You can use phpMyAdmin to change the value(s) in the database, or use something like the following:

$bbuserinfo['myvar'] = "newval";

$DB_site->query("UPDATE user SET 'col_name' = '".$bbuserinfo['myval']."' WHERE userid='".$bbuserinfo['userid']."' LIMIT 1");

gengar003
05-30-2003, 10:15 PM
Yesterday at 09:10 PM Gary W said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=402079#post402079)

$bbuserinfo['myvar'] = "newval";

$DB_site->query("UPDATE user SET 'col_name' = '".$bbuserinfo['myval']."' WHERE userid='".$bbuserinfo['userid']."' LIMIT 1");


Yes, permanently, like that, and I assume that 'col_name' is/would be well, um... so, to change $bbuserinfo['myvar'] to "newval", I'd do...
$bbuserinfo['myvar'] = "newval";

$DB_site->query("UPDATE user SET 'myvar' = '".$bbuserinfo['myvar']."' WHERE userid='".$bbuserinfo['userid']."' LIMIT 1");



right?

Gary King
05-30-2003, 10:57 PM
Yes.

gengar003
05-31-2003, 10:59 PM
05-27-03 at 02:46 AM filburt1 said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=400357#post400357)
TINYINT is a datatype like long, int, String, etc.
NULL means literally "nothing."


ALTER TABLE user ADD yourfield TINYINT(1) NOT NULL DEFAULT 0;




I'm trying to run that query, but I get this error:

Error

SQL-query :


ALTER TABLE user ADD yourfield TINYINT( 1 ) NOT NULL DEFAULT0

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

Boofo
05-31-2003, 11:24 PM
You need a space between DEFAULT and 0.

And TINYINT( 1 ) should be TINYINT(1).

gengar003
05-31-2003, 11:30 PM
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.

:):):):):):):):):)

filburt1
05-31-2003, 11:35 PM
Today at 08:24 PM Boofo said this in Post #12 (https://vborg.vbsupport.ru/showthread.php?postid=402615#post402615)
You need a space between DEFAULT and 0.

And TINYINT( 1 ) should be TINYINT(1).

Whitespace doesn't matter.

gengar003
06-01-2003, 02:18 PM
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?

Gary King
06-01-2003, 08:37 PM
Today at 11:18 AM gengar003 said this in Post #15 (https://vborg.vbsupport.ru/showthread.php?postid=402891#post402891)
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?

Answer #1:

ALTER TABLE `tbl_name` ADD `col_name` TEXT;

For default, do you actually want the default to be the string: 'None' , or NULL (nothing there)?

Answer #2:

$bbuserinfo[col_name]

gengar003
06-01-2003, 08:44 PM
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?

Gary King
06-01-2003, 08:50 PM
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.

gengar003
06-01-2003, 09:40 PM
but, wouldnt' that make the person who's viewing the post see their own info there, instead of the poster's?

Gary King
06-01-2003, 09:56 PM
My mistake, it's $post[col_name].

gengar003
06-01-2003, 10:06 PM
and vbulletin will automatically figure that out? cool!

gengar003
06-01-2003, 10:16 PM
<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...*

Gary King
06-01-2003, 11:36 PM
Today at 07:06 PM gengar003 said this in Post #21 (https://vborg.vbsupport.ru/showthread.php?postid=403141#post403141)
and vbulletin will automatically figure that out? cool!

Because showthread.php SELECTs everything in the user table (SELECT user.* FROM ...), so anything and everything in the user table (for only the users who have posted in the thread you are viewing, though) will already be ready to be used.

gengar003
06-02-2003, 11:53 AM
ok :)