I am trying to pass the values of an array from one PHP page to another but I am not having any luck. I need someone to tell me what I am doing wrong or if there is a bettter way.
Here is my code snippet for page one:
<?php
//Page 1 - Get values from the database
//This page is included from the main page
session_start();
$MYDB_CONNECTION = "something1";
$MYDB_USER = "something2";
$MYDB_PASS = "something3";
$link = mysql_connect($MYDB_CONNECTION, $MYDB_USER, $MYDB_PASS) or die(mysql_error());
if (!$link) {
die('Could not connect: ' . mysql_error() . "<br>" . error_message);
}
// echo 'Connected successfully' . '<br>';
mysql_select_db(customer);
$query = "SELECT * FROM board_members";
$result = mysql_query($query) or die(mysql_error());
$data = array(); // create a variable to hold the information
while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) !== false)
{
$data[] = $row; // add the row in to the results (data) array
}
$_Session['serializedArray'] = serialize($data);
?>
Here is my code snippet for page 2:
<?
//Page 2 - Test display of values from database
session_start();
$data = unserialize($_Session['serializedArray']);
print_r ($data);
print_r ("Third person is: ".$data[2]['FirstName']." ".$data[2]['LastName']."-".$data[2]['Amount']);
?>