Notice: Undefined index: t_id in c:program fileseasyphp1-7wwwsmttprint_preview.php on line 4...
<br />
<b>Notice</b>: Undefined variable: r in <b>c:program fileseasyphp1-7wwwsmttprint_preview.php</b> on line <b>79</b><br />
The first Notice means that the variable $_REQUEST[‘t_id’] has not been set. You can’t use a variable that has no value. It’s like using a remote with no batteries: it just won’t work. The @ surpresses them, but hiding a problem does NOT equal solving the problem. Change
[php]$t_id=$_REQUEST[‘t_id’];[/php]
into
[php]if (isset($_POST[‘t_id’])) { $t_id = $_POST[‘t_id’]; } else { $t_id = “”; }[/php]
Notice that I changed the $_REQUEST into $_POST, in accordance to ‘Use The Right Tool For The Right Job’, which means using $_POST for form variables. Sloppy coding
The second Notice is exactly the same as the first: a variable that has not been initialized. The cause is different though: you keep using $r3 throughout your script, and all of a sudden you use $r. I’m thinking this is a typo. Sloppy coding
Notice: Use of undefined constant E_STRICT - assumed 'E_STRICT' in c:program fileseasyphp1-7wwwsmttprint_preview.php on line 6...
As you can see in the PHP Manual, which is your bible and should be open in a separate window or tab whenever you’re developing PHP code, the constant E_STRICT has only been introduced PHP5. You getting this error tells me you’re devving on PHP4
I took out all of the HTML code in the quote below, since HTML doesn’t add functionality to your PHP script.
I fixed a few problems, but it’s up to you to do the actual debugging. But I’m thinking the highlighting will help you a bit with your (may I? sloppy!) code
[php]
<?php
error_reporting(E_ALL);
include "db1.php";
session_start();
$t_id=$_REQUEST['t_id'];
?>
<?
$sql3="select * from voucher where t_id='$t_id'";
$result3=mysql_query($sql3)or die(mysql_error());
@$r3=mysql_fetch_assoc($result3);
?>
<? echo $r3['prepare_by'] ; ?>
<? echo $r3['emp_1'] ; ?>
<? echo $r3['email'] ; ?>
<? echo $r3['designation'] ; ?>
<?
echo date ("m/d/Y ");
echo date ("g:i a");
?>
<? echo $r3['department'] ; ?>
<? echo $r3['selectmanager']; ?>
<? echo @$r['purpose']; ?>
<? echo $t_id; " ?>
<? echo $r['pay_to']; ?>
<? echo $r['emp_2']; ?>
<? echo $r['ecer']; ?>
<?
$sql2="select * from details where t_id ='$t_id'";
$result2=mysql_query($sql2)or die(mysql_error());
while($r2=mysql_fetch_assoc($result2))
{
?>
<? echo $r2['acc_no']; ?>
<? echo $r2['item']; ?>
<? echo $r2['description']; ?>
<? echo $r2['amount']; ?>
<?
}
?>
<?php
$sql = "select SUM(amount) AS total from details";
$result = mysql_query($sql) or die(mysql_error());
$r = mysql_fetch_array($result);
$total = $r['total'];
echo "$total";
?>
[/php]