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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.