473,396 Members | 2,076 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,396 software developers and data experts.

passing variable using url - what's wrong?

Hi.

I want to send a variable to my script using url.
I don't know why but echo in "szczegoly.php" display nothing...

// strona1.php
<A HREF=\"./szczegoly.php?nazwah=$nazwa_hotelu\">$nazwa_hotelu </A>

//szczegoly.php
<?php
echo "<p>{$_GET['nazwah']}</p>";
?>

What's wrong?

Thanks.
Leszek
Jan 3 '06 #1
7 1384
Leszek wrote:
Hi.

I want to send a variable to my script using url.
I don't know why but echo in "szczegoly.php" display nothing...

// strona1.php
<A HREF=\"./szczegoly.php?nazwah=$nazwa_hotelu\">$nazwa_hotelu </A>

//szczegoly.php
<?php
echo "<p>{$_GET['nazwah']}</p>";
?>

What's wrong?

Thanks.
Leszek

Simple things first:
If you change szczegoly.php to the following:

<?php
echo "GET SET<br>\n";
echo "<pre>\n";
print_r($_GET);
echo "</pre>\n";
?>

what do you get?

Jan 3 '06 #2
Right. I changed like you said.

This is what i'm getting
GET SET
Array
(
)
Does it mean that $_GET is empty?
So,
<A HREF=\"./szczegoly.php?nazwah=$nazwa_hotelu\">$nazwa_hotelu </A>
doesn't send nazwah to $_GET??

Jan 3 '06 #3
Leszek wrote:
Right. I changed like you said.

This is what i'm getting
GET SET
Array
(
)
Does it mean that $_GET is empty?
So,
<A HREF=\"./szczegoly.php?nazwah=$nazwa_hotelu\">$nazwa_hotelu </A>
doesn't send nazwah to $_GET??


I does indeed mean that $_GET is empty.
So, what web server are you using to serve up the pages?
I am suspicious about the './' prefix. Why is it there?
Also, I think you need to adjust the line to read:

<A HREF="szczegoly.php?nazwah=<?php echo $nazwa_hotelu;?>">$nazwa_hotelu</A>

-david-

Jan 3 '06 #4

So, what web server are you using to serve up the pages?
I am suspicious about the './' prefix. Why is it there?
Also, I think you need to adjust the line to read:

<A HREF="szczegoly.php?nazwah=<?php echo
$nazwa_hotelu;?>">$nazwa_hotelu</A>

-david-


Whole line looks like this:
echo "<b><tr><td align=\"left\"><b><A
HREF=\"http://localhost/boin/Robocza/szczegoly.php?nazwah=$nazwa_hotelu\">$nazwa_hotelu </A></b></td>";

but still
echo {$_GET['nazwah']};
shows nothing
Jan 3 '06 #5
<?php
echo "<p>{$_GET['nazwah']}</p>";
?>
gives
Array
(
[nazwah] => ALEXANDER
)
so now if i want to echo this value - can it be:echo {$_GET['nazwah']};
??ThanksLeszek
Jan 3 '06 #6
Leszek wrote:
<?php
echo "<p>{$_GET['nazwah']}</p>";
?>
gives
Array
(
[nazwah] => ALEXANDER
)
so now if i want to echo this value - can it be:echo {$_GET['nazwah']};
??ThanksLeszek

If you want to echo it then you can use:

echo $_GET['nazwah']."<br>\n";
or
printf('%s<br>\n', $_GET['nazwah']);

If you want to use set some default value if it is not set, you can do
something like:

$my_value = isset($_GET['nazwah']) ? $_GET['nazwah'] : 'default value';

-david-
Jan 3 '06 #7
Works great:))

Thanks.
Leszek
Jan 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
7
by: Jonas Daunoravicius | last post by:
The subject pretty much sums up what I need to do. Here is what I have so far, but still can't figure out how to get it working: <script language="javascript" type="text/javascript"> function...
20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
1
by: Shawn | last post by:
As if it won't be clear enough from my code, I'm pretty new to C programming. This code is being compiled with an ANSI-C compatible compiler for a microcontroller. That part, I believe, will be...
8
by: S. | last post by:
Hi all, Can someone please help me with this? I have the following struct: typedef struct { char *name; int age; } Student;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.