Website Babble Webmaster Forums  


Go Back   Website Babble Webmaster Forums > Creating a Website > HTML, PHP, CSS, Javascript & Coding/Programming Topics

Your WB Notifications

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-15-2008, 08:44 AM
Kakashi266's Avatar
Master Babbler
 
Join Date: Mar 2008
Posts: 201
Kakashi266 is a reputable WB member and has over 100 reputation pointsKakashi266 is a reputable WB member and has over 100 reputation points
Default PHP: store sessions in database

Hey guys and gals, I've got a little problem I've been working on for a few days now. I want to be able to store session information in my mysql database. I've read more tutorials on it than I can shake a stick at, but they haven't helped me at all. Even the ones that seem designed to do precisely what I want don't work. I've been doing some trial and error for the past day, but I haven't gotten anywhere useful.

So basically, while I continue my trial and error, I just wanted to put word out there, to see if someone can help me come up with the code.

**this is not a homework assignment or anything, just a little side-project of mine, so don't hold back, folks**

Anyway, I have a table called sessions, and the fields: session_Id, expiration, value.

Expiration is the current time plus the max life of the session, and value is the session data.

Currently, I have a command in the write() function (I'm creating a custom session handler) that should insert or update the table with new session information. The problem is that it does not work. I even echoed the data I wanted to insert right beneath it, and the data is there, just my mysqli commands are not working.

Here's code for consideration:
Code:
function write($id, $data)
{
	$newid = mysql_real_escape_string($id);
	$newdata = mysql_real_escape_string($data);

	$dbc = mysqli_connect('localhost','user','pass','database');
	$arg = "REPLACE sessions(session_Id,expiry,value) VALUES('$newid',time(),'$newdata')";
	$result = mysqli_query($dbc, $arg);
	return true;
}
Yeah, I know the time variable doesn't do what I wanted it to do, but I was just trying to get it to insert something.

I've gotta run right now, so if there's any other bit of code or information you need from me, let me know and I'll get it up asap. Thanks, guys.
__________________
I've designated Wednesday and Saturday as my official "Update the in-progress code on my sandbox site" days. So every Wednesday and Saturday, go here: http://www.foxneeson.exofire.net and check out the new features as I make them.
Reply With Quote
  #2 (permalink)  
Old 10-15-2008, 11:02 AM
Kakashi266's Avatar
Master Babbler
 
Join Date: Mar 2008
Posts: 201
Kakashi266 is a reputable WB member and has over 100 reputation pointsKakashi266 is a reputable WB member and has over 100 reputation points
Default

**Double post so you won't miss it**

Nevermind, guys, I figured it out. If you were getting ready to help me, thanks anyway. Nice to have a place where there are helpful people like you.
__________________
I've designated Wednesday and Saturday as my official "Update the in-progress code on my sandbox site" days. So every Wednesday and Saturday, go here: http://www.foxneeson.exofire.net and check out the new features as I make them.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -6. The time now is 01:59 AM.


 Subscribe to RSS

WB Sponsors

Search Engine Optimization

flash chat

Home Jobs Online

Search Engine Marketing

Paid Surveys

Web Design Company

custom website design

Best Links Management Software

Online Advertising Solution FREE trial!



 Subscribe to the Website Babble Feeds

2 Create a Website Homepage | 2 Create a Website Blog


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0