Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

problem

Posted on 2009-07-01
29
228 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??

0
Comment
Question by:designersx
  • 15
  • 5
  • 5
  • +1
29 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 24755006
<?php
$ni= $_REQUEST['ni'];
<a href="view.php?name=$ni">View The Details</a>
0
 
LVL 39

Expert Comment

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

Open in new window

0
 

Author Comment

by:designersx
ID: 24755134
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 100 total points
ID: 24755165
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
 

Author Comment

by:designersx
ID: 24755166
wrong cxr sir ur code is wrong
0
 
LVL 28

Expert Comment

by:gamebits
ID: 24755174
@cxr I don't know about you but I've been wrong before :)
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24755186
>> wrong cxr sir ur code is wrong

No, it is not. You might be using it wrong. Can you post your code?
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24755199
>> I've been wrong before :)

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

Author Comment

by:designersx
ID: 24755221
cxr: i don't mean that way, excuse me, apologize me , u r always a great for me, .sorry sorry again
0
 

Author Comment

by:designersx
ID: 24755251
<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
 

Author Comment

by:designersx
ID: 24755273
line 10 is not working??why??
0
 
LVL 28

Expert Comment

by:gamebits
ID: 24755302
keep it on separate line

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

echo "$ni"; // echo the variable
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24755304
Line 10 should be just:

echo $ni;

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

Author Comment

by:designersx
ID: 24755320
sir see the snapshot in the url name is coming but in the age name is not coming , why??
sna2.bmp
0
 

Author Comment

by:designersx
ID: 24755342
cxr: sir we have two different pages.
insert.php

view.php
0
 

Author Comment

by:designersx
ID: 24755360
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
 

Author Comment

by:designersx
ID: 24755436
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
 

Author Comment

by:designersx
ID: 24755487
could not executeUnknown column 'tttt' in 'where clause'
0
 
LVL 5

Accepted Solution

by:
yauhing earned 300 total points
ID: 24755835
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
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 100 total points
ID: 24755900
>> 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
 
LVL 5

Expert Comment

by:yauhing
ID: 24755934
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
 
LVL 5

Expert Comment

by:yauhing
ID: 24755955
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
 

Author Comment

by:designersx
ID: 24756442
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
 

Author Comment

by:designersx
ID: 24756462
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
 
LVL 5

Assisted Solution

by:yauhing
yauhing earned 300 total points
ID: 24756534
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
 

Author Comment

by:designersx
ID: 24756541
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
 
LVL 5

Expert Comment

by:yauhing
ID: 24756591
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
 

Author Comment

by:designersx
ID: 24756593
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
 

Author Closing Comment

by:designersx
ID: 31598792
all r fantastic.................
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question