LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-11-2004, 03:43 PM   #1
LQ Newbie
Registered: Dec 2004
Posts: 1

Rep: Reputation: 0
MySQL++ Query

Hey Everyone,

I am creating a Reservation DB and C++ program and have caught a snag. I am using Linux, MySQL, MySQL++, and C++ for developing this program. I am having trouble executing a command.

I want to run the query that looks like this

mysql_query(con,"SELECT * FROM RESERVATIONS WHERE STATUS = 'EnterStatus'");

EnterStatus is a variable that accepts the value from a user input on a basic cin line.

This query returns me 0 results if I were to type in confirmed for EnterStatus. However if I run the query as

mysql_query(con,"SELECT * FROM RESERVATIONS WHERE STATUS = \'confirmed\'");

This returns 5 results as it should. Am I not using correct syntax for passing a varaible into a query or am I just missing something?

Thanks all for your help!!!
Old 12-15-2004, 06:47 AM   #2
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
You should pass the content of the EnterStatus variable to the query, not the word 'EnterStatus'. My C++ is a bit rusty, but is should be something like

mysql_query(con,"SELECT * FROM RESERVATIONS WHERE STATUS = '" + EnterStatus + "'");


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mySQL query help ezra143 Programming 3 04-25-2005 03:17 PM
Need mysql query help DropHit Linux - Software 7 04-01-2005 11:32 AM
Mysql Error: Lost Connection to Mysql during query ramnath Programming 5 11-18-2003 12:27 PM
mysql query ? shaahul Linux - Software 1 09-06-2003 03:35 AM
mysql query !!! hitesh_linux Linux - General 1 02-03-2003 03:36 AM

All times are GMT -5. The time now is 04:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration