• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

SELECT statement trouble in PHP

I have a query:
$displ_query  = "SELECT * FROM content_ WHERE content_id = $_SERVER['HTTP_REFERER']";

The idea is to trap the sent url:
echo "<u><a href='_cont/_main.php?sender=displ_body_qry&content_id=$content_id'";

where the $content_id variable from the calling page is equal to a content id within my database.

I just don't know how this can be done. Please help if you can.
Thanks!
0
rae_rae
Asked:
rae_rae
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try this:
$displ_query  = "SELECT * FROM content_ WHERE content_id = '{$_SERVER['HTTP_REFERER']}'";
0
 
rae_raeAuthor Commented:
Thanks but no dice. The {$_SERVER['HTTP_REFERER']} echos out as:
http://www.nettekk.com/cms/

I need it to only contain:
$content_id, which from above you can see is in
echo "<u><a href='_cont/_main.php?sender=displ_body_qry&content_id=$content_id'";
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about this:
$displ_query  = "SELECT * FROM content_ WHERE content_id = '{$_GET['content_id']}'";
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rae_raeAuthor Commented:
$displ_query  = "SELECT * FROM content_ WHERE section_name='{$_GET['section_name']}";

echos out the right variable.
0
 
lostcarparkCommented:
Two things:

1. You don't need to place quotes around array indexes within strings.
2. You need to put quotes around string values in queries.

Try this:

$displ_query  = "SELECT * FROM content_ WHERE content_id = '$_SERVER[HTTP_REFERER]' ";

Alternatively you could use the . operater for concatenation:

$displ_query  = "SELECT * FROM content_ WHERE content_id = '" . $_SERVER['HTTP_REFERER'] . "'";

Hope this helps.
0
 
rae_raeAuthor Commented:
Thanks a ton!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now