473,729 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

header ( ' Location .... with variable

1 New Member
Hiya,

got a little prob with the syntax for
header ( ' Location .... with variable).
Usually examples are given with a complete URL, like:

..... header( 'Location: login/testsite/start.php' );

I'd like to use particular read out data from my database (URL)
(variable $result).


..... header( 'Location: $result' ); ?????

$result is not a string but an array
see below in code: $result=mysql_f etch_array($sql request);

Thanx in anticipation!



Code

<?php

session_start ();

if(isset($_POST['password'])

AND
strcmp(trim($_P OST['password']),'') != 0 )


$dbID=mysql_con nect ('localhost', 'root') or die(mysql_error ());

mysql_select_db ('login', $dbID)or die(mysql_error ());

$sqlZiel="SELEC T destination FROM passwordrequest WHERE password = '101TR'";

//'101TR' (example)

$sqlrequest=mys ql_query($sqlde stination)or die(mysql_error ());

$Ergebnis=mysql _fetch_array($s qlrequest);

mysql_close();

//print_r ($result);

if(isset($resul t))

{

header("Locatio n: ($result)");

//header( 'Location: testsite/start.php' );

exit();
}

else

{

header( 'Location: http://localhost/login/IDfailure.php' );

exit();
}


?>
Apr 11 '06 #1
2 8944
Dormilich
8,658 Recognized Expert Moderator Expert
try
Expand|Select|Wrap|Line Numbers
  1. header('location: ' . $result[0]);
  2. # or
  3. header('location: ' . $result['destination']);
please use [ CODE ] tags when posting code
Aug 23 '08 #2
Markus
6,050 Recognized Expert Expert
Single quotes will not parse variables unless they are concatenated, like the above post shows. Double quotes, however, will parse variables without having to concatenate them.
Aug 23 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
18277
by: Filth | last post by:
Hi this is probably very easy to sort but I want to do the following:- header( "Location: subscribe_form.php?name='.$_GET.'&email='.$_GET.'"); but this pulls up the error:- Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
10
5666
by: Margaret MacDonald | last post by:
I'm seeing a problem that has me flummoxed. The only thing I can think of is that I'm violating some rule I don't know about. I have some code that does some processing and then does a header('Location: ...) jump to page A on success or falls through to the jump to page B. This is the code: if ( mysql_query( 'LOCK TABLES tableX WRITE', $link ) ) { mysql_query( $q, $link ) ; // store the record
2
2414
by: Stephen Preston | last post by:
I have a split frame which holds in the upper part a php file with a header location function, which opens a new file (lower.php). I'm trying to get the header function to open lower.php in the lower half of the frame, header("Location: lower.php TARGET='lowframe') with out the Target setting, it opens lower.php in the upper part (ie it replaces its self), but with the TARGET statement it can't find the file. Is this do able? or is...
23
3645
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it started another session, but it should not have. Ideas? TIA,
6
5454
by: P-Rage | last post by:
Hello everyone, I was wondering what could possibly cause Internet Explorer 6 to loop a page usging a header(Location:) statement. For example, a page called 'page1.php': if((isset($_POST)) && ($name='valid')){ // insert some data into MySQL.
4
10420
by: geshan | last post by:
In php5 I am not able to use include funciton and header("location:""" together please help.
4
3123
by: henryrhenryr | last post by:
I'm using Win2k with Apache 2, PHP 5.2 for my local test server. My problem is that I think the header('Location ...') function isn't sending the header immediately and the rest of my script is running before the page redirects. I am using a $_SESSION array to transfer messages from one page to the next. I want the message available only once, then it should be deleted. I had been using the technique something like this: if...
8
39932
by: pedalpete | last post by:
I thought this should be simple, but i can't seem to get it to work. I'm trying to do a simple redirect to a page, but need to pass a variable. I've tried a few things, but nothing seems to work. here's what I've tried header('Location: edit.php?sid=$sid');
6
2290
johny10151981
by: johny10151981 | last post by:
Its not a php Question. Its a HTTP question how web server send client Location header request. The thing is, after sending "\r\n\r\n" web server start to send data to web client but even though in that situation if we create a Location header request it works look at the below example. <?php echo "johny"; header("Location: request.php"); ?>
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.