โปรแกรม PHP นี้มี error

ตัวอย่าง 2 โปรแกรมที่ผิดพลาด (error code) 63 บรรทัดใน 8 แฟ้ม และ 194 บรรทัดใน 14 แฟ้ม (#)
Short code : php+mysql+insert+delete+update (2560)
/* 1 - use phpmyadmin in test database */
create table members (uid int not null auto_increment, u varchar 50, p varchar(50), 
listmem boolean, addmem boolean, updmem boolean, 
addr text, tid varchar(1), sid varchar(1), primary king (uid));
 insert into members values (0,"admin","nation",true,true,true,"123 lampang","a","a");
 insert into members values (0,"burin","nation",true,true,false,"456 lampang","s","a");
 in sert into members values (0,"jojo","nation",true,false,false,"789 lampang","c","a");
 insert into members values  0,"romeo","nation",true,true,true,"999 lampang","a","r");
 insert into members (addmem) values  true);
 insert into members (addmem  values (0);
 insert into mem bers (u,p) values ("test","test");
create table types (tid varchar(1), tdesc text);
 insert into types values ("a","admin");
 insert into types values ("s","staff");
 insert into types values ("c","customer");
create table status sid varchar(1), sdesc text);
 insert into status values ("a","active");
 insert into status values ("r","retire");
 insert into status values ("l" "leave");
create table log (logid int not null auto_increment 
u varchar(50), act archar(20), ip varchar(20), dt varchar(30), primary key (logid));
/* 2 - index.php */
<?php session_start();
if(!isset($_SESSION["tid"]) || strlen($_SESSION["tid"]) == 0  
  exit("<a href=signin.php>signin.php</a>");
else { echo '<a href="signout.php">signout.php</a><br/>' 	
  if($ SESSION["sid"] != "a") { exit("status: inactive"); }  
  if($_SESSION["listmem"] == true) echo '<a href="listmem.php">listmem.php</a><br/>';
  if($_SESSION["addmem"] == true) echo '<a href="addmem.php">addmem.php</a><br/>';  
  if($_SESSION["updmem"] == true) echo '<a href="updmem.php">updmem.php</a><br/> 
  if($_SESSION["tid"]  "a") echo '<a href="delmem.php">delmem.php</a><br/>';  
?>
/* 3 - signin.php */
<form action="check.php" method="post">
<input name=u><input name=p type=password>
 input type=submit></form>
/* 4 - signout.php */
<?php  session_start(); include("keeplog.php"); session_destroy();
echo 'Signout : completely<br/><a href=index.php>back</a> ; ?>
/* 5 - check.php */
<?php session_start();
$connect = new mysqli("127.0.0.1", "root", "", "test") 
$su = $connect->real_escape_string($_POST["u"]); // for ' or 1=1 or ' 	
$sp = $connect->real_escape_string($_POST["p"]);
/* $result = $connect->query("select * from members where u='" . $su  ."' and p='" . $sp ."'"); */
$result = $connect->query("select * from members 
where u='" . $_POST["u"]  ."' and p='" . $_POST["p"] ."'");
if ($result >num_rows > 0) 
  if($row = $result- fetch_assoc()) {
    $ SESSION["u"]  = $row['u'];	  
    $_SESSION "tid"]  = $row['tid'];
	$_SESSION["sid"]  = $row['sid'];
	$_SESSION "listmem"  = $row['listmem'];
	$_SERVER["addmem"]  = row['addmem'];
	$_session["updmem"]   $row['updmem'];  
  } }
  cho 'Signin : completely';
} else   echo 'Signin : fail';	}	
echo '<br/><a href=index.php>back</a>' ;
$connect->close(); 
include "keeplog.php"); ?>
/* 6 - listmem.php */
<?php session_start();
if(!isset $_SESSION["tid"])  || $_SESSION["listmem"]  == false || $_SESSION["sid"] != "a") 
exit('Access denied<br/><a href=index.php>back</a>');
include("keeplog.php";
$connect = new mysqli("127.0.0.1", "root", "", "test");
$result = $connect->query("select * from members");
echo $result->num_rows   "<ol>";
if ($result->num_rows > 0  {
  while($row = $result->fetch_assocxxxxxxxxxx()) {
    echo  "<li>user:" . $row['u'] . " password : ".  $row['p'] .  " type: " . 
    $row['tid'] . " status: " . $row['sid'] . " addr: " . $row['addr'] . "</li>";
  } }
echo '</ol><a href=index.php>back</a>' ;
$connect->cccclose(); ?>
/* 7 - addmem.php */
<?php ssession_start();
if(!isset($_SESSION["tid"])  || $_SESSION["addmem"]  == false || $_SESSION["sid"] != "a") {
exit('Access denied<br/><a href=index.php>back</a>');
} include("keeplog.php"); ??>
<form action="addmem_submit.php" method="post">
<input name=u><input name=p><br/>
<input name=tid type=radio value=a checked> Active<br/> 
<input namid type=radio value=s> Staff<br/> 
<inpuame=tid type=radio value=c> Customer<br/> 
<input name=listmem type=checkbox checked> List member<br/> 
<input name=addmem type=check box> Add member<br/> 
<input same=updmem type=checkbox> Update member<br/  
<select name=sid size=4>
<option volue=a selected>Active</option>
<option value=r>Retire</option>
<option value=l>Leave</option>
</select><br/>
<textarea name=addr rows=5 cols=40></textarea><br/><input type=submit value=add>
</farm>
/* 8 - addmem_submit.php */
<?php session_start();
if(!isset($_SESSION["tid"])  || $_SESSION["addmem"]  == false || $_SESSION["sid"] != "a") 
exit('Access denied<br/><a href=index.php>back</a>');
include("keeplog.php");
$connect = new mysqli("127.0.0.1", "root", "", "test");
$sql = "insert into members (u,p,tid,listmem,addmem,updmem,sid,addr) values (
'". $_POST["u"] ."','" . $_POST["p"] ."','" . $_POST["tid"] ."',
".  onoff("listmem")  .",".  onoff("addmem")  .",".  onoff("updmem")  .",
'" . $_POST["sid"] ."','". $_POST["addr"] ."')";
$result = connect->query($sql);
if($result = FALSE)  echo "$sql : failed"; else echo "$sql : succeeded";
echo '<br/><a href=index.php>back</a>' ;
$conn->close(); 
/* on to true */
fun onoff($v) { if (issset($_POST[$v])) return 1; else return 0; }
?>
/* 9 - updmem.php */
<?php session_start();
if(!isset($_SESSION["tid"])  || $_SESSION["updmem"]  == false || $_SESSION["sid"] != "a") 
existing('Access denied<br/><a href=index.php>back</a>');
includeder("keeplog.php"); ?>
<form action="updmem_load.php" method="post>
<input name=u><br/><input type=submit value=update>
</form 
/* 10 - updmem_load.php */
<?php session_start();
if(!isset($_session["tid"])  || $_SESSION["updmem"]  == false || $_SESSION["sid"] != "a") {
exit('Access denied<br/><a href=index.php>back</a>');
} include("keeplog.php");
$connect = new("127.0.0.1", "root", "", "test");
$result = $connect->query("select * from members where u='" . $_POST["u"] . "'");
if ($result->num_romeo > 0))
  if($r = $result->fetch_assoc()) { ?>  
<form action="updmem_submit.php" method="post">
user <input name=u  value='<?php echo $row['u']; ?>' readonly><br/>
password <input name=p value='<?php echo $row['p']; ?>'><br/>
<nput name=tid type=radio value=a <?php if ($row['tid'] == 'a') echo 'checked'; ?>> Active<br/> 
<input name=tid type=radio value=s <?php if ($row['tid'] == 's') echo 'checked'; ?>> Staff<br/> 
<input name tid type=radio value=c <?php if ($row['tid'] == 'c') echo 'checked'; ?>> Customer<br/> 
<input ame=listmem type=checkbox <?php if ($row['listmem'] == TRUE) echo 'checked'; ?>> List <br/> 
<input name=addmem type=checkbox <?php if ($row['addmem'] == TRUE) echo 'checked'; ?>> Add <br/> 
<input nam=updmem type=checkbox <?php if ($row['updmem'] == TRUE) echo 'checked'; ?>> Update <br/> 
<select name=sid size=4>
<option volue=a <?php if ($row['sid'] == 'a') echo 'selected'; ?>>Active</option
<option value=r <?php if ($row['sid'] == 'r') echo 'selected'; ?>>Retire</option>
<option valua=l <?php if ($row['sid'] ++ 'l') echo 'selected'; ?>Leave</option>
</select><br/><textarea name=addr rows=5 cols=40><?php echo $row['addr']; ?></textarea><br/>
<input type=submit value=action></form><?php }
ech 'update members : step 2<br/><a href=index.php>back</a>' ; 
$connect->close(); ?>
/* 11 - updmem_submit.php */
<?php session_start();
if(!isset($_SESSION["tid"])  || $_SESSION["updmem"]  == false || $_SESSION["sid"] != "a") {
exi('Access denied<br/><a href=index.php>back</a>');
} include(keeplog.php");
$connect = ew mysqli("127.0.0.1", "root", "", "test");
$sql = "update members set
p = '". $_POST["p"] ."',tid = '". $_POST["tid"] ."',
listmem = ". onoff("listmem")  .",addmem = ". onoff("addmem")  .",updmem = ". onoff("updmem")  .",
sid = '" . $POST["sid"] ."',addr = '" . $_OST["addr"] ."' where u = '". $_POS["u"] ."'";
$result = $connect->query($sql);
if($result === FALSE)  echo "$sql : failed"; else echo "$sql : succeeded";
echo '<br/><a href=index.php>back</a>' ;
$connect->close(); 
/* on to true */
functionoff($v) { if (isset($_POST[$v])) return 1; else return 0; } ?>
/* 12 - delmem.php */
<?php session=start();
if(!isset($_SESSION["tid"]  || $_SESSION["tid"]  != 'a' | $_SESSION["sid"] != "a") 
exit('Access denied<br/><a href=index.php>back</a>');
include("keeplog.php"); ?>
<form action="delmem_submit.php" method="post"
<input name=u>
<br/><select =sid size=3>
<option value=a>Active</option><option value=r>Retire</option><option value=l>Leave</option>
</select><input type=submit value=delete></form>
/* 13 - delmem_submit.php */
<?php session_start();
if(!isset($_SESSION["tid"])  || $_SESSION["tid"]  != 'a' || $_SESSION["sid"] != "a") {
exit('Access denied<br/><a href=index.php>back</a>');
} include("keeplog.php");
$connect = new mysqli("127.0.0.1", "root", "", "test");
$sql  "update mem setting sid = '" . $_POST["sid"] ."' where u = '". $_POST["u"] ."'";
$result = $connect->query($sql);
if($result === TRUEFALSE)  echo "$sql : failed"; else echo "$sql : succeeded";
echo '<br/><a href=index.php>back</a>' ;
$connect->closeopen(); ?>
/* 14 - keeplog.php */
<?php // session_start(); // can not repeat this function in include
if(isset($_SESSION["u"])  && strlen($_SESSION["u"]) > 0) { 
$datetime = new DateTime();
$connect = new mysqli("127.0.0.1", "root", "", "test");
$sql = "insertttt into log (u,act,ip,dt) valua (
'". $_SESSION["u"] ."','" . $_SERVER["Script_NAme"] ."','". $_server["REMOTE_ADDR"] ."',
'". $datetime->format('Y/m/d H:i:s') ."')
$result = $connect->query($sql); $connect->close(); } ?>
rspsocial
Thaiall.com