php-general Digest 20 Apr 2002 10:20:54 -0000 Issue 1297

Topics (messages 93756 through 93797):

Re: Image functions
        93756 by: Matthew Gray

header redirection
        93757 by: Norman Zhang
        93758 by: Kevin Stone
        93792 by: Jason Wong

Leading zeros in array index
        93759 by: Kent Briggs
        93760 by: Joshua b. Jore
        93771 by: Kent Briggs

$HTTP_*_VARS ?
        93761 by: Tobias Lindqvist

URL for "Powered by PHP" gif
        93762 by: Todd Cary
        93763 by: Jason Wong

Getting All Variables?
        93764 by: Devin Atencio
        93788 by: Jason Wong

PHP @ 24-hour programming competition
        93765 by: Visontay Peter

Empty $_SESSION and $_POST ??
        93766 by: Andre Dubuc
        93769 by: Miguel Cruz
        93777 by: Andre Dubuc
        93782 by: Andre Dubuc
        93789 by: Jason Wong

multidimensional array
        93767 by: Rodrigo Peres
        93770 by: Miguel Cruz

Out of memory error message
        93768 by: Mullin, Reginald

Re: 3dim Array problem
        93772 by: Hugh Bothwell

redirect browser
        93773 by: Joe
        93790 by: Jason Wong

Re: Variable Inside Variable
        93774 by: Jeff Oien
        93776 by: Miguel Cruz
        93779 by: Jeff Oien
        93781 by: Miguel Cruz

Re: some problems about gd in php
        93775 by: zhaoxd
        93791 by: Jason Wong

Does anyone have auto-signup stopping code? URGENT!
        93778 by: Leif K-Brooks
        93780 by: Miguel Cruz

Re: [PHP-INST] can't view PHP
        93783 by: Andre Dubuc

.phps
        93784 by: Mantas Kriauciunas

Attachments
        93785 by: Jason Soza
        93786 by: Jason Wong
        93797 by: Jason Soza

About socket function
        93787 by: KeithAY

Re: $PHP_SELF question
        93793 by: Justin French

Re: Australian *nix Hosts?
        93794 by: Justin French
        93796 by: The_RadiX

Re: 3dim Array problem ** SOLVED **
        93795 by: heinisch.creaction.de

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
You won't get very far if you aren't outputting an image to the browser
using ImageJpeg(), etc.

Matt

Matthew J Gray
UWRF - Information Technology Services
[EMAIL PROTECTED]

Gerard Samuel wrote:

> Im trying to modify a poll script to not use the hard coded image files
> and use php's image functions.
> On the file that will be outputing the poll graphics, I tried at the top
> of the page ->
> header("Content-type: image/png");
> and
> header("Content-type: image/jpeg");
>
> For some reason, when the page is viewed, the only thing that gets
> output to the browser is the url of the page....
>
> I tried using one of the examples on php.net image create routines and
> its still doing the same thing..
>
> Here is a snip
>
> <?php
>
> /*
>  *  THIS HAS TO GO HERE FOR THE IMAGE BARS
>  */
> header("Content-type: image/jpeg");
>
> $pollID = $HTTP_POST_VARS['pollID'];
> $voteID = $HTTP_POST_VARS['voteID'];
>
> <------snip--------->
>
> If I comment out the header call, Im back to normal...
> Im running PHP 4.1.2 with GD support
> Any thoughts
> Thanks

--- End Message ---
--- Begin Message ---
Hi,

I use header(location: ...) for redirection to another page. But I also want
to include <title>, <meta> and <link> tags in the other page. Is there a way
to this? Because php complains that the header already been sent.

Regards,
Norman


--- End Message ---
--- Begin Message ---
Headers will be created whenever information is outuputted to the browser.
In this case when you include the .html file into your php script the
browser is going to create all the headers it will ever know for that page.
Obviously this does you no good if you want to add headers later.

Ways around this.  You can use output buffering to set headers in non-linear
format.  You could use a Javascript to refresh the page after it loads.  Or
the way I prefer to do it.. just echo a meta refresh tag between the <head>
tags of your html page.  This works with the vast majority of browsers and
you can control the number of seconds before the page redirects.

echo '<head>';
echo '<META HTTP-EQUIV="Refresh" Content="5;
URL=http://www.yourdomain.com";>';
echo '</head>';

Hope this helps,
Kevin

----- Original Message -----
From: "Norman Zhang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 19, 2002 3:07 PM
Subject: [PHP] header redirection


> Hi,
>
> I use header(location: ...) for redirection to another page. But I also
want
> to include <title>, <meta> and <link> tags in the other page. Is there a
way
> to this? Because php complains that the header already been sent.
>
> Regards,
> Norman
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 05:07, Norman Zhang wrote:
> Hi,
>
> I use header(location: ...) for redirection to another page. But I also
> want to include <title>, <meta> and <link> tags in the other page. Is there
> a way to this? Because php complains that the header already been sent.

Show us your code.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Spiritual leadership should remain spiritual leadership and the temporal
power should not become too important in any church.
- Eleanor Roosevelt
*/
--- End Message ---
--- Begin Message ---
My first post here, sorry if this has been covered before:

Why does including a leading zero in an array index cause
problems? For example, the output of this script:

----------------

$x = array("a","b","c","d","e","f","g","h","i","j");

echo $x[0];
echo $x[1];
echo $x[2];
echo $x[3];
echo $x[4];
echo $x[5];
echo $x[6];
echo $x[7];
echo $x[8];
echo $x[9];

echo "<br>";

echo $x[00];
echo $x[01];
echo $x[02];
echo $x[03];
echo $x[04];
echo $x[05];
echo $x[06];
echo $x[07];
echo $x[08];
echo $x[09];

-----------------

returns this result:

abcdefghij
abcdefghaa

The [08] and [09] values are messed up but [00] thru [07] are
ok.

-- 
Kent Briggs, [EMAIL PROTECTED]
Briggs Softworks, http://www.briggsoft.com
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oh it's probably because your numbers are being interpreted as octal.
Either use the array as '00' .. '09' or just 0 .. 9. 00 .. 09 is valid for
00 to 07 but there is no such thing as 08 and 09 in octal.

Joshua b. Jore
http://www.greentechnologist.org

On Fri, 19 Apr 2002, Kent Briggs wrote:

> My first post here, sorry if this has been covered before:
>
> Why does including a leading zero in an array index cause
> problems? For example, the output of this script:
>
> ----------------
>
> $x = array("a","b","c","d","e","f","g","h","i","j");
>
> echo $x[0];
> echo $x[1];
> echo $x[2];
> echo $x[3];
> echo $x[4];
> echo $x[5];
> echo $x[6];
> echo $x[7];
> echo $x[8];
> echo $x[9];
>
> echo "<br>";
>
> echo $x[00];
> echo $x[01];
> echo $x[02];
> echo $x[03];
> echo $x[04];
> echo $x[05];
> echo $x[06];
> echo $x[07];
> echo $x[08];
> echo $x[09];
>
> -----------------
>
> returns this result:
>
> abcdefghij
> abcdefghaa
>
> The [08] and [09] values are messed up but [00] thru [07] are
> ok.
>
> --
> Kent Briggs, [EMAIL PROTECTED]
> Briggs Softworks, http://www.briggsoft.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (OpenBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8wJg3fexLsowstzcRAuB5AKDQHKjsW20dLYEGy1EtCjWVR33rAQCgzKvM
XrOBdgtSSpa0L23Y1jvCB40=
=RJw6
-----END PGP SIGNATURE-----

--- End Message ---
--- Begin Message ---

"Joshua B. Jore" wrote:
> 
> Oh it's probably because your numbers are being interpreted as octal.
> Either use the array as '00' .. '09' or just 0 .. 9. 00 .. 09 is valid for
> 00 to 07 but there is no such thing as 08 and 09 in octal.

Ok, thanks.

-- 
Kent Briggs, [EMAIL PROTECTED]
Briggs Softworks, http://www.briggsoft.com
--- End Message ---
--- Begin Message ---
Hi there.
Hoe come I cant use $HTTP_*_VARS in my script ? I have register_globals
on, track vars is also on and i have made the necessary changes in my
apache config ( the ALLOWOVERRIDE ALL ). My system is Win XP, Apache (
newest ) and newest PHP release.

Thanks.

--- End Message ---
--- Begin Message ---
Can someone provide me with the URL for a gif that I can place on my pages so
that I can give credit to PHP (Apache would be nice too).

Many thanks......

Todd

--
Todd Cary
Ariste Software
2200 D Street Extension
Petaluma, CA 94952
707-773-4523
[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 06:46, Todd Cary wrote:
> Can someone provide me with the URL for a gif that I can place on my pages
> so that I can give credit to PHP (Apache would be nice too).

Presumably you've already looked on www.php.net?

You can get the PHP logo and a "Powered by Zend" logo using phpinfo().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
"No, no, I don't mind being called the smartest man in the world.  I just 
wish 
 it wasn't this one."
-- Adrian Veidt/Ozymandias, WATCHMEN 
*/
--- End Message ---
--- Begin Message ---

Is there an easy way in PHP to have it display to screen all the variables
that
it has in memory? So i can see what variables there is and what they are set
to?

--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 07:23, Devin Atencio wrote:
> Is there an easy way in PHP to have it display to screen all the variables
> that
> it has in memory? So i can see what variables there is and what they are
> set to?

print_r($GLOBALS);

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
There has been an alarming increase in the number of things you know
nothing about.
*/
--- End Message ---
--- Begin Message ---
Hi!

I have quite an unusual problem for you :) There will be a 24-hour
programming competition at our university, where teams of 3 have one
day to solve a complex problem (which will be revealed on the day
of the competition). Teams cannot get help from "outside", so no outward
network / phone communication is available, but you can use anything you
take there with you (any development tools, books, pre-written software
etc.)

The language in which you write the software is up to you, the most
popular choices being C++ and Java - but this year our team are going
to use PHP (and PHP-GTK).

The big question is: will PHP be enough for the whole project, or will
we need something else (like external C/Java modules)?
Last year the task was to write an artificially intelligent soccer game
based on a client-server architecture: there was a server acting like
some kind of game controller (referee) and 2D display screen, while
the automated clients (players) were playing individually according
to the game's rules and some simulated information on what they 'see'
at the time.

It's said that it will be something quite different this year -
but required knowledge includes:
algorithm theory, information and code theory, artificial intelligence,
queuing, databases, client-server architectures, computer networks,
control theory, 2D graphic programming and software ergonomy.
All this in 24 hours - nice, eh? :)

So the question again - are there any parts of all this where you think
PHP will not be enough? (Apart from the graphics, for which we'll use
PHP-GTK). If so, what kind of outside module integration do you
recommend for us?
Also, which PHP sites / resources / code libraries do you think we should
(recursively) download which might help us a lot? (Apart from php.net,
of course.)

We're really interested in your opinions - is this feasible or
are we just plain mad? :)

Thanks,
Peter Visontay
http://prodigycenter.com/cv/


--- End Message ---
--- Begin Message ---
I've switched  "register_globals=off" and "register_argc_argv=off" in php.ini 
to use $_SESSION and/or $_POST. All my code had been written using $var

Unfortunately, I cannot seem to access the arrays in either $_SESSION and 
$_POST. I've set each page to start with <?php session_start(); ob_start(); 
?> since I'm also processing the variables from an input html form. Below 
that, on my first page the " if  (!isset($_SESSION['count'] . . . "

Everything seems to work OK until I try to access, on my last page, 
'confirm-guest.php' which attempts to capture either the session variables or 
the posted variables from the previous two pages. 

Whenever I try:

print("$_SESSION['sfname']);  or  print("$_POST['scity']

I get a parse error "expecting 'T_STRING' . . ." -- obviously there's nothing 
in the array or I haven't set it. Problem is how do you set the "variables", 
as in $_POST['sfname'] -- I thought that it would pick them up automatically 
from the text input.

Btw, I retained these satements (which could be the problem):

$sfname = $_POST['sfname'];

Since when I tried to use $_POST['sfname'] in the scipt I got the same parse 
error as above.

I'm REALLY confused about the whole session thing -- I don't know where else 
to read up on it -- I've scoured PHP.net, Zend, PHPBuilder -- and I've 
followed what they said, but . . .

Can anyone enlighten me on what I'm doing wrong, or where my thinking is 
amiss? I'd greatly appreciate any help.

Tia,
Andre


-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
On Fri, 19 Apr 2002, Andre Dubuc wrote:
> Whenever I try:
> 
> print("$_SESSION['sfname']);  or  print("$_POST['scity']
> 
> I get a parse error "expecting 'T_STRING' . . ." -- obviously there's nothing 
> in the array or I haven't set it.

You just have a simple syntax error.

You can use any of the following:

   print $_SESSION['sfname'];
   print "{$_SESSION['sfname']}";
   print "${_SESSION['sfname']}";

But you can't put a bare array dereference inside a quoted string like you
tried above. You need to surround it with {curly braces} or take it 
outside the quoted string.

miguel

--- End Message ---
--- Begin Message ---
On Friday 19 April 2002 08:13 pm, you wrote:
> On Fri, 19 Apr 2002, Andre Dubuc wrote:
> > Whenever I try:
> >
> > print("$_SESSION['sfname']);  or  print("$_POST['scity']
> >
> > I get a parse error "expecting 'T_STRING' . . ." -- obviously there's
> > nothing in the array or I haven't set it.
>
> You just have a simple syntax error.
>
> You can use any of the following:
>
>    print $_SESSION['sfname'];
>    print "{$_SESSION['sfname']}";
>    print "${_SESSION['sfname']}";
>
> But you can't put a bare array dereference inside a quoted string like you
> tried above. You need to surround it with {curly braces} or take it
> outside the quoted string.
>
> miguel


Hi Miguel,

I tried all three -- none work.  I question whether register_globals is truly 
"off" since, earlier when I changed php.ini it dumped my Postgresql and left 
the phpinfo() unchanged. This time it reported the change, and Postgresql is 
working.

Is there a way I can verify that (a) globals are off and (b) $_SESSION or 
$_POST are on? This probably what's happening -- I can't access the arrays at 
all -- so, I think that might be where the problem lies. The $vars still work 
though throughout all scripts.

Any ideas?

Tia,
Andre

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
I'm running PHP 4.1.2 + Apache 1.3.23 + PostgreSQL 7.2.

I've tried reverting back to globals=on, and same problem. Yet, earlier in 
another script I used $sfname = $_GET['sfname']; to get the value of sfname 
-- now, it won't work. I'm truly stumped -- I don't know whether it's my 
code? [I beginning to think it isn't because of the flakiness of the php.ini 
failing to report changes accurately] 

I've dumped PHP and re-installed it, but the same problem persists.

Now for the big question -- what's wrong with globals=on anyway? Eventually 
the site will be public, and probably the host won't allow globals on, but 
what's the security risk?

You say $_SESSION[] and $_POST[] are always on -- even if globals are on?
Can I verify what all the variables in the array are? Where would I look? By 
the look of things, I've got a major problem -- but I don't know where to 
look.

Help? Please?

Tia,
Andre


On Friday 19 April 2002 10:17 pm, you wrote:
> I accidentally deleted your last message. But with current versions of
> PHP, $_POST, etc., are always on and there's no way to turn them off.
> Which version are you running? (check phpinfo()).
>
> miguel
>
> On Fri, 19 Apr 2002, Miguel Cruz wrote:
> > On Fri, 19 Apr 2002, Andre Dubuc wrote:
> > > Whenever I try:
> > >
> > > print("$_SESSION['sfname']);  or  print("$_POST['scity']
> > >
> > > I get a parse error "expecting 'T_STRING' . . ." -- obviously there's
> > > nothing in the array or I haven't set it.
> >
> > You just have a simple syntax error.
> >
> > You can use any of the following:
> >
> >    print $_SESSION['sfname'];
> >    print "{$_SESSION['sfname']}";
> >    print "${_SESSION['sfname']}";
> >
> > But you can't put a bare array dereference inside a quoted string like
> > you tried above. You need to surround it with {curly braces} or take it
> > outside the quoted string.
> >
> > miguel

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 09:41, Andre Dubuc wrote:

> Is there a way I can verify that (a) globals are off and (b) $_SESSION or
> $_POST are on? This probably what's happening -- I can't access the arrays
> at all -- so, I think that might be where the problem lies. The $vars still
> work though throughout all scripts.

Use:

  print_r($GLOBALS);

to see what variables you have.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Dr. Jekyll had something to Hyde.
*/
--- End Message ---
--- Begin Message ---
Hi list,

In order to avoid many left joins I took an aproach that I didn't know
if it's good, but I couldn't figure out another way. If my cliente has
10 phone numbers I buld an array, serialize it and store in database, so
I didn't have to create another table. The problem is now I need to
migrate the data to this format, how can I select the multiple data and
put in multidimensional array at runtime to store again. for example I
need to put all fileds with graduation and all fields with discipline
with equal id in array named school serialize it and after insert in
another table.

Thank's

Rodrigo


--- End Message ---
--- Begin Message ---
On Fri, 19 Apr 2002, Rodrigo Peres wrote:
> In order to avoid many left joins I took an aproach that I didn't know
> if it's good, but I couldn't figure out another way. If my cliente has
> 10 phone numbers I buld an array, serialize it and store in database, so
> I didn't have to create another table.

What do you have against left joins?

miguel

--- End Message ---
--- Begin Message ---
Hi Guys,

Does anyone know what the following error message is and how I can go about
solving it?

***ERROR MSG***
Out of memory during "large" request for 2147487744 bytes, total sbrk() is
1459608 bytes.

This error message gets written to Apache's error logs every other time I
execute my MSSQL query.  The web browser then displays "The page cannot be
displayed" error (404).

***SAMPLE MSSQL QUERY***
if ($ViewItemNumber){
$ViewItemNumber = urldecode($ViewItemNumber);
$sql = "SELECT
Item.ItemNumber,Item.Description,Item.Type,Item.Comments,Inventory.Site,Inve
ntory.Location,Inventory.ItemNumber,Inventory.SerialNumber,Inventory.Lot,Inv
entory.OnHandQuantity FROM Item,Inventory WHERE
(Item.ItemNumber='$ViewItemNumber' AND
Item.ItemNumber=Inventory.ItemNumber)";
$query = mssql_query($sql) or die ("THE SECOND (2) TABLE SELECTION
FAILED.");
$results = mssql_fetch_array($query);
echo $results['ItemNumber'];
}


Note: I'm running LAMP locally (NY) and connecting remotely to a Windows
2000 box running MS SQL Server 2000 (UK) with the FreeTDS package. 


O      From Now 'Till Then,
\->    Reginald Alex Mullin
/\      212-894-1690



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the postmaster at [EMAIL PROTECTED]


www.sothebys.com
**********************************************************************

--- End Message ---
--- Begin Message ---
>  while( $res=$UDV -> getDbAns()) {    // fetch mains

Just checking:

On success, $UDV->getDbAns() returns array of string;
On fail, it returns false.

>  if(strlen($res[0]) > 2) {     // if result is OK
>     $menarr[$h]=$res[0]; // put them in array

Here is your problem - you set $menarr[$h] to
a string, then later try to set stringval[$s][$h] to
a string.  Unsurprisingly, PHP has no idea how to
treat a string as a 2d array.


>     // get submenues
>     $selchi="select chi from link where pa = '$res[0]'";

Try echoing this string to make sure it is what you think;
might have to be
    ... where pa = '{$res[0]}' ";

>     $UDB ->  talk2DB($selchi);
>     while($chia=$UDB -> getDbAns()) {
>        if(strlen($chia[0]) >3) {     // if result is OK
>           //echo "<b>".$chia[0]."</b><br>";
>           // Youll get a <0x20> separated string
>           $subp=explode(" ",$chia[0]); // explode it, to get single values

>           if(is_array($subp)) { // if there are more than one in it

... the result of explode() is _always_ an array; this
test and the alternate code are unnecessary.

>              $maxs=count($subp); // check out how many
>              for($n=0; $n < $maxs ; $n++) {    // each child in main/sub/n

why not use foreach() ?  not much difference, maybe,
just a bit easier to follow...

>                 // put the value in main/sub/n
> error here  ->   $menarr[$h][$s][$n]=$subp[$n];

as above, $menarr[$h] is a string.


>              }
>           }

>del             else // if there´s only one value
>del             {
>del                 $menarr[$h][$s][0]=$chia[0];
>del             }

>         }// end if sub
>         $s++; // submenues plus one

You never set $s to 0; your submenus are going to be
numbered funny, ie

$menarr[0][0]
$menarr[0][1]
$menarr[0][2]
$menarr[1][3]
$menarr[1][4]
etc

>      }// end while subs
>   }// end if main
>
>   $h++; // mainmenues plus one
> }// end while mainmenues



Here is my reorganized code:

$h = 0;
while ( $res = $UDV->getDbAns() ) {
    if ( strlen($res[0]) <= 2 )
        continue;    // skip invalid results ('--' ?)

    $menarr[$h]['menu'] = $res[0];    // store menu name

    $child_query = "SELECT chi FROM link WHERE pa='{$res[0]}' ";
    $UDB->talk2DB($child_query);

    $s = 0;
    while ( $child = $UDB->getDbAns() ) {
        if ( strlen($child[0]) <= 3 ) {
            continue;

        $subp = explode(" ", $child[0]);
        foreach($subp as $key => $val)
            $menarr[$h][$s][$key] = $val;

        $s++;
    }

    $h++;
}

Hope this helps.

P.S.  ... it seems to me the query-in-query could be
replaced by a single sorted query; the result would
probably be a little faster, but (shrug) save that for later.


--- End Message ---
--- Begin Message ---
I had developed the web-based survey for student.
And I need to check that each only fill in the form once time.
So I write following code to check if the student number
exist in the database or not.
if yes, don't let them to fill in again.
if no, redirect the browser to the page for them to fill in.

=====================

<?php

 @ $db = mysql_pconnect("localhost", "survey", "survey");

 if (!$db)
 {
  echo "Error: Could not connect to database.";
  exit;
 }

 mysql_select_db("survey");
 $query = mysql_query("select * from surveydb where studno = '$studno'");
 $result = mysql_num_rows($query);

 if ($result>=1)
 {
  echo "Student Number $studno already existed in the database.<br><br>"
  ."You don't need to input again!";
 }
 else
 {
  header("Location: http://www.XXX.edu/index.php";);
  exit;
 }
?>

=====================

the code can check the student no. are exist in database or not
but the browser don't redirect to the page if student not exist
in database and display the following error code:

====================
Warning: Cannot add header information - headers already sent
by (output started at c:\html\html\check.php:4) in
c:\html\html\check.php on line 42
====================

I had no idea about this.
Can anyone tell me what's wrong of my code?

Thx!

Joe



--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 09:26, Joe wrote:


> =====================
>
> <?php



> ====================
> Warning: Cannot add header information - headers already sent
> by (output started at c:\html\html\check.php:4) in
> c:\html\html\check.php on line 42
> ====================
>
> I had no idea about this.
> Can anyone tell me what's wrong of my code?

You cannot have anything between the beginning of the file and your <?php 
tag. Not even whitespace (spaces, tabs, newlines etc).


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
A real person has two reasons for doing anything ... a good reason and
the real reason.
*/
--- End Message ---
--- Begin Message ---
> On Friday 19 April 2002 09:31, Jeff Oien wrote:
> > I have a script which retrieves the body of an email message from
> > a MySQL database to be sent to someone who applies using a form.
> > The script contains this:
> >
> > $url = "<a
> > href=\"http://$HTTP_HOST$SCRIPT_NAME\";>http://$HTTP_HOST$SCRIPT_NAME</a>";
> > $url = addslashes("$url");
> >
> > $msg1 .= "$body"; //to be sent via mail()
> >
> > Then within the body of the message I want $url to show up.
> > The body of the message in the database looks like this:
> > -----------
> > You are receiving this exclusive message to confirm your
> > application through $url.
> > -----------
> > I've tried everything I can think of with $url, curly brackets, backslashes
> > etc. What am I missing? Thanks.
> 
> Use eval().

I have $url (literally) embedded in some text in the database that is to be 
sent as an email message. I'm using this and $url disappears with a blank
spot in the text:
eval("\$body = \"$body\";");
I've tried variations and can't get it to work. Any help? Thanks.
Jeff Oien
--- End Message ---
--- Begin Message ---
On Fri, 19 Apr 2002, Jeff Oien wrote:
>> Use eval().
> 
> I have $url (literally) embedded in some text in the database that is to be 
> sent as an email message. I'm using this and $url disappears with a blank
> spot in the text:
> eval("\$body = \"$body\";");
> I've tried variations and can't get it to work. Any help? Thanks.

While you could do something like:

  $body = eval("return \"{$body}\";");

...the huge, monstrous, gigantic problem is that if you allow anyone to 
edit any part of $body or any string that goes into it, you are basically 
handing them control of your server, because they can get eval() to 
execute any code they want.

Far better would be to put a placeholder in $body like @@@ and then just 
do $body = ereg_replace('@@@', $url, $body);

miguel

--- End Message ---
--- Begin Message ---
> On Fri, 19 Apr 2002, Jeff Oien wrote:
> >> Use eval().
> > 
> > I have $url (literally) embedded in some text in the database that is to be 
> > sent as an email message. I'm using this and $url disappears with a blank
> > spot in the text:
> > eval("\$body = \"$body\";");
> > I've tried variations and can't get it to work. Any help? Thanks.
> 
> While you could do something like:
> 
>   $body = eval("return \"{$body}\";");
> 
> ...the huge, monstrous, gigantic problem is that if you allow anyone to 
> edit any part of $body or any string that goes into it, you are basically 
> handing them control of your server, because they can get eval() to 
> execute any code they want.
> 
> Far better would be to put a placeholder in $body like @@@ and then just 
> do $body = ereg_replace('@@@', $url, $body);
> 
> miguel

That's giving me a blank also. The form for changing the email is in a 
password protected area where only two people are allowed. But I'll
implement the more secure version when I can get it to work. Thanks
for the help.
Jeff Oien 
--- End Message ---
--- Begin Message ---
On Fri, 19 Apr 2002, Jeff Oien wrote:
>> Far better would be to put a placeholder in $body like @@@ and then just 
>> do $body = ereg_replace('@@@', $url, $body);
> 
> That's giving me a blank also. The form for changing the email is in a 
> password protected area where only two people are allowed. But I'll
> implement the more secure version when I can get it to work. Thanks
> for the help.

If that's giving you a blank then something else is wrong in your code.  
This definitely does work:
 
   $body = "Hello, and thank you. Please visit the site @@@.";
   $url = "http://boogers.on.toast/";;
   $body = ereg_replace('@@@', $url, $body);

Start from the simplest case, verify that it works, and then work out to
include all the other funky stuff you've got going on.

miguel

--- End Message ---
--- Begin Message ---

Yeah,I have already restarted web server and there was no error in compiling during 
configure/make/install .Using gd,I get the information that concern about GD Support 
,GD version,WBMP Support ,etc.as follow:

GD Support -------------------------------------------enabled
GD Version--------------------------------------------1.6.2 or higher
WBMP Support---------------------------------------enabled

the environment variable of  LS_COLORS is 
"no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:"


By the way,my OS is linux 7.2;kernel is 2.4.17.Before I compiled gd-1.8.4 , I 
configure/make/make install libpng-1.2.0&zlib-1.1.4&jpeg-6b without any arguments such 
as --prefix and others.Is this right?During the process,there was no error reported.Is 
my test code right?
              
Thank you
                                                        zhaoxd
> On Friday 19 April 2002 18:57, zhaoxd wrote:
> > The version of php is php-4.1.2,the latest version,apache-1.3.24,also
> > latest.
>  
> > I have installed gd-1.8.4 in apache server without any problems.To check if
> > the gd can work,I write some codes in php like this:
>  <?
> 
> [snip]
> 
> > Is this a compiling problem?The compiling command of php is:
> 
> > 
> 
> > ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.24
> > --enable-track-vars --with-gd=../gd-1.8.4 --with-png-dir=../libpng
> > --with-zlib-dir=../zlib
>  
> 
> 1) If this was a recompile:
>  a) Presumably there were no errors during configure/make/install?
>  b) Did you restart the webserver? 
> 
> 2) What do you get using phpinfo()?

--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 09:36, zhaoxd wrote:
> Yeah,I have already restarted web server and there was no error in
> compiling during configure/make/install .Using gd,I get the information
> that concern about GD Support ,GD version,WBMP Support ,etc.as follow:
 
> GD Support -------------------------------------------enabled
> GD Version--------------------------------------------1.6.2 or higher
> WBMP Support---------------------------------------enabled

If it was a recompile, try to do a clean installation. Remove the directory 
containing your existing php src, untar your tarball, then 
configure/make/install.

> > > ./configure --with-mysql=/usr/local/mysql
> > > --with-apache=../apache_1.3.24
 --enable-track-vars
> > > --with-gd=../gd-1.8.4 --with-png-dir=../libpng --with-zlib-dir=../zlib

Also, what is inside these directories?

../gd-1.8.4
../libpng
../zlib

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Physician:  One upon whom we set our hopes when ill and our dogs when well.
-- Ambrose Bierce
*/
--- End Message ---
--- Begin Message ---
I have a website where people can signup.  Some jerk just made a program
that cheats by signing up automaticly and transfering what he gets when he
starts (you can get virtual money in my game).  Does anyone have code to
stop automatic signups?  I would write it, but he's about to distribute his
program, which would create quite q mess and unbalance the game.  Thanks if
you can help! 
--- End Message ---
--- Begin Message ---
On Fri, 19 Apr 2002, Leif K-Brooks wrote:
> I have a website where people can signup.  Some jerk just made a program
> that cheats by signing up automaticly and transfering what he gets when
> he starts (you can get virtual money in my game).  Does anyone have code
> to stop automatic signups?  I would write it, but he's about to
> distribute his program, which would create quite q mess and unbalance
> the game.  Thanks if you can help!

To defeat a program you need to come up with something that only a person 
can do. 

One idea would be to generate a 3-digit number and use GD to display it as
a GIF. Randomly vary the offset and colors so he can't just hash out all
the possibilities. Display the GIF image, and require that the user look
at it and enter that number in order to have their registration processed.

This works because people's brains are very good at pattern recognition 
but computers are awful at it.

miguel

--- End Message ---
--- Begin Message ---
Hi Joey,

Don't know whetehr I can help, but I ran into the same problem with my Linux 
box. In Mozilla et al, I had to change in "Preferences > Advanced > Proxies > 
Manual Proxy Config >> No proxy for: Localhost".

I haven't followed your thead, and I'm no familair with networking, butthta 
might steer you in a new direction. It worked for me while I'm protyping my 
site.

Hth,
Andre


On Friday 19 April 2002 11:31 pm, you wrote:
> yes i've tried that too *sigh* :( i've read the manual over and over again
> and installed it a few times and added all those lines ppl suggested but
> still no luck. I'm about to just give up. I know how to work PHP but I just
> can't find where this problem comes from. Maybe it's a windows thingy who
> knows, maybe i need IIS on my system which of course doesn't come with Win
> XP Home Edition. I read something about webpage in management tools in
> Windows but i don't have that so i can't change things there.  I really do
> appreciate all your reactions and replies.
>
>
> "Christoph görgen" <[EMAIL PROTECTED]> wrote in message
> news:003101c1e77e$c3ca5fc0$0e00000a@AGENTUR...
>
> > > Everytime i try to view a php file on my server it prompts me to
>
> download
>
> > > the file then opens it up in word pad. I can view any other file just
>
> not
>
> > > php.
> > >
> > > Can anyone help me with this problem please?
> >
> > Already tried to insert these lines into your httpd.conf ... ?
> > #if you use php3#
> > AddType application/x-httpd-php3 .php3
> > #if u use php4:#
> > AddType application/x-httpd-php3 .php4 .php
> >
> > that should solve your problem after having restarted the webserver
> > good luck
> > chris

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
Hey [EMAIL PROTECTED],

 as i understand files .phps should view code nice and in colors...
 but when i set up everything good in http.conf and (as i think)
 everything is perfect.... it wants me to download that .phps
 file...what can be wrong? im using PHPTriad on win2k

 thank you

:------------------------------:
        Have A Nice Day! 
 Mantas Kriauciunas A.k.A mNTKz

Contacts:
[EMAIL PROTECTED]
Http://mntkz-hata.visiems.lt

--- End Message ---
--- Begin Message ---
I apologize in advance, this question most likely doesn't belong here, but
if anyone can help that'd be great:

Using both Perl and PHP to send mail with attachments from forms, the
attachments get truncated. Since both Perl scripts and PHP scripts do this,
I'm ruling out coding error, and since my mailserver has been receiving
e-mails from other sources and has transmitted the whole attachments from
them, I'm ruling it out too. Does anyone know if Apache has some sort of
limitation on attachments? Is there a setting for this in httpd.conf? I
don't have any .htaccess files laying around, just httpd.conf and virtual
hosts. Is there like a max_file_size thing I need to mess with?

Again, I apologize for the off-topic nature of this, just looking for some
help.

Thanks,
Jason

--- End Message ---
--- Begin Message ---
On Saturday 20 April 2002 12:29, Jason Soza wrote:

> Using both Perl and PHP to send mail with attachments from forms, the
> attachments get truncated. Since both Perl scripts and PHP scripts do this,
> I'm ruling out coding error, and since my mailserver has been receiving
> e-mails from other sources and has transmitted the whole attachments from
> them, I'm ruling it out too. Does anyone know if Apache has some sort of
> limitation on attachments? Is there a setting for this in httpd.conf? I
> don't have any .htaccess files laying around, just httpd.conf and virtual
> hosts. Is there like a max_file_size thing I need to mess with?

If you're using GET in your form(s) change it to POST.

Also, please do not reply to an existing thread and change the subject. This 
messes up the threading for those of us who use an intelligent mail client. 
Start your own thread.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
QOTD:
        If it's too loud, you're too old.
*/
--- End Message ---
--- Begin Message ---
Sorry for the thread thing, I wasn't aware I was causing probs. I usually
just use "Reply" to save having to enter the e-mail address, just laziness.
I'll keep from doing in this in the future, thanks for letting me know.

I'm using 'POST' in my forms - any other ideas or places I could check?
Thanks again.

Jason

-----Original Message-----
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 8:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Attachments


On Saturday 20 April 2002 12:29, Jason Soza wrote:

> Using both Perl and PHP to send mail with attachments from forms, the
> attachments get truncated. Since both Perl scripts and PHP scripts do
this,
> I'm ruling out coding error, and since my mailserver has been receiving
> e-mails from other sources and has transmitted the whole attachments from
> them, I'm ruling it out too. Does anyone know if Apache has some sort of
> limitation on attachments? Is there a setting for this in httpd.conf? I
> don't have any .htaccess files laying around, just httpd.conf and virtual
> hosts. Is there like a max_file_size thing I need to mess with?

If you're using GET in your form(s) change it to POST.

Also, please do not reply to an existing thread and change the subject. This
messes up the threading for those of us who use an intelligent mail client.
Start your own thread.

--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
QOTD:
        If it's too loud, you're too old.
*/

--- End Message ---
--- Begin Message ---
Hi all,

I got a problem when I using socket function in PHP.
After I use fsockopen() to open socket, I send a msg
using fwrite() and receive a msg using fread(), this work fine. However, I
use fwrite() again to send a msg and use
fread() to receive a response msg, it failed.
The sequence of function call is :
fsockopen -> fwrite -> fread -> fwrite -> fread then fail
Why this happen? any method to solve it?
Thx all your kindly help!!!

Regards,
Keith AY



--- End Message ---
--- Begin Message ---
Spend a bit of time reading up on predefined variables (like $PHP_SELF) in
the manual:

http://www.php.net/manual/fi/reserved.variables.php

I believe you're after SCRIPT_NAME, but it's worth familiarising yourself
with them all for future reference.


Justin French
--------------------
Creative Director
http://Indent.com.au
--------------------




on 18/04/02 11:48 PM, Brinkman, Theodore
([EMAIL PROTECTED]) wrote:

> I've got an include file that provides the basic framework for every page on
> my site, and at the bottom of each page, I want to spit out when the page
> was last updated.  I used $PHP_SELF inside the include file, and got the
> include file's path.  Is there a variable equivalent to $PHP_SELF that
> returns the path for the file that is being executed?
> 
> Basically, if I'm running index.php, and I include template.php is there any
> way, from inside template.php, to get index.php short of passing it as a
> parameter?
> 
> - Theo

--- End Message ---
--- Begin Message ---
Hi,

I stopped searching in Australia and looked over to the US, and am pretty
happy with experthost.com (2GB/50meg/20POP starting at US$15/m)... since
signing up, I changed over to a reseller account to run multiple domains for
clients, and am now paying around US$6.25/m per domain.

I know that additional bandwidth is available too.


The problem is that AU bandwidth is waaaay expensive.  A comparable plan to
the above on a reliable, customer service drive ISP in AU is more like
AU$50-150/month, and as you know, getting up near 5gb puts the price through
the roof.

Bandwidth is the US is soooo much cheaper.  Unless you have a specificly
focused group of Australian users, and are server a lot of large files, or
stuff that requires really short ping times (like gaming?), I'd recommend
looking overseas...  just ensure they have 24/7 support, otherwise you'll
have email/support delays and 3am phone calls :)


Justin French
--------------------
Creative Director
http://Indent.com.au
--------------------



on 15/04/02 11:31 PM, The_RadiX ([EMAIL PROTECTED]) wrote:

> Hi yes I have already read the posts about the hosting questions
> 
> 
> But as I am in Australia I'd like to know if anyone here has had any dealings
> with a good Australian host and any recommendations..
> 
> 
> 
> 
> Thanks a heap..
> 
> 
> P.S. I see what spec's US and EU guys have on the sites and from the months I
> have hunted around AUS I found that it's pretty exp. just to get like 5gb a
> month downloads is around AUD$300p/m which is kinda pricey for me..
> 
> 
> 
> 
> Thanks again..
> 
> 
> 
> 
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> Julien Bonastre [The-Spectrum.org CEO]
> A.K.A. The_RadiX
> [EMAIL PROTECTED]
> ABN: 64 235 749 494
> Mobile: 0407 122 268
> QUT Student #: 04475739
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> 
> 
> 
> 

--- End Message ---
--- Begin Message ---
Thanks a heap guys and Justin for your support..


Yeah I am heavily interested in www.powweb.com anybody know if they're any
good??

They have really 1337 service it seems and give me 12GB p/m and 200mb for
only USD$7.77 ...

w00t.. w00t!



Anybody here use them? any exp. with them??


Thanks a heap...


:::::::::::::::::::::::::::::::::::::::::::
:  Julien Bonastre [The-Spectrum.org CEO]
:  A.K.A. The_RadiX
:  [EMAIL PROTECTED]
:  ABN: 64 235 749 494
:  QUT Student :: 04475739
:::::::::::::::::::::::::::::::::::::::::::


----- Original Message -----
From: "Justin French" <[EMAIL PROTECTED]>
To: "The_RadiX" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, April 20, 2002 3:31 PM
Subject: Re: [PHP] Australian *nix Hosts?


> Hi,
>
> I stopped searching in Australia and looked over to the US, and am pretty
> happy with experthost.com (2GB/50meg/20POP starting at US$15/m)... since
> signing up, I changed over to a reseller account to run multiple domains
for
> clients, and am now paying around US$6.25/m per domain.
>
> I know that additional bandwidth is available too.
>
>
> The problem is that AU bandwidth is waaaay expensive.  A comparable plan
to
> the above on a reliable, customer service drive ISP in AU is more like
> AU$50-150/month, and as you know, getting up near 5gb puts the price
through
> the roof.
>
> Bandwidth is the US is soooo much cheaper.  Unless you have a specificly
> focused group of Australian users, and are server a lot of large files, or
> stuff that requires really short ping times (like gaming?), I'd recommend
> looking overseas...  just ensure they have 24/7 support, otherwise you'll
> have email/support delays and 3am phone calls :)
>
>
> Justin French
> --------------------
> Creative Director
> http://Indent.com.au
> --------------------
>
>
>
> on 15/04/02 11:31 PM, The_RadiX ([EMAIL PROTECTED]) wrote:
>
> > Hi yes I have already read the posts about the hosting questions
> >
> >
> > But as I am in Australia I'd like to know if anyone here has had any
dealings
> > with a good Australian host and any recommendations..
> >
> >
> >
> >
> > Thanks a heap..
> >
> >
> > P.S. I see what spec's US and EU guys have on the sites and from the
months I
> > have hunted around AUS I found that it's pretty exp. just to get like
5gb a
> > month downloads is around AUD$300p/m which is kinda pricey for me..
> >
> >
> >
> >
> > Thanks again..
> >
> >
> >
> >
> > :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> > Julien Bonastre [The-Spectrum.org CEO]
> > A.K.A. The_RadiX
> > [EMAIL PROTECTED]
> > ABN: 64 235 749 494
> > Mobile: 0407 122 268
> > QUT Student #: 04475739
> > :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> >
> >
> >
> >
>

--- End Message ---
--- Begin Message ---
I was too tired, but a coffee and a c* and everything woks fine :)
Just forgot to init the array correctly !
At 19.04.2002  15:24, you wrote:
>
>Hi Folks,
>I have a problem assigning an 3dim array, maybe I´m to tired today to see the
>mistake, but PHP thinks, that it finds "Illegal string index" at the 
>marked line.
>could someone verify this, maybe find my mistake??
>FYI getDbAns(), talk2DB are substitutions for DB - related routines, and the
>produce the correct data.
>Sorry for the "overcommented" code, but I have syntax highlighting.
>TIA Oliver
>
>while( $res=$UDV -> getDbAns()) // fetch mains
>{
>     if(strlen($res[0]) > 2) // if result is OK
>     {
>        $menarr[$h]=$res[0]; // put them in array

should be $menarr[$h][0][0]=$res[0];

>        // get submenues
>        $selchi="select chi from link where pa = '$res[0]'";
>        $UDB ->  talk2DB($selchi);
>        while($chia=$UDB -> getDbAns())
>        {
>           if(strlen($chia[0]) >3) // if result is OK
>           {
>              //echo "<b>".$chia[0]."</b><br>";
>              // Youll get a <0x20> separated string
>              $subp=explode(" ",$chia[0]); // explode it, to get single values
>              if(is_array($subp)) // if there are more than one in it
>              {
>                 $maxs=count($subp); // check out how many
>                 for($n=0; $n < $maxs ; $n++)// each child in main/sub/n
>                 {
>                    // put the value in main/sub/n
>error here  ->   $menarr[$h][$s][$n]=$subp[$n];
>                 }
>              }
>              else // if there´s only one value
>              {
>                  $menarr[$h][$s][0]=$chia[0];
>              }
>           }// end if sub
>           $s++; // submenues plus one
>
>        }// end while subs
>     }// end if main
>
>     $h++; // mainmenues plus one
>}// end while mainmenues
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---

Reply via email to