Variable help for a newbie?

This is a discussion on "Variable help for a newbie?" within the PHP Forum section. This forum, and the thread "Variable help for a newbie? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 27th, 2006, 12:19
New Member
Join Date: Nov 2006
Location: Southeast
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Variable help for a newbie?

Hi. I'm just starting with PHP and this looks like a good place to ask my question. Thanks in advance!

I have the GD (Graphic Draw) Library working...sort of. It will display the default "PHP Rules" image from a stream, but I need it to use the binary stream from my database, instead.

My code is:

Code: Select all
<?php
header('Content-Type: image/jpeg');
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);
$im = imagecreatefromstring($data);
if($im !== false) imagejpeg($im);
else echo 'An error occurred.';
?>
<?php 
session_start();
$_SESSION['empcode'] = $empcode;
$_SESSION['middle'] = $middle;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['leavehours'] = $leavehours;
?>
<?php
//CONNECTION STATEMENT. Can also be plugged into an .inc file, then just refer to the .inc file.
$conn = mssql_connect("*DATABASE*","*USERNAME*","*PASSWORD*") or die ("Could Not Connect to Database.<br>Please Notify Computer Services.");
mssql_select_db('Database',$conn);
?>
<?php
 
$RESULTDS=mssql_query("SELECT DISTINCT LH.[Employee Number], M2.[HRYRAT], M2.[EMPNO], M2.[MANLAP], M2.[PAYCTR], M2.[MANLAC], M2.[MANLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[NAMEMI], M2.[NAMEL], M2.[NAMEF], EH.[DATE], EH.[ENETPA], LH.[LOCC], EH.[EGRSER], EH.[EREGHR], EH.[EDEDUC], EH.[EROTHR], EH.[EFWHD], EH.[EPEDAT], EH.[ESSDED], EH.[EHOSPD], EH.[ELIFED], EH.[ECRUD], M2.[POSITN], M2.[MCTDWH], M2.[MHDATE], M2.[MCTDCS], M2.[MO3TOT], M2.[MCTDLD], M2.[MCTDGE], M2.[MALPPP], M2.[MSLPPP], M2.[MWHSTA], M2.[MWHALL], M2.[MWHADD], EH.[EGARND], EP.[EMPNO], DP.[EMPNO], EI.[DDEPTN], EI.[NEWOCC], EI.[HRYRAT], EI.[MEMPAD], EI.[MEMPCS], EI.[MEMPZI], view_EmployeeInfo.[EmpPicture]
FROM LEAVHST LH 
JOIN MASTERL2 M2 
ON LH.[Employee Number]=M2.EMPNO JOIN EARNHIST EH
ON EH.[EEMPNO]=M2.EMPNO JOIN EMPPICTURE EP
ON EP.[EMPNO]=EH.EEMPNO JOIN Departments DP
ON DP.[EMPNO]=EP.EMPNO JOIN View_EmployeeInfo EI
ON EI.[EMPNO]=M2.EMPNO
WHERE M2.[EMPNO] = '".$_POST['employeenumber']."' and 
M2.[MSSNO] = '".$_POST['password']."' 
 
ORDER BY EH.[DATE] desc"); 
$RESULT=mssql_fetch_assoc($RESULTDS) or die("<CENTER><img src=\"http://orserva/images/invalidnumber.gif\"></CENTER><BR><CENTER><table width=60 //border=0><tr><td><font size=\"3\" color=\"#000000\" face=\"arial\">Need help? Here is an example entry:</font></td></tr><tr><td align=center><img //src=\"http://orserva/images/leaveexample.gif\"></td></tr><tr><td><font size=\"3\" color=\"#000000\" //face=\"arial\">Enter your Employee Number<BR>Enter your password (Social Security Number)<BR>Click Submit<BR><BR>If you're still having difficulty, click here to </font><font size=\"3\" color=\"#ff0000\" //face=\"arial\"><BR><a href=\"mailto:HelpDesk@cortn.org? subject=Problem with the Pay Stubs On Demand //System\"><b>E-mail the HelpDesk</b></a></font></td></tr></table></CENTER>");
 
?>
I need the $data variable to point to the employee image in the database, BUT.... since the header info has to be at the top of the page, that variable doesn't yet "exist" at the point where the code is run.

The code above is displaying the "PHP Rules" image, so the GD Library works.

Any help is greatly appreciated.


EDIT: The code above is in a file called "showpic.php." I call it by using <img src="showpic.php"> in another file.

Last edited by phpnoob; Nov 27th, 2006 at 12:22. Reason: Addition
Reply With Quote

  #2 (permalink)  
Old Nov 27th, 2006, 16:25
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Variable help for a newbie?

You need to use;

ob_start();

to buffer the output so the header doesn't get sent while you run through the rest of the code.

When everything is set to go, use;

ob_end_flush();

to flush the output buffer and send everything on its way.
Reply With Quote
  #3 (permalink)  
Old Nov 27th, 2006, 20:49
New Member
Join Date: Nov 2006
Location: Southeast
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Variable help for a newbie?

Quote:
Originally Posted by ukgeoff View Post
You need to use;

ob_start();

to buffer the output so the header doesn't get sent while you run through the rest of the code.

When everything is set to go, use;

ob_end_flush();

to flush the output buffer and send everything on its way.
Would you be so kind as to show a moron where these functions go in my code? Sorry, but I'm a PHP newbie.

Thanks!
Reply With Quote
  #4 (permalink)  
Old Nov 27th, 2006, 21:14
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Variable help for a newbie?

Place ob_start(); as the first line of code in your file. Before any other php or html.

When you have processsed the last of your php, place the ob_end_flush(); line there.
Reply With Quote
Reply

Tags
gd library help

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
is this variable right? geyids PHP Forum 4 Aug 6th, 2007 21:45
Undefined variable: row csun PHP Forum 3 Jun 5th, 2007 12:44
Variable problem trylah JavaScript Forum 0 Apr 11th, 2007 08:22
Passing a Variable to ASP Smog36 Flash & Multimedia Forum 1 Sep 13th, 2006 14:05
variable problems... tehrobot Flash & Multimedia Forum 4 Sep 13th, 2006 13:01


All times are GMT. The time now is 11:27.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43