skateme Posted April 8, 2007 Share Posted April 8, 2007 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! Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 check the case of your keys, also, can you post all your code Quote Link to comment Share on other sites More sharing options...
dsaba Posted April 8, 2007 Share Posted April 8, 2007 undefined variables will echo empty or an error if you have error reporting turned on i don't see where you defined that variable before you echoed it in the title Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 8, 2007 Share Posted April 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.