Jump to content

need help!


skateme

Recommended Posts

I want to make the title of the page the product's name. This is the code:

 

<?

session_start();

if(isset($_GET['pid']))

{

$mProdId=$_GET['pid'];

}

else

{

header("Location: index.php");

}

include("include/db.php");

 

$message="";

$Index=0;

if(!isset($_SESSION['RowNo']))

{

$_SESSION['RowNo']=0;

}

if(!isset($_SESSION['arrCart']))

{

$_SESSION['arrCart'][0][0]="";

}

$Index=$_SESSION['RowNo'];

 

if(isset($_POST['cmdAdd']))

{

if(strlen($_POST['txtQty'])>0 && $_POST['txtQty']>0)

{

$found=0;

for($i=1;$i<=$Index;$i++)

{

if($_SESSION['arrCart'][$i][0]==$mProdId)

{

$found=1;

}

}

$mStock=0;

if($found==0)

{

$mStock=CalcStock($mProdId);

if($mStock>=$_POST['txtQty'])

{

$_SESSION['RowNo']++;

$Index=$_SESSION['RowNo'];

$_SESSION['arrCart'][$Index][0]=$mProdId; // Product Id

$_SESSION['arrCart'][$Index][1]=$_POST['txtQty'];  // Quantity

header("Location: view_cart.php");

}

else

{

if($mStock>0)

{

$message="Error occured:<br>You can order $mStock maximum.";

}

else

{

$message="Error occured:<br>This product is out of stock. ";

}

}

}

else

{

$message="Error occured:<br>You have already added this product.";

}

}

}

?>

<html>

<head>

<meta http-equiv="Content-Language" content="en-us">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<link href="include/soma.css" rel="stylesheet" type="text/css">

<title><? echo $row['ProdName']; ?></title>

<meta name="keywords" content="BLAH BLAH">

<meta name="decription" content="BLAH BLAH">

<script language="JavaScript" src="include/validation.js"></script>

<script language="JavaScript">

function BlankCheck()

{

if(IsBlank(document.frm.txtQty,"Quantity")) return false;

if(IsZero(document.frm.txtQty,"Quantity")) return false;

return true;

}

</script>

</head>

<body topmargin="0" leftmargin="0">

<? include("include/top.php"); ?>

       

  <table width="100%" border="0" cellpadding="5" cellspacing="2" bgcolor="#FFFFFF">

<form name="frm" action="product_detl.php?pid=<? echo $mProdId; ?>" method="post" onSubmit="return BlankCheck();"> 

    <tr>

      <td colspan="2"> </td>

    </tr>

    <?

$query="select * from product where product.ProdId='$mProdId'";

$result=mysql_query($query) or die(mysql_error());

//echo $query;

if(mysql_num_rows($result)>0)

{

$row=mysql_fetch_array($result);

?>

    <tr>

      <td colspan="2" valign="top"><? echo $row['ProdName']; ?></tr>

 

As you can see, I put that line in the Title tags. It doesn't work. Please help! Thanks!

Link to comment
https://forums.phpfreaks.com/topic/46152-need-help/
Share on other sites

You define the variable $row['ProdName'] on line 103 of that script. However you call for this variable on line 76!

 

You cannot call a variable before it has been defined! PHP doesn't back track itself. It parses each line at a time

 

if you want to use the $row['ProdName'] variable to define the title for the page then you will want to move the SQL query that defines the $row array before line 76 instead.

Link to comment
https://forums.phpfreaks.com/topic/46152-need-help/#findComment-224340
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.