Syntax error NEED HELP! (Still Need Help! [SERIOUSLY!])

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

zain1992
Forum Newbie
Posts: 15
Joined: Thu Oct 26, 2006 3:10 pm

Post by zain1992 »

ok i did what i could. i basically put he $cityp = $_POST["cityp"]; code every Php code begining, but still didnt work out right.
zain1992
Forum Newbie
Posts: 15
Joined: Thu Oct 26, 2006 3:10 pm

Post by zain1992 »

here is the code now (edited version:)

Code: Select all

<? session_start(); ?>
<html>
<head>
<title>qfq -- <?php $cityp = $_POST["cityp"]; echo $cityp; ?></title>
<meta name="generator" content="text/html">
<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
</head>
<body>
<table class="bd" width="100%"><tr><td class="hr"><h2>Quick Fare Quotes 

System</h2></td></tr></table>
<table width="100%">
<tr>

<td width="10%" valign="top">
<li>
</td>
<td width="5%">
</td>
<td bgcolor="#e0e0e0">
</td>
<td width="5%">
</td>
<td width="80%" valign="top">
<?
  $cityp = $_POST['cityp'];
  $conn = connect();
  $showrecs = 20;
  $pagerange = 10;

  $a = @$_GET["a"];
  $recid = @$_GET["recid"];
  if (isset($_GET["order"])) $order = @$_GET["order"];
  if (isset($_GET["type"])) $ordtype = @$_GET["type"];

  if (isset($_POST["filter"])) $filter = @$_POST["filter"];
  if (isset($_POST["filter_field"])) $filterfield = 

@$_POST["filter_field"];
  $wholeonly = false;
  if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"];

  if (!isset($order) && isset($_SESSION["order"])) $order = 

$_SESSION["order"];
  if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = 

$_SESSION["type"];
  if (!isset($filter) && isset($_SESSION["filter"])) $filter = 

$_SESSION["filter"];
  if (!isset($filterfield) && isset($_SESSION["filter_field"])) 

$filterfield = $_SESSION["filter_field"];

  $page = @$_GET["page"];
  if (!isset($page)) $page = 1;

  $sql = @$_POST["sql"];

  switch ($sql) {
    case "insert":
      sql_insert();
      break;
    case "update":
      sql_update();
      break;
    case "delete":
      sql_delete();
      break;
  }

  switch ($a) {
    case "add":
      addrec();
      break;
    case "view":
      viewrec($recid);
      break;
    case "edit":
      editrec($recid);
      break;
    case "del":
      deleterec($recid);
      break;
    default:
      select();
      break;
  }

  if (isset($order)) $_SESSION["order"] = $order;
  if (isset($ordtype)) $_SESSION["type"] = $ordtype;
  if (isset($filter)) $_SESSION["filter"] = $filter;
  if (isset($filterfield)) $_SESSION["filter_field"] = $filterfield;
  if (isset($wholeonly)) $_SESSION["wholeonly"] = $wholeonly;

  mysql_close($conn);
?>
</td></tr></table>
<table class="bd" width="100%"><tr><td 

class="hr">http://www.sqlmaestro.com/products/mysql/phpgenerator/</td></

tr></table>
</body>
</html>

<? 
$cityp = $_POST["cityp"]; 
   function select()
  {
  global $cityp;
  global $a;
  global $showrecs;
  global $page;
  global $filter;
  global $filterfield;
  global $wholeonly;
  global $order;
  global $ordtype;


  if ($a == "reset") {
    $filter = "";
    $filterfield = "";
    $wholeonly = "";
    $order = "";
    $ordtype = "";
  }

  $checkstr = "";
  if ($wholeonly) $checkstr = " checked";
  if ($ordtype == "asc") { $ordtypestr = "desc"; } else { $ordtypestr = 

"asc"; }
  $res = sql_select();
  $count = sql_getrecordcount();
  if ($count % $showrecs != 0) {
    $pagecount = intval($count / $showrecs) + 1;
  }
  else {
    $pagecount = intval($count / $showrecs);
  }
  $startrec = $showrecs * ($page - 1);
  if ($startrec < $count) {mysql_data_seek($res, $startrec);}
  $reccount = min($showrecs * $page, $count);
  $fields = array(
    "AirLine" => "AirLine",
    "Class" => "Class",
    "AdtPrice" => "AdtPrice",
    "chdPrice" => "chdPrice",
    "InfPrice" => "InfPrice",
    "MaxStay" => "MaxStay",
    "MinStay" => "MinStay",
    "Rules" => "Rules",
    "TktBy" => "TktBy",
    "Chg" => "Chg",
    "Can" => "Can",
    "TrvlBetweena" => "TrvlBetweena",
    "TrvlBetweenb" => "TrvlBetweenb");
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr><td>Citypair: <?php echo $cityp; ?></td></tr>
<tr><td>Fares shown <? echo $startrec + 1 ?> - <? echo $reccount ?> of 

<? $cityp = $_POST["cityp"]; echo $count; ?></td></tr>
</table>
<hr size="1" noshade>
<form action="edit.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><b>Custom Filter</b>&nbsp;</td>
<td><input type="text" name="filter" value="<? echo $filter ?>"></td>
<td><select name="filter_field">
<option value="">All Fields</option>
<?
  $cityp = $_POST["cityp"]; 
  reset($fields);
  foreach($fields as $val => $caption) {
    if ($val == $filterfield) {$selstr = " selected"; } else {$selstr = 

""; }
?>
<option value="<? $cityp = $_POST["cityp"]; echo $val; ?>"<? $cityp = 

$_POST["cityp"]; echo $selstr; ?>><? $cityp = $_POST["cityp"]; echo 

htmlspecialchars($caption); ?></option>
<? } ?>
</select></td>
<td><input type="checkbox" name="wholeonly"<? $cityp = $_POST["cityp"]; 

echo $checkstr; ?>>Whole words only</td>
</td></tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="action" value="Apply Filter"></td>
<td><a href="edit.php?a=reset">Reset Filter</a></td>
</tr>
</table>
</form>
<hr size="1" noshade>
<? $cityp = $_POST["cityp"]; showpagenav($page, $pagecount); ?>
<br>
<table class="tbl" border="0" cellspacing="1" 

cellpadding="5"width="100%">
<tr>
<?
  $cityp = $_POST["cityp"]; 
  reset($fields);
  foreach($fields as $val => $caption) {
?>
<td class="hr"><a class="hr" href="edit.php?order=<? echo $val 

?>&type=<? echo $ordtypestr ?>"><? echo htmlspecialchars($caption) 

?></a></td>
<? } ?>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
</tr>
<?
  $cityp = $_POST["cityp"]; 
  for ($i = $startrec; $i < $reccount; $i++)
  {
    $row = mysql_fetch_assoc($res);
    $style = "dr";
    if ($i % 2 != 0) {
      $style = "sr";
    }
?>
<tr>
<?
  $cityp = $_POST["cityp"]; 
  reset($fields);
  foreach($fields as $val => $caption) {
?>
<td class="<? echo $style ?>"><? echo htmlspecialchars($row[$val]) 

?></td>
<? } ?>
<td class="<? echo $style ?>"><a href="edit.php?a=view&recid=<? echo $i 

?>">View</a></td>
<td class="<? echo $style ?>"><a href="edit.php?a=edit&recid=<? echo $i 

?>">Edit</a></td>
<td class="<? echo $style ?>"><a href="edit.php?a=del&recid=<? echo $i 

?>">Delete</a></td>
</tr>
<?
  }
  mysql_free_result($res);
?>
</table>
<br>
<? $cityp = $_POST["cityp"]; showpagenav($page, $pagecount); ?>
<? } ?>

<? 
  $cityp = $_POST["cityp"]; 
  function showrow($row)
  {
?>
<table class="tbl" border="0" cellspacing="1" 

cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("AirLine")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["AirLine"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Class")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Class"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("AdtPrice")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["AdtPrice"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("chdPrice")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["chdPrice"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("InfPrice")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["InfPrice"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("MaxStay")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["MaxStay"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("MinStay")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["MinStay"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Rules")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Rules"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TktBy")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["TktBy"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Chg")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Chg"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Can")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["Can"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TrvlBetweena")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["TrvlBetweena"]) ?></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TrvlBetweenb")."&nbsp;" ?></td>
<td class="dr"><? echo htmlspecialchars($row["TrvlBetweenb"]) ?></td>
</tr>
</table>
<? } ?>

<? 
  $cityp = $_POST["cityp"]; 
  function showroweditor($row)
  {
  global $cityp;
  global $conn;
?>
<table class="tbl" border="0" cellspacing="1" 

cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("AirLine")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="AirLine" maxlength="15" 

value="<? echo str_replace('"', '"', trim($row["AirLine"])) 

?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Class")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Class" maxlength="15" value="<? 

echo str_replace('"', '"', trim($row["Class"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("AdtPrice")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="AdtPrice" value="<? echo 

str_replace('"', '"', trim($row["AdtPrice"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("chdPrice")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="chdPrice" value="<? echo 

str_replace('"', '"', trim($row["chdPrice"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("InfPrice")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="InfPrice" value="<? echo 

str_replace('"', '"', trim($row["InfPrice"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("MaxStay")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="MaxStay" maxlength="3" value="<? 

echo str_replace('"', '"', trim($row["MaxStay"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("MinStay")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="MinStay" maxlength="3" value="<? 

echo str_replace('"', '"', trim($row["MinStay"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Rules")."&nbsp;" ?></td>
<td class="dr"><textarea cols="35" rows="4" name="Rules" 

maxlength="100"><? echo str_replace('"', '"', trim($row["Rules"])) 

?></textarea></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TktBy")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="TktBy" maxlength="10" value="<? 

echo str_replace('"', '"', trim($row["TktBy"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Chg")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Chg" value="<? echo 

str_replace('"', '"', trim($row["Chg"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("Can")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="Can" value="<? echo 

str_replace('"', '"', trim($row["Can"])) ?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TrvlBetweena")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="TrvlBetweena" maxlength="11" 

value="<? echo str_replace('"', '"', trim($row["TrvlBetweena"])) 

?>"></td>
</tr>
<tr>
<td class="hr"><? echo htmlspecialchars("TrvlBetweenb")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="TrvlBetweenb" maxlength="11" 

value="<? echo str_replace('"', '"', trim($row["TrvlBetweenb"])) 

?>"></td>
</tr>
</table>
<? } ?>

<? function showpagenav($page, $pagecount)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="edit.php?a=add">Add Fare</a>&nbsp;</td>
<? if ($page > 1) { ?>
<td><a href="edit.php?page=<? echo $page - 1 

?>"><<&nbsp;Prev</a>&nbsp;</td>
<? } ?>
<?
  $cityp = $_POST["cityp"]; 
  global $pagerange;

  if ($pagecount > 1) {

  if ($pagecount % $pagerange != 0) {
    $rangecount = intval($pagecount / $pagerange) + 1;
  }
  else {
    $rangecount = intval($pagecount / $pagerange);
  }
  for ($i = 1; $i < $rangecount + 1; $i++) {
    $startpage = (($i - 1) * $pagerange) + 1;
    $count = min($i * $pagerange, $pagecount);

    if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) {
      for ($j = $startpage; $j < $count + 1; $j++) {
        if ($j == $page) {
?>
<td><b><? echo $j ?></b></td>
<? } else { ?>
<td><a href="edit.php?page=<? echo $j ?>"><? echo $j ?></a></td>
<? } } } else { ?>
<td><a href="edit.php?page=<? echo $startpage ?>"><? echo $startpage 

."..." .$count ?></a></td>
<? } } } ?>
<? if ($page < $pagecount) { ?>
<td>&nbsp;<a href="edit.php?page=<? echo $page + 1 

?>">Next&nbsp;>></a>&nbsp;</td>
<? } ?>
</tr>
</table>
<? } ?>

<? 
$cityp = $_POST["cityp"]; 
function showrecnav($a, $recid, $count)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="edit.php">Index Page</a></td>
<? if ($recid > 0) { ?>
<td><a href="edit.php?a=<? echo $a ?>&recid=<? echo $recid - 1 ?>">Prior 

Fare</a></td>
<? } if ($recid < $count) { ?>
<td><a href="edit.php?a=<? echo $a ?>&recid=<? echo $recid + 1 ?>">Next 

Fare</a></td>
<? } ?>
</tr>
</table>
<hr size="1" noshade>
<? } ?>

<?
$cityp = $_POST["cityp"]; 
 function addrec()
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="edit.php">Index Page</a></td>
</tr>
</table>
<hr size="1" noshade>
<form action="edit.php" method="post">
<p><input type="hidden" name="sql" value="insert"></p>
<?
$row = array(
  "AirLine" => "",
  "Class" => "",
  "AdtPrice" => "",
  "chdPrice" => "",
  "InfPrice" => "",
  "MaxStay" => "",
  "MinStay" => "",
  "Rules" => "",
  "TktBy" => "",
  "Chg" => "",
  "Can" => "",
  "TrvlBetweena" => "",
  "TrvlBetweenb" => "");
showroweditor($row)
?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<? } ?>

<? 
$cityp = $_POST["cityp"]; 
function viewrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("view", $recid, $count);
?>
<br>
<? showrow($row) ?>
<br>
<hr size="1" noshade>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="edit.php?a=add">Add Fare</a></td>
<td><a href="edit.php?a=edit&recid=<? echo $recid ?>">Edit Fare</a></td>
<td><a href="edit.php?a=del&recid=<? echo $recid ?>">Delete 

Fare</a></td>
</tr>
</table>
<?
  mysql_free_result($res);
} ?>

<? 
$cityp = $_POST["cityp"]; 
function editrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("edit", $recid, $count);
?>
<br>
<form action="edit.php" method="post">
<input type="hidden" name="sql" value="update">
<input type="hidden" name="xAirLine" value="<? echo $row["AirLine"] ?>">
<input type="hidden" name="xClass" value="<? echo $row["Class"] ?>">
<input type="hidden" name="xAdtPrice" value="<? echo $row["AdtPrice"] 

?>">
<input type="hidden" name="xchdPrice" value="<? echo $row["chdPrice"] 

?>">
<input type="hidden" name="xInfPrice" value="<? echo $row["InfPrice"] 

?>">
<input type="hidden" name="xMaxStay" value="<? echo $row["MaxStay"] ?>">
<input type="hidden" name="xMinStay" value="<? echo $row["MinStay"] ?>">
<input type="hidden" name="xRules" value="<? echo $row["Rules"] ?>">
<input type="hidden" name="xTktBy" value="<? echo $row["TktBy"] ?>">
<input type="hidden" name="xChg" value="<? echo $row["Chg"] ?>">
<input type="hidden" name="xCan" value="<? echo $row["Can"] ?>">
<input type="hidden" name="xTrvlBetweena" value="<? echo 

$row["TrvlBetweena"] ?>">
<input type="hidden" name="xTrvlBetweenb" value="<? echo 

$row["TrvlBetweenb"] ?>">
<? showroweditor($row) ?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<?
  mysql_free_result($res);
} ?>

<? 
$cityp = $_POST["cityp"]; 
function deleterec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("del", $recid, $count);
?>
<br>
<form action="edit.php" method="post">
<input type="hidden" name="sql" value="delete">
<input type="hidden" name="xAirLine" value="<? echo $row["AirLine"] ?>">
<input type="hidden" name="xClass" value="<? echo $row["Class"] ?>">
<input type="hidden" name="xAdtPrice" value="<? echo $row["AdtPrice"] 

?>">
<input type="hidden" name="xchdPrice" value="<? echo $row["chdPrice"] 

?>">
<input type="hidden" name="xInfPrice" value="<? echo $row["InfPrice"] 

?>">
<input type="hidden" name="xMaxStay" value="<? echo $row["MaxStay"] ?>">
<input type="hidden" name="xMinStay" value="<? echo $row["MinStay"] ?>">
<input type="hidden" name="xRules" value="<? echo $row["Rules"] ?>">
<input type="hidden" name="xTktBy" value="<? echo $row["TktBy"] ?>">
<input type="hidden" name="xChg" value="<? echo $row["Chg"] ?>">
<input type="hidden" name="xCan" value="<? echo $row["Can"] ?>">
<input type="hidden" name="xTrvlBetweena" value="<? echo 

$row["TrvlBetweena"] ?>">
<input type="hidden" name="xTrvlBetweenb" value="<? echo 

$row["TrvlBetweenb"] ?>">
<? showrow($row) ?>
<p><input type="submit" name="action" value="Confirm"></p>
</form>
<?
  mysql_free_result($res);
} ?>

<? 
$cityp = $_POST["cityp"]; 
function connect()
{
  $conn = mysql_connect("localhost", "root", "ookerate");
  mysql_select_db("qfq");
  return $conn;
}

function sqlvalue($val, $quote)
{
  if ($quote)
    $tmp = sqlstr($val);
  else
    $tmp = $val;
  if ($tmp == "")
    $tmp = "NULL";
  elseif ($quote)
    $tmp = "'".$tmp."'";
  return $tmp;
}

function sqlstr($val)
{
  return str_replace("'", "''", $val);
}

function sql_select()
{
  global $cityp;
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;

  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = 

"%" .$filterstr ."%";
 if ( !isset($cityp) ) { 
        die('there is no $cityp'); 
  } 
  $sql = "select `AirLine`, `Class`, `AdtPrice`, `chdPrice`, `InfPrice`, 

`MaxStay`, `MinStay`, `Rules`, `TktBy`, `Chg`, `Can`, `TrvlBetweena`, 

`TrvlBetweenb` from $cityp";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && 

$filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (`AirLine` like '" .$filterstr ."') or (`Class` like 

'" .$filterstr ."') or (`AdtPrice` like '" .$filterstr ."') or 

(`chdPrice` like '" .$filterstr ."') or (`InfPrice` like '" .$filterstr 

."') or (`MaxStay` like '" .$filterstr ."') or (`MinStay` like '" 

.$filterstr ."') or (`Rules` like '" .$filterstr ."') or (`TktBy` like 

'" .$filterstr ."') or (`Chg` like '" .$filterstr ."') or (`Can` like '" 

.$filterstr ."') or (`TrvlBetweena` like '" .$filterstr ."') or 

(`TrvlBetweenb` like '" .$filterstr ."')";
  }
  if (isset($order) && $order!='') $sql .= " order by \"" 

.sqlstr($order) ."\"";
  if (isset($ordtype) && $ordtype!='') $sql .= " " .sqlstr($ordtype);
  echo '<div>Debug: ', htmlentities($sql), "</div>\n"; 
  $res = mysql_query($sql, $conn) or die(mysql_error());
  return $res;
}

function sql_getrecordcount()
{
  global $cityp;
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;

  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = 

"%" .$filterstr ."%";
  $sql = "select count(*) from $cityp";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && 

$filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (`AirLine` like '" .$filterstr ."') or (`Class` like 

'" .$filterstr ."') or (`AdtPrice` like '" .$filterstr ."') or 

(`chdPrice` like '" .$filterstr ."') or (`InfPrice` like '" .$filterstr 

."') or (`MaxStay` like '" .$filterstr ."') or (`MinStay` like '" 

.$filterstr ."') or (`Rules` like '" .$filterstr ."') or (`TktBy` like 

'" .$filterstr ."') or (`Chg` like '" .$filterstr ."') or (`Can` like '" 

.$filterstr ."') or (`TrvlBetweena` like '" .$filterstr ."') or 

(`TrvlBetweenb` like '" .$filterstr ."')";
  }
  echo '<div>Debug: ', htmlentities($sql), "</div>\n"; 
  $res = mysql_query($sql, $conn) or die(mysql_error());
  $row = mysql_fetch_assoc($res);
  reset($row);
  return current($row);
}

function sql_insert()
{
  global $cityp;
  global $conn;
  global $_POST;

  $sql = "insert into $cityp (`AirLine`, `Class`, `AdtPrice`, 

`chdPrice`, `InfPrice`, `MaxStay`, `MinStay`, `Rules`, `TktBy`, `Chg`, 

`Can`, `TrvlBetweena`, `TrvlBetweenb`) values (" 

.sqlvalue(@$_POST["AirLine"], true) .", " .sqlvalue(@$_POST["Class"], 

true) .", " .sqlvalue(@$_POST["AdtPrice"], false) .", " 

.sqlvalue(@$_POST["chdPrice"], false) .", " 

.sqlvalue(@$_POST["InfPrice"], false) .", " 

.sqlvalue(@$_POST["MaxStay"], true) .", " .sqlvalue(@$_POST["MinStay"], 

true) .", " .sqlvalue(@$_POST["Rules"], true) .", " 

.sqlvalue(@$_POST["TktBy"], true) .", " .sqlvalue(@$_POST["Chg"], false) 

.", " .sqlvalue(@$_POST["Can"], false) .", " 

.sqlvalue(@$_POST["TrvlBetweena"], true) .", " 

.sqlvalue(@$_POST["TrvlBetweenb"], true) .")";
  echo '<div>Debug: ', htmlentities($sql), "</div>\n"; 
mysql_query($sql, $conn) or die(mysql_error());
}

function sql_update()
{
  global $cityp;
  global $conn;
  global $_POST;

  $sql = "update $cityp set `AirLine`=" .sqlvalue(@$_POST["AirLine"], 

true) .", `Class`=" .sqlvalue(@$_POST["Class"], true) .", `AdtPrice`=" 

.sqlvalue(@$_POST["AdtPrice"], false) .", `chdPrice`=" 

.sqlvalue(@$_POST["chdPrice"], false) .", `InfPrice`=" 

.sqlvalue(@$_POST["InfPrice"], false) .", `MaxStay`=" 

.sqlvalue(@$_POST["MaxStay"], true) .", `MinStay`=" 

.sqlvalue(@$_POST["MinStay"], true) .", `Rules`=" 

.sqlvalue(@$_POST["Rules"], true) .", `TktBy`=" 

.sqlvalue(@$_POST["TktBy"], true) .", `Chg`=" .sqlvalue(@$_POST["Chg"], 

false) .", `Can`=" .sqlvalue(@$_POST["Can"], false) .", `TrvlBetweena`=" 

.sqlvalue(@$_POST["TrvlBetweena"], true) .", `TrvlBetweenb`=" 

.sqlvalue(@$_POST["TrvlBetweenb"], true) ." where " ."(`AirLine`=" 

.sqlvalue(@$_POST["xAirLine"], true) .") and (`Class`=" 

.sqlvalue(@$_POST["xClass"], true) .") and (`AdtPrice`=" 

.sqlvalue(@$_POST["xAdtPrice"], false) .") and (`chdPrice`=" 

.sqlvalue(@$_POST["xchdPrice"], false) .") and (`InfPrice`=" 

.sqlvalue(@$_POST["xInfPrice"], false) .") and (`MaxStay`=" 

.sqlvalue(@$_POST["xMaxStay"], true) .") and (`MinStay`=" 

.sqlvalue(@$_POST["xMinStay"], true) .") and (`Rules`=" 

.sqlvalue(@$_POST["xRules"], true) .") and (`TktBy`=" 

.sqlvalue(@$_POST["xTktBy"], true) .") and (`Chg`=" 

.sqlvalue(@$_POST["xChg"], false) .") and (`Can`=" 

.sqlvalue(@$_POST["xCan"], false) .") and (`TrvlBetweena`=" 

.sqlvalue(@$_POST["xTrvlBetweena"], true) .") and (`TrvlBetweenb`=" 

.sqlvalue(@$_POST["xTrvlBetweenb"], true) .")";
  echo '<div>Debug: ', htmlentities($sql), "</div>\n"; 
  mysql_query($sql, $conn) or die(mysql_error());
}

function sql_delete()
{
  global $cityp;
  global $conn;
  global $_POST;

  $sql = "delete from $cityp where " ."(`AirLine`=" 

.sqlvalue(@$_POST["xAirLine"], true) .") and (`Class`=" 

.sqlvalue(@$_POST["xClass"], true) .") and (`AdtPrice`=" 

.sqlvalue(@$_POST["xAdtPrice"], false) .") and (`chdPrice`=" 

.sqlvalue(@$_POST["xchdPrice"], false) .") and (`InfPrice`=" 

.sqlvalue(@$_POST["xInfPrice"], false) .") and (`MaxStay`=" 

.sqlvalue(@$_POST["xMaxStay"], true) .") and (`MinStay`=" 

.sqlvalue(@$_POST["xMinStay"], true) .") and (`Rules`=" 

.sqlvalue(@$_POST["xRules"], true) .") and (`TktBy`=" 

.sqlvalue(@$_POST["xTktBy"], true) .") and (`Chg`=" 

.sqlvalue(@$_POST["xChg"], false) .") and (`Can`=" 

.sqlvalue(@$_POST["xCan"], false) .") and (`TrvlBetweena`=" 

.sqlvalue(@$_POST["xTrvlBetweena"], true) .") and (`TrvlBetweenb`=" 

.sqlvalue(@$_POST["xTrvlBetweenb"], true) .")";
  echo '<div>Debug: ', htmlentities($sql), "</div>\n"; 
  mysql_query($sql, $conn) or die(mysql_error());
} ?>
OK so what am i doing wrong that when i input the cityp through POST method it says this on top of the page:
Debug: select `AirLine`, `Class`, `AdtPrice`, `chdPrice`, `InfPrice`, `MaxStay`, `MinStay`, `Rules`, `TktBy`, `Chg`, `Can`, `TrvlBetweena`, `TrvlBetweenb` from iahkhi
Debug: select count(*) from iahkhi
Also maybe i should approach this using cookies? i dont know so can some one please help me.

also thanks for everybody replyig to this. it will really help.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

zain1992 wrote:
Debug: select `AirLine`, `Class`, `AdtPrice`, `chdPrice`, `InfPrice`, `MaxStay`, `MinStay`, `Rules`, `TktBy`, `Chg`, `Can`, `TrvlBetweena`, `TrvlBetweenb` from iahkhi
Debug: select count(*) from iahkhi
That's the output of the debug code I gave you. If you don't need it anymore remove it.
May I ask you about your level of experience in php coding and what you're trying to achieve?
Post Reply