Session arrays in php
hello -
im still having a problem. this array will set but only shows one record from the array. when there are 3 demo data sets.
thanks in advance for your help.
i want to store the variable id in an array and access that array through session id hyper link on the same page. so that when that hyper link is clicked the session id is passed to the next page.
here is the page code:
<?php
if (!isset($_SESSION)) {
session_start();
?>
<?php require_once('conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$Id = $_SESSION['Id']; //get users id to pass to record
$Name = $_SESSION['name']; // display users name
$Group = $_SESSION['Group']; // access control group for moderators, members, users
$maxRows_List = 10;
$pageNum_List = 0;
if (isset($_GET['pageNum_List'])) {
$pageNum_List = $_GET['pageNum_List'];
$startRow_List = $pageNum_List * $maxRows_List;
mysql_select_db($database_List, $List);
$query_List = "SELECT * WHERE b.UId1='$UserId'";
$query_limit_List = sprintf("%s LIMIT %d, %d", $query_List, $startRow_List, $maxRows_List);
$List = mysql_query($query_limit_List, $List) or die(mysql_error());
$row_List = mysql_fetch_assoc($List);
$List_Array = array();
while ($row = mysql_fetch_array($List))
foreach($row['Id'] as $i=>$val)
$List_Array = $val;
//return $List_Array;
$_SESSION['Id'] = $List_Array;
$myList_Array = $_SESSION['Id'];
if (isset($_GET['totalRows_List'])) {
$totalRows_List = $_GET['totalRows_List'];
} else {
$all_List = mysql_query($query_List);
$totalRows_List = mysql_num_rows($all_List);
$totalPages_List = ceil($totalRows_List/$maxRows_List)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
background-color: #0E03D6;
.thrColLiqHdr #container {
width: 80%; /* this will create a container 80% of the browser width */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
.thrColLiqHdr #header {
background: #FFFFFF;
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
.thrColLiqHdr #header h1 {
margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
/* Tips for sidebars:
1. Since we are working in percentages, it's best not to use side padding on the sidebars. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColLiqHdr #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
.thrColLiqHdr #sidebar1 {
float: left; /* this element must precede in the source order any element you would like it be positioned next to */
width: 22%; /* since this element is floated, a width must be given */
background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 15px 0; /* top and bottom padding create visual space within this div */
.thrColLiqHdr #sidebar2 {
float: right; /* this element must precede in the source order any element you would like it be positioned next to */
width: 23%; /* since this element is floated, a width must be given */
background: #FFFFFF; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 15px 0; /* top and bottom padding create visual space within this div */
.thrColLiqHdr #sidebar1 p, .thrColLiqHdr #sidebar1 h3, .thrColLiqHdr #sidebar2 p, .thrColLiqHdr #sidebar2 h3 {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
/* Tips for mainContent:
1. the space between the mainContent and sidebars is created with the left and right margins on the mainContent div.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 300px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
.thrColLiqHdr #mainContent {
margin: 0 24% 0 23.5%; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the sidebar spaces when the content in each sidebar ends. */
.thrColLiqHdr #footer {
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background:#FFFFFF;
.thrColLiqHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
.fltlft { /* this class can be used to float an element left in your page The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain its child floats */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
#apDiv1 {
position:absolute;
left:206px;
top:83px;
width:151px;
height:34px;
z-index:1;
#apDiv2 {
position:absolute;
left:363px;
top:84px;
width:519px;
height:37px;
z-index:2;
-->
</style><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColLiqHdr #sidebar2, .thrColLiqHdr #sidebar1 { padding-top: 30px; }
.thrColLiqHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
</head>
<body class="thrColLiqHdr">
<div id="container">
<div id="header">
<h1> </h1>
<p> </p>
<p> </p>
<!-- end #header --></div>
<div id="sidebar1">
<h3> </h3>
<!-- show users ratings overall and per list -->
<!-- end #sidebar1 --></div>
<div id="sidebar2">
<h3> </h3>
<!-- display current viewers of user list in space and show count of number of views -->
<!-- end #sidebar2 --></div>
<div id="mainContent">
<h1> </h1>
<blockquote>
<table border="1" cellpadding="1" cellspacing="1">
<tr></tr>
<caption align="center">
List Click to Edit
</caption>
<?php do { ?>
<tr>
<td><a href="list.php"><?php echo $myList_Array['Id']; ?></a></td> <-- this is the column that i want to have access the session id -->
<td><?php echo $row_List['Subject'];?></td>
<td><?php echo $row_List['Date']; ?></td>
</tr>
<?php } while($row_List = mysql_fetch_assoc($List));
?>
</table>
<h2> </h2>
<p> </p>
</blockquote>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
<?php
mysql_free_result($List);
?>
thnks a lot!
Michael Fesser wrote:
> .oO(John Doe)
>
>
>>wich is the <%Session.Timeout=n%> equivalent in
PHP to increase the time
>>specified in session.gc_maxlifetime?
>
>
>
http://www.php.net/ini_set
>
> Micha
Similar Messages
-
Hi.
I need to pass an array to php. But not by passing a string
which will be split by a character (","). I was wondering if i can
really pass an array to a php as an array not string.
Thank you.You can pass arrays to PHP and from PHP to Flash if you use
AMFPHP. It's a
remoting replacement that I got hooked on long ago. It's most
excellent.
www.amfphp.org
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Send Array to PHP with HTTPService
How can I send an array via HTTPService to a PHP script
please?
If I do this:
var params:Object=new Objsect();
params.myData=myDataArray; //myDataArray is an Array var that
I need to send
myService.send(params);
It will not pass on an array.
How can I pass the Array to PHP?u can convert the array in to a string in FLEX and in PHP u can use the "split" command...
here s sample program see if it helps u
http://flexarraytransfer.blogspot.com/ -
How to generate a random session variable in php
i want to generate a random session variable and insert the variable in a mysql record to use later to validate an account set up.
person fills out form to create account and submits; inserts form information in mysql record.
i want the random variable to be inserted from a hidden field and the page sends an email with a link to click on to compare the variable to validate the user.
Not sure how to generate a random session variable and get that to the hidden field value to be inserted with the other form information.
thanks for your help,
Jim BalthropTo insert the key I would personally do something like...
$key = md5($username . $password . $salt);
Insert that into your MySQL database, then send them a email with it, my next code shows how to activate it.
This is to activate the account.
<?php
$key;
$errors = array();
if(isset($_GET['key']){
$key = $_GET['key'];
$sql = 'SELECT * FROM users WHERE key = \'' . $key '\' LIMIT 1';
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)){
$sql2 = 'UPDATE users SET active = 1 WHERE key = \'' . $key '\' LIMIT 1';
$result2 = mysql_query($sql2) or die(mysql_error());
if($result2){
//successfully activated account
else{
//Something Went Wrong!
else{
$errors[] = 'Invaild Key, Please try again!';
else{
$errors[] = 'Invaild Key, Please try again!';
?> -
Hi All,
I have created a page that shows thumbnail images of all
images in a
given directory. Here is the function that searches the
directory and
builds an array of qualified files:
> function getImages($dir) {
> $directory = new DirectoryIterator($dir);
> $fileTypes =
'#\.jpg$|\.jpeg$|\.gif$|\.png$|\.JPG$|\.GIF$|\.PNG$#i';
> $filtered = new RegexIterator($directory, $fileTypes);
> $array = array();
> foreach ($filtered as $item) {
> $array[] = $item->getFilename();
> }
> return new ArrayIterator($array);
> }
>
> // get an ArrayIterator of filenames and the total
number:
> $images = getImages('../images/images_news/');
> $totalImages = $images->count();
Here is the HTML and PHP used to display the images (I'm
excluding code
that is specific to the paging function):
> // Implement offset and files per page
> foreach (new LimitIterator($images, $offset,
$filesperpage) as
> $image) { ?>
> <div class="imgcont">
> <div class="imgholder">
> <img src="../images/images_news/<?php echo $image;
?>"
> alt="<?php echo $image; ?>" height="55"
class="center" />
> </div>
> <p class="smallname"><?php echo $image;
?></p><br />
> </div>
> <?php } ?>
> <div class="clear"><br />
My question is this. I need to provide a way to delete images
that will
no longer be needed. Actually, I need to be able to delete
the main
image and the thumbnail image, each of which is in a separate
directory. What I don't know is how this type of thing is
normally done
(I don't want the FTP route because I don't want a client
messing about
in the directory structure). And what I don't understand is
how to
select one or more files to delete when they were produced by
an array.
For ease of use, it would be nice if I could add a checkbox
that the
user could check to indicate that the image(s) should be
deleted. I
just can't figure out how to select the file(s). I sure hope
this is
not one of those simple things that will make me hide my head
in shame.
Any help would be most appreciated.
BrettBrett wrote:
> the thumbnail images now have _tmb inserted between
> the file name and the extension. So when deleting I keep
getting
> warnings that the file mypic001.jpg cannot be found in
the thumbs
> directory. How do I get the _tmb into the file name?
foreach ($_POST['images'] as $image) {
unlink($mainImgDir . $image);
$pos = strrpos($image, '.');
$thumb = substr($image, 0, $pos) . '_tmb' . substr($image,
$pos);
unlink($thumbsDir . $thumb);
> By the way, you used unset() where I think you meant
unlink().
Yes, I did. Sorry about that.
> Finally, I have discovered that if I upload a file named
Ti301.JPG, I
> get Ti301.JPG001_thb.jpg. It seems that the strtolower()
function in
> getNextFilename5.php is not converting the uppercase
extension, it is
> just adding the incremented number plus _tmb and the new
extension. Any
> ideas about how to correct that?
That shouldn't be happening, but I don't have time to look
into that
now. Sorry.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
I have to send a large number of variable to php and want to
avoid having to repeatedly call the php script, so I thought the
way to do this would be to send an array. I generally use code
similar to the following to receive individual variables in php:
$count = mysql_real_escape_string($_GET["count"]);
Unfortunately, I don't know how to accept an array from Flex
into PHP. I realize that this is more of a php question than a Flex
question, but am hoping that someone has done this before. Here's
how I want to send the array from Flex:These links might help:
link1
link2
link3 -
Bind PL/SQL array to PHP array
Hi all!
I try to bind a PL/SQL array (nested tables, index by integer) returned by a PL/SQL-function to an PHP array.
Here is the code:
create or replace package MyPackage as
TYPE my_type IS TABLE OF VARCHAR2(1024);
FUNCTION MyFunction RETURN my_type;
end MyPackage;
create or replace PACKAGE BODY MyPackage is
FUNCTION MyFunction RETURN my_type IS
t_docs my_type;
begin
t_docs := my_type('val0','val1','val2');
return t_docs;
end MyFunction;
end MyPackage;
In the PHP-code ist looks like this
$query = "begin :vals := MyPackage.MyFunction; end;";
$stmt = oci_parse ($conn, $query);
oci_bind_array_by_name($stmt, ":vals", $vals_array, 5, 512, SQLT_CHR);
oci_execute ($stmt);
Output:
PLS-00382: expression is of wrong type. Error in Line....
This error point to
begin :vals := MyPackage.MyFunction; end;
^^^
Questions:
Is it generally possible to bind a pl/sql array to a php array? Or only the other was around?
Could you please post a snipet of code how to do it the right way :-)
Thanks a lot for your help! ChristianAs you noted, you can't return a PL/SQL array and map it to a PHP array when it is a record type. Likewise, you can't map an object type to a PHP array. You can return a reference cursor through PL/SQL, and then fetch the function result with oci_fetch_assoc($rc).
Alternatively, you can return an object type collection or a pipelined table function result into PHP. It's a bit long but you'll find examples on my blog. Start here, and there's a link to a full discussion of pipelined table functions:
http://blog.mclaughlinsoftware.com/2009/03/19/beats-a-reference-cursor/
This is an object table example, which you may prefer over pipelined table functions:
http://blog.mclaughlinsoftware.com/2009/03/23/object-record-collections/
Hope this helps. -
I am new to web applications, but for what I need is to know
how to use session variables. When a user logins I want thier
information stored so when they visit my account they are able to
see thier information and not someone elses. Any help should be in
PHP format. Thank you in advance.prashi123 wrote:
> I am new to web applications, but for what I need is to
know how to use session
> variables. When a user logins I want thier information
stored so when they
> visit my account they are able to see thier information
and not someone elses.
> Any help should be in PHP format. Thank you in advance.
http://www.php.net/manual/en/features.sessions.php
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/ -
Creating a session variable with PHP
Can anyone offer me a PHP script that creates a session
variable? The Dreamweaver CS3 Help documentation offers coding
samples for ColdFusion and ASP but not for PHP. I tried this
without success:
"$_SESSION['usermail']= $_POST['sub_email'];" in which I am
trying to capture an email address from a form and save it to use
in a confirmation email to a new subscriber. Any help would be
sincerely appreciated.
[email protected]I use this -
<?php
if (!isset($_SESSION)) {
session_start();
?>
at the top of the page, and then this within the code block
where you are
processing the form's data -
$_SESSION['usermail']= $_POST['sub_email'];
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Jugdish" <[email protected]> wrote in
message
news:gb8aov$691$[email protected]..
> Can anyone offer me a PHP script that creates a session
variable? The
> Dreamweaver CS3 Help documentation offers coding samples
for ColdFusion
> and ASP
> but not for PHP. I tried this without success:
> "$_SESSION['usermail']= $_POST['sub_email'];" in which I
am trying to
> capture
> an email address from a form and save it to use in a
confirmation email to
> a
> new subscriber. Any help would be sincerely appreciated.
> [email protected]
> -
Help,about session array in JSP
Maybe It is a simple question for you.But it really trouble
me.How to store an array into session variable and how to retrive it out from sesson,The session is exactly like the request except that it spans multiple requests.
int[] myArray = new int[5];
for (int i=0; i<myArray.length; i++) {
// build array
session.setAttribute("integerArray", myArray);To retrieve the array:
(int[]) session.getAttribute("integerArray"); -
Accessing session variables with php
I am trying to access the session variable $_SESSION['MM_Username'] in one of my php pages, but it is somehow showing empty (i.e it does not contain the username that was entered during login).
I checked and confirmed that my login.php function is properly setting the MM_Username session variable by echoing it from the login function.
So why can't I read it from another php file in the same session? Do I need to do something else before the session variables can
be properly read from any php file in the same session? Any help would be appreciated.Here is a test code I am using to access the session variable $_SESSION['MM_username'] from the php page test.php. But it is not working.
I get an empty string all the time for $username. Can any one see something wrong with this code?
<?php require_once('Connections/MyTestingConn.php'); ?>
<?php session_start(); ?>
<?php
$username = "-1";
if (isset($_SESSION['MM_username'])) {
$username = $_SESSION['MM_username'];
echo $username;
else
echo "Eror: can not access session variable";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
</body>
</html> -
Passing Session Variable from PHP to Applet
I'm trying to pass a session variable from a PHP script to a third party applet. The applet needs to accept the variable as a string into a parameter. I think the htnl has to be dynamically created to turn the session variable into a string for the parameter value. Any suggestions ?
This is really a PHP question. You might get better results on a PHP forum.
-
Just wondering if there's a better method than this:
FLASH:
Convert array to a string, delimit by whatever character,
pass string.
PHP:
Receive string from Flash, explode by whatever character,
into array.
Is there a better/faster/cleaner way? Of course you could
package the array into an XML object, but that seems messier, and
slower, both programmatically, and performance wise.
What do you think?Flash remoting is the absolute best. It's binary, compressed,
and
serialized/deserialized very quickly. AMFPHP takes care of
the server
end and Flash does remoting serialization internally. That's
what I think :)
Patrick
http://www.baynewmedia.com/
cayennecode wrote:
> Just wondering if there's a better method than this:
>
> FLASH:
> Convert array to a string, delimit by whatever
character, pass string.
>
> PHP:
> Receive string from Flash, explode by whatever
character, into array.
>
> Is there a better/faster/cleaner way? Of course you
could package the array
> into an XML object, but that seems messier, and slower,
both programmatically,
> and performance wise.
>
> What do you think?
> -
How to use a session, created in a jsp page, in a php page
Hello, forgive me for the newbie question.
Here is my problem:
I want to have a jsp page create a session, set some session variables and then redirect to a php page which will access those same session variables.
I have the redirection worked out, but I can't seem to find out how to use the jsp session in my php script.
Is this possible at all, and if so, how does it work?Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
<%
String someValue = (String)session.getAttribute("theAttributeName");
%>
<script type="text/javascript">
Calendar.setup({inputField:"f_date_dfFirstPmtDate",
button:"f_trigger_dfFirstPmtDate",
singleClick:true,
ifFormat:<%=someVale%>});
</script> -
Quick question about PHP sessions and Air app
Could someone clear this up for me?
My air app makes html requests to php scripts, php login, search etc. I've been advised to use sessions in the php scripts to ensure each request to a script is done by a logged in user.
So is the session identifier stored automatically by air somewhere, similar to a cookie in a browser?4.4.1 is indeed the version of php in 10.4.6, but it's also the version of php that's running on my 10.3.9 server. You can execute php -v on your server to see which version you've got, but it seems unlikely that it's a version other than 4.4.1 if you haven't updated it yourself. Are there security updates you haven't applied?
Maybe you are looking for
-
Is the software from Roxio that converts VHS to DVD compatible with Yosemite?
Is the software from Roxio that converts VHS to DVD compatible with Yosemite?
-
Where can I find a list of Camcorders compatible with FCP X?
Where can I find a list of Camcorders compatible with FCP X?
-
Hi - I keep getting a message stating "in house Zoetrope Client" is expiring on Sep 19, 2013, now in 12 days. it is in settings under profile. there is also a remove button. I have no idea if i need this or how to resolve this - any suggestions w
-
I have used my task manager to check to see if another version was open and that did not help. I've signed in and out of CC, that didn't help. The only thing that works is shutting down my computer and restarting. That only lasts for awhile and if I
-
Hi, Am trying to migrate Business rules from QA Environment to DEV Environment through LCM process from shared services. Migration process happening successfully in both environments but while checking in EssBase rules are not appearing but its not t