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

designersxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Open in new window

0
designersxAuthor 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
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

gamebitsCommented:
2 choices

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

or

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

0
designersxAuthor Commented:
wrong cxr sir ur code is wrong
0
gamebitsCommented:
@cxr I don't know about you but I've been wrong before :)
0
Roger BaklundCommented:
>> wrong cxr sir ur code is wrong

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

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

0
designersxAuthor Commented:
line 10 is not working??why??
0
gamebitsCommented:
keep it on separate line

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

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

echo $ni;

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

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

0
designersxAuthor Commented:
could not executeUnknown column 'tttt' in 'where clause'
0
yauhingCommented:
Hi, I found two possible problems in the provided code.

1) You may use urlencode when making the link if the name contains some special character.
2) $ni should inside ' and ' ( example: select * from sindia where ni='user_name' )
insert.php
<?php
include('config.php');
$ni= $_REQUEST['ni'];
?><a href="view.php?name=<?=urlencode($ni)?>">View The Details</a>
 
 
view.php
<?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());
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roger BaklundCommented:
>> cxr: sir we have two different pages.

Indeed. I did not notice, sorry!

>> Unknown column 'tttt' in 'where clause'

This is because the missing apostrophes that yauhing pointed out.

You should not use "shorttags", i.e. "<?=", you should use full PHP start tags "<?php". This is because some servers does not support shorttags, while all servers support the full tags.

<a href="view.php?name=<?php echo urlencode($ni); ?>">View The Details</a>
0
yauhingCommented:
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

0
yauhingCommented:
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

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

0
yauhingCommented:
Hi designersx,

$ni should inside ' and '. ( example of the sql: select * from sindia where ni='user_name' )

Error because the missing apostrophes.

your sql is: select * from sindia where ni=ttt
correct sql should be: select * from sindia where ni='ttt'

The difference is ttt and 'ttt'
0
designersxAuthor 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.
0
yauhingCommented:
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)."'";
0
designersxAuthor 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.
0
designersxAuthor Commented:
all r fantastic.................
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.