0

I'm having a strange problem with a website I'm working on. What I want to do is pass a SQL query variable (in this case cid) using a link, but for some reason it just isn't working.

This type of query works just fine on other pages of this site, but when I try it here, the variable isn't passed.

Here is my SQL query:

$query = 'SELECT CID AS "Course ID", courseNumber AS "Course Number", courseNumber AS "Course Number", startDate AS "Starts", endDate AS "Through", facAddress as "Location", facCity as "Location", county as "County" FROM class where CID="$cid"';

I would think that this link would then pass the CID number (in this case 12) to the report query.

https://www.contractor-training-ca.org/mailer/report.php?cid=12

Instead, I get this error:
Unknown column '$cid' in 'where clause'

It's probably something really stupid that I'm missing, any help would be appreciated...

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by httpgal
0

Hi

you have to get the cid value

$cid = $_GET['cid'];

insert the above line before your code starts in the page.

Let we check.

0

$query = 'SELECT CID AS "Course ID", courseNumber AS "Course Number", courseNumber AS "Course Number", startDate AS "Starts", endDate AS "Through", facAddress as "Location", facCity as "Location", county as "County" FROM class where CID='.$cid;

Edited by wangsg: CID=' . $cid;

0

Still having the same issue. Inserted the code as suggested but it didn't make any difference. Here is my page code:

<?php

$cid = $_GET['cid'];
include ('config.php');
include ('sqlreporter.php');

//Setup Email Subject
$subject = 'Welcome to the Subsidized Contractor Training Program';

//Color is the color report table, it can be set to be grey, green or blue
$color = 'gray';

$header = '<p><b>Welcome to the Subsidized Contractor Training Program</b>. 
</br></p>';

$footer = '<p><strong>Subsidized Contractor Training </strong> is brought to you by Energy Upgrade California and Conservation Services Group.</p>';

$query = 'SELECT CID AS "Course ID", courseNumber AS "Course Number", courseNumber AS "Course Number", startDate AS "Starts", endDate AS "Through", facAddress as "Location", facCity as "Location", county as "County" FROM class where CID="$cid"';

$report = generateReport($query, $header, $footer, $color);

$recipient1 = 'rdulay@gmail.com';

html_email($recipient1,$subject,$report);


?>

If I put any class id (CID) in the SQL query, it works just fine, but passing it through the URL is still failing.
https://www.contractor-training-ca.org/mailer/report.php?cid=12

0

Thank you!!

$query = 'SELECT CID AS "Course ID", courseNumber AS "Course Number", courseNumber AS "Course Number", startDate AS "Starts", endDate AS "Through", facAddress as "Location", facCity as "Location", county as "County" FROM class where CID='. $cid .'';

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.