Page 1 of 1

[solved]MySQL problems

Posted: Sat Oct 23, 2004 4:31 am
by sakaveli
hi guys,

in my DB ive got a table called "user_settings" which holds one field named "flash" if this field is set to 1 then my flash pages wll load up else my HTML pages will.

the problem is that when users click on the link to change the value (either to 1 or 0) i just insert a new row into the DB rather than modifying what is already there! how sould i query the DB for this scenario?

also, this question is kinda hard to word...if there are multiple users on my webpage, and one of them sets the "flash" field to 0, will this effect all my users? how do i get around this?

thanks ppl!

Posted: Sat Oct 23, 2004 4:39 am
by sakaveli
i have sold the fisrt half of the puzzle using http://dev.mysql.com/doc/mysql/en/UPDATE.html


but i stil need to know if this change would effect all my users?

Posted: Sat Oct 23, 2004 5:54 am
by Dale
I would have thought SESSIONS would help.

Posted: Sat Oct 23, 2004 6:48 am
by sakaveli
dale thanks for reply,

how do i use sessions? im still learning php and have not yet used sessions

Posted: Sat Oct 23, 2004 7:22 am
by cto1mac
session_start();

and then you have to initalize your session variables.

$_SESSION[user_id] = some value;

As long as the session_start is included on your pages, they session state will be maintained.

Posted: Sat Oct 23, 2004 8:00 am
by sakaveli
can i use the $_SESSION[user_id] variable in any of my files without having to write sessionstart() every time?

Posted: Sat Oct 23, 2004 9:56 am
by cto1mac
normally the way i handle this is to create a file with my db connection and session_start() in it and include it at the top of all of my pages using include_once("filename.php") or require_once("file.php").

Posted: Sat Oct 23, 2004 10:19 am
by sakaveli

Code: Select all

session_start();

if (!isset($_SESSIONї'flashpage'])) {
   $_SESSIONї'flashpage'] = 1;
}
this solved my problem!!

thanks for helping me out!!