Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Can Constants Be Used Inside Header()?


i have something similar to this:

<?php
header("Location: http://mysite.com/destination.php");
?>

i would like to replace "mysite.com/destination.php" with a constant.

for example, with a constant DESTINATION defined as
"mysite.com/destination.php".




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Header() Inside Apache SSI
I'm having trouble getting the header() call to work inside an Apache SSI. Basically I'm trying to do some user authentication. I have a login page where users enter id and password. It then directs to a PHP script to lookup the id and password in a MySQL db. If login info is correct, the script sets some PHP session vars.

Then in the page that needs authentication, which uses a SSI header page, I have php code that checks to see if the user has logged in by checking the existence of a session var. If so, the page keeps going, if not, I want to redirect them back to the login page automatically by calling header().

This setup works fine on my Redhat linux box running Apache 2.0 and PHP 4.2.2. Once I move it to another server which is running Apache 1.3.26 and PHP 4.2.2 on FreeBSD, the header() call doesn't work anymore. The session vars seem to all work fine, except the header call. When I try to call header in a pure PHP script that's not part of a SSI, the call also works fine. See below for my sample script: Code:

Php Constants In Php.ini
I am trying to set user_agent = PHP_VERSION in php.ini. In my php.ini
the instructions say that you can use constants in the php.ini file.
The only constants I can get to work, though, are the error level
constants like E_ALL, E_ERROR, E_WARNING, etc., ...

Is anyone aware of some sort of trick to getting others to work?

(I was thinking it would be nice to have the user agent string used by
my Php scripts to use PHP_VERSION in the string.)

--

List Constants
A little embarrassing but: is there any easy way to echo (the name and
value of ) all defined constants?

Constants Or Variables
I am translating an existing script into another human language. I am
putting all human language stuff in one file.

At the moment I use constants in the following way:

<?php
define("LNG_Changes_saved_OK", "Changes saved OK");
define("LNG_Delete_Are_you_sure", "Delete: Are you sure???");
?>

It is not too late yet to change to variables (array of strings) like this:

<?php
$lng["Changes_saved_OK"]="Changes saved OK";
$lng["Delete_Are_you_sure"]="Delete: Are you sure???";
?>

What is better and why? Are there alternative ways of doing this and why
would they be better? Please consider in your answer things like server
load, memory usage and speed etc.

Getting Apache Constants With PHP
I'm working on implementing a secure cookie protocol I've been reading
about, but I've run into a problem. I was hoping some smarter people
than myself here could help me. I need to access an apache constant
(set when using mod_ssl) through PHP, or Perl (but I'd have to get it
back into PHP). Does anyone know how to do this?

I was wondering if you could do something like set a PHP variable from
Apache. It looks like they are doing something like that
http://us3.php.net/configuration.changes when they are setting php
initiation values. That means they talk at least one way, I was hoping
there was a way to send more information. If anyone has any ideas it
would be greatly appreciated, I figure there should be a way to, but I
am not sure exactly how you'd do it.

Constants Vs Variables...
Recently I decided to make a login script for my site using PHP and MySQL, after some reading/talking I came to the conclusion that constants are more secure.  It is going pretty good, there have been some rough spots, mostly because of the lack of variables. Code:

Use Of Constants Or Session Vars
Does anyone see a problem with using defined constants as opposed to $_SESSION vars for holding data like a users id, name, email, etc.. Basically when a user logs in, I register their relevant info in session vars and use them throughout the app to be used in queires. so theres a lot of PHP Code:

Mcrypt And Predefined Constants
Has anyone here worked with mcrypt? I'm having trouble getting
predicable results.

Example if I use 3DES and MCRYPT_MODE_ECB I cannot encrypt "157058"
and then decrypt it and get the same thing. The 8 is obscured as
someother character.

Example if I use 3DES and MCRYPT_MODE_NFO I cannot encrypt
"poiuy789" and then decrypt it and get the same thing. The 789 is
obscured as other characters.

My key and connect string are both 16 character.

Any Ideas. I am trying to create a login that encrypts the id and PW
in a cookie so I can decryp and compare it to a record entry. The
client wants the PW in plain text in the DB.

Use Of Constants In An Interpreter Environment
what's the use of having constants in an interpreted language like
php, when there's no compile cycle?

Other than enforcing programmer discipline or affording a convinience
for the programmers, I don't see any.

Define()ing Constants Vs Global Variables
I'd like to open a discussion regarding define()ing constants for use throughout a script, or simply declaring global variables. I'd like to know who uses what and why, and what you think the advantages / disadvantages of either are. Example PHP Code:

Defining Site-wide Variables/constants
I'm relatively new to PHP, and have just converted a site from ASP to
PHP. There is one thing I haven't managed to do, though.

When the site was using ASP, I had one file (called variables.asp),
where I defined various variables that are used throughout the site. I
could then access all of these in any other file by simply including
that file (using #include), then referencing the variables.

I have been unable to do the same thing in PHP. I have been reading the
PHP manual and searching Google, and it seems that perhaps it would be
better done with constants (the values don't ever need to be changed by
the script, just printed to the screen), but I am still unable to get it
to work.

Is this even possible, and if so, what am I doing wrong?

Header Error Without Whitespace Issue - Cannot Modify Header Information
Error = WARNING: Cannot modify header information - headers already sent by (output started at /home/zoneof5/public_html/inde x-dev.html:10) in line 1528 of file common.inc.php

Which comes from me trying to take a login script and put it into an
existing .html file with .htaccess configured to parse php scripts....

Problem Setting A Received Header Using Header ()
I am reposting this as it wasn't very clear last time - and i still haven't made any progress with the code...

i am sending a header(1) to page.html from sender.php using a socket connection. I would then like to read that page's response, and set that response as a header for sender.php (header2- parsed from the response of page.html in order to set any cookies etc.... that page.html might want to set)

Whilst i have no trouble sending header(1) and retrieving the response, I don't seem to be able to set header(2) as a new header for sender.php or for any other page- I get a message from IE saying "the requested header has not been found on this site".
Right now I am using the header () to set that header, as in the following code:

Send Header Info To A Page, Retrieve Response And Send That As Header
I am sending a header to page.html from sender.php using fgets(). I am then trying to retrieve that page's response, and set that as a header in sender.php in order to set any cookies etc.... that page.html might want to set. Right now I am using the following code:

Php Inside Php
i'm trying to write table rows in php, the table works fine, i have a problem when i try to insert more php inside the table, you'll see below i have an IF statement in one of the table rows, this doesn't work PHP Code:

Calling Cgi As SSI Inside PHP??
Hello, i wanted to know if it is possible to execute perl scripts from inside PHP-scripted pages...

i have tried adding php to the SSI section of my apache server config file... SSI will work fine once i do that... however that will prevent any of the PHP from functioning inside the page.

Is there any way i can go about having both execute, and work in the same file?

Currently the page has around 2 small PHP scripts, and a cgi poll with the SSI inserted in it. I have tried changing to a PHP include, but that only works for PHP produced files... can i include a cgi file from PHP in a different format, and have it execute?

Php Inside Html Or Html Inside Php
To have a big (complete file) php tag and print the html code, or to have a html file and just insert php code when necesary ?
I would like to know this from the programming point of view and from the performance.

For example, I have big and complicated tables that I would like to write in plain html and insert some php variables, so, I'll had to open a tag, print a variable and close it a lot of time.
If there's is any other thing that I didn't mention about this, please tell me.

Inside Anchors
I am working on a website for a Hotel and on the first page we have a
flash movie that shows the latest news items. The news items are
retrieved from the database and shown in the movie.
The news items do all have a summary and some of them can have a more
detailed text.

If there is detailed text available I want to open the detailed text of
the news item, after clicking the item in the flash movie. This is
working without problems.

But if there is no detailed text I want to jump to the list with news
items and then jump to that specific news item with the anchor.

An example url for linking to the news-item is:

http://www.example.com/index2.php?p...3&language=NL#3
(note: the target of this link = "_top")

index2.php is the frameset containing a header, a left navigation and
content frame. All parameters in this URL are passed on into the file
which is loaded in the content frame.

news is the news.php file which is included into the content.php file in
the content frame. This file has all parameters available.

The news.php has a <a name="3"></a> just before the corresponding
news-item, but I can't get it to work.

The strange thing however is that if I use the anchored link in the
document itself, it is working. (on the top of the list with news-items
there are all hyperlinks in the style:

http://www.example.com/content.php?...1&language=NL#3
And this hyperlink is working (document is opened in the same frame)

Has it to do with the fact that the frameset is called (because of
refresh navigational items), even if the parameters are all passed on or
am I missing something trivial?

Php Inside Html
To call a php script from inside an HTML page I use the href tag with a
link like http://www.mydomain.com/script.php. This works but is it the
best way / only way?

PHP Inside JavaScript?
I have a JavaScript, but I wish to include a PHP file inside the JavaScript. Is this possible?

PHP Inside A BLOB?
is this possible at all? would make things a lot more flexible but i don't know if this is parsed at all after getting some html code from a mysql blob.

PHP Inside Of Javascript
Here is my code and for some reason it will not forward to the page i want it to. $site is getting set ive tested it but what is the problem then? Can I not insert php into javascript?

<?php
$site = "neon_score3.php";
?>

<script type="text/javascript">document.location.href='<?php $site;?>'</script>

IF Inside Query
I've been working jsp lately and there is a tag that you can place inside the query for an if statement.  Obviously there is no tag in php, but is there any way to place an if statement inside the query?

PHP Inside A Variable
I want to set PHP inside a variable. So something like:

$code = "<?php
echo 'my site';

?>";

but that doesn't seem to work. What can I do to put a php code inside a variable?

Php Inside An Image
I was wondering how people have the signatures with the ip php code encoded into their image. Can someone explain how they do it or point me in the direction of a tut that will?

If Statement Inside For Loop
Trying to build a script that sets selected if that is the value in the database (script modefied with static values for forum.)

What is does is make a dropdown box according to the number in stock, then it should selected the number that the customer has already selected.

The error is that it adds 'selected' to all values.

Call A Js Inside A Phpscript
Can i call a javascript inside a php script?

eg. echo "javascript_function()";

Help With If/Else Statement Inside Foreach()
I have the code below that collects data from an array that may go to many levels. This code works well and does exactly what I want. This part of the code also formats the data to html (I removed the formating to make the post easier to read). PHP Code:

Getting Maximum Value Inside A Loop
I'm using something like this, to output a table of rows:

// Set max_val
$max_val = 0;
// Do the loop
while ($row = mysql_fetch_assoc($result)) {
$max_val = max($max_val, $row['integer']);
// etc etc
echo $max_val;
// etc etc
}

I want the maximum value of $row['integer'] to be available in every row. The above example does this, with the exception of the first (top) row of the table, where $max_val is then the value of $row['integer'] for that row - not the actual maximum for all rows.

UPDATE Inside A WHILE Loop
I have a WHILE loop that steps through a set of retrieved records, depending on the status of a checkbox from a form, specific records will be updated.

Problem is I get an error "Warning: Supplied argument is not a valid MySQL result resource in codetest.php on line xxx" PHP Code:

Assembly Language Inside PHP - Possible / Not ?
I'd like to know whether it is possible to use inline assembly code
inside PHP? Remember good old Turbo Pascal 7, one could write Assembly
language inside it if you have a function that will be ran millions of
times inside a loop? This sped up the process by hundred-folds because
of the speed of that bit of assembly language.

Well, I'd like to do the same in PHP, but am unable to find any
conclusive evidence (and help) on whether this works and how.

Query Inside Queries?
What I'm trying to do is send a query to a DB to select all rows with a matching field. Then sort out all but one that has a perticular value in a different field.

I will also be performing a similure query that will sort the data in an order I specify. I think I can use the sort command but can you tell it what order to sort with?

So theres two problems, if you need more ifo I'd be more then happy to layout everything for you to look over.

RegEx - Numbers That Aren't Inside ()
I'm trying to come up with the RegEx to pull out single numbers and ranges of numbers but not if they're inside parathesis. So 34 and 56-27 would both need to match but (25) and (25-62) wouldn't. Any suggestions where to start?

How Can I Put XSL Tag Inside HTML Form Tag?
Sorry I couldn't find a XML/XSL group
I can only post these groups close to my subject.

In JSP (Java Server Page) you can do something
like this

<%
String v = myBean.getValue();
%>

<form .... >
<input name="myTag" value="<%= v %>">
</form>

You can do the similar thing in PHP.

But when I try in XSL I got error.

I have an XML file

<myTag attribute1="value1" />

Now I want to transform it into HTML form tag used XSL template
But XSL doesn't like this

<input name="myTag" value='
<xsl:value-of select="@attribute1" />
'></input>

How can I solve this problem?

Search Inside PDF Or MS Word With PHP, Possible?
Is it possible to search inside a PDF-flie, using PHP?
Same question for MS Word documents?
Searched for it, but I cannot find anything about it, there are also no
PEAR-packages available...

PEAR Used Inside A Function
Currently have had to give up on this one!

How would I use a PEAR class inside a new function?

I would like to include the mail_queue class inside a function to send out
emails when the function has been called.

However, when I try to do this I get the

Fatal error: Call to a member function on a non-object
in /usr/share/php/Mail/Queue.php

error

Currently I'm going to continue to call the mail_queue from the normal code
- but would like to know how to get it working from inside a function for
future reference.

Can I Use Smarty Variable Inside {php} ?
{section name=j start=0 loop=10 step=1}
{php} $xx={$smarty.section.j.index}; echo $xx; {/php}
{/section}

Table With Scroller Inside
How could i put a scroller inside a table?

How To Load A CGI Script Inside PHP?
Is there a way to load a CGI script inside PHP?

If-else Or Switch Inside A Vprintf()
The code below pulls all the data from the database correctly but I want to change what is displayed. Usually I would just use an if-else or a switch but the field i want to change is inside a vprintf(). Here's the code:

Code Inside Phpmailer
I want to send people in my email database information that I have in there. Basically I am sending players in a hockey league player info through an email. I figured the easiest way to do this is by emailing them a table with the results of my database query in it. When I tried to do this using phpmailer I got very lost. Everything is fine except I'm not sure how to structure the code inside the $body variable so that it will show up in the email. Code:

Error Inside The Textbox Value
i want to display current date if the value is empty.

<input type="text" name="I_CreatedOn" class='textbox' readonly
value='if(empty($row[I_CreatedOn]))? echo $date_now;:echo $row[I_CreatedOn];'>

Using Foreach Inside Switch
On a form there's a list of countries for the user to choose from. On the processing script, how can I check to make sure that users have indeed choosen from the list I have provided?

I tried the following but it gave me a "parse error, unexpected T_FOREACH, expecting T_CASE or T_DEFAULT or '}'" on the line with the foreach statement.

How should I code this security check? Code:

Popup Inside Echo
i cant get the javascript to work inside echo. i need the window to pop up.

echo ("<a href='.$zeb.' onclick="window.open('.$zeb.','popup','width=440,height=290,left=165,top=140'); return false"><img src='.$ICON.' border='0'></a>");

Character Set Inside A PHP Class?
I've been programming for a while... and it's been a long road to understanding and getting all the character sets correct for, well, everything.

We have lots of international customers, and I quickly found that having MySQL = latin_1, HTML = 8859-1, and our credit processor = UTF-8... doesn't work very consistently. So going forward... I'm using MySQL = UTF-8_general, the MySQL connection = UTF-8_general... HTML = utf-8... and it's all working fine and good... until just now. This is what I'm finding....

This is my test string that I'm using: Bièr hjärt Roló 202 3º 1ª

Creating a variable and echoing this in PHP works. Example: Code:

Queries Inside A Loop
Can you create queries inside a loop? Probably in a 'do while' loop.

The problem I've hit is that I have a web app for a sports team. On one page we enter how many tries(touchdowns) they scored, and then this number of drop-down menus appears on the next page, filled with all the possible players. The user then selects the players who scored and submits the form.

This action should then create a new record in the 'tries' table for each try scored (in other words, for each drop-down menu).

I've got it so that I can create one try automatically using the code below, but is there a way I can loop this so it repeats for every try? I've named them try1, try2, etc.

$createtry_sql = sprintf("INSERT into tries (tryOpponent, tryTeam, trySeason, tryPlayer) VALUES ('%s', '%s', '%s', '%s')",
   $_SESSION['creatematch']['opposition'],
   $_SESSION['creatematch']['ottersteam'],
   $_SESSION['creatematch']['season'],
   $_POST['try1']
   );
$createtry_query = mysql_query($createtry_sql) or die(mysql_error());

Variable Inside Vairable?
I have a piece of text which will be stored in a table in mysql in that text is a "count" of how many say cars are in the database.. But im not sure how to get this to work.. Any one got any hints of tips or point me in the right direction?

Variable Inside Of $_POST
What is the proper php syntax for doing something like this

$_POST['$row['myfield']']

$row was retreived using mysql_fetch_assoc

Seems like I can't get the syntax right


Copyright © 2005-08 www.BigResource.com, All rights reserved