473,379 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

header ( ' Location .... with variable

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_fetch_array($sqlrequest);

Thanx in anticipation!



Code

<?php

session_start ();

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

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


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

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

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

//'101TR' (example)

$sqlrequest=mysql_query($sqldestination)or die(mysql_error());

$Ergebnis=mysql_fetch_array($sqlrequest);

mysql_close();

//print_r ($result);

if(isset($result))

{

header("Location: ($result)");

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

exit();
}

else

{

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

exit();
}


?>
Apr 11 '06 #1
2 8782
Dormilich
8,658 Expert Mod 8TB
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 Expert 4TB
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
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:...
10
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...
2
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...
23
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...
6
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))...
4
by: geshan | last post by:
In php5 I am not able to use include funciton and header("location:""" together please help.
4
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...
8
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.