Jump to content

PHP MySQL Query Issue


zebe

Recommended Posts

Hi,

I'm trying to run a query like the following example:

[code]
$activity = $HTTP_POST_VARS["activity"];
$sql = "SELECT first, last, email FROM student_involvement WHERE " . $activity . " = 1";
$result = mysql_query($sql) or die(mysql_error());
[/code]

The variable $activity is pulling a column name from a predefined select list of activities. Each one of these fields is an int field and if it is true it will have a 1 false a 0. The query fails:

SELECT first, last, email FROM student_involvement WHERE acapella = 1
EXPORT ERROR:Unknown column 'acapella' in 'where clause'

Does anyone know why this is failing? The columns exist, I can pull general data from that table, but it seems to throw errors when I try to implement a WHERE clause...

Thanks for all of your help in advance![b][/b]
Link to comment
Share on other sites

Yes,

I have a form that was placing data into the fields. If a user checked that activity it would store a 1 in the respective field, 0 otherwise. All the int fields are storing are basic binary true false data from checkboxes. When I browse, those fields have 0's and 1's in them, so there is data in there...
Link to comment
Share on other sites

[quote author=ryanlwh link=topic=102606.msg407510#msg407510 date=1154462590]
are you connecting to a different database from php that has this table but without the acapella column?
[/quote]

True dat. Check to make sure you're not doing that.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.