embedding a parameter in a link to pass its value along

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

embedding a parameter in a link to pass its value along

Post by emelianenko »

Hello everybody

I have got this line below. The id gets passed on alright, but I d need that the email is also passed to the closeup.php page. I must be putting something wrong in here. I invented the variable 'z, so I am not sure if I actually need it, I think I dont'. This is a row displayed out of a SQL query

Code: Select all


echo '<td><a href=closeup.php?id='.addslashes($row['id']) .'  &z="'.addslashes($row['email']).'" ><img src="'.htmlspecialchars($row['thumb']).'"></a> </td>';

would be very grateful if anybody could pick up what is incorrect in that email parameter that is not going through

regards
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: embedding a parameter in a link to pass its value along

Post by social_experiment »

If you display something from the database use stripslashes(). As per the original question, are you retrieving the value of email from the database in your SQL query?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

Re: embedding a parameter in a link to pass its value along

Post by emelianenko »

yes, I am.

and just a few lines before I have the line I wrote
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: embedding a parameter in a link to pass its value along

Post by AbraCadaver »

Code: Select all

echo '<td><a href="closeup.php?id='.urlencode($row['id']).'&email="'.urlencode($row['email']).'">
<img src="'.htmlspecialchars($row['thumb']).'">
</a></td>';
Then on closeup.php

Code: Select all

echo $_GET['id'];
echo $_GET['email'];
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

Re: embedding a parameter in a link to pass its value along

Post by emelianenko »

Thank you very much. Definitively this code does sound very fine, compared to what I had. Yes, the id continues being passed alright, but the email is still not being passed along and when I hover on the pic it displays equal to empty space =

however if I do this

Code: Select all

 echo '<td><font size="-1">' .htmlspecialchars($row['email']). '</font>'."</td>";
it shows fine on my page

but when put in that link it does not show on hovering and consequently it is not forwarded to the closeup.php page
, hmm dont know..
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: embedding a parameter in a link to pass its value along

Post by AbraCadaver »

emelianenko wrote:Thank you very much. Definitively this code does sound very fine, compared to what I had. Yes, the id continues being passed alright, but the email is still not being passed along and when I hover on the pic it displays equal to empty space =

however if I do this

Code: Select all

 echo '<td><font size="-1">' .htmlspecialchars($row['email']). '</font>'."</td>";
it shows fine on my page

but when put in that link it does not show on hovering and consequently it is not forwarded to the closeup.php page
, hmm dont know..
Sorry, in my posted code there is an errant double-quote after email:

[text]<td><a href="closeup.php?id='.urlencode($row['id']).'&email=" <--- delete that double-quote[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
emelianenko
Forum Commoner
Posts: 35
Joined: Thu Sep 09, 2010 11:49 am

Re: embedding a parameter in a link to pass its value along

Post by emelianenko »

Bingo! Correct. That did the trick. The code is perfect now.

In the meantime I had a look at your website, spidean.com, which is very professional. Templates is something everybody is extremely interested in. My question, are they somehow related to Templates.com ?


best greetings

Emi

================================================================================================================================
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: embedding a parameter in a link to pass its value along

Post by social_experiment »

emelianenko wrote:yes, I am. and just a few lines before I have the line I wrote
Cool, next time paste all relevant code.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: embedding a parameter in a link to pass its value along

Post by AbraCadaver »

emelianenko wrote:Bingo! Correct. That did the trick. The code is perfect now.

In the meantime I had a look at your website, spidean.com, which is very professional. Templates is something everybody is extremely interested in. My question, are they somehow related to Templates.com ?


best greetings

Emi

================================================================================================================================
Hi, thanks. No, I sell a theme engine that runs on some free CMSs and I resell http://templatemonster.com templates and some themes for my theme engine from http://portalthemes.com.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply