[solved]MySQL problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

[solved]MySQL problems

Post 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!
Last edited by sakaveli on Sat Oct 23, 2004 10:20 am, edited 1 time in total.
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post 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?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

I would have thought SESSIONS would help.
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post by sakaveli »

dale thanks for reply,

how do i use sessions? im still learning php and have not yet used sessions
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

Post 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.
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post by sakaveli »

can i use the $_SESSION[user_id] variable in any of my files without having to write sessionstart() every time?
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

Post 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").
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post by sakaveli »

Code: Select all

session_start();

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

thanks for helping me out!!
Post Reply