Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request from URL not showing

Status
Not open for further replies.

dreampolice

Technical User
Dec 20, 2006
85
US
I have links that I list where each one shows a result from an Oracle database:
<a href="mylink.php?id=34">id34</a>
<a href="mylink.php?id=76">id76</a>
<a href="mylink.php?id=24">id24</a>

For example if someone clicked on id34 the page should show the record info for id = 34.

The problem is the record doesnt show.
Here is how request part in mylink.php looks:

Code:
$id=$_REQUEST ['id'];
$s=OCIParse($dbConnection, "select * from TableOne where id = $id");

Please advise what I am doing wrong.
 
I don't think there should be a space between $_REQUEST and ['id']. I never use request. I've always used $_POST. Try removing the space.
Mark

 
php is whitespace agnostic. the space does not matter.

the correct superglobal to address is $_GET but this will not be the issue in this case.

I can see nothing wrong with your code. It is possible that you are misforming your database query however, or that oracle does not neatly do type conversion. remember that the superglobal will hold the query variable as a string. you may need to cast it to an integer first (i doubt it but ...).

it goes without saying, i'm sure, that the example above is not a great statement of sql security. you must always test, validate and cleanse user submitted data before using it in a query.

for this precise problem, consider some debugging code.

Code:
$id=$_REQUEST ['id'];
$s=OCIParse($dbConnection, "select * from TableOne where id = $id");
if (!$s) {
    $e = oci_error($dbConnection);
    print htmlentities($e['message']);
    exit;
  }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top