no display


#1

hi…i have problem to view in report page…where all my data not displayed…please help me…i use the same coding anothe page to display data…it work fine…but giving problem in report page…here i attach my coding…

[php]

<?php include "db1.php"; session_start(); $t_id=$_REQUEST['t_id']; ?> Untitled Document
E-Payment Voucher TRANSACTION CODE:<? echo $t_id ; ?>

SMT Technologies SDN BHD.(279566-x)

<? $sql3="select * from voucher where t_id='$t_id'"; $result3=mysql_query($sql3)or die(mysql_error()); @$r3=mysql_fetch_assoc($result3);

?>

Prepared By <? echo $r3['prepare_by'] ; ?> Emp No <? echo $r3['emp_1'] ; ?>
E-mail Address <? echo $r3['email'] ; ?> Designation <? echo $r3['designation'] ; ?>
Date/Time <?php echo date ("m/d/Y ");echo date ("g:i a")?> Dept <? echo $r3['department'] ; ?>
Sect Manager <? echo $r3['selectmanager']; ?>

Voucher Details


Purpose
<? echo @$r['purpose']; ?>

Pay to
Employee No
ECER



ACCOUNT NO:
ITEM
DESCRIPTION
AMOUNT (RM)
 
<? ##################################################### ?> <? $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']; ?>

Total Amount:
RM <?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"; ?>

Attachment

Remark:


 

[/php] sumone please help me...realy blur

#2

I believe this has been pointed out to you more than once, but:

  • I still see you using @ for various kinds of statements - take them out
  • Give us some insight in what doesn’t work, or which errors you’re getting.
  • use the following code:
    [php]error_reporting(E_ALL);[/php]

Again, you can’t just dump your script here and ask for us to fix it. It’s not our script.


#3

Notice: Undefined index: t_id in c:program fileseasyphp1-7wwwsmttprint_preview.php on line 4…


Notice: Undefined variable: r in c:program fileseasyphp1-7wwwsmttprint_preview.php on line 79


this is wht happen when took out the @…


#4

That’s because the @ suppresses the errors. This can be advantageous but not while you are debugging problem code.

In the case of the first error (on line 4) this is not a show stopper but you should resolve it. You can do this by checking to see if the variable is set using the (ironically enough) isset() ( http://php.net/isset) function. If it’s not you can initialize it as appropriate.

The same goes with the second error. It has not been defined (or initialized). Again, not a show stopper.

If these 2 pieces of data are what’s missing… Then you need to look at how you are passing it. If not, then I think we need more info.


#5

They’re not showstoppers as in: the script won’t mind. The results however, will mind. Besides that, they may just be notices, but could become serious security holes. It’s always good to develop/debug with error_reporting(E_ALL); I’m using error_reporting(E_ALL | E_STRICT); to make sure EVERYTHING’s okay.

Besides that, you might wanna fix your PHP opening and closing tags (these: <?php and ?>), as I seem to be missing some (and find them appearing in other places).


#6

Absolutely… I agree. Good coding would resolve even the notices.

I didn’t look that close at the script based on the type of question and length of post. As I look back, it seems to me that there is a LOT of incorrect usage of the opening and closing tags.

EDIT: In all fairness… I did go back and RE-Look at the code (in EDIT mode) and the closing tags are their where they should be. It’s an apparent unfortunate side effect of the [php] tags. But I don’t know why.


#7

Crap, you’re right :-? Apologies for that one.
I guess it’s time to revise the [php] tags on the backend eh?


#8

Is this a script that you have written?


#9

when i try error_reporting(E_ALL | E_STRICT);…i get this error…

Notice: Use of undefined constant E_STRICT - assumed 'E_STRICT' in c:program fileseasyphp1-7wwwsmttprint_preview.php on line 6...

#10

i tried so many ways…i just not understand why the data not display…let me explain…in aftersave.php page…the data will be display…so when i click print preview button it will open new page with print preview…it called…print_preview.php…the coding is same…why the data displaye in aftersave.php page but not in print_preview.php…realy blurrrrrrr


#11
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 :wink:

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 :wink:

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 :wink:

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 :wink:

[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]

#12
[php]if (isset($_POST['t_id'])) { $t_id = $_POST['t_id']; } else { $t_id = ""; }[/php]
it doesnt help me....when i edit the code...all my data not stored in my databse....

#13

Well, I see three SELECT queries, and no UPDATE or INSERT queries. So naturally nothing is being saved.


#14

actually i make it zypora…the data displayed very well and i use @ to solve the undefined…but after i make changes with your advice i change [php]$t_id=$_REQUEST[‘t_id’];[/php] to [php]if (isset($_POST[‘t_id’])) { $t_id = $_POST[‘t_id’]; } else { $t_id = “”; }[/php]…all my data not displayed…actually this is the first project i do in php…what should i do now…please advice…thanks


#15

here i submit full coding
[php]

<?php ini_set('log_errors', 'Off'); ini_set('display_errors', 'On'); error_reporting(E_ALL); ?> <?php session_start(); error_reporting(E_ALL); include "db1.php"; if(isset($_REQUEST['t_id'])) { $t_id = $_REQUEST['t_id']; } else { $t_id = ""; } ?> Untitled Document h3 {background-color:#C0F5FA} .style9 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; } .style11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }

 

Manager Approval

 

<? $sql4="select * from voucher where t_id='$t_id'"; $result4=mysql_query($sql4)or die(mysql_error()); $r4=mysql_fetch_assoc($result4); ?>
Prepare by Transaction Code
<? echo $r4['prepare_by'];?>
<?php echo $t_id;?> Print Preview
[/php] thanks in advanced

#16

No it doesn’t. It hides it. Hiding is not the same as solving.

So we know that the problem is somewhere in that line. Have you tried echoing the value of $t_id after assigning it? That way you can see just what’s in there, and possible figure out what’s wrong. See also Debugging in the Tutorials section. It’ll help you get rid of issues like these.