Link to home
Start Free TrialLog in
Avatar of designersx
designersx

asked on

problem

<?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??

Avatar of gamebits
gamebits
Flag of Canada image

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

Open in new window

Avatar of designersx
designersx

ASKER

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
SOLUTION
Avatar of gamebits
gamebits
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wrong cxr sir ur code is wrong
@cxr I don't know about you but I've been wrong before :)
>> wrong cxr sir ur code is wrong

No, it is not. You might be using it wrong. Can you post your code?
>> I've been wrong before :)

That occasionally happens to me too, but not in this case...! ;)
cxr: i don't mean that way, excuse me, apologize me , u r always a great for me, .sorry sorry again
<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

line 10 is not working??why??
keep it on separate line

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

echo "$ni"; // echo the variable
Line 10 should be just:

echo $ni;

...because you have allready fetched the $ni variable in line 4.
sir see the snapshot in the url name is coming but in the age name is not coming , why??
sna2.bmp
cxr: sir we have two different pages.
insert.php

view.php
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.
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());

could not executeUnknown column 'tttt' in 'where clause'
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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

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.
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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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)."'";
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.
all r fantastic.................