By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

problem in passing argument

P: 52
HI again,


OK, now I have a page pictures.php
and I am using following code :
[PHP]printf("<a href=\"pictures.php?name=%s\">",urlencode($val[0]));
print ("<img src=\"$val[0]\" width=100%)/></a>");[/PHP]

the problem is no value is stored in $name in pictures.php
I don't get anything when i print $name.

Need a help.
Thanks
Jan 1 '08 #1
Share this Question
Share on Google+
11 Replies


Markus
Expert 5K+
P: 6,050
There's no reference to '$name'

=/
Jan 1 '08 #2

P: 52
There's no reference to '$name'

=/
I have included following line
[PHP]print ("$name");[/PHP]
in pictures.php
just after above code.

thanks
Jan 1 '08 #3

Markus
Expert 5K+
P: 6,050
$name is empty?

I'm really sorry, it's just i can't know what your code is.. you have to show me.
Jan 1 '08 #4

P: 52
OK,
here is the code I'm using
[PHP]<?php
$loginid=$_SESSION['loginid'];
mysql_connect('localhost','user','user');
mysql_select_db('test');
$query="select name from pictures where loginid='$loginid'";
$result=mysql_query($query);
print("<table width=95% align=center cellspacing=4> <tr>");
$count=0;
while($val=mysql_fetch_array($result))
{
if ($count++<5)
print("<td width=20%>");
else { print("</tr><tr><td width=20%>"); $count=0; }
printf("<a href=\"pictures.php?name=%s\">",urlencode($val[0]));
print ("<img src=\"$val[0]\" width=100%)/></a>");
print("</td>");

}
if ($count<5)
while ($count++<5) print ("<td width=20%>&nbsp;</td>");

print("</tr></table>");
print ("\n<br/><center><img src=\" $name \"><br/>");

?>[/PHP]

When I see the source code in my browser it doesn't show anything in place of $name in the last line

Thanks
Jan 2 '08 #5

rpnew
100+
P: 188
OK,
here is the code I'm using
[PHP]<?php
$loginid=$_SESSION['loginid'];
mysql_connect('localhost','user','user');
mysql_select_db('test');
$query="select name from pictures where loginid='$loginid'";
$result=mysql_query($query);
print("<table width=95% align=center cellspacing=4> <tr>");
$count=0;
while($val=mysql_fetch_array($result))
{
if ($count++<5)
print("<td width=20%>");
else { print("</tr><tr><td width=20%>"); $count=0; }
printf("<a href=\"pictures.php?name=%s\">",urlencode($val[0]));
print ("<img src=\"$val[0]\" width=100%)/></a>");
print("</td>");

}
if ($count<5)
while ($count++<5) print ("<td width=20%>&nbsp;</td>");

print("</tr></table>");
print ("\n<br/><center><img src=\" $name \"><br/>");

?>[/PHP]

When I see the source code in my browser it doesn't show anything in place of $name in the last line

Thanks
Hi,

Well i didnt find any place in your code where you are assigning any value to '$name' so it will be empty..... what do you exactly want '$name' to print??

if i'm not understanding your code then let me know

Regards,
RP
Jan 2 '08 #6

P: 52
Hi,

Well i didnt find any place in your code where you are assigning any value to '$name' so it will be empty..... what do you exactly want '$name' to print??

if i'm not understanding your code then let me know

Regards,
RP
Well, I think I should explain my code.

I am trying to make a page for pictures in which user will see thumnail-size pictures first. And when he clicks the picture, he will see the actual size of image later on the same page.

Ok, now I have included this code in line no. 14
[PHP]#
printf("<a href=\"pictures.php?name=%s\">",urlencode($val[0]));[/PHP]

Isn't this suppose to assign value of urlencode($val[0]) to name ??
and when clicked in the link, isn't this code supposed to pass value of $name to pictures.php (which is the same page in my case).

So, I need the value of $name so as to know which image has the user clicked.

I think, that clears my problem and your doubt.

But please do help me
Thanks
Jan 2 '08 #7

Markus
Expert 5K+
P: 6,050
Have you tried printing just $val[0]?

Also, don't say $name.. it makes people look for a variable called $name in your script when it isnt there. You're just reffering to the name= in the url.
Jan 2 '08 #8

P: 52
Hi,
thanks for your suggestions.

I have tried printing the value of $val[0] as well and it's working fine.
I can see in the page source as well as the url like pictures.php?name=something but it seems name is not taking that value.
later when I include
[PHP]print ("\n<br/><center><img src=\" $name \"><br/>");[/PHP]
name doesn't have any value.

Thanks
Jan 3 '08 #9

Markus
Expert 5K+
P: 6,050
Are you using $_GET['name'];

To retrieve the name?
Jan 3 '08 #10

P: 52
Hey,

I didn't use $_GET['name'] to retrieve the value.
Its working after I user $_GET array.

thanks for all your help and support.
I got that working now.

Thanks again
Jan 3 '08 #11

Markus
Expert 5K+
P: 6,050
Hey,

I didn't use $_GET['name'] to retrieve the value.
Its working after I user $_GET array.

thanks for all your help and support.
I got that working now.

Thanks again
Haha, after all that!

No probs, post back whenever :)
Jan 3 '08 #12

Post your reply

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