Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Set Session Variables From Records In A MySql Database


I am working on a memebship section for a website and I am trying to set session variables from records in a MySql database when the user logs in. I think I am missing something because try as I might the just don't work!

The sever I use had Glabal variables turned on, dont know if thats an issue in this case.

Heres the code on the check user page:




View Complete Forum Thread with Replies

Related Forum Messages:
Does PHP Have A Way To Export Records Of A MySQL Database?
Quite by accident, I found the mysqldump utility, that comes with MySQL,
which dumps/backsup a database, table, or record. It looks very versatile!

Does PHP have a way to export records of a MySQL database? Anything that
does the same independent of the database used?

View Replies !
How Many Records Will A MySql Database Hold?
how many records will a MySql database hold?

View Replies !
Display Records From A MYSQL Database On Multiple Pages.
I am trying to display records from a MYSQL database on multiple pages. I get the following error when I attempt to display the results

mysql_fetch_array(): supplied argument is not a valid MYSQL result in

c:intentpubwwwrootprogeneefsires1.php on line 238

The code is shown below. I am including a file called class.pager.php for page numbers (author: Tsigo) and this part works fine.

/* Now we use the LIMIT clause to grab a range of rows */
$result = mysql_query("SELECT sireid, sirename, sirethumbpic, comment_1,comment_2,comment_3 FROM beef".$start.", ".$limit);

View Replies !
Inserting Session Variables Into A Database
I get the following error message when I run the script:

Parse error: syntax error, unexpected T_VARIABLE in C:wampwwwNew Folder (2)process.php on line 24

I am trying to write the session variables to a table called schools in a table called school_users, this all works when I simply put words in 'here' in the MySQL command part of my script. So this shows its all OK, (the POST values also work),  but I think the trouble is when I use this:

$_SESSION['school_name'] in the MySQL command part, that, I think is why I get the error. Help to tell me how to put these in SQL commands or renaming them to $variables Code:

View Replies !
Automatic Delete From MySQL Database Table Expired Records?
I have a question . . .

how can i delete from MySQL database table automatic expired records ?
?

One think is to make a service that deleting the expired records . . .

Any other method ?



View Replies !
Session Variables To Store Database Field
On my site I allow users to log in. If the login is sussessful they are taken to a page saying welcome and their name is pulled from the database and displayed on screen. What I want to do is be able to store their name pulled from the database in a session variable if possible which I can then show there name on each page. Is this possible, im using MX to do so.

View Replies !
Losing Session Variables - Database For The Multilingual Content
I am trying to set up a php based multilanguage site. I thought about using the database for the multilingual content, but it seems more hassle than it's worth for the amount of actual writing on the site.

View Replies !
Session Variables - Query The Database To Get All Info On The User Logged In?
I have a login script working. All is fine. This works by querying a database and if the result = 1 then set a session. What i want to do is get all the information relating to the user currently logged in. When i echo the session i get the value 1. How do i query the database to get all info on the user logged in?

View Replies !
Session Variables From Mysql, Get Them All At Once?
I'm making a new site and am wondering about the best way to query a mysql server.. basically most of the site's pages will display some type of dynamic content based on the user, and im not sure which approach is better.. should i grab all the info i need at login to put into session variables? or should i have queries when/if i need to display the info... im leaning towards getting it all once so the sites main functionality is smoother.. anyone know if im about to make a mistake?

View Replies !
MySQL And PHP Session Variables
The following 3 mysql/php statements are used in my home page to
access my admin table:

$php_linkID = mysql_pconnect("localhost","user","pw");
mysql_select_db("test_db",$php_linkID);
$php_resultID = mysql_query("SELECT * FROM admin", $php_linkID);

On another web page I try to use another table in the same database
but I get an error on the if statement - I've saved the $php_linkID as
a session variable from the home page thinking I can just use it here
on a different web page - is this not possible?

$php_resultID = mysql_query("UPDATE controls SET screen_width =
frm_screen_width WHERE id = $php_session_member_name, $php_linkID);
if ($php_resultID != FALSE) <------ errors here
{
print "Database update error - Changes not made.";
}
else
{
print "My Controls successfully updated!";
}

View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:

View Replies !
Using Session Variables In Mysql Queries
My php code consists of getting a person's session_id() and placing that in a session variable for use in other pages.

The thing is, though, that when i place a session variable in a mysql query, i get the following error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/e/r/i/ericjacobson01/html/index.php on line 11

This is the part that php complains about:

$_SESSION['buyer_id'] = session_id();

$istableset = mysql_query("SELECT * FROM ' .$_SESSION['buyer_id'] '");

View Replies !
How To Connect Php Variables To A MySql Database
i have a login form and i would like to know how to connect it to a mysql database. no need for code, i just need the name of the fuctions and how to use it.

View Replies !
Sending Php Variables To Mysql Database
I want to send various php variables to a my mysql database automatically when the user goes to my page. The variables are things like Ip address, screen resolution, user agent, and etc. How do I do that? Keep in mind i'm just learning and i'm doing this little experiment just for learning purposes.

View Replies !
"Information Is Recieved" It Says, However, NO RECORDS In Database (mysql)
I finally got it to the point where there are NO errors and it says, "Information has been received." However there are NO RECORDS IN DATABASE! Code:

View Replies !
Warning: Session_start() [function.session-start]: Cannot Send Session Cookie - Problems With The Session Variables.
I am have a form on the page registration.html the content is posted to a page called registration.php Although the database is getting populated, i am having problems with the session variables. I get the following errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /usr/shared/web/intocore/registration.php:10) in /usr/shared/web/intocore/registration.php on line 41 Code:

View Replies !
Load Variables From Cookies That Are Connected To A MySql Database
I'm just getting my feet wet with PHP. I'm trying to load variables from cookies that are connected to a MySql database. I have a php login script already and am trying to create a flash interface for it. I can't seem to get the variables to load into flash from the cookie that is in the top of the html page. If anyone knows the process I would be totally in your debt.

View Replies !
Form Processing - Variables Posted Into Mysql Database
i am currently building a site that will provide a free e-mail service hosted by bigmailbox.com. i am also providing a community area, where users can sign-up and post messages. i was wondering if there would be a way to combine the form for the e-mail program with the form for the community and add the same username and password to both programs.

here's what i would like to do: have one form that would include several different fields.
upon submitting the form, i would like for some of the variables to be posted into my mysql database, and other variables (some of the same ones posted to the database) be passed to a cgi script on bigmailbox.com's servers.

View Replies !
Inserts A Temporary Session Record In My MySQL Database.
I´m running a site with sessions. Everytime someone logs in, my script inserts a temporary session record in my mySQL database. It all works fine, but my problem is to remove them; I would like to remove all session records that haven´t been used for an hour.

I know I could do this with a TIMESTAMP field, but everytime the user does something, goes to another page ect., I need to update that TIMESTAMP, but mySQL wont let me do that.

View Replies !
PHP:Unable To Post Variables From Html Form To Mysql Database
Plz dont treat this as another newbie query , i did my homework but
still getting nowhere :( :( :(

Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to
post data from html form to php file(connecting to mysql database and
inserting into a table) .
This seemingly simple problem is making me go mad !!! I googled
extensively and already tried the following

I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.

wot could be the problem .... is it the case that /etc/php.ini file is
not being read .... how do i know whether this is the default location
for php.ini?
Where can i find the PHPRC environment variable (the variable
responsible for the php.ini default location)

Is the problem something else .....?

Following is the code ...

form.html
---------
<HTML>
<HEAD>
<TITLE> email entry form </TITLE>
</HEAD>
<BODY>

<P>plz fil the form </P>

<FORM METHOD="POST" ACTON="form-handler.php">

NAME: <BR>
<INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR>
AGE: <br>
<INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR>

<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

form-handler.php
-----------------
<HTML>
<HEAD>
<TITLE> EMAIL FORM HANDLER </TITLE>
</HEAD>

<BODY>

<?
mysql_connect("localhost","root") or die("Failure on db connection");

mysql_select_db("mydb");

View Replies !
Session Problem: Session Exists, But Session Variables Don't Lasts
I have some troubles with session variables. I can easily create a session,
but the variable I append to global session array ( $_SESSION) lasts only
until the end of current function.

I prepared an example that can demonstrate the problem (see code bellow):
The program flow is this:
(1) It starts with "session_start()" and displays "login_form()".
(2) When user enters his username and password, it goes to "login()"
function which sets $_SESSION variables.
(3) This function also "Echoes" session_id and user name to the screen.
(4) Then it goes to "MyProgram()" function. It only "Echoes" the same
variables to the screen.

Strange is, that the session_id is the same in (3) and (4), but the user
name ($_SESSION["username"]) is only in (3), but not in (4). By other
words - $_SESSION["username"] variable filled up by "login()" function is
immediately cleared.

I don't know why.

There must be something missing, but after 3 days of watching it, I can not
find a problem here.

===========================================
<?
Function login($uzivatel, $heslo)
{
$_SESSION["username"] = $uzivatel;
$_SESSION["pass"] = $heslo;
$U_Name=$_SESSION['username'];
echo "Login username: $U_Name<BR>";
echo "Login session ID: ";
echo session_id();
echo "<BR>";
}

Function login_form()
{
echo ("<DIV ALIGN='center'>
<H1>Test</H1>
<P>Please enter your username and password:</P>
<form action='test.php' method='get'>
<INPUT TYPE='HIDDEN' NAME='login' VALUE=TRUE>
<TABLE BORDER=&#390;'>
<TR>
<TD ALIGN='right'><U>U</U>ser name:</TD>
<TD><INPUT NAME='uzivatel' SIZE=25 ACCESSKEY='U' TYPE='TEXT'></TD>
</TR>
<TR>
<TD align='right'><U>P</U>assword:</TD>
<TD><INPUT NAME='heslo' SIZE=25 ACCESSKEY='P' TYPE='PASSWORD'></TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN='RIGHT'><INPUT NAME='OK' ACCESSKEY='O' TYPE='SUBMIT'
VALUE='OK' TABINDEX=3></TD>
</TR>
</TABLE>
</FORM></DIV></HTML>");
}

Function MyProgram()
{
$U_Name=$_SESSION['username'];
echo "Program username: $U_Name<BR>";
echo "Program session ID: ";
echo session_id();
echo "<BR>";
}

{
session_start();
if ($_SESSION['username']):
MyProgram();
else:
{
if (!$login):
login_form(0);
else:
login($uzivatel, $heslo);
MyProgram();
endif;
}
endif;
}
?>
===========================================

View Replies !
Can Session Id Be Same For 2 Records ?
can i confidently believe that a session id will be unique for all the users even if there are lakhs of  users ?

is there any possiblility that the session id can be same for 2 records ?..

i want to send an email to the user to verify their account after their registration. so i am sending the session id in the get and once they click that link it will take to a page where it will compare the session id with the one that is stored in the database.. is this the correct way?

View Replies !
Session Variables Not Being Stored To Session.save_path Correctly
why PHP4 running on my Win2K dev box has not been writing the
$_SESSION variable correctly to session.save_path at the end of a
certain page.

Using print_r( $_SESSION ); showed that $_SESSION contained exactly what
I was expecting but once it was written to session.save_path it showed
an earlier state of $_SESSION in that page.

I spent ages trying to locate the problem. I was certain PHP or my
config was causing the problem. Why wouldn't I? after all print_r(
$_SESSION ) was showing the correct info.

View Replies !
Session Handling Problems - Session Variables Not Carrying To Next Pg
i am having trouble using session variables... this code was working for a long time (6 mths) without hassles and then suddenly ... i have a problem of.

"undefined index" when i try to access the session variables on a different page than where i d set them this is the index page of the control panel where the session vars are set Code:

View Replies !
What To Do If There Are No Records In The Database
I am pulling data from the database and displaying it using the code below:

$db = mysql_connect("localhost", "root");

mysql_select_db("pyramid",$db);

$result = mysql_query("SELECT * FROM table where area='Wales'",$db);

while ($myrow = mysql_fetch_row($result)) {

echo "blah blah";

}
?>

What do I do if there are no records? At the moment it just doesn't display anything. How do I get it to display a message saying there are no records?

View Replies !
Converting Post Variables Into Session Variables
I have a script in which I take a whole lot of data from a number of pages of a form, compile it into one, and let the user edit it before it's eventually thrown into a SQL database. The data coming from the forms is in post, and I've created arrays of all of the fields in the form, like: Code:

View Replies !
Losing Session Variables - Session.gc.divisor
I have a page containing a form. The page submits to itself and if the
data validates, stores the posted variables into a database and also
into a session. I then use header to redirect to another page which
fetches the variables from the session array and displays them.

All works fine on the Linux test server. However the production server
is Windoze running PHP 5. reg globals off I am intermittently losing
variables. from the session array

It's not a register globals issue - sometimes they are there sometimes
not. The only other difference I can see is the session.gc.divisor
which is set to 100

View Replies !
Session Array (lots Of Session Variables)
Is it best practice when dealing wit lots of session variables. to. Insert them in array as such, because i cant see what advantage it would be.

$_SESSION['serv'] = array();
$_SESSION['date'] = $_POST['date'];
$_SESSION['service'] = $_POST['service'];

View Replies !
Start A Session And Session Variables In Cron
i have a cron job setup to send out a link in a email that leads to a survey. I need to set session variables or something to hide elements needed to build the survey does anyone know how to do this I'd prefer Session or a better alternative.

I would just put the survey construction vars in the link itself and use GET but thats not very secure i dont think.

View Replies !
Update Certain Records In Database
I would like to update certain records in database so they are all written in lowercase....i have tried with it but doesn't work:

<?php
$db = mysql_connect("$host", "$user");
mysql_select_db("albums",$db);
$result = mysql_query("SELECT * FROM albums",$db);
while ($myrow = mysql_fetch_row($result)) {
$al_artist = strtolower($myrow[1]);
$al_name = strtolower($myrow[2]);
$site = strtolower($myrow[4]);
$sql = "UPDATE albums SET al_artist='$al_artist', al_name='$al_name' site='$site' WHERE id='$myrow[0]'";
$query = mysql_query($sql);
}
mysql_close($db)
?>

View Replies !
Deleting Records From Database
I have another question about record deletion from
database.

For example, my database has 10 records with ids 1
through 10. If I delete id #10 then everything is good
and all the records are still 1 through 9. However, if
I delete record id #4, then in my db I would have
records 1 through 10 with id #4 missing.

Is there a command that syncs the database? How do I
go about this to keep all the ids in the right order
after the deletion? or What do I need to do to prevent
that from happenning?

View Replies !
Insering Records Into Database
I am trying to insert some records through a form into my database(INTERBASE).I have test1.php where i have two include files, namely:connection.ini and aim.ini
In connection.ini, i have the db connection details and aim.ini, i have the form fields and the sql statements.Now, when i run my program, i am able to see the output, but, they are not inserted into my db.could some body please figure it out. Code:


View Replies !
Retrieve Last Ten Records From The Database
using LIMIT I know how to easily retrieve the first 10 records from the database. But is there an easy way to retrieve the LAST 10 records  from the database? e.g

$sql = "SELECT * FROM employees";

How would i retrieve the last 10 records.

View Replies !
Wont Add Records To My Database
can u check my codes and tell me whats wrong because for some reason it wont add records to my database, im using phpadmin v4.23 here are my codes

<htmL>
<body>
<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
<input type="Submit">
</form>
</body>
</html>

here are my php codes

<?
$username="root";
$password="";
$database="trial";

$first=$_POST['first'];


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
....

View Replies !
Database Records Query
Can anyone help me with the following mySQL code. Probably a simply solution but i cant find the answer anywhere. I have a table called news full of articles each one has an associated news_id. What i need to do is query the database and pull out the last article. Then i want to pull out the second to last article and finally the third to last article.

View Replies !
Show All Records From Database
How to show all records from database. (i mean row by row).for my code, i can only show the last record.

$query = "SELECT * FROM tblpatient";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
while ($row = mysql_fetch_assoc($result)){
echo $row['Name'];
echo '<br/>'
echo $row['Address'];
}

View Replies !
Batch Add Records To Database
I would like to create an option on my admin page to add batch records to Mysql database.

I guess I need a textarea, a field limiter and a line break :)

After the form has been submitted, the script should parse the data into arrays and add each array value to the database, most probably with a loop.

Can someone help me here? Example:

books

title | year | author

And what if I want to upload and insert CSV format (without phpmyadmin)?

View Replies !
User Is Verified By A MySQL Database, And Then A Session: 'user' Is Registered.
I have a problem with sessions. In my code admin.php the user is verified by a MySQL database, and then a session: 'user' is registered.

Well when the user presses a link to a another page called news.php it will be checked if the session is the same as in the same script, or if it's even registered (to prevent people trying to break in). But everytime i redirect to news.php I get a file included ip.php wich tells me Im about to break in. Code:

View Replies !
Sort Pages Of Records From Database
When I sort dates from my sql database, the records sort all in one time.I would like to sort only 20/25 records and after to clik a button and sort other 20/25 records and so on.

View Replies !
Flash Next Button For Database Records
Im making an student profile in flash. The database has already been created for us by our tutors at uni. I need help with my previos and next buttons. my work is due this friday I also have dynamic text boxes for car/bus/train/and bicycle. These data are s'posed to be loaded from the database either as a Yes/No. I cant figure these bits out.

View Replies !
Password Protected Database Records
Let's say that I have a MySQL database with 1 record for each client.

Now one client wants to modify his own record, how do you do just that using PHP?

I created a htaccess form for my clients but the problem I have is that they can edit the records of ALL my clients.

Anybody have a php script to paste here for me?

View Replies !
1 Record In Database But 2 Records Were Selected?
i'm retrieving a record from database. below the record, i have a yes and no button, where i can let user click and then count the number of yes and no.

everything works fine, but when i start to click the yes or no button, my record ,becomes two records. i only have one record in my database, but two same record was displayed.
this is the code: PHP Code:

View Replies !
Random Records From Access Database ?
I am retrieving records from an access database in php.But i want to select random 7 records....how can it be done ?

View Replies !
Comparing Previous And Next Records In The Database
at the moment if a listtype = 3 then it'll create a dropdown list of the product. incidentally if it is = 2 then it creates a product header and if it's = 1 then it shows it as a normal product.

Now I'm probably going about this the wrong way but if I can do it this way then great cos I've kinda got it figured in my head ok... just not in code:

View Replies !
Update All Records In A Database 364 Days
I have a calendar with events for this year in a SQL database that I would like to use for next year too (the events will remain the same). The days of the week are important; what is on Monday, November 6, 2006 should be on Monday, November 5, 2007.

I will copy the existing table to another table for the next year, so what I would want to do is update the dates to be 364 days from each date.

Does anyone know a command that I can update all records by 364 days?

The table is practice07
The field is PracticeDate (that holds the date that I want to update)

View Replies !
System That Upgrades Records In A Database
I'm trying to put together a system that upgrades records in a database and apparently have run into a bit of a glitch. I think the problem is with the $HTTP_POST_VARS portion of the code. Is there some variable that has to be set for this to work properly or what?
Ideas anyone?

The Input form: (1 of 3 forms)
<html>
<head>
<title>SystemsDoc Update</title>
</head>
<body bgcolor="white">
<form method="POST" action="sysdocupdate.php">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">UID to Update:</font></td>
<td><input type="text" name="UID" size=100></td>
</tr>................

View Replies !
Insert Records Into A Database At The Same Time?
What happens when 2 or more users query or insert records into a database at the same time? Does the website crash andis there a way to overcome it? Also, sometimes, when a user inserts a record it gets duplicated in the database 2 or 3 times. why is this?

View Replies !
Checking For Duplicate Records In Database
i got a form

<form method="post" action="haha.php">
username<input type="text" name="username">
<br>
email<input type="text" name="username">
<br>
<input type="submit" value="submit">
</form>

now i want to add a button beside the username field to check whether the user name is duplicated in database.

View Replies !
Make A Form That Can Add Records To My Database
im using phpadmin and i want to make a form that can add records to my database here are my html codes:

<htmL>
<body>
<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
<input type="Submit">
</form>
</body>
</html>


and here are my php codes

<?
$username="root";
....................

View Replies !
Updating Only Some Records Of Some Tables Of A Database
I manage a couple of mysql databases that are hosted on my server as well as at my ISP. We do update quite often some records in different tables & databases. As in South Africa, we pay per GB of traffic, complete dumping of all databases every day is excluded.

I am looking at a better way of only synchronizing the records that have been modified. In every table I created, I have a date_created & a date_modified, and of course everytime there is an automatic or manual update of the data, date_modified is updated. Code:

View Replies !
Convert Records From Database To Array
I read 10 lines of data from the database and I'd like to put it in an array. My problems are:

(1)
if the way of putting values inside an array is like this :
$arr = array(1 => "string1", 2 => "string2", 3 => "string3");
or
$arr = array("string1", "string2", "string3");

then how can I insert the values inside an array coming from :

while(list($stringdata)= mysql_fetch_row($result))
{
---------------------
}

View Replies !
Displaying Database Records Over Multiple Columns
I am currently using the following to generate a table with a single column with ten entries PHP Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved