We help IT Professionals succeed at work.

problem

designersx
designersx asked
on
257 Views
Last Modified: 2012-05-07
<?php
$ni= $_REQUEST['ni'];
<a href="view.php?name="."$ni">View The Details</a>

in $ni, i am getting the user name and i want to post it on another page when i click on anchor tag, please help me am i right in it??

Comment
Watch Question

CERTIFIED EXPERT

Commented:
<?php
$ni= $_REQUEST['ni'];
<a href="view.php?name=$ni">View The Details</a>
Top Expert 2008

Commented:
Try like this:
<?php
$ni= $_REQUEST['ni'];
echo '<a href="view.php?name='.$ni.'">View The Details</a>';
?>

Open in new window

Author

Commented:
that is wrong sir , sorry to say but it is wrong, it shows me
<a href="view.php?name=$ni

if $ni has user, so it should <a href="view.php?name=user
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
wrong cxr sir ur code is wrong
CERTIFIED EXPERT

Commented:
@cxr I don't know about you but I've been wrong before :)
Top Expert 2008

Commented:
>> wrong cxr sir ur code is wrong

No, it is not. You might be using it wrong. Can you post your code?
Top Expert 2008

Commented:
>> I've been wrong before :)

That occasionally happens to me too, but not in this case...! ;)

Author

Commented:
cxr: i don't mean that way, excuse me, apologize me , u r always a great for me, .sorry sorry again

Author

Commented:
<a href="view.php?name=<?php echo "$ni"; ?>">View The Details</a>,

that is ok

but there is one problem coming.
when i go to view.php, i am getting the error could not execute , why this is problem coming??
insert.php
<?php
include('config.php');
$ni= $_REQUEST['ni'];
?><a href="view.php?name=<?php echo "$ni"; ?>">View The Details</a>
 
view.php
<?php 
include('config.php');	
echo $ni = $_REQUEST['ni']; // not echoing why??
 
$sql = "select * from sindia where ni=".$ni;
$qid = mysql_query($sql) or die("could not execute".mysql_error());
?>

Open in new window

Author

Commented:
line 10 is not working??why??
CERTIFIED EXPERT

Commented:
keep it on separate line

$ni = $_REQUEST['ni']; // assigned to a variable

echo "$ni"; // echo the variable
Top Expert 2008

Commented:
Line 10 should be just:

echo $ni;

...because you have allready fetched the $ni variable in line 4.

Author

Commented:
sir see the snapshot in the url name is coming but in the age name is not coming , why??
sna2.bmp

Author

Commented:
cxr: sir we have two different pages.
insert.php

view.php

Author

Commented:
the main problem is i am getting the value in url but not in the view.php page.
this is main problem though i have the value in insert.php page.

Author

Commented:
there was the problem of query string, that problem is solved now.

now why it is saying me error could not execute,please help me.
<?php
include('config.php');
echo $niq = $_REQUEST['name'];
echo $sql = "select * from sindia where ni=".$niq;
$qid = mysql_query($sql) or die("could not execute".mysql_error());

Author

Commented:
could not executeUnknown column 'tttt' in 'where clause'
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Top Expert 2008
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Sorry, I found another bug.

In the insert.php you pass a variable "name".
But in the view.php you try to get the variable "ni".

So nothing output.
wrong code:
<a href="view.php?name=<?=urlencode($ni)?>">View The Details</a>
 
correct code:
<a href="view.php?ni=<?=urlencode($ni)?>">View The Details</a>

Open in new window

Commented:
Thanks cxr:

So the full PHP start tags should be:
<a href="view.php?ni=<?php echo urlencode($ni); ?>">View The Details</a>

Open in new window

Author

Commented:
u guys r rocking. thanks yauhing: sir, for ur code but i am not able to understand why i was wrong. the error of query string which u have quoted  was also noticed by me then i was able to bring the name in another page also , then

i was using the code

$ni = $_REQUEST['ni'];
$sql = "select * from sindia where ni=".$ni;
$qid = mysql_query($sql) or die("could not execute".mysql_error());

and ur code was

$ni = $_REQUEST['ni'];
echo $ni;
 
$sql = "select * from sindia where ni='".$ni."'";
$qid = mysql_query($sql) or die("could not execute".mysql_error());

tell me where is the difference? why in my case it was saying that could not execute

otherwise thanks for ur help experts.

Author

Commented:
this code worked.
<?php
include('config.php');
 
$ni = $_REQUEST['ni'];
echo $ni;
 
$sql = "select * from sindia where ni='".$ni."'";
$qid = mysql_query($sql) or die("could not execute".mysql_error());
 
while($rec = mysql_fetch_array($qid)){
	?><table bgcolor="#CCCCCC" border="1"><tr><td>Name of the Individual</td><td><?php
	echo $rec['ni'];
	?></td></tr><tr><td>Father/Husband/Owner/Partner Name</td><td><?php
	echo $rec['nf'];
	?></td></tr><tr><td>Product Code</td><td><?php
	echo $rec['pc'];
	?></td></tr><tr><td>Postal Address</td><td><?php
	echo $rec['pa'];
	?></td></tr><tr><td>Town</td><td><?php
	echo $rec['t'];
	?></td></tr><tr><td>Tel No.</td><td><?php
	echo $rec['tel'];
	?></td></tr><tr><td>State</td><td><?php
	echo $rec['s'];
	?></td></tr><tr><td>Mobile No.</td><td><?php
	echo $rec['mob'];
	?></td></tr><tr><td>Pin Code</td><td><?php
	echo $rec['pin'];
	?></td></tr><tr><td>Email</td><td><?php
	echo $rec['email'];
	?></td></tr><tr><td>Blood Group</td><td><?php
	echo $rec['bg'];
	?></td></tr><tr><td>Model of Communication</td><td><?php
	echo $rec['mc'];
	?></td></tr><tr><td>Sex</td><td><?php
	echo $rec['sex'];
	?></td></tr><tr><td>Date Of Birth</td><td><?php
	echo $rec['day'];
	echo "/";
	echo $rec['month'];
	echo "/";
	echo $rec['year'];
	?></td></tr><tr><td>Payment Rs.</td><td><?php
	echo $rec['pr'];
	?></td></tr><tr><td>Marital Status</td><td><?php
	echo $rec['ms'];
	?></td></tr><tr><td>Payment DD No.</td><td><?php
	echo $rec['pdn'];
	?></td></tr><tr><td>Bank</td><td><?php
	echo $rec['bank'];
	?></td></tr><tr><td>Nominee</td><td><?php
	echo $rec['nom'];
	?></td></tr><tr><td>Relationship</td><td><?php
	echo $rec['re'];
	?></td></tr><tr><td>Sponsor's Name</td><td><?php
	echo $rec['sn'];
	?></td></tr><tr><td>Sponsor's ID</td><td><?php
	echo $rec['sid'];
	?></td></tr><tr><td>Parent Name</td><td><?php
	echo $rec['parn'];
	?></td></tr><tr><td>Parent ID</td><td><?php
	echo $rec['pid'];
}
?></td></tr></table>

Open in new window

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
just tell me was there any error in my code, i want to close this question because my problem is solved.

if there was not any probs in the code i was using , that's ok, i just want to know.

Commented:
1) You can cancel line #5 after debug.
2) If magic_quotes is on, your code shoud be ok.
3) If magic_quotes is off, please change line #7 to: $sql = "select * from sindia where ni='".addslashes($ni)."'";

Author

Commented:
yauhing: thanks sir. for stating the problem.

i did this problem becuase i was habitual of using it like this and i have used it so mnay times and there it worked anyhow thanks a lot for all.u deserve 400 points for this.

Author

Commented:
all r fantastic.................
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.