It was suggested I send this to the list. The 'samp_db.inc' file follows this. The 
parse error is:
Parse error: parse error in /edit_member.php on line 11

#edit_member.php

<?php
include ("/users/mike/documents/include_files/samp_db.inc");
define (initial_page, 0);
define (display_entry, 1);
define (update_entry, 2);

function solicit_member_id ()
{
global $PHP_SELF;

printf ("<FORM METHOD=\"post\" ACTION=\"%s?action=%d\">\n",
$PHP_SELF, DISPLAY_ENTRY);
print ("Enter your membership ID number and password,\n");
print ("then select submit.\n<BR><BR>\n");
print ("<TABLE>\n");
print ("<TR>");
print ("<TD>Member ID</TD><TD>");
print ("<INPUT TYPE=text NAME=\"member_id\" size=10><BR>\n");
print ("</TD></TR>");
print ("<TR>");
print ("<TD>Password</TD><TD>");
print ("<INPUT TYPE=password NAME=\"password\" size=10><BR>\n");
print ("</TD></TR>");
print ("</TABLE>\n");
print ("<INPUT TYPE=\"submit\" NAME=\"button\" value=\"Submit\">\n");
print "</FORM>\n";
}

function display_entry ()
{
global $PHP_SELF;
global $member_id, $password;

$member_id = trim ($member_id);
if (empty ($member_id))
die ("No member ID specified");
if (!ereg ("^[0-9]+$", $member_id))
die ("Invalid member ID specified (must be a number)");
if (empty ($password))
die ("No password specified");
if (check_pass ($member_id, $password))
$admin = 0;
else if (check_pass (0, $password))
$admin = 1;
else
die ("Invalid password");

$query = "SELECT last_name, first_name, suffix, email,"
. "street, city, state, zip, phone, interests,"
. "member_id, expiration"
. " FROM member"
. " WHERE member_id = $member_id"
. " ORDER by last_name";
$result = mysql_query ($query)
or die ("Cannot execute query");
if (mysql_num_rows ($result) == 0)
die ("No user with member_id = $member_id found");
if (mysql_num_rows ($result) > 1)
die ("More than one user with member_id = $member_id found");

printf ("<FORM METHOD=\"post\" ACTION=\"%s?action=%d\">\n",
$PHP_SELF, UPDATE_ENTRY);
 
hidden_field ("member_id", $member_id);
hidden_field ("password", $password);
print ("<TABLE>\n");
$row = mysql_fetch_array ($result);
display_column ("Member ID", $row, "member_id", 0);

display_column ("Expiration", $row, "expiration", $admin);

display_column ("Last name", $row, "last_name", 1);
display_column ("First name", $row, "first_name", 1);
display_column ("Suffix", $row, "suffix", 1);
display_column ("Email", $row, "email", 1);
display_column ("Street", $row, "street", 1);
display_column ("City", $row, "city", 1);
display_column ("State", $row, "state", 1);
display_column ("Zip", $row, "zip", 1);
display_column ("Phone", $row, "phone", 1);
display_column ("Interests", $row, "interests", 1);
print ("</TABLE>\n");
print ("<INPUT TYPE=\"submit\" NAME=\"button\" value=\ "Submit\">\n");
print "</FORM>\n";

}

function check_pass ($id, $pass)
{

$query = "Select password from member_pass where member_id = $id";
if (!($result = mysql_query ($query)))
die ("Error reading password table");
if (!($row = mysql_fetch_array ($result)))
return (FALSE);
return ($row["password"] == $pass);
}

function display_column ($label, $row, $col_name, $editable)
{
print ("<TR>\n");
printf ("<TD>%s</TD>\n", htmlspecialchars ($label));
$value = htmlspecialchars ($row[$col_name]);
if ($editable)
{
$str = sprintf ("<INPUT TYPE=text NAME=\"row[%s]\"", $col_name);
$str .= sprintf (" VALUE=\"%s\" SIZE=\"80\">\n", $value);
}
else
$str = $value;
printf ("<TD>%s</TD>\n", $str);
print ("</TR>\n");
}

function update_entry ()
{
global $row, $member_id, $password;

$member_id = trim ($member_id);
if (empty ($member_id))
die ("No member ID specified");
if (!ereg ("^[0-9]+$", $member_id))
die ("Invalid member ID specified (must be number)");
if (!check_pass ($member_id, $password) && !check_pass (0, $password))
die ("Invalid password");
$result = mysql_query ("select * from member where 1 = 0");
if (!$result)
die ("Cannot query member table");

$query = "Update member ";
$delim = "set ";# put "set" before first column,"," before others
while (list ($col_name, $val) = each ($row))
{
$query .= "$delim $col_name =";
$delim = ",";

$val = trim ($val);
if (empty ($val))
{
if (nullable ($result, $col_name))
$query .= "NULL";
else
$query .= "\"\"";
}
else
$query .= "\"" . addslashes ($val) . "\"";
}
$query .= " where member_id = $member_id";
if (mysql_query ($query) && mysql_affected_rows () > 0)
print ("Entry updated successfully.\n");
else
print ("Entry not updated.\n");
}

function nullable ($result, $col_name)
{
for ($i = 0; $i < mysql_num_fields ($result); $i++)
{
if (!($fld = mysql_fetch_field ($result, $i)))
continue;
if ($fld->name == $col_name)
return (!$fld->not_null);
}
return (0);
}

if (empty ($action))
$action = INITIAL_PAGE;

$title = "Historical League member editing form";
html_begin ($title, $title);

samp_db_connect()
or die ("Cannot connect to the server");

switch ($action)
{
case initial_page:
solicit_member_id ();
break;
case display_entry:
display_entry ();
break;
case update_entry:
update_entry ();
break;


default:
die ("Unknown action code ($action)");
}

html_end ();
?>

_____________________________________________________


#samp_db.inc

<?php
function samp_db_connect ()
{
$link = mysql_pconnect ("localhost","username","password");
if ($link && mysql_select_db ("samp_db"))
return ($link);
return (false);
}

function html_begin ($title, $header)
{
print ("<html>\n");
print ("<head>\n");

if ($title)

print ("<title>$title</title>\n");
print ("</head>\n");
print ("<body>\n");

if ($header)
print ("<h2>$header</h2>\n");
}

function html_end ()
{
print ("</body></html>\n");
}

?>

Regards
Mike
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to